summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitrijs Ledkovs <xnox@debian.org>2013-09-24 09:14:03 +0100
committerDmitrijs Ledkovs <xnox@debian.org>2013-09-24 09:14:03 +0100
commit28161e9209f21be1a600f637565ecede94855a36 (patch)
tree5a82eaf04f3d680b0b4486f6d738bd3620d01f75 /src
libavg (1.7.1-4) unstable; urgency=low
* Drop automake1.10 dependency in favor of automake. Closes: #724398. # imported from the archive
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am9
-rw-r--r--src/Makefile.in653
-rw-r--r--src/anim/Anim.cpp123
-rw-r--r--src/anim/Anim.h90
-rw-r--r--src/anim/AttrAnim.cpp107
-rw-r--r--src/anim/AttrAnim.h92
-rw-r--r--src/anim/ContinuousAnim.cpp91
-rw-r--r--src/anim/ContinuousAnim.h59
-rw-r--r--src/anim/EaseInOutAnim.cpp71
-rw-r--r--src/anim/EaseInOutAnim.h55
-rw-r--r--src/anim/LinearAnim.cpp73
-rw-r--r--src/anim/LinearAnim.h60
-rw-r--r--src/anim/Makefile.am10
-rw-r--r--src/anim/Makefile.in592
-rw-r--r--src/anim/ParallelAnim.cpp113
-rw-r--r--src/anim/ParallelAnim.h64
-rw-r--r--src/anim/SimpleAnim.cpp182
-rw-r--r--src/anim/SimpleAnim.h79
-rw-r--r--src/anim/StateAnim.cpp123
-rw-r--r--src/anim/StateAnim.h70
-rw-r--r--src/anim/WaitAnim.cpp65
-rw-r--r--src/anim/WaitAnim.h53
-rw-r--r--src/api.h44
-rw-r--r--src/audio/AudioBuffer.cpp78
-rw-r--r--src/audio/AudioBuffer.h59
-rw-r--r--src/audio/AudioEngine.cpp99
-rw-r--r--src/audio/AudioEngine.h70
-rw-r--r--src/audio/AudioParams.cpp40
-rw-r--r--src/audio/AudioParams.h39
-rw-r--r--src/audio/Dynamics.h343
-rw-r--r--src/audio/IAudioSource.h46
-rw-r--r--src/audio/IProcessor.h37
-rw-r--r--src/audio/Makefile.am18
-rw-r--r--src/audio/Makefile.in705
-rw-r--r--src/audio/SDLAudioEngine.cpp228
-rw-r--r--src/audio/SDLAudioEngine.h78
-rw-r--r--src/audio/testlimiter.cpp112
-rw-r--r--src/avgconfig.h.in111
-rw-r--r--src/avgconfig_win.h28
-rw-r--r--src/avgconfigwrapper.h37
-rw-r--r--src/avgrc16
-rw-r--r--src/base/Backtrace.cpp93
-rw-r--r--src/base/Backtrace.h36
-rw-r--r--src/base/BezierCurve.cpp53
-rw-r--r--src/base/BezierCurve.h54
-rw-r--r--src/base/CmdLine.cpp82
-rw-r--r--src/base/CmdLine.h50
-rw-r--r--src/base/CmdQueue.h49
-rw-r--r--src/base/Command.h56
-rw-r--r--src/base/ConfigMgr.cpp322
-rw-r--r--src/base/ConfigMgr.h89
-rw-r--r--src/base/CubicSpline.cpp89
-rw-r--r--src/base/CubicSpline.h50
-rw-r--r--src/base/DirEntry.cpp65
-rw-r--r--src/base/DirEntry.h67
-rw-r--r--src/base/Directory.cpp135
-rw-r--r--src/base/Directory.h64
-rw-r--r--src/base/DlfcnWrapper.cpp61
-rw-r--r--src/base/DlfcnWrapper.h41
-rw-r--r--src/base/Exception.cpp99
-rw-r--r--src/base/Exception.h86
-rw-r--r--src/base/FileHelper.cpp163
-rw-r--r--src/base/FileHelper.h53
-rw-r--r--src/base/GeomHelper.cpp178
-rw-r--r--src/base/GeomHelper.h50
-rw-r--r--src/base/IFrameEndListener.h37
-rw-r--r--src/base/IPlaybackEndListener.h38
-rw-r--r--src/base/IPreRenderListener.h35
-rw-r--r--src/base/Logger.cpp213
-rw-r--r--src/base/Logger.h86
-rw-r--r--src/base/Makefile.am31
-rw-r--r--src/base/Makefile.in753
-rw-r--r--src/base/MathHelper.cpp88
-rw-r--r--src/base/MathHelper.h91
-rw-r--r--src/base/Matrix3x4.cpp128
-rw-r--r--src/base/Matrix3x4.h56
-rw-r--r--src/base/OSHelper.cpp182
-rw-r--r--src/base/OSHelper.h48
-rw-r--r--src/base/ObjectCounter.cpp182
-rw-r--r--src/base/ObjectCounter.h58
-rw-r--r--src/base/Point.cpp325
-rw-r--r--src/base/Point.h124
-rw-r--r--src/base/ProfilingZone.cpp85
-rw-r--r--src/base/ProfilingZone.h69
-rw-r--r--src/base/ProfilingZoneID.cpp42
-rw-r--r--src/base/ProfilingZoneID.h45
-rw-r--r--src/base/Queue.h150
-rw-r--r--src/base/Rect.h210
-rw-r--r--src/base/ScopeTimer.cpp40
-rw-r--r--src/base/ScopeTimer.h41
-rw-r--r--src/base/Signal.h119
-rw-r--r--src/base/StringHelper.cpp147
-rw-r--r--src/base/StringHelper.h145
-rw-r--r--src/base/Test.cpp114
-rw-r--r--src/base/Test.h82
-rw-r--r--src/base/TestSuite.cpp68
-rw-r--r--src/base/TestSuite.h49
-rw-r--r--src/base/ThreadProfiler.cpp187
-rw-r--r--src/base/ThreadProfiler.h78
-rw-r--r--src/base/TimeSource.cpp128
-rw-r--r--src/base/TimeSource.h60
-rw-r--r--src/base/Triangle.cpp103
-rw-r--r--src/base/Triangle.h50
-rw-r--r--src/base/Triangulate.cpp139
-rw-r--r--src/base/Triangulate.h22
-rw-r--r--src/base/Triple.cpp107
-rw-r--r--src/base/Triple.h66
-rw-r--r--src/base/UTF8String.cpp57
-rw-r--r--src/base/UTF8String.h43
-rw-r--r--src/base/WideLine.cpp51
-rw-r--r--src/base/WideLine.h48
-rw-r--r--src/base/WorkerThread.h166
-rw-r--r--src/base/XMLHelper.cpp78
-rw-r--r--src/base/XMLHelper.h44
-rw-r--r--src/base/testbase.cpp769
-rw-r--r--src/conradrelais/ConradRelais.cpp179
-rw-r--r--src/conradrelais/ConradRelais.h74
-rw-r--r--src/conradrelais/Makefile.am7
-rw-r--r--src/conradrelais/Makefile.in576
-rw-r--r--src/graphics/Bitmap.cpp1823
-rw-r--r--src/graphics/Bitmap.h185
-rw-r--r--src/graphics/BitmapManager.cpp117
-rw-r--r--src/graphics/BitmapManager.h59
-rw-r--r--src/graphics/BitmapManagerMsg.cpp91
-rw-r--r--src/graphics/BitmapManagerMsg.h66
-rw-r--r--src/graphics/BitmapManagerThread.cpp61
-rw-r--r--src/graphics/BitmapManagerThread.h51
-rw-r--r--src/graphics/BmpTextureMover.cpp107
-rw-r--r--src/graphics/BmpTextureMover.h54
-rw-r--r--src/graphics/ContribDefs.h75
-rw-r--r--src/graphics/FBO.cpp344
-rw-r--r--src/graphics/FBO.h90
-rw-r--r--src/graphics/Filter.cpp55
-rw-r--r--src/graphics/Filter.h56
-rw-r--r--src/graphics/Filter3x3.cpp68
-rw-r--r--src/graphics/Filter3x3.h82
-rw-r--r--src/graphics/FilterBandpass.cpp77
-rw-r--r--src/graphics/FilterBandpass.h52
-rw-r--r--src/graphics/FilterBlur.cpp69
-rw-r--r--src/graphics/FilterBlur.h45
-rw-r--r--src/graphics/FilterConvol.h141
-rw-r--r--src/graphics/FilterDilation.cpp71
-rw-r--r--src/graphics/FilterDilation.h45
-rw-r--r--src/graphics/FilterErosion.cpp71
-rw-r--r--src/graphics/FilterErosion.h45
-rw-r--r--src/graphics/FilterFastBandpass.cpp92
-rw-r--r--src/graphics/FilterFastBandpass.h46
-rw-r--r--src/graphics/FilterFastDownscale.cpp98
-rw-r--r--src/graphics/FilterFastDownscale.h47
-rw-r--r--src/graphics/FilterFloodfill.h165
-rw-r--r--src/graphics/FilterGauss.cpp203
-rw-r--r--src/graphics/FilterGauss.h52
-rw-r--r--src/graphics/FilterGetAlpha.cpp66
-rw-r--r--src/graphics/FilterGetAlpha.h45
-rw-r--r--src/graphics/FilterHighpass.cpp94
-rw-r--r--src/graphics/FilterHighpass.h46
-rw-r--r--src/graphics/FilterId.h46
-rw-r--r--src/graphics/FilterIntensity.cpp56
-rw-r--r--src/graphics/FilterIntensity.h45
-rw-r--r--src/graphics/FilterMask.cpp84
-rw-r--r--src/graphics/FilterMask.h45
-rw-r--r--src/graphics/FilterNormalize.cpp55
-rw-r--r--src/graphics/FilterNormalize.h44
-rw-r--r--src/graphics/FilterResizeBilinear.cpp77
-rw-r--r--src/graphics/FilterResizeBilinear.h39
-rw-r--r--src/graphics/FilterResizeGaussian.cpp78
-rw-r--r--src/graphics/FilterResizeGaussian.h41
-rw-r--r--src/graphics/FilterThreshold.cpp61
-rw-r--r--src/graphics/FilterThreshold.h44
-rw-r--r--src/graphics/FilterUnmultiplyAlpha.cpp57
-rw-r--r--src/graphics/FilterUnmultiplyAlpha.h43
-rw-r--r--src/graphics/Filtercolorize.cpp145
-rw-r--r--src/graphics/Filtercolorize.h48
-rw-r--r--src/graphics/Filterfill.h68
-rw-r--r--src/graphics/Filterfillrect.h75
-rw-r--r--src/graphics/Filterflip.cpp54
-rw-r--r--src/graphics/Filterflip.h43
-rw-r--r--src/graphics/FilterflipX.cpp78
-rw-r--r--src/graphics/FilterflipX.h43
-rw-r--r--src/graphics/Filterfliprgb.cpp84
-rw-r--r--src/graphics/Filterfliprgb.h44
-rw-r--r--src/graphics/Filterfliprgba.cpp56
-rw-r--r--src/graphics/Filterfliprgba.h44
-rw-r--r--src/graphics/Filterflipuv.cpp53
-rw-r--r--src/graphics/Filterflipuv.h44
-rw-r--r--src/graphics/Filtergrayscale.cpp80
-rw-r--r--src/graphics/Filtergrayscale.h45
-rw-r--r--src/graphics/GL/gl.h2262
-rw-r--r--src/graphics/GL/glext.h8565
-rw-r--r--src/graphics/GL/glu.h341
-rw-r--r--src/graphics/GL/glx.h552
-rw-r--r--src/graphics/GLBufferCache.cpp66
-rw-r--r--src/graphics/GLBufferCache.h53
-rw-r--r--src/graphics/GLConfig.cpp54
-rw-r--r--src/graphics/GLConfig.h46
-rw-r--r--src/graphics/GLContext.cpp469
-rw-r--r--src/graphics/GLContext.h132
-rw-r--r--src/graphics/GLTexture.cpp300
-rw-r--r--src/graphics/GLTexture.h94
-rw-r--r--src/graphics/GPUBandpassFilter.cpp96
-rw-r--r--src/graphics/GPUBandpassFilter.h53
-rw-r--r--src/graphics/GPUBlurFilter.cpp148
-rw-r--r--src/graphics/GPUBlurFilter.h56
-rw-r--r--src/graphics/GPUBrightnessFilter.cpp80
-rw-r--r--src/graphics/GPUBrightnessFilter.h48
-rw-r--r--src/graphics/GPUChromaKeyFilter.cpp253
-rw-r--r--src/graphics/GPUChromaKeyFilter.h58
-rw-r--r--src/graphics/GPUFilter.cpp318
-rw-r--r--src/graphics/GPUFilter.h85
-rw-r--r--src/graphics/GPUHueSatFilter.cpp124
-rw-r--r--src/graphics/GPUHueSatFilter.h54
-rw-r--r--src/graphics/GPUInvertFilter.cpp78
-rw-r--r--src/graphics/GPUInvertFilter.h47
-rw-r--r--src/graphics/GPUNullFilter.cpp76
-rw-r--r--src/graphics/GPUNullFilter.h47
-rw-r--r--src/graphics/GPURGB2YUVFilter.cpp88
-rw-r--r--src/graphics/GPURGB2YUVFilter.h49
-rw-r--r--src/graphics/GPUShadowFilter.cpp174
-rw-r--r--src/graphics/GPUShadowFilter.h61
-rw-r--r--src/graphics/GraphicsTest.cpp150
-rw-r--r--src/graphics/GraphicsTest.h52
-rw-r--r--src/graphics/HistoryPreProcessor.cpp157
-rw-r--r--src/graphics/HistoryPreProcessor.h89
-rw-r--r--src/graphics/ImagingProjection.cpp85
-rw-r--r--src/graphics/ImagingProjection.h59
-rw-r--r--src/graphics/Makefile.am64
-rw-r--r--src/graphics/Makefile.in839
-rw-r--r--src/graphics/OGLHelper.cpp477
-rw-r--r--src/graphics/OGLHelper.h141
-rw-r--r--src/graphics/OGLImagingContext.cpp105
-rw-r--r--src/graphics/OGLImagingContext.h58
-rw-r--r--src/graphics/OGLShader.cpp167
-rw-r--r--src/graphics/OGLShader.h74
-rw-r--r--src/graphics/PBO.cpp219
-rw-r--r--src/graphics/PBO.h71
-rw-r--r--src/graphics/Pixel16.h180
-rw-r--r--src/graphics/Pixel24.h190
-rw-r--r--src/graphics/Pixel32.cpp132
-rw-r--r--src/graphics/Pixel32.h207
-rw-r--r--src/graphics/Pixel8.h150
-rw-r--r--src/graphics/PixelFormat.cpp268
-rw-r--r--src/graphics/PixelFormat.h63
-rw-r--r--src/graphics/Pixeldefs.h29
-rw-r--r--src/graphics/ShaderRegistry.cpp78
-rw-r--r--src/graphics/ShaderRegistry.h59
-rw-r--r--src/graphics/TextureMover.cpp77
-rw-r--r--src/graphics/TextureMover.h71
-rw-r--r--src/graphics/TwoPassScale.h354
-rw-r--r--src/graphics/VertexArray.cpp230
-rw-r--r--src/graphics/VertexArray.h82
-rw-r--r--src/graphics/baseline/BandpassResult.pngbin0 -> 2864 bytes
-rw-r--r--src/graphics/baseline/BlurResult.pngbin0 -> 2809 bytes
-rw-r--r--src/graphics/baseline/ChromaKeyMedianResult.pngbin0 -> 622 bytes
-rw-r--r--src/graphics/baseline/ChromaKeyResult0.pngbin0 -> 410 bytes
-rw-r--r--src/graphics/baseline/ChromaKeyResult1.pngbin0 -> 503 bytes
-rw-r--r--src/graphics/baseline/ChromaKeyResult2.pngbin0 -> 497 bytes
-rw-r--r--src/graphics/baseline/ChromaKeySpillResult1.pngbin0 -> 370 bytes
-rw-r--r--src/graphics/baseline/ChromaKeySpillResult2.pngbin0 -> 335 bytes
-rw-r--r--src/graphics/baseline/ChromaKeySpillResult3.pngbin0 -> 353 bytes
-rw-r--r--src/graphics/baseline/DilationResult.pngbin0 -> 88 bytes
-rw-r--r--src/graphics/baseline/ErosionResult.pngbin0 -> 82 bytes
-rw-r--r--src/graphics/baseline/FastBandpassResult.pngbin0 -> 2859 bytes
-rw-r--r--src/graphics/baseline/FastDownscaleResult.pngbin0 -> 69 bytes
-rw-r--r--src/graphics/baseline/FloodfillResult.pngbin0 -> 121 bytes
-rw-r--r--src/graphics/baseline/Gauss15Result.pngbin0 -> 89 bytes
-rw-r--r--src/graphics/baseline/Gauss1Result.pngbin0 -> 81 bytes
-rw-r--r--src/graphics/baseline/Gauss3Result.pngbin0 -> 96 bytes
-rw-r--r--src/graphics/baseline/Gauss5Result.pngbin0 -> 95 bytes
-rw-r--r--src/graphics/baseline/GetAlphaResult.pngbin0 -> 1235 bytes
-rw-r--r--src/graphics/baseline/HighpassResult.pngbin0 -> 100 bytes
-rw-r--r--src/graphics/baseline/HslColorizeResult0.pngbin0 -> 3232 bytes
-rw-r--r--src/graphics/baseline/HslColorizeResult1.pngbin0 -> 3286 bytes
-rw-r--r--src/graphics/baseline/HslColorizeResult2.pngbin0 -> 3223 bytes
-rw-r--r--src/graphics/baseline/HslHueResult0.pngbin0 -> 3131 bytes
-rw-r--r--src/graphics/baseline/HslHueResult1.pngbin0 -> 3201 bytes
-rw-r--r--src/graphics/baseline/HslHueResult2.pngbin0 -> 3218 bytes
-rw-r--r--src/graphics/baseline/LineResultB8G8R8.pngbin0 -> 2848 bytes
-rw-r--r--src/graphics/baseline/LineResultB8G8R8A8.pngbin0 -> 2863 bytes
-rw-r--r--src/graphics/baseline/LineResultI8.pngbin0 -> 2855 bytes
-rw-r--r--src/graphics/baseline/MaskResultB8G8R8.pngbin0 -> 89 bytes
-rw-r--r--src/graphics/baseline/MaskResultB8G8R8X8.pngbin0 -> 89 bytes
-rw-r--r--src/graphics/baseline/MaskResultI8.pngbin0 -> 73 bytes
-rw-r--r--src/graphics/baseline/ResizeBilinearResultB8G8R8A8.pngbin0 -> 1288 bytes
-rw-r--r--src/graphics/baseline/ResizeBilinearResultB8G8R8X8.pngbin0 -> 812 bytes
-rw-r--r--src/graphics/baseline/ThresholdResult.pngbin0 -> 73 bytes
-rw-r--r--src/graphics/baseline/YUV2RGBResult1.pngbin0 -> 203 bytes
-rw-r--r--src/graphics/baseline/bandpass_i8-64x64.pngbin0 -> 1160 bytes
-rw-r--r--src/graphics/baseline/bandpass_spike.pngbin0 -> 293 bytes
-rw-r--r--src/graphics/baseline/blur05_flat.pngbin0 -> 1161 bytes
-rw-r--r--src/graphics/baseline/blur05_spike.pngbin0 -> 118 bytes
-rw-r--r--src/graphics/baseline/blur1_spike.pngbin0 -> 177 bytes
-rw-r--r--src/graphics/baseline/blur3_spike.pngbin0 -> 197 bytes
-rw-r--r--src/graphics/baseline/blur_rgb24-64x64.pngbin0 -> 3649 bytes
-rw-r--r--src/graphics/baseline/blur_rgb24alpha-64x64.pngbin0 -> 5501 bytes
-rw-r--r--src/graphics/baseline/copyPixels_B8G8R8X8_I8.pngbin0 -> 85 bytes
-rw-r--r--src/graphics/baseline/copyPixels_R8G8B8X8_I8.pngbin0 -> 85 bytes
-rw-r--r--src/graphics/benchmarkgraphics.cpp253
-rw-r--r--src/graphics/testfiles/chromakey-median.pngbin0 -> 3331 bytes
-rw-r--r--src/graphics/testfiles/chromakey.pngbin0 -> 2995 bytes
-rw-r--r--src/graphics/testfiles/dilation.pngbin0 -> 80 bytes
-rw-r--r--src/graphics/testfiles/erosion.pngbin0 -> 960 bytes
-rw-r--r--src/graphics/testfiles/flat.pngbin0 -> 2861 bytes
-rw-r--r--src/graphics/testfiles/floodfill.pngbin0 -> 119 bytes
-rw-r--r--src/graphics/testfiles/hsl.pngbin0 -> 3131 bytes
-rw-r--r--src/graphics/testfiles/i8-64x64.pngbin0 -> 2256 bytes
-rw-r--r--src/graphics/testfiles/rgb24-64x64.pngbin0 -> 2092 bytes
-rw-r--r--src/graphics/testfiles/rgb24-65x65.pngbin0 -> 2210 bytes
-rw-r--r--src/graphics/testfiles/rgb24alpha-64x64.pngbin0 -> 3392 bytes
-rw-r--r--src/graphics/testfiles/spike.pngbin0 -> 2820 bytes
-rw-r--r--src/graphics/testgpu.cpp404
-rw-r--r--src/graphics/testgraphics.cpp1063
-rw-r--r--src/imaging/Blob.cpp616
-rw-r--r--src/imaging/Blob.h120
-rw-r--r--src/imaging/CMUCamera.cpp385
-rw-r--r--src/imaging/CMUCamera.h79
-rw-r--r--src/imaging/CMUCameraUtils.cpp221
-rw-r--r--src/imaging/CMUCameraUtils.h44
-rw-r--r--src/imaging/Camera.cpp244
-rw-r--r--src/imaging/Camera.h109
-rw-r--r--src/imaging/CoordTransformer.cpp37
-rw-r--r--src/imaging/CoordTransformer.h45
-rw-r--r--src/imaging/DSCamera.cpp571
-rw-r--r--src/imaging/DSCamera.h106
-rw-r--r--src/imaging/DSHelper.cpp269
-rw-r--r--src/imaging/DSHelper.h62
-rwxr-xr-xsrc/imaging/DSSampleGrabber.cpp220
-rwxr-xr-xsrc/imaging/DSSampleGrabber.h91
-rw-r--r--src/imaging/DeDistort.cpp304
-rw-r--r--src/imaging/DeDistort.h86
-rw-r--r--src/imaging/FWCamera.cpp576
-rw-r--r--src/imaging/FWCamera.h99
-rw-r--r--src/imaging/FWCameraUtils.cpp185
-rw-r--r--src/imaging/FWCameraUtils.h44
-rw-r--r--src/imaging/FakeCamera.cpp160
-rw-r--r--src/imaging/FakeCamera.h72
-rw-r--r--src/imaging/FilterClearBorder.cpp67
-rw-r--r--src/imaging/FilterClearBorder.h51
-rw-r--r--src/imaging/FilterDistortion.cpp83
-rw-r--r--src/imaging/FilterDistortion.h56
-rw-r--r--src/imaging/FilterWipeBorder.cpp70
-rw-r--r--src/imaging/FilterWipeBorder.h51
-rw-r--r--src/imaging/Makefile.am45
-rw-r--r--src/imaging/Makefile.in774
-rw-r--r--src/imaging/Run.cpp36
-rw-r--r--src/imaging/Run.h56
-rw-r--r--src/imaging/TrackerConfig.cpp265
-rw-r--r--src/imaging/TrackerConfig.h72
-rw-r--r--src/imaging/TrackerThread.cpp544
-rw-r--r--src/imaging/TrackerThread.h135
-rw-r--r--src/imaging/V4LCamera.cpp708
-rw-r--r--src/imaging/V4LCamera.h98
-rw-r--r--src/imaging/avgtrackerrc.minimal49
-rw-r--r--src/imaging/baseline/FilterClearBorderResult1.pngbin0 -> 220 bytes
-rw-r--r--src/imaging/baseline/FilterClearBorderResult3.pngbin0 -> 171 bytes
-rw-r--r--src/imaging/baseline/FilterWipeBorderResult1.pngbin0 -> 230 bytes
-rw-r--r--src/imaging/baseline/FilterWipeBorderResult3.pngbin0 -> 187 bytes
-rw-r--r--src/imaging/checktracking.cpp101
-rw-r--r--src/imaging/testfiles/filterwipeborder.pngbin0 -> 1166 bytes
-rw-r--r--src/imaging/testimaging.cpp234
-rw-r--r--src/imaging/trackerconfigdtd.cpp175
-rw-r--r--src/imaging/trackerconfigdtd.h27
-rw-r--r--src/lmfit/Makefile.am8
-rw-r--r--src/lmfit/Makefile.in562
-rw-r--r--src/lmfit/lm_eval.c81
-rw-r--r--src/lmfit/lm_eval.h11
-rw-r--r--src/lmfit/lmmin.c1320
-rw-r--r--src/lmfit/lmmin.h52
-rw-r--r--src/oscpack/CHANGES68
-rw-r--r--src/oscpack/IpEndpointName.cpp81
-rw-r--r--src/oscpack/IpEndpointName.h74
-rw-r--r--src/oscpack/LICENSE28
-rw-r--r--src/oscpack/Makefile.am13
-rw-r--r--src/oscpack/Makefile.in593
-rw-r--r--src/oscpack/MessageMappingOscPacketListener.h73
-rw-r--r--src/oscpack/NetworkingUtils.cpp98
-rw-r--r--src/oscpack/NetworkingUtils.h49
-rw-r--r--src/oscpack/OscException.h54
-rw-r--r--src/oscpack/OscHostEndianness.h70
-rw-r--r--src/oscpack/OscOutboundPacketStream.cpp639
-rw-r--r--src/oscpack/OscOutboundPacketStream.h142
-rw-r--r--src/oscpack/OscPacketListener.h72
-rw-r--r--src/oscpack/OscPrintReceivedElements.cpp240
-rw-r--r--src/oscpack/OscPrintReceivedElements.h49
-rw-r--r--src/oscpack/OscReceivedElements.cpp722
-rw-r--r--src/oscpack/OscReceivedElements.h486
-rw-r--r--src/oscpack/OscTypes.cpp40
-rw-r--r--src/oscpack/OscTypes.h178
-rw-r--r--src/oscpack/PacketListener.h44
-rw-r--r--src/oscpack/README80
-rw-r--r--src/oscpack/TODO55
-rw-r--r--src/oscpack/TimerListener.h40
-rw-r--r--src/oscpack/UdpSocket.cpp1039
-rw-r--r--src/oscpack/UdpSocket.h158
-rw-r--r--src/parport/Makefile.am6
-rw-r--r--src/parport/Makefile.in576
-rw-r--r--src/parport/ParPort.cpp234
-rw-r--r--src/parport/ParPort.h80
-rw-r--r--src/player/AVGNode.cpp56
-rw-r--r--src/player/AVGNode.h45
-rw-r--r--src/player/AppleTrackpadInputDevice.cpp114
-rw-r--r--src/player/AreaNode.cpp283
-rw-r--r--src/player/AreaNode.h122
-rw-r--r--src/player/Arg.cpp44
-rw-r--r--src/player/Arg.h120
-rw-r--r--src/player/ArgBase.cpp66
-rw-r--r--src/player/ArgBase.h65
-rw-r--r--src/player/ArgList.cpp256
-rw-r--r--src/player/ArgList.h84
-rw-r--r--src/player/BlurFXNode.cpp89
-rw-r--r--src/player/BlurFXNode.h59
-rw-r--r--src/player/BoostPython.h33
-rw-r--r--src/player/CameraNode.cpp404
-rw-r--r--src/player/CameraNode.h132
-rw-r--r--src/player/Canvas.cpp350
-rw-r--r--src/player/Canvas.h128
-rw-r--r--src/player/CanvasNode.cpp66
-rw-r--r--src/player/CanvasNode.h47
-rw-r--r--src/player/ChromaKeyFXNode.cpp155
-rw-r--r--src/player/ChromaKeyFXNode.h77
-rw-r--r--src/player/CircleNode.cpp287
-rw-r--r--src/player/CircleNode.h75
-rw-r--r--src/player/Contact.cpp235
-rw-r--r--src/player/Contact.h99
-rw-r--r--src/player/CursorEvent.cpp135
-rw-r--r--src/player/CursorEvent.h87
-rw-r--r--src/player/CursorState.cpp58
-rw-r--r--src/player/CursorState.h56
-rw-r--r--src/player/CurveNode.cpp178
-rw-r--r--src/player/CurveNode.h78
-rw-r--r--src/player/DisplayEngine.cpp187
-rw-r--r--src/player/DisplayEngine.h97
-rw-r--r--src/player/DisplayParams.cpp70
-rw-r--r--src/player/DisplayParams.h53
-rw-r--r--src/player/DivNode.cpp425
-rw-r--r--src/player/DivNode.h99
-rw-r--r--src/player/Event.cpp141
-rw-r--r--src/player/Event.h99
-rw-r--r--src/player/EventDispatcher.cpp159
-rw-r--r--src/player/EventDispatcher.h65
-rw-r--r--src/player/FXNode.cpp108
-rw-r--r--src/player/FXNode.h69
-rw-r--r--src/player/FilledVectorNode.cpp214
-rw-r--r--src/player/FilledVectorNode.h86
-rw-r--r--src/player/HueSatFXNode.cpp157
-rw-r--r--src/player/HueSatFXNode.h73
-rw-r--r--src/player/IInputDevice.h82
-rw-r--r--src/player/Image.cpp408
-rw-r--r--src/player/Image.h98
-rw-r--r--src/player/ImageNode.cpp230
-rw-r--r--src/player/ImageNode.h75
-rw-r--r--src/player/InvertFXNode.cpp66
-rw-r--r--src/player/InvertFXNode.h57
-rw-r--r--src/player/KeyEvent.cpp80
-rw-r--r--src/player/KeyEvent.h335
-rw-r--r--src/player/LibMTDevInputDevice.cpp189
-rw-r--r--src/player/LibMTDevInputDevice.h73
-rw-r--r--src/player/LineNode.cpp105
-rw-r--r--src/player/LineNode.h64
-rw-r--r--src/player/MainCanvas.cpp82
-rw-r--r--src/player/MainCanvas.h51
-rw-r--r--src/player/Makefile.am102
-rw-r--r--src/player/Makefile.in967
-rw-r--r--src/player/MaterialInfo.cpp53
-rw-r--r--src/player/MaterialInfo.h49
-rw-r--r--src/player/MeshNode.cpp142
-rw-r--r--src/player/MeshNode.h62
-rw-r--r--src/player/MouseEvent.cpp89
-rw-r--r--src/player/MouseEvent.h66
-rw-r--r--src/player/MultitouchInputDevice.cpp128
-rw-r--r--src/player/MultitouchInputDevice.h76
-rw-r--r--src/player/Node.cpp620
-rw-r--r--src/player/Node.h214
-rw-r--r--src/player/NodeDefinition.cpp122
-rw-r--r--src/player/NodeDefinition.h74
-rw-r--r--src/player/NodeRegistry.cpp126
-rw-r--r--src/player/NodeRegistry.h62
-rw-r--r--src/player/NullFXNode.cpp62
-rw-r--r--src/player/NullFXNode.h53
-rw-r--r--src/player/OGLSurface.cpp379
-rw-r--r--src/player/OGLSurface.h96
-rw-r--r--src/player/OffscreenCanvas.cpp260
-rw-r--r--src/player/OffscreenCanvas.h92
-rw-r--r--src/player/OffscreenCanvasNode.cpp82
-rw-r--r--src/player/OffscreenCanvasNode.h57
-rw-r--r--src/player/PanoImageNode.cpp351
-rw-r--r--src/player/PanoImageNode.h95
-rw-r--r--src/player/Player.cpp1716
-rw-r--r--src/player/Player.h277
-rw-r--r--src/player/PluginManager.cpp183
-rw-r--r--src/player/PluginManager.h76
-rw-r--r--src/player/PolyLineNode.cpp124
-rw-r--r--src/player/PolyLineNode.h65
-rw-r--r--src/player/PolygonNode.cpp172
-rw-r--r--src/player/PolygonNode.h68
-rw-r--r--src/player/RasterNode.cpp646
-rw-r--r--src/player/RasterNode.h157
-rw-r--r--src/player/RectNode.cpp163
-rw-r--r--src/player/RectNode.h67
-rw-r--r--src/player/SDLDisplayEngine.cpp1078
-rw-r--r--src/player/SDLDisplayEngine.h128
-rw-r--r--src/player/SDLMain.h14
-rw-r--r--src/player/SDLMain.m32
-rw-r--r--src/player/SVG.cpp172
-rw-r--r--src/player/SVG.h79
-rw-r--r--src/player/SVGElement.cpp115
-rw-r--r--src/player/SVGElement.h62
-rw-r--r--src/player/ShadowFXNode.cpp141
-rw-r--r--src/player/ShadowFXNode.h72
-rw-r--r--src/player/Shape.cpp121
-rw-r--r--src/player/Shape.h68
-rw-r--r--src/player/SoundNode.cpp333
-rw-r--r--src/player/SoundNode.h102
-rw-r--r--src/player/TUIOInputDevice.cpp216
-rw-r--r--src/player/TUIOInputDevice.h80
-rw-r--r--src/player/TestHelper.cpp147
-rw-r--r--src/player/TestHelper.h74
-rw-r--r--src/player/TextEngine.cpp301
-rw-r--r--src/player/TextEngine.h76
-rw-r--r--src/player/Timeout.cpp93
-rw-r--r--src/player/Timeout.h54
-rw-r--r--src/player/TouchEvent.cpp202
-rw-r--r--src/player/TouchEvent.h87
-rw-r--r--src/player/TouchStatus.cpp109
-rw-r--r--src/player/TouchStatus.h59
-rw-r--r--src/player/TrackerCalibrator.cpp239
-rw-r--r--src/player/TrackerCalibrator.h75
-rw-r--r--src/player/TrackerInputDevice.cpp491
-rw-r--r--src/player/TrackerInputDevice.h122
-rw-r--r--src/player/TrackerTouchStatus.cpp120
-rw-r--r--src/player/TrackerTouchStatus.h70
-rw-r--r--src/player/VectorNode.cpp521
-rw-r--r--src/player/VectorNode.h117
-rw-r--r--src/player/VideoNode.cpp782
-rw-r--r--src/player/VideoNode.h154
-rw-r--r--src/player/VideoWriter.cpp255
-rw-r--r--src/player/VideoWriter.h102
-rw-r--r--src/player/VideoWriterThread.cpp326
-rw-r--r--src/player/VideoWriterThread.h85
-rw-r--r--src/player/WordsNode.cpp851
-rw-r--r--src/player/WordsNode.h162
-rw-r--r--src/player/WrapPython.h49
-rw-r--r--src/player/XInputMTInputDevice.cpp372
-rw-r--r--src/player/XInputMTInputDevice.h76
-rw-r--r--src/player/testcalibrator.cpp119
-rw-r--r--src/player/testplayer.cpp88
-rw-r--r--src/python/Makefile.am6
-rw-r--r--src/python/Makefile.in703
-rw-r--r--src/python/__init__.py19
-rw-r--r--src/python/anim.py487
-rw-r--r--src/python/app.py144
-rw-r--r--src/python/apphelpers.py367
-rw-r--r--src/python/appstarter.py373
-rw-r--r--src/python/camcalibrator.py474
-rw-r--r--src/python/clusteredEventList.py257
-rw-r--r--src/python/coordcalibrator.py134
-rw-r--r--src/python/data/CamImgBorder.pngbin0 -> 3031 bytes
-rw-r--r--src/python/data/Feedback.pngbin0 -> 196 bytes
-rw-r--r--src/python/data/Makefile.am4
-rw-r--r--src/python/data/Makefile.in480
-rw-r--r--src/python/data/TouchFeedback.pngbin0 -> 4494 bytes
-rw-r--r--src/python/data/black.pngbin0 -> 142 bytes
-rw-r--r--src/python/data/border.pngbin0 -> 8074 bytes
-rw-r--r--src/python/data/camcalibrator.avg27
-rw-r--r--src/python/data/crosshair.pngbin0 -> 189 bytes
-rw-r--r--src/python/draggable.py107
-rw-r--r--src/python/eventList.py174
-rw-r--r--src/python/gameapp.py327
-rw-r--r--src/python/geom.py206
-rw-r--r--src/python/grabbable.py320
-rw-r--r--src/python/graph.py169
-rw-r--r--src/python/mathutil.py168
-rw-r--r--src/python/mtemu.py154
-rw-r--r--src/python/parsecamargs.py47
-rw-r--r--src/python/statemachine.py100
-rw-r--r--src/python/textarea.py643
-rw-r--r--src/python/trackerhelper.py58
-rw-r--r--src/python/ui/Makefile.am2
-rw-r--r--src/python/ui/Makefile.in496
-rwxr-xr-xsrc/python/ui/__init__.py4
-rw-r--r--src/python/ui/button.py364
-rw-r--r--src/python/ui/gesture.py746
-rw-r--r--src/python/ui/helper.py61
-rw-r--r--src/python/ui/keyboard.py243
-rw-r--r--src/python/utils.py101
-rw-r--r--src/samples/Makefile.am4
-rw-r--r--src/samples/Makefile.in522
-rwxr-xr-xsrc/samples/anim1.py17
-rwxr-xr-xsrc/samples/anim2.py19
-rwxr-xr-xsrc/samples/asyncload.py96
-rwxr-xr-xsrc/samples/attributes.py12
-rw-r--r--src/samples/canvas.avg6
-rwxr-xr-xsrc/samples/canvas.py13
-rwxr-xr-xsrc/samples/drag.py37
-rwxr-xr-xsrc/samples/event1.py21
-rw-r--r--src/samples/event2.avg6
-rwxr-xr-xsrc/samples/event2.py20
-rwxr-xr-xsrc/samples/event3.py31
-rwxr-xr-xsrc/samples/gestures.py256
-rw-r--r--src/samples/globalcoords.avg4
-rwxr-xr-xsrc/samples/gpuhuefx.py77
-rw-r--r--src/samples/invertfx.py42
-rw-r--r--src/samples/localcoords.avg7
-rw-r--r--src/samples/localcoordsrot.avg7
-rwxr-xr-xsrc/samples/mesh.py18
-rwxr-xr-xsrc/samples/minimal.py8
-rw-r--r--src/samples/mpeg1-48x48-sound.avibin0 -> 28534 bytes
-rwxr-xr-xsrc/samples/plugin.py17
-rw-r--r--src/samples/rgb24-64x64.pngbin0 -> 2092 bytes
-rw-r--r--src/samples/rotcustompivot.avg5
-rw-r--r--src/samples/rotdefaultpivot.avg5
-rwxr-xr-xsrc/samples/sampleapp.py29
-rwxr-xr-xsrc/samples/showvideo.py16
-rw-r--r--src/samples/text.avg4
-rwxr-xr-xsrc/samples/timer.py16
-rwxr-xr-xsrc/samples/timer2.py18
-rwxr-xr-xsrc/samples/timer3.py17
-rwxr-xr-xsrc/samples/twovideos.py44
-rwxr-xr-xsrc/samples/video.py11
-rwxr-xr-xsrc/samples/videochooser.py74
-rw-r--r--src/samples/words1.avg6
-rw-r--r--src/samples/words2.avg7
-rw-r--r--src/samples/wordspos.avg11
-rw-r--r--src/test/1x1_white.pngbin0 -> 2791 bytes
-rw-r--r--src/test/AVGAppTest.py183
-rw-r--r--src/test/AVTest.py621
-rw-r--r--src/test/AnimTest.py431
-rw-r--r--src/test/DynamicsTest.py401
-rw-r--r--src/test/EventTest.py739
-rw-r--r--src/test/FXTest.py450
-rw-r--r--src/test/ImageTest.py498
-rw-r--r--src/test/InputDeviceTest.py199
-rw-r--r--src/test/Makefile.am9
-rw-r--r--src/test/Makefile.in798
-rw-r--r--src/test/OffscreenTest.py474
-rw-r--r--src/test/PlayerTest.py769
-rw-r--r--src/test/PluginTest.py72
-rw-r--r--src/test/PythonTest.py431
-rwxr-xr-xsrc/test/Test.py138
-rw-r--r--src/test/UITest.py1370
-rw-r--r--src/test/VectorTest.py698
-rw-r--r--src/test/WordsTest.py621
-rw-r--r--src/test/baseline/test2VideosAtOnce1.pngbin0 -> 4250 bytes
-rw-r--r--src/test/baseline/testAVGFile.pngbin0 -> 5767 bytes
-rw-r--r--src/test/baseline/testAnim1.pngbin0 -> 6524 bytes
-rw-r--r--src/test/baseline/testAnim2.pngbin0 -> 5795 bytes
-rw-r--r--src/test/baseline/testAnim3.pngbin0 -> 6622 bytes
-rw-r--r--src/test/baseline/testArc1.pngbin0 -> 264 bytes
-rw-r--r--src/test/baseline/testArc2.pngbin0 -> 492 bytes
-rw-r--r--src/test/baseline/testBitmap1.pngbin0 -> 1257 bytes
-rw-r--r--src/test/baseline/testBlend1.pngbin0 -> 24802 bytes
-rw-r--r--src/test/baseline/testBlend2.pngbin0 -> 23161 bytes
-rw-r--r--src/test/baseline/testBlurFX1.pngbin0 -> 2994 bytes
-rw-r--r--src/test/baseline/testBlurFX2.pngbin0 -> 6838 bytes
-rw-r--r--src/test/baseline/testBlurFX3.pngbin0 -> 2418 bytes
-rw-r--r--src/test/baseline/testButtonDisabled.pngbin0 -> 1561 bytes
-rw-r--r--src/test/baseline/testButtonDown.pngbin0 -> 1492 bytes
-rw-r--r--src/test/baseline/testButtonOver.pngbin0 -> 1399 bytes
-rw-r--r--src/test/baseline/testButtonUp.pngbin0 -> 1212 bytes
-rw-r--r--src/test/baseline/testCanvasAlpha.pngbin0 -> 3790 bytes
-rw-r--r--src/test/baseline/testCanvasBlendModes.pngbin0 -> 8527 bytes
-rw-r--r--src/test/baseline/testCanvasCrop.pngbin0 -> 1745 bytes
-rw-r--r--src/test/baseline/testCanvasDependencies1.pngbin0 -> 1022 bytes
-rw-r--r--src/test/baseline/testCanvasDependencies2.pngbin0 -> 2726 bytes
-rw-r--r--src/test/baseline/testCanvasMipmap.pngbin0 -> 893 bytes
-rw-r--r--src/test/baseline/testCanvasMultisample.pngbin0 -> 3472 bytes
-rw-r--r--src/test/baseline/testCanvasNullFX1.pngbin0 -> 2214 bytes
-rw-r--r--src/test/baseline/testCanvasNullFX2.pngbin0 -> 1995 bytes
-rw-r--r--src/test/baseline/testCanvasResize.pngbin0 -> 1022 bytes
-rw-r--r--src/test/baseline/testCheckboxClickedDown.pngbin0 -> 1732 bytes
-rw-r--r--src/test/baseline/testCheckboxClickedOut.pngbin0 -> 1497 bytes
-rw-r--r--src/test/baseline/testCheckboxClickedOver.pngbin0 -> 1642 bytes
-rw-r--r--src/test/baseline/testCheckboxDown.pngbin0 -> 1492 bytes
-rw-r--r--src/test/baseline/testCheckboxOver.pngbin0 -> 1399 bytes
-rw-r--r--src/test/baseline/testCheckboxUp.pngbin0 -> 1212 bytes
-rw-r--r--src/test/baseline/testCircle1.pngbin0 -> 295 bytes
-rw-r--r--src/test/baseline/testCircle2.pngbin0 -> 414 bytes
-rw-r--r--src/test/baseline/testCircle3.pngbin0 -> 3350 bytes
-rw-r--r--src/test/baseline/testCircle4.pngbin0 -> 1620 bytes
-rw-r--r--src/test/baseline/testCircle5.pngbin0 -> 1821 bytes
-rw-r--r--src/test/baseline/testColorFX1.pngbin0 -> 2170 bytes
-rw-r--r--src/test/baseline/testColorFX2.pngbin0 -> 1166 bytes
-rw-r--r--src/test/baseline/testColorFX3.pngbin0 -> 1511 bytes
-rw-r--r--src/test/baseline/testColorFX4.pngbin0 -> 2103 bytes
-rw-r--r--src/test/baseline/testColorFX5.pngbin0 -> 2105 bytes
-rw-r--r--src/test/baseline/testColorFX6.pngbin0 -> 2082 bytes
-rw-r--r--src/test/baseline/testColorFX7.pngbin0 -> 3067 bytes
-rw-r--r--src/test/baseline/testComplexDiv1.pngbin0 -> 2404 bytes
-rw-r--r--src/test/baseline/testContAnim1.pngbin0 -> 6562 bytes
-rw-r--r--src/test/baseline/testContAnim2.pngbin0 -> 4908 bytes
-rw-r--r--src/test/baseline/testContAnim3.pngbin0 -> 4155 bytes
-rw-r--r--src/test/baseline/testContAnim4.pngbin0 -> 4553 bytes
-rw-r--r--src/test/baseline/testContinuousAnim1.pngbin0 -> 4723 bytes
-rw-r--r--src/test/baseline/testContinuousAnim2.pngbin0 -> 2548 bytes
-rw-r--r--src/test/baseline/testContrast1.pngbin0 -> 1640 bytes
-rw-r--r--src/test/baseline/testContrast2.pngbin0 -> 1385 bytes
-rw-r--r--src/test/baseline/testContrast3.pngbin0 -> 9533 bytes
-rw-r--r--src/test/baseline/testCropImage1.pngbin0 -> 1494 bytes
-rw-r--r--src/test/baseline/testCropImage10.pngbin0 -> 5718 bytes
-rw-r--r--src/test/baseline/testCropImage2.pngbin0 -> 1110 bytes
-rw-r--r--src/test/baseline/testCropImage3.pngbin0 -> 3572 bytes
-rw-r--r--src/test/baseline/testCropImage4.pngbin0 -> 3404 bytes
-rw-r--r--src/test/baseline/testCropImage5.pngbin0 -> 3389 bytes
-rw-r--r--src/test/baseline/testCropImage6.pngbin0 -> 7900 bytes
-rw-r--r--src/test/baseline/testCropImage7.pngbin0 -> 6616 bytes
-rw-r--r--src/test/baseline/testCropImage8.pngbin0 -> 5925 bytes
-rw-r--r--src/test/baseline/testCropImage9.pngbin0 -> 5823 bytes
-rw-r--r--src/test/baseline/testCropMovie1.pngbin0 -> 6265 bytes
-rw-r--r--src/test/baseline/testCropMovie10.pngbin0 -> 5754 bytes
-rw-r--r--src/test/baseline/testCropMovie2.pngbin0 -> 4527 bytes
-rw-r--r--src/test/baseline/testCropMovie3.pngbin0 -> 4102 bytes
-rw-r--r--src/test/baseline/testCropMovie4.pngbin0 -> 3482 bytes
-rw-r--r--src/test/baseline/testCropMovie5.pngbin0 -> 3350 bytes
-rw-r--r--src/test/baseline/testCropMovie6.pngbin0 -> 6430 bytes
-rw-r--r--src/test/baseline/testCropMovie7.pngbin0 -> 3948 bytes
-rw-r--r--src/test/baseline/testCropMovie8.pngbin0 -> 6345 bytes
-rw-r--r--src/test/baseline/testCropMovie9.pngbin0 -> 5786 bytes
-rw-r--r--src/test/baseline/testCurve1.pngbin0 -> 382 bytes
-rw-r--r--src/test/baseline/testCurve2.pngbin0 -> 552 bytes
-rw-r--r--src/test/baseline/testCurve3.pngbin0 -> 653 bytes
-rw-r--r--src/test/baseline/testCurve4.pngbin0 -> 829 bytes
-rw-r--r--src/test/baseline/testDivDynamics1.pngbin0 -> 2396 bytes
-rw-r--r--src/test/baseline/testDivDynamics2.pngbin0 -> 2620 bytes
-rw-r--r--src/test/baseline/testDivDynamics3.pngbin0 -> 2698 bytes
-rw-r--r--src/test/baseline/testDivDynamics4.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testDivDynamics5.pngbin0 -> 2396 bytes
-rw-r--r--src/test/baseline/testDraggable1.pngbin0 -> 5805 bytes
-rw-r--r--src/test/baseline/testDraggable2.pngbin0 -> 5765 bytes
-rw-r--r--src/test/baseline/testDynamicMediaDir1.pngbin0 -> 3302 bytes
-rw-r--r--src/test/baseline/testDynamicMediaDir2.pngbin0 -> 5141 bytes
-rw-r--r--src/test/baseline/testDynamicWords1.pngbin0 -> 390 bytes
-rw-r--r--src/test/baseline/testDynamicWords2.pngbin0 -> 1356 bytes
-rw-r--r--src/test/baseline/testDynamicWords3.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testDynamicWords4.pngbin0 -> 874 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnim1.pngbin0 -> 4985 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnim2.pngbin0 -> 5106 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnim3.pngbin0 -> 5045 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnimC1.pngbin0 -> 2513 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnimC2.pngbin0 -> 2513 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnimC3.pngbin0 -> 2481 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnimC4.pngbin0 -> 2182 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnimC5.pngbin0 -> 2481 bytes
-rw-r--r--src/test/baseline/testEaseInOutAnimC6.pngbin0 -> 2566 bytes
-rw-r--r--src/test/baseline/testEvents.pngbin0 -> 7493 bytes
-rw-r--r--src/test/baseline/testFXUpdateFX.pngbin0 -> 3452 bytes
-rw-r--r--src/test/baseline/testFXUpdateMaskPos.pngbin0 -> 2791 bytes
-rw-r--r--src/test/baseline/testFXUpdateMaskTex1.pngbin0 -> 1484 bytes
-rw-r--r--src/test/baseline/testFXUpdateMaskTex2.pngbin0 -> 2861 bytes
-rw-r--r--src/test/baseline/testFXUpdateTex.pngbin0 -> 2210 bytes
-rw-r--r--src/test/baseline/testFXUpdateVideo.pngbin0 -> 10424 bytes
-rw-r--r--src/test/baseline/testFadeIn1.pngbin0 -> 2161 bytes
-rw-r--r--src/test/baseline/testFadeIn2.pngbin0 -> 2304 bytes
-rw-r--r--src/test/baseline/testFadeIn3.pngbin0 -> 2473 bytes
-rw-r--r--src/test/baseline/testFadeOut1.pngbin0 -> 2161 bytes
-rw-r--r--src/test/baseline/testFadeOut2.pngbin0 -> 1886 bytes
-rw-r--r--src/test/baseline/testFadeOut3.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testFocusContext1.pngbin0 -> 3011 bytes
-rw-r--r--src/test/baseline/testFocusContext2.pngbin0 -> 3629 bytes
-rw-r--r--src/test/baseline/testFocusContext3.pngbin0 -> 4164 bytes
-rw-r--r--src/test/baseline/testFocusContext4.pngbin0 -> 2241 bytes
-rw-r--r--src/test/baseline/testFocusContext5.pngbin0 -> 1379 bytes
-rw-r--r--src/test/baseline/testFontDir.pngbin0 -> 1595 bytes
-rw-r--r--src/test/baseline/testGamma1.pngbin0 -> 2009 bytes
-rw-r--r--src/test/baseline/testGamma2.pngbin0 -> 2196 bytes
-rw-r--r--src/test/baseline/testHinting1.pngbin0 -> 2865 bytes
-rw-r--r--src/test/baseline/testHueSatFX1.pngbin0 -> 3456 bytes
-rw-r--r--src/test/baseline/testHueSatFX2.pngbin0 -> 3824 bytes
-rw-r--r--src/test/baseline/testHueSatFX3.pngbin0 -> 2641 bytes
-rw-r--r--src/test/baseline/testHueSatFX4.pngbin0 -> 3764 bytes
-rw-r--r--src/test/baseline/testHugeImage0.pngbin0 -> 3578 bytes
-rw-r--r--src/test/baseline/testHugeImage1.pngbin0 -> 3136 bytes
-rw-r--r--src/test/baseline/testI18NWords1.pngbin0 -> 2792 bytes
-rw-r--r--src/test/baseline/testI18NWords2.pngbin0 -> 3693 bytes
-rw-r--r--src/test/baseline/testI18NWords3.pngbin0 -> 3534 bytes
-rw-r--r--src/test/baseline/testImageNullFX1.pngbin0 -> 4153 bytes
-rw-r--r--src/test/baseline/testImageNullFX2.pngbin0 -> 4700 bytes
-rw-r--r--src/test/baseline/testImageNullFX3.pngbin0 -> 4174 bytes
-rw-r--r--src/test/baseline/testImgDynamics1.pngbin0 -> 2396 bytes
-rw-r--r--src/test/baseline/testImgDynamics2.pngbin0 -> 2620 bytes
-rw-r--r--src/test/baseline/testImgDynamics3.pngbin0 -> 2698 bytes
-rw-r--r--src/test/baseline/testImgDynamics4.pngbin0 -> 2858 bytes
-rw-r--r--src/test/baseline/testImgDynamics5.pngbin0 -> 2396 bytes
-rw-r--r--src/test/baseline/testImgHRef1.pngbin0 -> 2332 bytes
-rw-r--r--src/test/baseline/testImgHRef2.pngbin0 -> 2545 bytes
-rw-r--r--src/test/baseline/testImgHRef3.pngbin0 -> 3564 bytes
-rw-r--r--src/test/baseline/testImgMask1.pngbin0 -> 698 bytes
-rw-r--r--src/test/baseline/testImgMask2.pngbin0 -> 2333 bytes
-rw-r--r--src/test/baseline/testImgMask3.pngbin0 -> 2476 bytes
-rw-r--r--src/test/baseline/testImgMaskCanvas.pngbin0 -> 2081 bytes
-rw-r--r--src/test/baseline/testImgMaskPos.pngbin0 -> 867 bytes
-rw-r--r--src/test/baseline/testImgMaskSize1.pngbin0 -> 519 bytes
-rw-r--r--src/test/baseline/testImgMaskSize2.pngbin0 -> 849 bytes
-rw-r--r--src/test/baseline/testImgMaskSize3.pngbin0 -> 916 bytes
-rw-r--r--src/test/baseline/testImgPos1.pngbin0 -> 1182 bytes
-rw-r--r--src/test/baseline/testImgPos2.pngbin0 -> 1374 bytes
-rw-r--r--src/test/baseline/testImgSize1.pngbin0 -> 1055 bytes
-rw-r--r--src/test/baseline/testImgSize2.pngbin0 -> 1217 bytes
-rw-r--r--src/test/baseline/testImgWarp1.pngbin0 -> 1138 bytes
-rw-r--r--src/test/baseline/testInactiveVector1.pngbin0 -> 247 bytes
-rw-r--r--src/test/baseline/testInactiveVector2.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testIntAnim1.pngbin0 -> 2476 bytes
-rw-r--r--src/test/baseline/testIntAnim2.pngbin0 -> 2182 bytes
-rw-r--r--src/test/baseline/testIntensity1.pngbin0 -> 1620 bytes
-rw-r--r--src/test/baseline/testIntensity2.pngbin0 -> 1700 bytes
-rw-r--r--src/test/baseline/testIntensity3.pngbin0 -> 8629 bytes
-rw-r--r--src/test/baseline/testIntensity4.pngbin0 -> 3618 bytes
-rw-r--r--src/test/baseline/testInvertFX1.pngbin0 -> 619 bytes
-rw-r--r--src/test/baseline/testInvertFX2.pngbin0 -> 3674 bytes
-rw-r--r--src/test/baseline/testJustify.pngbin0 -> 2413 bytes
-rw-r--r--src/test/baseline/testLetterSpacing1.pngbin0 -> 1809 bytes
-rw-r--r--src/test/baseline/testLetterSpacing2.pngbin0 -> 1711 bytes
-rw-r--r--src/test/baseline/testLinearAnim1.pngbin0 -> 4985 bytes
-rw-r--r--src/test/baseline/testLinearAnim2.pngbin0 -> 5106 bytes
-rw-r--r--src/test/baseline/testLinearAnim3.pngbin0 -> 5106 bytes
-rw-r--r--src/test/baseline/testLinearAnimC1.pngbin0 -> 2513 bytes
-rw-r--r--src/test/baseline/testLinearAnimC2.pngbin0 -> 2469 bytes
-rw-r--r--src/test/baseline/testLinearAnimC3.pngbin0 -> 2508 bytes
-rw-r--r--src/test/baseline/testLinearAnimC4.pngbin0 -> 2182 bytes
-rw-r--r--src/test/baseline/testLinearAnimC5.pngbin0 -> 2508 bytes
-rw-r--r--src/test/baseline/testLinearAnimC6.pngbin0 -> 2500 bytes
-rw-r--r--src/test/baseline/testLinearAnimZeroDuration1.pngbin0 -> 5106 bytes
-rw-r--r--src/test/baseline/testLinearAnimZeroDuration2.pngbin0 -> 5784 bytes
-rw-r--r--src/test/baseline/testLinearAnimZeroDuration3.pngbin0 -> 5784 bytes
-rw-r--r--src/test/baseline/testLinearAnimZeroDurationC1.pngbin0 -> 2182 bytes
-rw-r--r--src/test/baseline/testLinearAnimZeroDurationC2.pngbin0 -> 5784 bytes
-rw-r--r--src/test/baseline/testLinearAnimZeroDurationC3.pngbin0 -> 5784 bytes
-rw-r--r--src/test/baseline/testMediaDir1.pngbin0 -> 6900 bytes
-rw-r--r--src/test/baseline/testMediaDir2.pngbin0 -> 4961 bytes
-rw-r--r--src/test/baseline/testMesh1.pngbin0 -> 2390 bytes
-rw-r--r--src/test/baseline/testMesh2.pngbin0 -> 2103 bytes
-rw-r--r--src/test/baseline/testMesh3.pngbin0 -> 719 bytes
-rw-r--r--src/test/baseline/testMesh4.pngbin0 -> 1810 bytes
-rw-r--r--src/test/baseline/testMesh5.pngbin0 -> 2309 bytes
-rw-r--r--src/test/baseline/testMesh6.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testMipmap.pngbin0 -> 506 bytes
-rw-r--r--src/test/baseline/testMove1.pngbin0 -> 6514 bytes
-rw-r--r--src/test/baseline/testNodeInCanvasNullFX1.pngbin0 -> 2461 bytes
-rw-r--r--src/test/baseline/testOffscreen1.pngbin0 -> 2510 bytes
-rw-r--r--src/test/baseline/testOffscreen2.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testOffscreen3.pngbin0 -> 2464 bytes
-rw-r--r--src/test/baseline/testOffscreen4.pngbin0 -> 2510 bytes
-rw-r--r--src/test/baseline/testOffscreen5.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testOffscreenAutoRender1.pngbin0 -> 2510 bytes
-rw-r--r--src/test/baseline/testOffscreenAutoRender2.pngbin0 -> 2517 bytes
-rw-r--r--src/test/baseline/testOffscreenMultisampleScreenshot.pngbin0 -> 3713 bytes
-rw-r--r--src/test/baseline/testOffscreenScreenshot.pngbin0 -> 2792 bytes
-rw-r--r--src/test/baseline/testOutlines.pngbin0 -> 3149 bytes
-rw-r--r--src/test/baseline/testPanoDynamics1.pngbin0 -> 38510 bytes
-rw-r--r--src/test/baseline/testPanoDynamics2.pngbin0 -> 2858 bytes
-rw-r--r--src/test/baseline/testPanoDynamics3.pngbin0 -> 38564 bytes
-rw-r--r--src/test/baseline/testPanoImage.pngbin0 -> 37544 bytes
-rw-r--r--src/test/baseline/testPanoImagewNOP.pngbin0 -> 37544 bytes
-rw-r--r--src/test/baseline/testParaWords.pngbin0 -> 4290 bytes
-rw-r--r--src/test/baseline/testParallelAnimC1.pngbin0 -> 3283 bytes
-rw-r--r--src/test/baseline/testParallelAnimC2.pngbin0 -> 2586 bytes
-rw-r--r--src/test/baseline/testParallelAnimC3.pngbin0 -> 2519 bytes
-rw-r--r--src/test/baseline/testParallelAnims1.pngbin0 -> 5791 bytes
-rw-r--r--src/test/baseline/testParallelAnims2.pngbin0 -> 6139 bytes
-rw-r--r--src/test/baseline/testPieSlice1.pngbin0 -> 325 bytes
-rw-r--r--src/test/baseline/testPieSlice2.pngbin0 -> 800 bytes
-rw-r--r--src/test/baseline/testPieSlice3.pngbin0 -> 142 bytes
-rw-r--r--src/test/baseline/testPlayBeforeConnect.pngbin0 -> 3986 bytes
-rw-r--r--src/test/baseline/testPointAnim1.pngbin0 -> 2510 bytes
-rw-r--r--src/test/baseline/testPointAnim2.pngbin0 -> 2506 bytes
-rw-r--r--src/test/baseline/testPointAnim3.pngbin0 -> 2506 bytes
-rw-r--r--src/test/baseline/testPolyLine1.pngbin0 -> 432 bytes
-rw-r--r--src/test/baseline/testPolyLine2.pngbin0 -> 592 bytes
-rw-r--r--src/test/baseline/testPolyLine3.pngbin0 -> 558 bytes
-rw-r--r--src/test/baseline/testPolyLine4.pngbin0 -> 616 bytes
-rw-r--r--src/test/baseline/testPolyLine5.pngbin0 -> 558 bytes
-rw-r--r--src/test/baseline/testPolyLine6.pngbin0 -> 184 bytes
-rw-r--r--src/test/baseline/testPolygon1.pngbin0 -> 565 bytes
-rw-r--r--src/test/baseline/testPolygon2.pngbin0 -> 554 bytes
-rw-r--r--src/test/baseline/testPolygon3.pngbin0 -> 716 bytes
-rw-r--r--src/test/baseline/testPolygon4.pngbin0 -> 716 bytes
-rw-r--r--src/test/baseline/testPolygon5.pngbin0 -> 767 bytes
-rw-r--r--src/test/baseline/testPolygon6.pngbin0 -> 741 bytes
-rw-r--r--src/test/baseline/testPositioning.pngbin0 -> 3435 bytes
-rw-r--r--src/test/baseline/testRawText1.pngbin0 -> 2771 bytes
-rw-r--r--src/test/baseline/testRawText2.pngbin0 -> 4481 bytes
-rw-r--r--src/test/baseline/testRawText3.pngbin0 -> 4222 bytes
-rw-r--r--src/test/baseline/testRawText4.pngbin0 -> 1946 bytes
-rw-r--r--src/test/baseline/testRect1.pngbin0 -> 212 bytes
-rw-r--r--src/test/baseline/testRect2.pngbin0 -> 196 bytes
-rw-r--r--src/test/baseline/testRect3.pngbin0 -> 235 bytes
-rw-r--r--src/test/baseline/testRect4.pngbin0 -> 321 bytes
-rw-r--r--src/test/baseline/testRenderPipeline.pngbin0 -> 3381 bytes
-rw-r--r--src/test/baseline/testRotate1.pngbin0 -> 4931 bytes
-rw-r--r--src/test/baseline/testRotate1a.pngbin0 -> 2369 bytes
-rw-r--r--src/test/baseline/testRotate1b.pngbin0 -> 2363 bytes
-rw-r--r--src/test/baseline/testRotate2.pngbin0 -> 980 bytes
-rw-r--r--src/test/baseline/testRotatePivot1.pngbin0 -> 4188 bytes
-rw-r--r--src/test/baseline/testRotatePivot2.pngbin0 -> 6048 bytes
-rw-r--r--src/test/baseline/testRotatePivot3.pngbin0 -> 4942 bytes
-rw-r--r--src/test/baseline/testRoundedRect1.pngbin0 -> 312 bytes
-rw-r--r--src/test/baseline/testRoundedRect2.pngbin0 -> 311 bytes
-rw-r--r--src/test/baseline/testRoundedRect3.pngbin0 -> 212 bytes
-rw-r--r--src/test/baseline/testRoundedRect4.pngbin0 -> 221 bytes
-rw-r--r--src/test/baseline/testRoundedRect5.pngbin0 -> 256 bytes
-rw-r--r--src/test/baseline/testRoundedRect6.pngbin0 -> 237 bytes
-rw-r--r--src/test/baseline/testScrollPane1.pngbin0 -> 429 bytes
-rw-r--r--src/test/baseline/testScrollPane2.pngbin0 -> 1682 bytes
-rw-r--r--src/test/baseline/testScrollPane3.pngbin0 -> 998 bytes
-rw-r--r--src/test/baseline/testScrollPane4.pngbin0 -> 1012 bytes
-rw-r--r--src/test/baseline/testShadowFX1.pngbin0 -> 2173 bytes
-rw-r--r--src/test/baseline/testShadowFX2.pngbin0 -> 2759 bytes
-rw-r--r--src/test/baseline/testShadowFX3.pngbin0 -> 1157 bytes
-rw-r--r--src/test/baseline/testShadowFX4.pngbin0 -> 1154 bytes
-rw-r--r--src/test/baseline/testShadowFX5.pngbin0 -> 2703 bytes
-rw-r--r--src/test/baseline/testShadowFX6.pngbin0 -> 805 bytes
-rw-r--r--src/test/baseline/testSimpleWords.pngbin0 -> 1955 bytes
-rw-r--r--src/test/baseline/testSpanWords.pngbin0 -> 2503 bytes
-rw-r--r--src/test/baseline/testSplineAnim1.pngbin0 -> 4985 bytes
-rw-r--r--src/test/baseline/testSplineAnim2.pngbin0 -> 5106 bytes
-rw-r--r--src/test/baseline/testSplineAnim3.pngbin0 -> 6171 bytes
-rw-r--r--src/test/baseline/testStateAnim1.pngbin0 -> 5765 bytes
-rw-r--r--src/test/baseline/testStateAnim2.pngbin0 -> 5320 bytes
-rw-r--r--src/test/baseline/testStateAnim3.pngbin0 -> 5320 bytes
-rw-r--r--src/test/baseline/testStateAnim4.pngbin0 -> 5765 bytes
-rw-r--r--src/test/baseline/testStateAnim5.pngbin0 -> 5320 bytes
-rw-r--r--src/test/baseline/testStateAnimC1.pngbin0 -> 2473 bytes
-rw-r--r--src/test/baseline/testStateAnimC2.pngbin0 -> 2506 bytes
-rw-r--r--src/test/baseline/testStateAnimC3.pngbin0 -> 2472 bytes
-rw-r--r--src/test/baseline/testStateAnimC4.pngbin0 -> 2506 bytes
-rw-r--r--src/test/baseline/testStateAnimC5.pngbin0 -> 2506 bytes
-rw-r--r--src/test/baseline/testSvgBmp.pngbin0 -> 157 bytes
-rw-r--r--src/test/baseline/testSvgNode.pngbin0 -> 222 bytes
-rw-r--r--src/test/baseline/testSvgPosBmp.pngbin0 -> 155 bytes
-rw-r--r--src/test/baseline/testSvgScaleBmp1.pngbin0 -> 347 bytes
-rw-r--r--src/test/baseline/testSvgScaleBmp2.pngbin0 -> 207 bytes
-rw-r--r--src/test/baseline/testSvgScaledNode1.pngbin0 -> 359 bytes
-rw-r--r--src/test/baseline/testSvgScaledNode2.pngbin0 -> 511 bytes
-rw-r--r--src/test/baseline/testTexCompression1.pngbin0 -> 2367 bytes
-rw-r--r--src/test/baseline/testTexCompression2.pngbin0 -> 810 bytes
-rw-r--r--src/test/baseline/testTextArea1.pngbin0 -> 2681 bytes
-rw-r--r--src/test/baseline/testTextArea2.pngbin0 -> 354 bytes
-rw-r--r--src/test/baseline/testTexturedCurve1.pngbin0 -> 3811 bytes
-rw-r--r--src/test/baseline/testTexturedCurve2.pngbin0 -> 4002 bytes
-rw-r--r--src/test/baseline/testTexturedPolyLine1.pngbin0 -> 2755 bytes
-rw-r--r--src/test/baseline/testTexturedPolyLine2.pngbin0 -> 2545 bytes
-rw-r--r--src/test/baseline/testTexturedPolyLine3.pngbin0 -> 3059 bytes
-rw-r--r--src/test/baseline/testTexturedPolyLine4.pngbin0 -> 2482 bytes
-rw-r--r--src/test/baseline/testTexturedPolygon1.pngbin0 -> 5278 bytes
-rw-r--r--src/test/baseline/testTexturedPolygon2.pngbin0 -> 4889 bytes
-rw-r--r--src/test/baseline/testTexturedPolygon3.pngbin0 -> 4985 bytes
-rw-r--r--src/test/baseline/testTexturedPolygon4.pngbin0 -> 5447 bytes
-rw-r--r--src/test/baseline/testTexturedPolygon5.pngbin0 -> 2624 bytes
-rw-r--r--src/test/baseline/testTexturedPolygon6.pngbin0 -> 2629 bytes
-rw-r--r--src/test/baseline/testTexturedRect1.pngbin0 -> 2487 bytes
-rw-r--r--src/test/baseline/testTexturedRect2.pngbin0 -> 2515 bytes
-rw-r--r--src/test/baseline/testTexturedRect3.pngbin0 -> 3933 bytes
-rw-r--r--src/test/baseline/testTexturedRect4.pngbin0 -> 1950 bytes
-rw-r--r--src/test/baseline/testTexturedRect5.pngbin0 -> 2008 bytes
-rw-r--r--src/test/baseline/testTexturedRect6.pngbin0 -> 1491 bytes
-rw-r--r--src/test/baseline/testTexturedRect7.pngbin0 -> 251 bytes
-rw-r--r--src/test/baseline/testTexturedRect8.pngbin0 -> 283 bytes
-rw-r--r--src/test/baseline/testUIButtonDisabled.pngbin0 -> 1722 bytes
-rw-r--r--src/test/baseline/testUIButtonDown.pngbin0 -> 1657 bytes
-rw-r--r--src/test/baseline/testUIButtonUp.pngbin0 -> 1364 bytes
-rw-r--r--src/test/baseline/testUIKeyboard.pngbin0 -> 971 bytes
-rw-r--r--src/test/baseline/testUIKeyboardDownA1.pngbin0 -> 1285 bytes
-rw-r--r--src/test/baseline/testUIKeyboardDownA111S1.pngbin0 -> 1530 bytes
-rw-r--r--src/test/baseline/testUIKeyboardDownA212S2.pngbin0 -> 1531 bytes
-rw-r--r--src/test/baseline/testUIKeyboardDownS1.pngbin0 -> 1200 bytes
-rw-r--r--src/test/baseline/testVideo-h264-48x48.h2641.pngbin0 -> 9756 bytes
-rw-r--r--src/test/baseline/testVideo-mjpeg-48x48.avi1.pngbin0 -> 13061 bytes
-rw-r--r--src/test/baseline/testVideo-mpeg1-48x48-sound.avi1.pngbin0 -> 10948 bytes
-rw-r--r--src/test/baseline/testVideo-mpeg1-48x48.mpg1.pngbin0 -> 10904 bytes
-rw-r--r--src/test/baseline/testVideo-rgba-48x48.mov1.pngbin0 -> 6434 bytes
-rw-r--r--src/test/baseline/testVideo-vp6a-yuva-48x48.flv1.pngbin0 -> 10033 bytes
-rw-r--r--src/test/baseline/testVideoActive1.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testVideoActive2.pngbin0 -> 10508 bytes
-rw-r--r--src/test/baseline/testVideoDynamics1.pngbin0 -> 4236 bytes
-rw-r--r--src/test/baseline/testVideoDynamics2.pngbin0 -> 5735 bytes
-rw-r--r--src/test/baseline/testVideoDynamics3.pngbin0 -> 5598 bytes
-rw-r--r--src/test/baseline/testVideoDynamics4.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testVideoDynamics5.pngbin0 -> 4236 bytes
-rw-r--r--src/test/baseline/testVideoFPS.pngbin0 -> 3215 bytes
-rw-r--r--src/test/baseline/testVideoHRef1.pngbin0 -> 3531 bytes
-rw-r--r--src/test/baseline/testVideoLoop.pngbin0 -> 10904 bytes
-rw-r--r--src/test/baseline/testVideoMaskRGBA1.pngbin0 -> 804 bytes
-rw-r--r--src/test/baseline/testVideoMaskRGBA2.pngbin0 -> 2147 bytes
-rw-r--r--src/test/baseline/testVideoMaskRGBA3.pngbin0 -> 2619 bytes
-rw-r--r--src/test/baseline/testVideoMaskRGBA4.pngbin0 -> 2194 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUV1.pngbin0 -> 1499 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUV2.pngbin0 -> 4117 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUV3.pngbin0 -> 3861 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUV4.pngbin0 -> 3115 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUVJ1.pngbin0 -> 1804 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUVJ2.pngbin0 -> 417 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUVJ3.pngbin0 -> 1524 bytes
-rw-r--r--src/test/baseline/testVideoMaskYUVJ4.pngbin0 -> 1092 bytes
-rw-r--r--src/test/baseline/testVideoNullFX.pngbin0 -> 4769 bytes
-rw-r--r--src/test/baseline/testVideoOpacityRGBA1.pngbin0 -> 2215 bytes
-rw-r--r--src/test/baseline/testVideoOpacityRGBA2.pngbin0 -> 2245 bytes
-rw-r--r--src/test/baseline/testVideoOpacityYUV1.pngbin0 -> 3986 bytes
-rw-r--r--src/test/baseline/testVideoOpacityYUV2.pngbin0 -> 3976 bytes
-rw-r--r--src/test/baseline/testVideoSeek0.pngbin0 -> 11091 bytes
-rw-r--r--src/test/baseline/testVideoSeek1.pngbin0 -> 11683 bytes
-rw-r--r--src/test/baseline/testVideoSeek2.pngbin0 -> 11139 bytes
-rw-r--r--src/test/baseline/testVideoSeek3.pngbin0 -> 851 bytes
-rw-r--r--src/test/baseline/testVideoState1.pngbin0 -> 10904 bytes
-rw-r--r--src/test/baseline/testVideoState2.pngbin0 -> 10424 bytes
-rw-r--r--src/test/baseline/testVideoState3.pngbin0 -> 10561 bytes
-rw-r--r--src/test/baseline/testVideoState4.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testVideoState5.pngbin0 -> 10904 bytes
-rw-r--r--src/test/baseline/testVideoWriter1.pngbin0 -> 4659 bytes
-rw-r--r--src/test/baseline/testVideoWriterCanvas1.pngbin0 -> 3935 bytes
-rw-r--r--src/test/baseline/testWarp1.pngbin0 -> 8512 bytes
-rw-r--r--src/test/baseline/testWarp2.pngbin0 -> 8401 bytes
-rw-r--r--src/test/baseline/testWarp3.pngbin0 -> 8451 bytes
-rw-r--r--src/test/baseline/testWordsBR.pngbin0 -> 1170 bytes
-rw-r--r--src/test/baseline/testWordsDynamics1.pngbin0 -> 513 bytes
-rw-r--r--src/test/baseline/testWordsDynamics2.pngbin0 -> 552 bytes
-rw-r--r--src/test/baseline/testWordsDynamics3.pngbin0 -> 552 bytes
-rw-r--r--src/test/baseline/testWordsDynamics4.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testWordsDynamics5.pngbin0 -> 513 bytes
-rw-r--r--src/test/baseline/testWordsMask1.pngbin0 -> 4057 bytes
-rw-r--r--src/test/baseline/testWordsMask2.pngbin0 -> 3471 bytes
-rw-r--r--src/test/baseline/testWordsMask3.pngbin0 -> 3420 bytes
-rw-r--r--src/test/baseline/testWordsMask4.pngbin0 -> 4055 bytes
-rw-r--r--src/test/baseline/testWordsMask5.pngbin0 -> 4129 bytes
-rw-r--r--src/test/baseline/testWordsMask6.pngbin0 -> 3854 bytes
-rw-r--r--src/test/baseline/testWordsNullFX.pngbin0 -> 949 bytes
-rw-r--r--src/test/baseline/testWordsShadowFX1.pngbin0 -> 2034 bytes
-rw-r--r--src/test/baseline/testWordsShadowFX2.pngbin0 -> 2228 bytes
-rw-r--r--src/test/baseline/testWrapMode1.pngbin0 -> 2901 bytes
-rw-r--r--src/test/baseline/testWrapMode2.pngbin0 -> 3698 bytes
-rw-r--r--src/test/baseline/testWrapMode3.pngbin0 -> 2901 bytes
-rw-r--r--src/test/baseline/testWrapMode4.pngbin0 -> 3927 bytes
-rw-r--r--src/test/baseline/testbasics.pngbin0 -> 2510 bytes
-rw-r--r--src/test/baseline/testline1.pngbin0 -> 348 bytes
-rw-r--r--src/test/baseline/testline2.pngbin0 -> 351 bytes
-rw-r--r--src/test/baseline/testline3.pngbin0 -> 364 bytes
-rw-r--r--src/test/baseline/testline4.pngbin0 -> 385 bytes
-rw-r--r--src/test/baseline/testlineopacity1.pngbin0 -> 154 bytes
-rw-r--r--src/test/baseline/testlineopacity2.pngbin0 -> 156 bytes
-rw-r--r--src/test/baseline/testlotsoflines.pngbin0 -> 369 bytes
-rw-r--r--src/test/baseline/testplugin1.pngbin0 -> 356 bytes
-rw-r--r--src/test/baseline/testplugin2.pngbin0 -> 357 bytes
-rw-r--r--src/test/baseline/testtexturedline1.pngbin0 -> 1854 bytes
-rw-r--r--src/test/baseline/testtexturedline2.pngbin0 -> 136 bytes
-rw-r--r--src/test/baseline/testtexturedline3.pngbin0 -> 1371 bytes
-rw-r--r--src/test/baseline/testtexturedline4.pngbin0 -> 1837 bytes
-rw-r--r--src/test/baseline/testtexturedline5.pngbin0 -> 213 bytes
-rw-r--r--src/test/button_check.pngbin0 -> 3040 bytes
-rw-r--r--src/test/button_disabled.pngbin0 -> 4308 bytes
-rw-r--r--src/test/button_down.pngbin0 -> 4221 bytes
-rw-r--r--src/test/button_over.pngbin0 -> 4131 bytes
-rw-r--r--src/test/button_up.pngbin0 -> 3923 bytes
-rw-r--r--src/test/camcfgs.py133
-rwxr-xr-xsrc/test/checkcamera.py227
-rw-r--r--src/test/checker.pngbin0 -> 3526 bytes
-rwxr-xr-xsrc/test/checkspeed.py105
-rw-r--r--src/test/colorramp.pngbin0 -> 4471 bytes
-rw-r--r--src/test/crop_bkgd.pngbin0 -> 369 bytes
-rw-r--r--src/test/extrafonts/.svn/entries62
-rw-r--r--src/test/extrafonts/.svn/prop-base/testaddfontdir.ttf.svn-base5
-rw-r--r--src/test/extrafonts/.svn/text-base/testaddfontdir.ttf.svn-basebin0 -> 1736 bytes
-rw-r--r--src/test/extrafonts/testaddfontdir.ttfbin0 -> 1736 bytes
-rw-r--r--src/test/fonts/.svn/entries164
-rw-r--r--src/test/fonts/.svn/prop-base/Vera.ttf.svn-base5
-rw-r--r--src/test/fonts/.svn/prop-base/VeraBI.ttf.svn-base5
-rw-r--r--src/test/fonts/.svn/prop-base/VeraBd.ttf.svn-base5
-rw-r--r--src/test/fonts/.svn/prop-base/VeraIt.ttf.svn-base5
-rw-r--r--src/test/fonts/.svn/text-base/Vera.ttf.svn-basebin0 -> 65932 bytes
-rw-r--r--src/test/fonts/.svn/text-base/VeraBI.ttf.svn-basebin0 -> 63208 bytes
-rw-r--r--src/test/fonts/.svn/text-base/VeraBd.ttf.svn-basebin0 -> 58716 bytes
-rw-r--r--src/test/fonts/.svn/text-base/VeraIt.ttf.svn-basebin0 -> 63684 bytes
-rw-r--r--src/test/fonts/Vera.ttfbin0 -> 65932 bytes
-rw-r--r--src/test/fonts/VeraBI.ttfbin0 -> 63208 bytes
-rw-r--r--src/test/fonts/VeraBd.ttfbin0 -> 58716 bytes
-rw-r--r--src/test/fonts/VeraIt.ttfbin0 -> 63684 bytes
-rw-r--r--src/test/freidrehen.jpgbin0 -> 3856 bytes
-rw-r--r--src/test/greyscale.pngbin0 -> 2245 bytes
-rw-r--r--src/test/illustratorRect.svg7
-rw-r--r--src/test/image.avg8
-rw-r--r--src/test/keyboard_bg.pngbin0 -> 781 bytes
-rw-r--r--src/test/keyboard_ovl.pngbin0 -> 775 bytes
-rw-r--r--src/test/mask.pngbin0 -> 1270 bytes
-rw-r--r--src/test/mask1.pngbin0 -> 227 bytes
-rw-r--r--src/test/mask2.pngbin0 -> 1598 bytes
-rw-r--r--src/test/oe.pngbin0 -> 3178 bytes
-rw-r--r--src/test/panoimage.pngbin0 -> 58076 bytes
-rw-r--r--src/test/plugin/ColorNode.cpp163
-rw-r--r--src/test/plugin/Makefile.am19
-rw-r--r--src/test/plugin/Makefile.in619
-rw-r--r--src/test/rect.svg8
-rw-r--r--src/test/rectborder.pngbin0 -> 2810 bytes
-rw-r--r--src/test/rgb24-32x32.pngbin0 -> 3584 bytes
-rw-r--r--src/test/rgb24-64x64.pngbin0 -> 2092 bytes
-rw-r--r--src/test/rgb24-65x65.pngbin0 -> 2210 bytes
-rw-r--r--src/test/rgb24alpha-32x32.pngbin0 -> 4088 bytes
-rw-r--r--src/test/rgb24alpha-64x64.pngbin0 -> 3392 bytes
-rw-r--r--src/test/rgb24alpha.tifbin0 -> 29970 bytes
-rw-r--r--src/test/shadow.pngbin0 -> 3168 bytes
-rw-r--r--src/test/testapp.py168
-rw-r--r--src/test/testcase.py327
-rw-r--r--src/test/testmediadir/mjpeg-48x48.avibin0 -> 10240 bytes
-rw-r--r--src/test/testmediadir/rgb24-64x64a.pngbin0 -> 3392 bytes
-rw-r--r--src/test/widebmp.jpgbin0 -> 33903 bytes
-rw-r--r--src/utils/Makefile.am5
-rw-r--r--src/utils/Makefile.in536
-rwxr-xr-xsrc/utils/avg_audioplayer.py51
-rwxr-xr-xsrc/utils/avg_checktouch.py54
-rwxr-xr-xsrc/utils/avg_checkvsync.py44
-rwxr-xr-xsrc/utils/avg_chromakey.py246
-rwxr-xr-xsrc/utils/avg_showcamera.py165
-rwxr-xr-xsrc/utils/avg_showfile.py40
-rwxr-xr-xsrc/utils/avg_showfont.py74
-rwxr-xr-xsrc/utils/avg_showsvg.py58
-rwxr-xr-xsrc/utils/avg_videoinfo.py219
-rwxr-xr-xsrc/utils/avg_videoplayer.py101
-rw-r--r--src/video/AVCCOpaque.cpp48
-rw-r--r--src/video/AVCCOpaque.h45
-rw-r--r--src/video/AsyncDemuxer.cpp152
-rw-r--r--src/video/AsyncDemuxer.h63
-rw-r--r--src/video/AsyncVideoDecoder.cpp494
-rw-r--r--src/video/AsyncVideoDecoder.h115
-rw-r--r--src/video/AudioDecoderThread.cpp93
-rw-r--r--src/video/AudioDecoderThread.h59
-rw-r--r--src/video/FFMpegDecoder.cpp1208
-rw-r--r--src/video/FFMpegDecoder.h178
-rw-r--r--src/video/FFMpegDemuxer.cpp142
-rw-r--r--src/video/FFMpegDemuxer.h59
-rw-r--r--src/video/FrameAge.cpp34
-rw-r--r--src/video/FrameAge.h37
-rw-r--r--src/video/IDemuxer.h46
-rw-r--r--src/video/Makefile.am47
-rw-r--r--src/video/Makefile.in756
-rw-r--r--src/video/PacketVideoMsg.cpp57
-rw-r--r--src/video/PacketVideoMsg.h55
-rw-r--r--src/video/VDPAU.cpp393
-rw-r--r--src/video/VDPAU.h115
-rw-r--r--src/video/VideoDecoder.cpp42
-rw-r--r--src/video/VideoDecoder.h86
-rw-r--r--src/video/VideoDecoderThread.cpp163
-rw-r--r--src/video/VideoDecoderThread.h67
-rw-r--r--src/video/VideoDemuxerThread.cpp130
-rw-r--r--src/video/VideoDemuxerThread.h63
-rw-r--r--src/video/VideoInfo.cpp64
-rw-r--r--src/video/VideoInfo.h63
-rw-r--r--src/video/VideoMsg.cpp141
-rw-r--r--src/video/VideoMsg.h94
-rw-r--r--src/video/WrapFFMpeg.h60
-rw-r--r--src/video/baseline/mjpeg-48x48.avi_1.pngbin0 -> 7047 bytes
-rw-r--r--src/video/baseline/mjpeg-48x48.avi_100.pngbin0 -> 6784 bytes
-rw-r--r--src/video/baseline/mjpeg-48x48.avi_2.pngbin0 -> 7029 bytes
-rw-r--r--src/video/baseline/mjpeg-48x48.avi_201.pngbin0 -> 6978 bytes
-rw-r--r--src/video/baseline/mjpeg-48x48.avi_53.pngbin0 -> 6817 bytes
-rw-r--r--src/video/baseline/mjpeg-48x48.avi_end.pngbin0 -> 6967 bytes
-rw-r--r--src/video/baseline/mjpeg-48x48.avi_loop.pngbin0 -> 7041 bytes
-rw-r--r--src/video/baseline/mpeg1-48x48-sound.avi_end.pngbin0 -> 3282 bytes
-rw-r--r--src/video/baseline/mpeg1-48x48-sound.avi_loop.pngbin0 -> 3428 bytes
-rw-r--r--src/video/baseline/mpeg1-48x48.mpg_1.pngbin0 -> 6127 bytes
-rw-r--r--src/video/baseline/mpeg1-48x48.mpg_2.pngbin0 -> 5951 bytes
-rw-r--r--src/video/baseline/mpeg1-48x48.mpg_end.pngbin0 -> 5953 bytes
-rw-r--r--src/video/baseline/mpeg1-48x48.mpg_loop.pngbin0 -> 6138 bytes
-rwxr-xr-xsrc/video/testfiles/22.050Hz_16bit_mono.wavbin0 -> 4454 bytes
-rw-r--r--src/video/testfiles/44.1kHz_16bit_6Chan.oggbin0 -> 159170 bytes
-rwxr-xr-xsrc/video/testfiles/44.1kHz_16bit_mono.wavbin0 -> 8864 bytes
-rwxr-xr-xsrc/video/testfiles/44.1kHz_16bit_stereo.aifbin0 -> 352854 bytes
-rwxr-xr-xsrc/video/testfiles/44.1kHz_16bit_stereo.wavbin0 -> 352844 bytes
-rwxr-xr-xsrc/video/testfiles/44.1kHz_24bit_mono.wavbin0 -> 8864 bytes
-rwxr-xr-xsrc/video/testfiles/44.1kHz_24bit_stereo.aifbin0 -> 529254 bytes
-rwxr-xr-xsrc/video/testfiles/44.1kHz_24bit_stereo.wavbin0 -> 352844 bytes
-rwxr-xr-xsrc/video/testfiles/44.1kHz_mono.oggbin0 -> 4177 bytes
-rw-r--r--src/video/testfiles/44.1kHz_stereo.mp3bin0 -> 47647 bytes
-rw-r--r--src/video/testfiles/44.1kHz_stereo.oggbin0 -> 10211 bytes
-rwxr-xr-xsrc/video/testfiles/48kHz_16bit_mono.wavbin0 -> 9644 bytes
-rwxr-xr-xsrc/video/testfiles/48kHz_16bit_stereo.aifbin0 -> 384054 bytes
-rwxr-xr-xsrc/video/testfiles/48kHz_16bit_stereo.wavbin0 -> 384044 bytes
-rwxr-xr-xsrc/video/testfiles/48kHz_24bit_mono.wavbin0 -> 9644 bytes
-rwxr-xr-xsrc/video/testfiles/48kHz_24bit_stereo.aifbin0 -> 576054 bytes
-rwxr-xr-xsrc/video/testfiles/48kHz_24bit_stereo.wavbin0 -> 384044 bytes
-rw-r--r--src/video/testfiles/48kHz_stereo.mp3bin0 -> 47808 bytes
-rw-r--r--src/video/testfiles/48kHz_stereo.oggbin0 -> 104701 bytes
-rw-r--r--src/video/testfiles/h264-48x48.h264bin0 -> 131081 bytes
-rw-r--r--src/video/testfiles/mjpeg-48x48.avibin0 -> 329852 bytes
-rw-r--r--src/video/testfiles/mpeg1-48x48-sound.avibin0 -> 28534 bytes
-rw-r--r--src/video/testfiles/mpeg1-48x48.mpgbin0 -> 10240 bytes
-rw-r--r--src/video/testfiles/rgba-48x48.movbin0 -> 127378 bytes
-rw-r--r--src/video/testfiles/vp6a-yuva-48x48.flvbin0 -> 13669 bytes
-rw-r--r--src/video/testvideo.cpp527
-rw-r--r--src/wrapper/Makefile.am39
-rw-r--r--src/wrapper/Makefile.in675
-rw-r--r--src/wrapper/WrapHelper.cpp345
-rw-r--r--src/wrapper/WrapHelper.h320
-rw-r--r--src/wrapper/anim_wrap.cpp112
-rw-r--r--src/wrapper/avg_wrap.cpp260
-rw-r--r--src/wrapper/bitmap_wrap.cpp162
-rw-r--r--src/wrapper/device_wrap.cpp93
-rw-r--r--src/wrapper/event_wrap.cpp250
-rw-r--r--src/wrapper/fx_wrap.cpp101
-rw-r--r--src/wrapper/node_wrap.cpp340
-rw-r--r--src/wrapper/raster_wrap.cpp208
-rw-r--r--src/wrapper/raw_constructor.hpp61
1196 files changed, 115198 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..9752f5d
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,9 @@
+if ENABLE_TESTS
+ TESTDIRS = test
+endif
+
+SUBDIRS = base graphics imaging lmfit oscpack audio video player conradrelais parport \
+ anim wrapper python utils samples $(TESTDIRS)
+
+EXTRA_DIST = avgrc avgconfigwrapper.h api.h avgconfig_win.h
+
diff --git a/src/Makefile.in b/src/Makefile.in
new file mode 100644
index 0000000..91a5913
--- /dev/null
+++ b/src/Makefile.in
@@ -0,0 +1,653 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+ $(srcdir)/avgconfig.h.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = base graphics imaging lmfit oscpack audio video player conradrelais parport \
+ anim wrapper python test utils samples
+
+EXTRA_DIST = avgrc avgconfigwrapper.h api.h avgconfig_win.h
+all: avgconfig.h
+ $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+avgconfig.h: stamp-h1
+ @if test ! -f $@; then \
+ rm -f stamp-h1; \
+ $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+ else :; fi
+
+stamp-h1: $(srcdir)/avgconfig.h.in $(top_builddir)/config.status
+ @rm -f stamp-h1
+ cd $(top_builddir) && $(SHELL) ./config.status src/avgconfig.h
+$(srcdir)/avgconfig.h.in: $(am__configure_deps)
+ ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+ rm -f stamp-h1
+ touch $@
+
+distclean-hdr:
+ -rm -f avgconfig.h stamp-h1
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @fail= failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @fail= failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) avgconfig.h.in $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) avgconfig.h.in $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) avgconfig.h.in $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) avgconfig.h.in $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile avgconfig.h
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-hdr distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all \
+ ctags-recursive install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-generic clean-libtool \
+ ctags ctags-recursive distclean distclean-generic \
+ distclean-hdr distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-recursive uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/anim/Anim.cpp b/src/anim/Anim.cpp
new file mode 100644
index 0000000..c5dc830
--- /dev/null
+++ b/src/anim/Anim.cpp
@@ -0,0 +1,123 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+
+#include "Anim.h"
+
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include "../player/Player.h"
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+Anim::Anim(const object& startCallback, const object& stopCallback)
+ : m_StartCallback(startCallback),
+ m_StopCallback(stopCallback),
+ m_bRunning(false),
+ m_bIsRoot(true)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ Player::get()->registerPlaybackEndListener(this);
+}
+
+Anim::~Anim()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+ if (Player::exists()) {
+ Player::get()->unregisterPlaybackEndListener(this);
+ }
+}
+
+void Anim::setStartCallback(const object& startCallback)
+{
+ m_StartCallback = startCallback;
+}
+
+void Anim::setStopCallback(const object& stopCallback)
+{
+ m_StopCallback = stopCallback;
+}
+
+void Anim::start(bool)
+{
+ if (m_bRunning) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "Anim.start(): animation already running."));
+ }
+ if (!(Player::get()->isPlaying())) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "Animation playback can only be started when the player is running."));
+ }
+ m_bRunning = true;
+ if (m_bIsRoot) {
+ Player::get()->registerPreRenderListener(this);
+ }
+ if (m_StartCallback != object()) {
+ call<void>(m_StartCallback.ptr());
+ }
+}
+
+bool Anim::isRunning() const
+{
+ return m_bRunning;
+}
+
+void Anim::setHasParent()
+{
+ assert(!m_bRunning);
+ m_bIsRoot = false;
+}
+
+void Anim::onPreRender()
+{
+ step();
+}
+
+void Anim::onPlaybackEnd()
+{
+ AnimPtr tempThis = shared_from_this();
+ m_StartCallback = object();
+ m_StopCallback = object();
+ if (m_bRunning) {
+ abort();
+ }
+}
+
+void Anim::setStopped()
+{
+ if (m_bIsRoot) {
+ Player::get()->unregisterPreRenderListener(this);
+ }
+ m_bRunning = false;
+ if (m_StopCallback != object()) {
+ try {
+ m_StopCallback();
+ } catch (error_already_set &) {
+ cerr << "Python exception in Anim stop callback." << endl;
+ PyErr_Print();
+ exit(5);
+ }
+ }
+}
+
+}
diff --git a/src/anim/Anim.h b/src/anim/Anim.h
new file mode 100644
index 0000000..b704090
--- /dev/null
+++ b/src/anim/Anim.h
@@ -0,0 +1,90 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Anim_H_
+#define _Anim_H_
+
+#include "../api.h"
+// Python docs say python.h should be included before any standard headers (!)
+#include "../player/WrapPython.h"
+
+#include "../base/IPreRenderListener.h"
+#include "../base/IPlaybackEndListener.h"
+
+#include <boost/python.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <boost/enable_shared_from_this.hpp>
+
+#include <string>
+
+namespace avg {
+
+class Anim;
+class GroupAnim;
+
+typedef boost::shared_ptr<class Anim> AnimPtr;
+typedef boost::weak_ptr<class Anim> AnimWeakPtr;
+
+class AVG_API Anim: public boost::enable_shared_from_this<Anim>, IPreRenderListener,
+ IPlaybackEndListener
+{
+public:
+ Anim(const boost::python::object& startCallback,
+ const boost::python::object& stopCallback);
+ virtual ~Anim();
+
+ void setStartCallback(const boost::python::object& startCallback);
+ void setStopCallback(const boost::python::object& stopCallback);
+ virtual void start(bool bKeepAttr=false);
+ virtual void abort() = 0;
+ bool isRunning() const;
+ void setHasParent();
+
+ virtual void onPreRender();
+ virtual void onPlaybackEnd();
+ virtual bool step() = 0;
+
+protected:
+ void setStopped();
+
+private:
+ Anim();
+ Anim(const Anim&);
+ boost::python::object m_StartCallback;
+ boost::python::object m_StopCallback;
+ bool m_bRunning;
+ bool m_bIsRoot;
+};
+
+template<class T>
+bool isPythonType(const boost::python::object& obj)
+{
+ boost::python::extract<T> ext(obj);
+ return ext.check();
+}
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/AttrAnim.cpp b/src/anim/AttrAnim.cpp
new file mode 100644
index 0000000..8a01471
--- /dev/null
+++ b/src/anim/AttrAnim.cpp
@@ -0,0 +1,107 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+
+#include "AttrAnim.h"
+
+#include "../base/Exception.h"
+#include "../player/Player.h"
+#include "../player/Node.h"
+
+using namespace boost;
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+AttrAnim::AttrAnimationMap AttrAnim::s_ActiveAnimations;
+
+bool ObjAttrID::operator < (const ObjAttrID& other) const
+{
+ Node * pNode = extract<Node*>(m_Node);
+ Node * pOtherNode = extract<Node*>(other.m_Node);
+ if (pNode < pOtherNode) {
+ return true;
+ } else if (pNode > pOtherNode) {
+ return false;
+ } else if (m_sAttrName < other.m_sAttrName) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+int AttrAnim::getNumRunningAnims()
+{
+ return s_ActiveAnimations.size();
+}
+
+AttrAnim::AttrAnim(const object& node, const string& sAttrName,
+ const object& startCallback, const object& stopCallback)
+ : Anim(startCallback, stopCallback),
+ m_Node(node),
+ m_sAttrName(sAttrName)
+{
+ object obj = getValue();
+}
+
+AttrAnim::~AttrAnim()
+{
+}
+
+void AttrAnim::start(bool bKeepAttr)
+{
+ stopActiveAttrAnim();
+ Anim::start();
+ addToMap();
+}
+
+object AttrAnim::getValue() const
+{
+ return m_Node.attr(m_sAttrName.c_str());
+}
+
+void AttrAnim::setValue(const object& val)
+{
+ m_Node.attr(m_sAttrName.c_str()) = val;
+}
+
+void AttrAnim::addToMap()
+{
+ s_ActiveAnimations[ObjAttrID(m_Node, m_sAttrName)] =
+ dynamic_pointer_cast<AttrAnim>(shared_from_this());
+}
+
+void AttrAnim::removeFromMap()
+{
+ s_ActiveAnimations.erase(ObjAttrID(m_Node, m_sAttrName));
+}
+
+void AttrAnim::stopActiveAttrAnim()
+{
+ ObjAttrID id(m_Node, m_sAttrName);
+ AttrAnimationMap::iterator it = s_ActiveAnimations.find(id);
+ if (it != s_ActiveAnimations.end()) {
+ it->second->abort();
+ }
+}
+
+
+
+}
diff --git a/src/anim/AttrAnim.h b/src/anim/AttrAnim.h
new file mode 100644
index 0000000..44c09c4
--- /dev/null
+++ b/src/anim/AttrAnim.h
@@ -0,0 +1,92 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _AttrAnim_H_
+#define _AttrAnim_H_
+
+#include "Anim.h"
+
+#include "../api.h"
+// Python docs say python.h should be included before any standard headers (!)
+#include "../player/WrapPython.h"
+
+#include <boost/python.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+struct ObjAttrID {
+ ObjAttrID(const boost::python::object& node, const std::string& sAttrName)
+ : m_Node(node),
+ m_sAttrName(sAttrName)
+ {
+ }
+ boost::python::object m_Node;
+ std::string m_sAttrName;
+ bool operator < (const ObjAttrID& other) const;
+};
+
+class AttrAnim;
+
+typedef boost::shared_ptr<class Anim> AttrAnimPtr;
+typedef boost::weak_ptr<class Anim> AttrAnimWeakPtr;
+
+class AVG_API AttrAnim: public Anim
+{
+public:
+ static int getNumRunningAnims();
+
+ AttrAnim(const boost::python::object& node, const std::string& sAttrName,
+ const boost::python::object& startCallback,
+ const boost::python::object& stopCallback);
+ virtual ~AttrAnim();
+
+ virtual void start(bool bKeepAttr=false);
+
+protected:
+ boost::python::object getValue() const;
+ void setValue(const boost::python::object& val);
+
+ void addToMap();
+ void removeFromMap();
+ void stopActiveAttrAnim();
+
+private:
+ AttrAnim();
+ AttrAnim(const AttrAnim&);
+
+ boost::python::object m_Node;
+ std::string m_sAttrName;
+
+ typedef std::map<ObjAttrID, AttrAnimPtr> AttrAnimationMap;
+ static AttrAnimationMap s_ActiveAnimations;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/ContinuousAnim.cpp b/src/anim/ContinuousAnim.cpp
new file mode 100644
index 0000000..a5e84e4
--- /dev/null
+++ b/src/anim/ContinuousAnim.cpp
@@ -0,0 +1,91 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ContinuousAnim.h"
+
+#include "../base/Exception.h"
+#include "../base/MathHelper.h"
+#include "../player/Player.h"
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+ContinuousAnim::ContinuousAnim(const object& node, const string& sAttrName,
+ const object& startValue, const object& speed, bool bUseInt,
+ const object& startCallback, const object& stopCallback)
+ : AttrAnim(node, sAttrName, startCallback, stopCallback),
+ m_StartValue(startValue),
+ m_Speed(speed),
+ m_bUseInt(bUseInt)
+{
+}
+
+ContinuousAnim::~ContinuousAnim()
+{
+}
+
+void ContinuousAnim::start(bool bKeepAttr)
+{
+ AttrAnim::start();
+ if (!bKeepAttr) {
+ setValue(m_StartValue);
+ }
+ m_EffStartValue = getValue();
+ m_StartTime = Player::get()->getFrameTime();
+}
+
+void ContinuousAnim::abort()
+{
+ if (isRunning()) {
+ AnimPtr tempThis = shared_from_this();
+ removeFromMap();
+ setStopped();
+ }
+}
+
+bool ContinuousAnim::step()
+{
+ object curValue;
+ double time = (Player::get()->getFrameTime()-m_StartTime)/1000.0;
+ if (isPythonType<double>(m_EffStartValue)) {
+ curValue = object(time*extract<double>(m_Speed)+m_EffStartValue);
+ if (m_bUseInt) {
+ double d = extract<double>(curValue);
+ curValue = object(round(d));
+ }
+ } else if (isPythonType<DPoint>(m_EffStartValue)) {
+ DPoint pt = extract<DPoint>(m_Speed);
+ curValue = object(time*pt+m_EffStartValue);
+ if (m_bUseInt) {
+ DPoint pt = extract<DPoint>(curValue);
+ curValue = object(DPoint(round(pt.x), round(pt.y)));
+ }
+ } else {
+ throw (Exception(AVG_ERR_TYPE,
+ "Animated attributes must be either numbers or Point2D."));
+ }
+ setValue(curValue);
+ return false;
+}
+
+}
diff --git a/src/anim/ContinuousAnim.h b/src/anim/ContinuousAnim.h
new file mode 100644
index 0000000..d87d601
--- /dev/null
+++ b/src/anim/ContinuousAnim.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ContinuousAnim_H_
+#define _ContinuousAnim_H_
+
+#include "../api.h"
+
+#include "SimpleAnim.h"
+
+namespace avg {
+
+class AVG_API ContinuousAnim: public AttrAnim {
+public:
+ ContinuousAnim(const boost::python::object& node, const std::string& sAttrName,
+ const boost::python::object& startValue,
+ const boost::python::object& speed,
+ bool bUseInt=false,
+ const boost::python::object& startCallback=boost::python::object(),
+ const boost::python::object& stopCallback=boost::python::object());
+ virtual ~ContinuousAnim();
+
+ virtual void start(bool bKeepAttr=false);
+ virtual void abort();
+ virtual bool step();
+
+private:
+ boost::python::object m_StartValue;
+ boost::python::object m_Speed;
+ bool m_bUseInt;
+
+ boost::python::object m_EffStartValue;
+ long long m_StartTime;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/EaseInOutAnim.cpp b/src/anim/EaseInOutAnim.cpp
new file mode 100644
index 0000000..b2fd956
--- /dev/null
+++ b/src/anim/EaseInOutAnim.cpp
@@ -0,0 +1,71 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "EaseInOutAnim.h"
+
+#include "../player/Player.h"
+#include "../base/MathHelper.h"
+
+#include <math.h>
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+EaseInOutAnim::EaseInOutAnim(const object& node, const string& sAttrName,
+ long long duration, const object& startValue, const object& endValue,
+ long long easeInDuration, long long easeOutDuration, bool bUseInt,
+ const object& startCallback, const object& stopCallback)
+ : SimpleAnim(node, sAttrName, duration, startValue, endValue, bUseInt, startCallback,
+ stopCallback),
+ m_EaseInDuration(double(easeInDuration)/duration),
+ m_EaseOutDuration(double(easeOutDuration)/duration)
+{
+}
+
+EaseInOutAnim::~EaseInOutAnim()
+{
+}
+
+double EaseInOutAnim::interpolate(double t)
+{
+ double accelDist = m_EaseInDuration*2/M_PI;
+ double decelDist = m_EaseOutDuration*2/M_PI;
+ double dist;
+ if (t<m_EaseInDuration) {
+ // Acceleration stage
+ double nt = t/m_EaseInDuration;
+ double s = sin(-M_PI/2+nt*M_PI/2)+1;
+ dist = s*accelDist;
+ } else if (t > 1-m_EaseOutDuration) {
+ // Deceleration stage
+ double nt = (t-(1-m_EaseOutDuration))/m_EaseOutDuration;
+ double s = sin(nt*M_PI/2);
+ dist = accelDist+(1-m_EaseInDuration-m_EaseOutDuration)+s*decelDist;
+ } else {
+ // Linear stage
+ dist = accelDist+t-m_EaseInDuration;
+ }
+ return dist/(accelDist+(1-m_EaseInDuration-m_EaseOutDuration)+decelDist);
+}
+
+}
diff --git a/src/anim/EaseInOutAnim.h b/src/anim/EaseInOutAnim.h
new file mode 100644
index 0000000..0555c68
--- /dev/null
+++ b/src/anim/EaseInOutAnim.h
@@ -0,0 +1,55 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _EaseInOutAnim_H_
+#define _EaseInOutAnim_H_
+
+#include "../api.h"
+
+#include "SimpleAnim.h"
+
+namespace avg {
+
+class AVG_API EaseInOutAnim: public SimpleAnim {
+public:
+ EaseInOutAnim(const boost::python::object& node, const std::string& sAttrName,
+ long long duration,
+ const boost::python::object& pStartValue,
+ const boost::python::object& pEndValue,
+ long long easeInDuration, long long easeOutDuration, bool bUseInt=false,
+ const boost::python::object& startCallback=boost::python::object(),
+ const boost::python::object& stopCallback=boost::python::object());
+ virtual ~EaseInOutAnim();
+
+protected:
+ virtual double interpolate(double t);
+
+private:
+ double m_EaseInDuration;
+ double m_EaseOutDuration;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/LinearAnim.cpp b/src/anim/LinearAnim.cpp
new file mode 100644
index 0000000..58abffe
--- /dev/null
+++ b/src/anim/LinearAnim.cpp
@@ -0,0 +1,73 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "LinearAnim.h"
+
+#include "../player/Player.h"
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+LinearAnim::LinearAnim(const object& node, const string& sAttrName, long long duration,
+ const object& startValue, const object& endValue, bool bUseInt,
+ const object& startCallback, const object& stopCallback)
+ : SimpleAnim(node, sAttrName, duration, startValue, endValue, bUseInt, startCallback,
+ stopCallback)
+{
+}
+
+LinearAnim::~LinearAnim()
+{
+}
+
+double LinearAnim::interpolate(double t)
+{
+ return t;
+}
+
+double LinearAnim::getStartPart(double start, double end, double cur)
+{
+ return (cur-start)/(end-start);
+}
+
+AnimPtr fadeIn(const boost::python::object& node, long long duration, double max,
+ const boost::python::object& stopCallback)
+{
+ object startVal = node.attr("opacity");
+ AnimPtr pAnim(new LinearAnim(node, "opacity", duration, startVal,
+ object(max), false, object(), stopCallback));
+ pAnim->start(false);
+ return pAnim;
+}
+
+AnimPtr fadeOut(const boost::python::object& node, long long duration,
+ const boost::python::object& stopCallback)
+{
+ object startVal = node.attr("opacity");
+ AnimPtr pAnim(new LinearAnim(node, "opacity", duration, startVal,
+ object(0), false, object(), stopCallback));
+ pAnim->start(true);
+ return pAnim;
+}
+
+}
diff --git a/src/anim/LinearAnim.h b/src/anim/LinearAnim.h
new file mode 100644
index 0000000..b7870aa
--- /dev/null
+++ b/src/anim/LinearAnim.h
@@ -0,0 +1,60 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _LinearAnim_H_
+#define _LinearAnim_H_
+
+#include "../api.h"
+
+#include "SimpleAnim.h"
+
+namespace avg {
+
+class AVG_API LinearAnim: public SimpleAnim {
+public:
+ LinearAnim(const boost::python::object& node, const std::string& sAttrName,
+ long long duration,
+ const boost::python::object& pStartValue,
+ const boost::python::object& pEndValue,
+ bool bUseInt=false,
+ const boost::python::object& startCallback=boost::python::object(),
+ const boost::python::object& stopCallback=boost::python::object());
+ virtual ~LinearAnim();
+
+protected:
+ virtual double interpolate(double t);
+
+private:
+ double getStartPart(double start, double end, double cur);
+};
+
+AnimPtr fadeIn(const boost::python::object& node, long long duration, double max=1.0,
+ const boost::python::object& stopCallback=boost::python::object());
+
+AnimPtr fadeOut(const boost::python::object& node, long long duration,
+ const boost::python::object& stopCallback=boost::python::object());
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/Makefile.am b/src/anim/Makefile.am
new file mode 100644
index 0000000..1ac89b5
--- /dev/null
+++ b/src/anim/Makefile.am
@@ -0,0 +1,10 @@
+INCLUDES = -I.. @XML2_CFLAGS@ @PYTHON_INCLUDES@
+
+ALL_H = Anim.h SimpleAnim.h LinearAnim.h AttrAnim.h ContinuousAnim.h EaseInOutAnim.h \
+ WaitAnim.h ParallelAnim.h StateAnim.h
+
+ALL_CPP = Anim.cpp SimpleAnim.cpp LinearAnim.cpp AttrAnim.cpp ContinuousAnim.cpp \
+ EaseInOutAnim.cpp WaitAnim.cpp ParallelAnim.cpp StateAnim.cpp
+
+noinst_LTLIBRARIES = libanim.la
+libanim_la_SOURCES = $(ALL_CPP) $(ALL_H)
diff --git a/src/anim/Makefile.in b/src/anim/Makefile.in
new file mode 100644
index 0000000..1fc5ad2
--- /dev/null
+++ b/src/anim/Makefile.in
@@ -0,0 +1,592 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/anim
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libanim_la_LIBADD =
+am__objects_1 = Anim.lo SimpleAnim.lo LinearAnim.lo AttrAnim.lo \
+ ContinuousAnim.lo EaseInOutAnim.lo WaitAnim.lo ParallelAnim.lo \
+ StateAnim.lo
+am__objects_2 =
+am_libanim_la_OBJECTS = $(am__objects_1) $(am__objects_2)
+libanim_la_OBJECTS = $(am_libanim_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libanim_la_SOURCES)
+DIST_SOURCES = $(libanim_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.. @XML2_CFLAGS@ @PYTHON_INCLUDES@
+ALL_H = Anim.h SimpleAnim.h LinearAnim.h AttrAnim.h ContinuousAnim.h EaseInOutAnim.h \
+ WaitAnim.h ParallelAnim.h StateAnim.h
+
+ALL_CPP = Anim.cpp SimpleAnim.cpp LinearAnim.cpp AttrAnim.cpp ContinuousAnim.cpp \
+ EaseInOutAnim.cpp WaitAnim.cpp ParallelAnim.cpp StateAnim.cpp
+
+noinst_LTLIBRARIES = libanim.la
+libanim_la_SOURCES = $(ALL_CPP) $(ALL_H)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/anim/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/anim/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libanim.la: $(libanim_la_OBJECTS) $(libanim_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libanim_la_OBJECTS) $(libanim_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Anim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AttrAnim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ContinuousAnim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EaseInOutAnim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LinearAnim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ParallelAnim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SimpleAnim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StateAnim.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WaitAnim.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/anim/ParallelAnim.cpp b/src/anim/ParallelAnim.cpp
new file mode 100644
index 0000000..1833fab
--- /dev/null
+++ b/src/anim/ParallelAnim.cpp
@@ -0,0 +1,113 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ParallelAnim.h"
+
+#include "../player/Player.h"
+
+using namespace boost;
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+ParallelAnim::ParallelAnim(const vector<AnimPtr>& anims,
+ const object& startCallback, const object& stopCallback, long long maxAge)
+ : Anim(startCallback, stopCallback),
+ m_Anims(anims),
+ m_MaxAge(maxAge)
+{
+ vector<AnimPtr>::iterator it;
+ for (it=m_Anims.begin(); it != m_Anims.end(); ++it) {
+ (*it)->setHasParent();
+ }
+}
+
+ParallelAnim::~ParallelAnim()
+{
+ if (Player::exists()) {
+ abort();
+ }
+}
+
+void ParallelAnim::start(bool bKeepAttr)
+{
+ Anim::start();
+ m_StartTime = Player::get()->getFrameTime();
+
+ vector<AnimPtr>::iterator it;
+ for (it=m_Anims.begin(); it != m_Anims.end(); ++it) {
+ (*it)->start(bKeepAttr);
+ if ((*it)->isRunning()) {
+ m_RunningAnims.push_back(*it);
+ }
+ m_This = dynamic_pointer_cast<ParallelAnim>(shared_from_this());
+ }
+}
+
+void ParallelAnim::abort()
+{
+ if (isRunning()) {
+ vector<AnimPtr>::iterator it;
+ for (it=m_RunningAnims.begin(); it != m_RunningAnims.end(); ++it) {
+ (*it)->abort();
+ }
+ m_RunningAnims.clear();
+ setStopped();
+ ParallelAnimPtr tempThis = m_This;
+ m_This = ParallelAnimPtr();
+ tempThis = ParallelAnimPtr();
+ }
+}
+
+bool ParallelAnim::step()
+{
+ assert(isRunning());
+ vector<AnimPtr>::iterator it;
+ for (it=m_RunningAnims.begin(); it != m_RunningAnims.end(); ) {
+ AnimPtr pAnim = (*it);
+ bool bDone;
+ if (pAnim->isRunning()) {
+ bDone = pAnim->step();
+ } else {
+ bDone = true;
+ }
+ if (bDone) {
+ it = m_RunningAnims.erase(it);
+ } else {
+ ++it;
+ }
+ }
+ if (m_RunningAnims.empty()) {
+ setStopped();
+ ParallelAnimPtr tempThis = m_This;
+ m_This = ParallelAnimPtr();
+ tempThis = ParallelAnimPtr();
+ return true;
+ }
+ if (m_MaxAge != -1 && Player::get()->getFrameTime()-m_StartTime >= m_MaxAge) {
+ abort();
+ return true;
+ }
+ return false;
+}
+
+}
diff --git a/src/anim/ParallelAnim.h b/src/anim/ParallelAnim.h
new file mode 100644
index 0000000..5e5b651
--- /dev/null
+++ b/src/anim/ParallelAnim.h
@@ -0,0 +1,64 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ParallelAnim_H_
+#define _ParallelAnim_H_
+
+#include "../api.h"
+
+#include "Anim.h"
+
+#include <vector>
+
+namespace avg {
+
+class ParallelAnim;
+typedef boost::shared_ptr<class ParallelAnim> ParallelAnimPtr;
+
+class AVG_API ParallelAnim: public Anim {
+public:
+ virtual ~ParallelAnim();
+ ParallelAnim(const std::vector<AnimPtr>& anims,
+ const boost::python::object& startCallback=boost::python::object(),
+ const boost::python::object& stopCallback=boost::python::object(),
+ long long maxAge=-1);
+
+ virtual void start(bool bKeepAttr=false);
+ virtual void abort();
+
+ virtual bool step();
+
+private:
+ std::vector<AnimPtr> m_Anims;
+ std::vector<AnimPtr> m_RunningAnims;
+ long long m_MaxAge;
+
+ long long m_StartTime;
+ ParallelAnimPtr m_This; // Makes sure there is always a reference to the animation
+ // while it's running.
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/SimpleAnim.cpp b/src/anim/SimpleAnim.cpp
new file mode 100644
index 0000000..9f0b002
--- /dev/null
+++ b/src/anim/SimpleAnim.cpp
@@ -0,0 +1,182 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+
+#include "SimpleAnim.h"
+
+#include "../base/Exception.h"
+#include "../base/MathHelper.h"
+#include "../player/Player.h"
+
+using namespace boost;
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+SimpleAnim::SimpleAnim(const object& node, const string& sAttrName, long long duration,
+ const object& startValue, const object& endValue, bool bUseInt,
+ const object& startCallback, const object& stopCallback)
+ : AttrAnim(node, sAttrName, startCallback, stopCallback),
+ m_Duration(duration),
+ m_StartValue(startValue),
+ m_EndValue(endValue),
+ m_bUseInt(bUseInt)
+{
+}
+
+SimpleAnim::~SimpleAnim()
+{
+ if (Player::exists() && isRunning()) {
+ setStopped();
+ }
+}
+
+void SimpleAnim::start(bool bKeepAttr)
+{
+ AttrAnim::start();
+ if (bKeepAttr) {
+ m_StartTime = calcStartTime();
+ } else {
+ m_StartTime = Player::get()->getFrameTime();
+ }
+ if (m_Duration == 0) {
+ setValue(m_EndValue);
+ remove();
+ } else {
+ step();
+ }
+}
+
+void SimpleAnim::abort()
+{
+ if (isRunning()) {
+ remove();
+ }
+}
+
+template<class T>
+object typedLERP(const object& startValue, const object& endValue, double part)
+{
+ T start = extract<T>(startValue);
+ T end = extract<T>(endValue);
+ T cur = start+(end-start)*part;
+ return object(cur);
+}
+
+bool SimpleAnim::step()
+{
+ assert(isRunning());
+ double t = ((double(Player::get()->getFrameTime())-m_StartTime)
+ /m_Duration);
+ if (t >= 1.0) {
+ setValue(m_EndValue);
+ remove();
+ return true;
+ } else {
+ object curValue;
+ double part = interpolate(t);
+ if (isPythonType<double>(m_StartValue)) {
+ curValue = typedLERP<double>(m_StartValue, m_EndValue, part);
+ if (m_bUseInt) {
+ double d = extract<double>(curValue);
+ curValue = object(round(d));
+ }
+ } else if (isPythonType<DPoint>(m_StartValue)) {
+ curValue = typedLERP<DPoint>(m_StartValue, m_EndValue, part);
+ if (m_bUseInt) {
+ DPoint pt = extract<DPoint>(curValue);
+ curValue = object(DPoint(round(pt.x), round(pt.y)));
+ }
+ } else {
+ throw (Exception(AVG_ERR_TYPE,
+ "Animated attributes must be either numbers or Point2D."));
+ }
+ setValue(curValue);
+ return false;
+ }
+}
+
+long long SimpleAnim::getStartTime() const
+{
+ return m_StartTime;
+}
+
+long long SimpleAnim::getDuration() const
+{
+ return m_Duration;
+}
+
+long long SimpleAnim::calcStartTime()
+{
+ double part;
+ if (isPythonType<double>(m_StartValue)) {
+ if (m_EndValue == m_StartValue) {
+ part = 0;
+ } else {
+ part = getStartPart(extract<double>(m_StartValue),
+ extract<double>(m_EndValue), extract<double>(getValue()));
+ }
+ } else if (isPythonType<DPoint>(m_StartValue)) {
+ double start = DPoint(extract<DPoint>(m_StartValue)).x;
+ double end = DPoint(extract<DPoint>(m_EndValue)).x;
+ double cur = DPoint(extract<DPoint>(getValue())).x;
+ if (start == end) {
+ start = DPoint(extract<DPoint>(m_StartValue)).y;
+ end = DPoint(extract<DPoint>(m_EndValue)).y;
+ start = DPoint(extract<DPoint>(getValue())).y;
+ }
+ if (start == end) {
+ part = 0;
+ } else {
+ part = getStartPart(start, end, cur);
+ }
+ } else {
+ throw (Exception(AVG_ERR_TYPE,
+ "Animated attributes must be either numbers or Point2D."));
+ }
+ return Player::get()->getFrameTime()-(long long)(part*getDuration());
+}
+
+double SimpleAnim::getStartPart(double start, double end, double cur)
+{
+ double tstart = 0;
+ double tend = 1;
+ bool bDir = (start < end);
+ for (int i=0; i<10; ++i) {
+ double tmiddle = (tstart+tend)/2;
+ double part = interpolate(tmiddle);
+ double middle = start+(end-start)*part;
+ if ((bDir && middle < cur) || (!bDir && middle >= cur)) {
+ tstart = tmiddle;
+ } else {
+ tend = tmiddle;
+ }
+ }
+ return (tend+tstart)/2;
+}
+
+void SimpleAnim::remove()
+{
+ AnimPtr tempThis = shared_from_this();
+ removeFromMap();
+ setStopped();
+}
+
+}
diff --git a/src/anim/SimpleAnim.h b/src/anim/SimpleAnim.h
new file mode 100644
index 0000000..874359d
--- /dev/null
+++ b/src/anim/SimpleAnim.h
@@ -0,0 +1,79 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _SimpleAnim_H_
+#define _SimpleAnim_H_
+
+#include "../api.h"
+// Python docs say python.h should be included before any standard headers (!)
+#include "../player/WrapPython.h"
+
+#include "AttrAnim.h"
+
+#include <boost/python.hpp>
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+class SimpleAnim;
+typedef boost::shared_ptr<class SimpleAnim> SimpleAnimPtr;
+
+class AVG_API SimpleAnim: public AttrAnim
+{
+public:
+ SimpleAnim(const boost::python::object& node, const std::string& sAttrName,
+ long long duration,
+ const boost::python::object& pStartValue,
+ const boost::python::object& pEndValue,
+ bool bUseInt,
+ const boost::python::object& startCallback,
+ const boost::python::object& stopCallback);
+ virtual ~SimpleAnim()=0;
+
+ virtual void start(bool bKeepAttr=false);
+ virtual void abort();
+ virtual bool step();
+
+protected:
+ virtual double interpolate(double t)=0;
+ void remove();
+
+private:
+ long long getStartTime() const;
+ long long getDuration() const;
+ long long calcStartTime();
+ virtual double getStartPart(double start, double end, double cur);
+
+ long long m_Duration;
+ boost::python::object m_StartValue;
+ boost::python::object m_EndValue;
+ bool m_bUseInt;
+ long long m_StartTime;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/StateAnim.cpp b/src/anim/StateAnim.cpp
new file mode 100644
index 0000000..543a06a
--- /dev/null
+++ b/src/anim/StateAnim.cpp
@@ -0,0 +1,123 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "StateAnim.h"
+
+#include "../base/Exception.h"
+#include "../player/Player.h"
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+AnimState::AnimState(const string& sName, AnimPtr pAnim, const string& sNextName)
+ : m_sName(sName),
+ m_pAnim(pAnim),
+ m_sNextName(sNextName)
+{
+}
+
+AnimState::AnimState()
+{
+}
+
+StateAnim::StateAnim(const vector<AnimState>& states)
+ : Anim(object(), object()),
+ m_bDebug(false)
+{
+ vector<AnimState>::const_iterator it;
+ for (it=states.begin(); it != states.end(); ++it) {
+ m_States[(*it).m_sName] = *it;
+ it->m_pAnim->setHasParent();
+ }
+}
+
+StateAnim::~StateAnim()
+{
+ setState("");
+}
+
+void StateAnim::abort()
+{
+ setState("");
+}
+
+void StateAnim::setState(const std::string& sName, bool bKeepAttr)
+{
+ if (m_sCurStateName == sName) {
+ return;
+ }
+ if (!m_sCurStateName.empty()) {
+ m_States[m_sCurStateName].m_pAnim->abort();
+ }
+ switchToNewState(sName, bKeepAttr);
+}
+
+const std::string& StateAnim::getState() const
+{
+ return m_sCurStateName;
+}
+
+void StateAnim::setDebug(bool bDebug)
+{
+ m_bDebug = bDebug;
+}
+
+bool StateAnim::step()
+{
+ // Make sure the object isn't deleted until the end of the method.
+ AnimPtr tempThis = shared_from_this();
+
+ if (!m_sCurStateName.empty()) {
+ const AnimState& curState = m_States[m_sCurStateName];
+ bool bDone = curState.m_pAnim->step();
+ if (bDone) {
+ switchToNewState(curState.m_sNextName, false);
+ }
+ }
+ return false;
+}
+
+void StateAnim::switchToNewState(const string& sName, bool bKeepAttr)
+{
+ if (m_bDebug) {
+ cerr << this << " State change: '" << m_sCurStateName << "' --> '" << sName
+ << "'" << endl;
+ }
+ string sOldStateName = m_sCurStateName;
+ m_sCurStateName = sName;
+ if (!sName.empty()) {
+ map<string, AnimState>::iterator it = m_States.find(sName);
+ if (it == m_States.end()) {
+ throw Exception(AVG_ERR_INVALID_ARGS, "StateAnim: State "+sName+" unknown.");
+ } else {
+ it->second.m_pAnim->start(bKeepAttr);
+ }
+ if (sOldStateName == "") {
+ Anim::start(false);
+ }
+ } else {
+ Anim::setStopped();
+ }
+}
+
+}
diff --git a/src/anim/StateAnim.h b/src/anim/StateAnim.h
new file mode 100644
index 0000000..2d614fa
--- /dev/null
+++ b/src/anim/StateAnim.h
@@ -0,0 +1,70 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _StateAnim_H_
+#define _StateAnim_H_
+
+#include "../api.h"
+
+#include "Anim.h"
+
+#include <vector>
+#include <map>
+
+namespace avg {
+
+struct AVG_API AnimState {
+ AnimState(const std::string& sName, AnimPtr pAnim, const std::string& sNextName = "");
+ AnimState();
+
+ std::string m_sName;
+ AnimPtr m_pAnim;
+ std::string m_sNextName;
+};
+
+class AVG_API StateAnim: public Anim {
+public:
+ StateAnim(const std::vector<AnimState>& states);
+ virtual ~StateAnim();
+
+ virtual void abort();
+
+ virtual void setState(const std::string& sName, bool bKeepAttr=false);
+ const std::string& getState() const;
+ void setDebug(bool bDebug);
+
+ virtual bool step();
+
+private:
+ void switchToNewState(const std::string& sName, bool bKeepAttr);
+
+ std::map<std::string, AnimState> m_States;
+ bool m_bDebug;
+ bool m_bIsAborting;
+ std::string m_sCurStateName;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/anim/WaitAnim.cpp b/src/anim/WaitAnim.cpp
new file mode 100644
index 0000000..a73ae6b
--- /dev/null
+++ b/src/anim/WaitAnim.cpp
@@ -0,0 +1,65 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WaitAnim.h"
+
+#include "../player/Player.h"
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+WaitAnim::WaitAnim(long long duration, const object& startCallback,
+ const object& stopCallback)
+ : Anim(startCallback, stopCallback),
+ m_Duration(duration)
+{
+}
+
+WaitAnim::~WaitAnim()
+{
+}
+
+void WaitAnim::start(bool bKeepAttr)
+{
+ Anim::start();
+ m_StartTime = Player::get()->getFrameTime();
+}
+
+void WaitAnim::abort()
+{
+ setStopped();
+}
+
+bool WaitAnim::step()
+{
+ assert(isRunning());
+ if (m_Duration != -1 && Player::get()->getFrameTime()-m_StartTime > m_Duration) {
+ setStopped();
+ return true;
+ } else {
+ return false;
+ }
+
+}
+
+}
diff --git a/src/anim/WaitAnim.h b/src/anim/WaitAnim.h
new file mode 100644
index 0000000..a8d8446
--- /dev/null
+++ b/src/anim/WaitAnim.h
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _WaitAnim_H_
+#define _WaitAnim_H_
+
+#include "../api.h"
+
+#include "SimpleAnim.h"
+
+namespace avg {
+
+class AVG_API WaitAnim: public Anim {
+public:
+ WaitAnim(long long duration = -1,
+ const boost::python::object& startCallback=boost::python::object(),
+ const boost::python::object& stopCallback=boost::python::object());
+ virtual ~WaitAnim();
+
+ virtual void start(bool bKeepAttr=false);
+ virtual void abort();
+
+ virtual bool step();
+
+private:
+ long long m_Duration;
+ long long m_StartTime;
+};
+
+}
+
+#endif
+
+
+
diff --git a/src/api.h b/src/api.h
new file mode 100644
index 0000000..31dd3e2
--- /dev/null
+++ b/src/api.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Jan Boelsche (regular.gonzales@googlemail.com).
+//
+
+#ifndef _API_H_
+#define _API_H_
+
+#ifdef _WIN32 // in declspec land
+#pragma warning(disable: 4251)
+#define AVG_PLUGIN_API extern "C" __declspec(dllexport)
+#ifdef AVG_PLUGIN
+#define AVG_API __declspec(dllimport)
+#define AVG_TEMPLATE_API
+#else
+#define AVG_API __declspec(dllexport)
+#define AVG_TEMPLATE_API __declspec(dllexport)
+#endif
+#else // not _WIN32, plain and simple
+#define AVG_API
+#define AVG_TEMPLATE_API
+#define AVG_PLUGIN_API extern "C"
+#endif
+
+#endif
+
diff --git a/src/audio/AudioBuffer.cpp b/src/audio/AudioBuffer.cpp
new file mode 100644
index 0000000..705cee1
--- /dev/null
+++ b/src/audio/AudioBuffer.cpp
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "AudioBuffer.h"
+
+#include <string>
+#include <cstring>
+
+namespace avg {
+
+AudioBuffer::AudioBuffer(int numFrames, AudioParams ap)
+ : m_NumFrames(numFrames),
+ m_AP(ap)
+{
+ m_pData = new short[numFrames*sizeof(short)*ap.m_Channels];
+}
+
+AudioBuffer::~AudioBuffer()
+{
+ delete[] m_pData;
+}
+
+short* AudioBuffer::getData()
+{
+ return m_pData;
+}
+
+int AudioBuffer::getNumFrames()
+{
+ return m_NumFrames;
+}
+
+int AudioBuffer::getNumBytes()
+{
+ return m_NumFrames*m_AP.m_Channels*sizeof(short);
+}
+
+int AudioBuffer::getFrameSize()
+{
+ return m_AP.m_Channels*sizeof(short);
+}
+
+int AudioBuffer::getNumChannels()
+{
+ return m_AP.m_Channels;
+}
+
+int AudioBuffer::getRate()
+{
+ return m_AP.m_SampleRate;
+}
+
+void AudioBuffer::clear()
+{
+ memset(m_pData, 0, m_NumFrames*sizeof(short)*m_AP.m_Channels);
+}
+
+}
diff --git a/src/audio/AudioBuffer.h b/src/audio/AudioBuffer.h
new file mode 100644
index 0000000..ccb52ec
--- /dev/null
+++ b/src/audio/AudioBuffer.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _AudioBuffer_H_
+#define _AudioBuffer_H_
+
+#include "../api.h"
+#include "AudioParams.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg
+{
+
+class AVG_API AudioBuffer
+{
+ public:
+ AudioBuffer(int numFrames, AudioParams ap);
+ virtual ~AudioBuffer();
+
+ short* getData();
+ int getNumFrames();
+ int getNumBytes();
+ int getFrameSize();
+ int getNumChannels();
+ int getRate();
+ void clear();
+
+ private:
+ int m_NumFrames;
+ short* m_pData;
+ AudioParams m_AP;
+};
+
+typedef boost::shared_ptr<AudioBuffer> AudioBufferPtr;
+
+}
+
+#endif /*AUDIOFRAME_H_*/
diff --git a/src/audio/AudioEngine.cpp b/src/audio/AudioEngine.cpp
new file mode 100644
index 0000000..109951e
--- /dev/null
+++ b/src/audio/AudioEngine.cpp
@@ -0,0 +1,99 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "AudioEngine.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+using namespace std;
+
+namespace avg {
+
+AudioEngine::AudioEngine()
+ : m_bEnabled(true),
+ m_Volume(1)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+AudioEngine::~AudioEngine()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+ m_AudioSources.clear();
+}
+
+void AudioEngine::setAudioEnabled(bool bEnabled)
+{
+ AVG_ASSERT(m_AudioSources.empty());
+ m_bEnabled = bEnabled;
+ if (m_bEnabled) {
+ play();
+ } else {
+ pause();
+ }
+}
+
+void AudioEngine::init(const AudioParams& ap, double volume)
+{
+ m_Volume = volume;
+}
+
+AudioSourceList& AudioEngine::getSources()
+{
+ return m_AudioSources;
+}
+
+void AudioEngine::addSource(IAudioSource* pSource)
+{
+ m_AudioSources.push_back(pSource);
+}
+
+void AudioEngine::removeSource(IAudioSource* pSource)
+{
+ AudioSourceList::iterator it;
+ for(it = m_AudioSources.begin(); it != m_AudioSources.end(); it++)
+ {
+ if (*it == pSource) {
+ m_AudioSources.erase(it);
+ break;
+ }
+ }
+}
+
+void AudioEngine::setVolume(double volume)
+{
+ m_Volume = volume;
+}
+
+double AudioEngine::getVolume() const
+{
+ return m_Volume;
+}
+
+bool AudioEngine::isEnabled() const
+{
+ return m_bEnabled;
+}
+
+}
diff --git a/src/audio/AudioEngine.h b/src/audio/AudioEngine.h
new file mode 100644
index 0000000..7659bd3
--- /dev/null
+++ b/src/audio/AudioEngine.h
@@ -0,0 +1,70 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _AudioEngine_H_
+#define _AudioEngine_H_
+
+#include "../api.h"
+#include "IAudioSource.h"
+#include "AudioParams.h"
+
+#include <vector>
+
+namespace avg {
+
+typedef std::vector<IAudioSource*> AudioSourceList;
+
+class AVG_API AudioEngine
+{
+ public:
+ AudioEngine();
+ virtual ~AudioEngine();
+
+ virtual int getChannels() = 0;
+ virtual int getSampleRate() = 0;
+ virtual const AudioParams * getParams() = 0;
+
+ virtual void setAudioEnabled(bool bEnabled);
+
+ virtual void init(const AudioParams& ap, double volume);
+ virtual void teardown() = 0;
+
+ virtual void play() = 0;
+ virtual void pause() = 0;
+
+ AudioSourceList& getSources();
+ virtual void addSource(IAudioSource* pSource);
+ virtual void removeSource(IAudioSource* pSource);
+ virtual void setVolume(double volume);
+ double getVolume() const;
+ bool isEnabled() const;
+
+ private:
+ bool m_bEnabled;
+ AudioSourceList m_AudioSources;
+ double m_Volume;
+};
+
+}
+
+#endif
diff --git a/src/audio/AudioParams.cpp b/src/audio/AudioParams.cpp
new file mode 100644
index 0000000..f7eca98
--- /dev/null
+++ b/src/audio/AudioParams.cpp
@@ -0,0 +1,40 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "AudioParams.h"
+
+#include "../base/ObjectCounter.h"
+
+namespace avg {
+ AudioParams::AudioParams()
+ {
+ }
+
+ AudioParams::AudioParams(int sampleRate, int channels, int outputBufferSamples)
+ : m_SampleRate(sampleRate),
+ m_Channels(channels),
+ m_OutputBufferSamples(outputBufferSamples)
+ {
+ }
+}
+
diff --git a/src/audio/AudioParams.h b/src/audio/AudioParams.h
new file mode 100644
index 0000000..c4e1203
--- /dev/null
+++ b/src/audio/AudioParams.h
@@ -0,0 +1,39 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _AudioParams_H_
+#define _AudioParams_H_
+
+namespace avg {
+
+struct AudioParams {
+ AudioParams();
+ AudioParams(int sampleRate, int channels, int outputBufferSamples);
+ int m_SampleRate;
+ int m_Channels;
+ int m_OutputBufferSamples;
+};
+
+}
+
+#endif
diff --git a/src/audio/Dynamics.h b/src/audio/Dynamics.h
new file mode 100644
index 0000000..ae05a7e
--- /dev/null
+++ b/src/audio/Dynamics.h
@@ -0,0 +1,343 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Andreas Beisler.
+//
+
+#pragma once
+#ifndef __Dynamics_H__
+#define __Dynamics_H__
+
+#include "../api.h"
+#include "IProcessor.h"
+
+#include <math.h>
+#include <cmath>
+#include <limits>
+#include <memory.h>
+
+#define LOOKAHEAD 64
+#define AVG1 27
+#define AVG2 38
+
+namespace avg {
+
+// Dynamics processor (compressor & limiter).
+template<typename T, int CHANNELS>
+class AVG_API Dynamics: public IProcessor<T>
+{
+ public:
+ Dynamics(T fs);
+ virtual ~Dynamics();
+ virtual void process(T* pSamples);
+
+ void setThreshold(T threshold);
+ T getThreshold() const;
+ void setRmsTime(T rmsTime);
+ T getRmsTime() const;
+ void setRatio(T ratio);
+ T getRatio() const;
+ void setAttackTime(T attTime);
+ T getAttackTime() const;
+ void setReleaseTime(T relTime);
+ T getReleaseTime() const;
+ void setMakeupGain(T makeupGain);
+ T getMakeupGain() const;
+
+ private:
+ void maxFilter(T& rms);
+
+ T m_fs;
+
+ T threshold_;
+ T preGain_;
+
+ T rmsTime_;
+ T rmsCoef_;
+ T rms1_;
+
+ T* lookaheadBuf_;
+ int lookaheadBufIdx_;
+
+ T ratio_;
+ T inverseRatio_;
+
+ T attTime_;
+ T attCoef_;
+ T relTime_;
+ T relCoef_;
+ T env1_;
+
+ T* avg1Buf_;
+ int avg1BufRIdx_;
+ int avg1BufWIdx_;
+ T avg1Old_;
+
+ T* avg2Buf_;
+ int avg2BufRIdx_;
+ int avg2BufWIdx_;
+ T avg2Old_;
+
+ T* delayBuf_;
+ int delayBufIdx_;
+
+ T makeupGain_;
+ T postGain_;
+};
+
+template<typename T, int CHANNELS>
+Dynamics<T, CHANNELS>::Dynamics(T fs)
+ : m_fs(fs),
+ threshold_(0.),
+ preGain_(1.),
+ rmsTime_(0.),
+ rmsCoef_(0.),
+ rms1_(0.),
+ lookaheadBuf_(0),
+ lookaheadBufIdx_(0),
+ ratio_(std::numeric_limits<T>::infinity()),
+ inverseRatio_(0.),
+ attTime_(0.),
+ attCoef_(0.),
+ relTime_(0.),
+ relCoef_(0.),
+ env1_(0.),
+ avg1Buf_(0),
+ avg1BufRIdx_(0),
+ avg1BufWIdx_(AVG1 - 1),
+ avg1Old_(0.),
+ avg2Buf_(0),
+ avg2BufRIdx_(0),
+ avg2BufWIdx_(AVG2 - 1),
+ avg2Old_(0.),
+ delayBuf_(0),
+ delayBufIdx_(0),
+ makeupGain_(0.),
+ postGain_(1.)
+{
+ lookaheadBuf_ = new T[LOOKAHEAD];
+ for (int i = 0; i < LOOKAHEAD; i++) {
+ lookaheadBuf_[i] = 1.f;
+ }
+
+ avg1Buf_ = new T[AVG1];
+ memset(avg1Buf_, 0, sizeof(T) * (AVG1));
+
+ avg2Buf_ = new T[AVG2];
+ memset(avg2Buf_, 0, sizeof(T) * (AVG2));
+
+ delayBuf_ = new T[LOOKAHEAD*CHANNELS];
+ memset(delayBuf_, 0, sizeof(T)*LOOKAHEAD*CHANNELS);
+
+ setThreshold(0.);
+ setRmsTime(0.);
+ setRatio(std::numeric_limits<T>::infinity());
+ setAttackTime(0.);
+ setReleaseTime(0.05);
+ setMakeupGain(0.);
+}
+
+template<typename T, int CHANNELS>
+Dynamics<T, CHANNELS>::~Dynamics()
+{
+ delete[] lookaheadBuf_;
+
+ delete[] avg1Buf_;
+ delete[] avg2Buf_;
+
+ delete[] delayBuf_;
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::maxFilter(T& rms)
+{
+ int j = lookaheadBufIdx_;
+ for (int i = 0; i < LOOKAHEAD; i++)
+ {
+ j = (j+1)&(LOOKAHEAD-1);
+ if (lookaheadBuf_[j] < rms) {
+ lookaheadBuf_[j] = rms;
+ }
+ }
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::process(T* pSamples)
+{
+
+ //---------------- Preprocessing
+ T x = 0.f;
+ for (int i = 0; i < CHANNELS; i++) {
+ // Apply pregain
+ const T tmp = pSamples[i] * preGain_;
+
+ T abs = std::fabs(tmp);
+ if (abs > x) {
+ x = abs;
+ }
+ }
+
+ //---------------- RMS
+ T rms = (1. - rmsCoef_) * x * x + rmsCoef_ * rms1_;
+ rms1_ = rms;
+ rms = sqrt(rms);
+
+ //---------------- Max filter
+ if (rms > 1.) {
+ maxFilter(rms);
+ }
+
+ //---------------- Ratio
+ T dbMax = std::log10(lookaheadBuf_[lookaheadBufIdx_]);
+ T dbComp = dbMax * inverseRatio_;
+ T comp = std::pow(static_cast<T>(10.), dbComp);
+ T c = comp / lookaheadBuf_[lookaheadBufIdx_];
+
+ lookaheadBuf_[lookaheadBufIdx_] = 1.;
+ lookaheadBufIdx_ = (lookaheadBufIdx_+1)%LOOKAHEAD;
+
+ //---------------- Attack/release envelope
+ if (env1_ <= c) {
+ c = c + (env1_ - c) * relCoef_;
+ } else {
+ c = c + (env1_ - c) * attCoef_;
+ }
+ env1_ = c;
+
+ //---------------- Smoothing
+ const T tmp1 = avg1Old_ + c - avg1Buf_[avg1BufRIdx_];
+ avg1Old_ = tmp1;
+ avg1Buf_[avg1BufWIdx_] = c;
+ c = tmp1;
+ avg1BufRIdx_ = (avg1BufRIdx_+1)%AVG1;
+ avg1BufWIdx_ = (avg1BufWIdx_+1)%AVG1;
+
+ const T tmp2 = avg2Old_ + c - avg2Buf_[avg2BufRIdx_];
+ avg2Old_ = tmp2;
+ avg2Buf_[avg2BufWIdx_] = c;
+ c = tmp2;
+ avg2BufRIdx_ = (avg2BufRIdx_+1)%AVG2;
+ avg2BufWIdx_ = (avg2BufWIdx_+1)%AVG2;
+
+ c = c / (static_cast<T>(AVG1) * static_cast<T>(AVG2));
+
+ //---------------- Postprocessing
+ for (int i = 0; i < CHANNELS; i++) {
+ // Delay input samples
+ const T in = delayBuf_[delayBufIdx_*CHANNELS+i];
+ delayBuf_[delayBufIdx_*CHANNELS+i] = pSamples[i];
+
+ // Apply control signal
+ pSamples[i] = in * c * postGain_;
+ }
+
+ delayBufIdx_ = (delayBufIdx_+1)&(LOOKAHEAD-1);
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::setThreshold(T threshold)
+{
+ threshold_ = threshold;
+ preGain_ = std::pow(10., -threshold / 20.);
+}
+
+template<typename T, int CHANNELS>
+T Dynamics<T, CHANNELS>::getThreshold() const
+{
+ return threshold_;
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::setRmsTime(T rmsTime)
+{
+ rmsTime_ = rmsTime;
+ rmsCoef_ = 0.;
+ if (rmsTime > 0.) {
+ rmsCoef_ = std::pow(0.001, 1. / (m_fs * rmsTime));
+ }
+}
+
+template<typename T, int CHANNELS>
+T Dynamics<T, CHANNELS>::getRmsTime() const
+{
+ return rmsTime_;
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::setRatio(T ratio)
+{
+ ratio_ = ratio;
+ inverseRatio_ = 1. / ratio;
+}
+
+template<typename T, int CHANNELS>
+T Dynamics<T, CHANNELS>::getRatio() const
+{
+ return ratio_;
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::setAttackTime(T attTime)
+{
+ attTime_ = attTime;
+ attCoef_ = 0.;
+ if (attTime > 0.) {
+ attCoef_ = pow(0.001, 1. / (m_fs * attTime));
+ }
+}
+
+template<typename T, int CHANNELS>
+T Dynamics<T, CHANNELS>::getAttackTime() const
+{
+ return attTime_;
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::setReleaseTime(T relTime)
+{
+ relTime_ = relTime;
+ relCoef_ = 0.;
+ if (relTime > 0.) {
+ relCoef_ = pow(0.001, 1. / (m_fs * relTime));
+ }
+}
+
+template<typename T, int CHANNELS>
+T Dynamics<T, CHANNELS>::getReleaseTime() const
+{
+ return relTime_;
+}
+
+template<typename T, int CHANNELS>
+void Dynamics<T, CHANNELS>::setMakeupGain(T makeupGain)
+{
+ makeupGain_ = makeupGain;
+ postGain_ = std::pow(10., makeupGain / 20.);
+}
+
+template<typename T, int CHANNELS>
+T Dynamics<T, CHANNELS>::getMakeupGain() const
+{
+ return makeupGain_;
+}
+
+}
+
+#endif
diff --git a/src/audio/IAudioSource.h b/src/audio/IAudioSource.h
new file mode 100644
index 0000000..a112904
--- /dev/null
+++ b/src/audio/IAudioSource.h
@@ -0,0 +1,46 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _IAudioSource_H_
+#define _IAudioSource_H_
+
+#include "../api.h"
+#include "AudioBuffer.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+namespace avg {
+
+class AVG_API IAudioSource
+{
+ public:
+ virtual ~IAudioSource() {};
+ virtual int fillAudioBuffer(AudioBufferPtr pBuffer) = 0;
+};
+
+typedef boost::weak_ptr<IAudioSource> IAudioSourceWeakPtr;
+
+}
+
+#endif /*AUDIOSOURCE_H_*/
diff --git a/src/audio/IProcessor.h b/src/audio/IProcessor.h
new file mode 100644
index 0000000..8faea24
--- /dev/null
+++ b/src/audio/IProcessor.h
@@ -0,0 +1,37 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Processor_H_
+#define _Processor_H_
+
+namespace avg {
+
+template<typename T>
+class AVG_API IProcessor
+{
+public:
+ virtual ~IProcessor() {};
+ virtual void process(T* pSamples) = 0;
+
+};
+
+}
+#endif
diff --git a/src/audio/Makefile.am b/src/audio/Makefile.am
new file mode 100644
index 0000000..74a6c05
--- /dev/null
+++ b/src/audio/Makefile.am
@@ -0,0 +1,18 @@
+
+INCLUDES = -I.. @PTHREAD_CFLAGS@ @FFMPEG_CFLAGS@
+
+ALL_H = AudioEngine.h AudioBuffer.h AudioParams.h IAudioSource.h SDLAudioEngine.h \
+ Dynamics.h IProcessor.h
+
+TESTS=testlimiter
+
+noinst_LTLIBRARIES = libaudio.la
+noinst_PROGRAMS=testlimiter
+
+libaudio_la_SOURCES = AudioEngine.cpp AudioBuffer.cpp AudioParams.cpp \
+ SDLAudioEngine.cpp \
+ $(ALL_H)
+
+testlimiter_SOURCES = testlimiter.cpp $(ALL_H)
+testlimiter_LDADD = ./libaudio.la ../base/libbase.la \
+ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@
diff --git a/src/audio/Makefile.in b/src/audio/Makefile.in
new file mode 100644
index 0000000..10bf73a
--- /dev/null
+++ b/src/audio/Makefile.in
@@ -0,0 +1,705 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+TESTS = testlimiter$(EXEEXT)
+noinst_PROGRAMS = testlimiter$(EXEEXT)
+subdir = src/audio
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libaudio_la_LIBADD =
+am__objects_1 =
+am_libaudio_la_OBJECTS = AudioEngine.lo AudioBuffer.lo AudioParams.lo \
+ SDLAudioEngine.lo $(am__objects_1)
+libaudio_la_OBJECTS = $(am_libaudio_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+PROGRAMS = $(noinst_PROGRAMS)
+am_testlimiter_OBJECTS = testlimiter.$(OBJEXT) $(am__objects_1)
+testlimiter_OBJECTS = $(am_testlimiter_OBJECTS)
+testlimiter_DEPENDENCIES = ./libaudio.la ../base/libbase.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libaudio_la_SOURCES) $(testlimiter_SOURCES)
+DIST_SOURCES = $(libaudio_la_SOURCES) $(testlimiter_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.. @PTHREAD_CFLAGS@ @FFMPEG_CFLAGS@
+ALL_H = AudioEngine.h AudioBuffer.h AudioParams.h IAudioSource.h SDLAudioEngine.h \
+ Dynamics.h IProcessor.h
+
+noinst_LTLIBRARIES = libaudio.la
+libaudio_la_SOURCES = AudioEngine.cpp AudioBuffer.cpp AudioParams.cpp \
+ SDLAudioEngine.cpp \
+ $(ALL_H)
+
+testlimiter_SOURCES = testlimiter.cpp $(ALL_H)
+testlimiter_LDADD = ./libaudio.la ../base/libbase.la \
+ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/audio/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/audio/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libaudio.la: $(libaudio_la_OBJECTS) $(libaudio_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libaudio_la_OBJECTS) $(libaudio_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+testlimiter$(EXEEXT): $(testlimiter_OBJECTS) $(testlimiter_DEPENDENCIES)
+ @rm -f testlimiter$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(testlimiter_OBJECTS) $(testlimiter_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AudioBuffer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AudioEngine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AudioParams.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SDLAudioEngine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testlimiter.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/audio/SDLAudioEngine.cpp b/src/audio/SDLAudioEngine.cpp
new file mode 100644
index 0000000..e2f673c
--- /dev/null
+++ b/src/audio/SDLAudioEngine.cpp
@@ -0,0 +1,228 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "SDLAudioEngine.h"
+#include "Dynamics.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+#include <iostream>
+
+namespace avg {
+
+using namespace std;
+using namespace boost;
+
+SDLAudioEngine* SDLAudioEngine::s_pInstance = 0;
+
+SDLAudioEngine* SDLAudioEngine::get()
+{
+ return s_pInstance;
+}
+
+SDLAudioEngine::SDLAudioEngine()
+ : m_pTempBuffer(),
+ m_pMixBuffer(0),
+ m_pLimiter(0)
+{
+ AVG_ASSERT(s_pInstance == 0);
+ if (SDL_InitSubSystem(SDL_INIT_AUDIO) == -1) {
+ AVG_TRACE(Logger::ERROR, "Can't init SDL audio subsystem.");
+ exit(-1);
+ }
+ s_pInstance = this;
+}
+
+SDLAudioEngine::~SDLAudioEngine()
+{
+ if (m_pMixBuffer) {
+ delete[] m_pMixBuffer;
+ }
+ SDL_QuitSubSystem(SDL_INIT_AUDIO);
+}
+
+int SDLAudioEngine::getChannels()
+{
+ return m_AP.m_Channels;
+}
+
+int SDLAudioEngine::getSampleRate()
+{
+ return m_AP.m_SampleRate;
+}
+
+const AudioParams * SDLAudioEngine::getParams()
+{
+ if (isEnabled()) {
+ return &m_AP;
+ } else {
+ return 0;
+ }
+}
+
+void SDLAudioEngine::init(const AudioParams& ap, double volume)
+{
+ AudioEngine::init(ap, volume);
+ m_AP = ap;
+ Dynamics<double, 2>* pLimiter = new Dynamics<double, 2>(m_AP.m_SampleRate);
+ pLimiter->setThreshold(0.); // in dB
+ pLimiter->setAttackTime(0.); // in seconds
+ pLimiter->setReleaseTime(0.05); // in seconds
+ pLimiter->setRmsTime(0.); // in seconds
+ pLimiter->setRatio(std::numeric_limits<double>::infinity());
+ pLimiter->setMakeupGain(0.); // in dB
+ m_pLimiter = pLimiter;
+
+ SDL_AudioSpec desired;
+ desired.freq = m_AP.m_SampleRate;
+ desired.format = AUDIO_S16SYS;
+ desired.channels = m_AP.m_Channels;
+ desired.silence = 0;
+ desired.samples = m_AP.m_OutputBufferSamples;
+ desired.callback = audioCallback;
+ desired.userdata = this;
+
+ if (SDL_OpenAudio(&desired, 0) < 0) {
+ //throw new Exception("Cannot open audio device");
+ }
+}
+
+void SDLAudioEngine::teardown()
+{
+ {
+ mutex::scoped_lock Lock(m_Mutex);
+ SDL_PauseAudio(1);
+ }
+ // Optimized away - takes too long.
+// SDL_CloseAudio();
+
+ getSources().clear();
+ if (m_pLimiter) {
+ delete m_pLimiter;
+ m_pLimiter = 0;
+ }
+}
+
+void SDLAudioEngine::setAudioEnabled(bool bEnabled)
+{
+ SDL_LockAudio();
+ mutex::scoped_lock Lock(m_Mutex);
+ AudioEngine::setAudioEnabled(bEnabled);
+ SDL_UnlockAudio();
+}
+
+void SDLAudioEngine::play()
+{
+ SDL_PauseAudio(0);
+}
+
+void SDLAudioEngine::pause()
+{
+ SDL_PauseAudio(1);
+}
+
+void SDLAudioEngine::addSource(IAudioSource* pSource)
+{
+ SDL_LockAudio();
+ mutex::scoped_lock Lock(m_Mutex);
+ AudioEngine::addSource(pSource);
+ SDL_UnlockAudio();
+}
+
+void SDLAudioEngine::removeSource(IAudioSource* pSource)
+{
+ SDL_LockAudio();
+ mutex::scoped_lock Lock(m_Mutex);
+ AudioEngine::removeSource(pSource);
+ SDL_UnlockAudio();
+}
+
+void SDLAudioEngine::setVolume(double volume)
+{
+ SDL_LockAudio();
+ mutex::scoped_lock Lock(m_Mutex);
+ AudioEngine::setVolume(volume);
+ SDL_UnlockAudio();
+}
+
+void SDLAudioEngine::mixAudio(Uint8 *pDestBuffer, int destBufferLen)
+{
+ int numFrames = destBufferLen/(2*getChannels()); // 16 bit samples.
+
+ if (getSources().size() == 0) {
+ return;
+ }
+ if (!m_pTempBuffer || m_pTempBuffer->getNumFrames() < numFrames) {
+ if (m_pTempBuffer) {
+ delete[] m_pMixBuffer;
+ }
+ m_pTempBuffer = AudioBufferPtr(new AudioBuffer(numFrames, m_AP));
+ m_pMixBuffer = new double[getChannels()*numFrames];
+ }
+
+ for (int i = 0; i < getChannels()*numFrames; ++i) {
+ m_pMixBuffer[i]=0;
+ }
+ {
+ mutex::scoped_lock Lock(m_Mutex);
+ AudioSourceList::iterator it;
+ for(it = getSources().begin(); it != getSources().end(); it++) {
+ m_pTempBuffer->clear();
+ (*it)->fillAudioBuffer(m_pTempBuffer);
+ addBuffers(m_pMixBuffer, m_pTempBuffer);
+ }
+ }
+ calcVolume(m_pMixBuffer, numFrames*getChannels(), getVolume());
+ for (int i = 0; i < numFrames; ++i) {
+ m_pLimiter->process(m_pMixBuffer+i*getChannels());
+ for (int j = 0; j < getChannels(); ++j) {
+ ((short*)pDestBuffer)[i*2+j]=short(m_pMixBuffer[i*2+j]*32768);
+ }
+ }
+}
+
+void SDLAudioEngine::audioCallback(void *userData, Uint8 *audioBuffer, int audioBufferLen)
+{
+ SDLAudioEngine *pThis = (SDLAudioEngine*)userData;
+ pThis->mixAudio(audioBuffer, audioBufferLen);
+}
+
+void SDLAudioEngine::addBuffers(double *pDest, AudioBufferPtr pSrc)
+{
+ int numFrames = pSrc->getNumFrames();
+ short * pData = pSrc->getData();
+ for(int i = 0; i < numFrames*getChannels(); ++i) {
+ pDest[i] += pData[i]/32768.0;
+ }
+}
+
+void SDLAudioEngine::calcVolume(double *pBuffer, int numSamples, double volume)
+{
+ // TODO: We need a VolumeFader class that keeps state.
+ for(int i = 0; i < numSamples; ++i) {
+ pBuffer[i] *= volume;
+ }
+}
+
+}
diff --git a/src/audio/SDLAudioEngine.h b/src/audio/SDLAudioEngine.h
new file mode 100644
index 0000000..f7c33a2
--- /dev/null
+++ b/src/audio/SDLAudioEngine.h
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _SDLAudioEngine_H_
+#define _SDLAudioEngine_H_
+
+#include "../api.h"
+#include "AudioEngine.h"
+#include "AudioBuffer.h"
+#include "IProcessor.h"
+
+#include <SDL/SDL.h>
+
+#include <boost/thread/mutex.hpp>
+
+namespace avg {
+
+class AVG_API SDLAudioEngine : public AudioEngine
+{
+ public:
+ static SDLAudioEngine* get();
+ SDLAudioEngine();
+ virtual ~SDLAudioEngine();
+
+ virtual int getChannels();
+ virtual int getSampleRate();
+ virtual const AudioParams * getParams();
+
+ virtual void init(const AudioParams& AP, double volume);
+ virtual void teardown();
+
+ virtual void setAudioEnabled(bool bEnabled);
+
+ virtual void play();
+ virtual void pause();
+
+ virtual void addSource(IAudioSource* pSource);
+ virtual void removeSource(IAudioSource* pSource);
+ virtual void setVolume(double volume);
+
+ private:
+ void mixAudio(Uint8 *pDestBuffer, int destBufferLen);
+ static void audioCallback(void *userData, Uint8 *audioBuffer, int audioBufferLen);
+ void addBuffers(double *pDest, AudioBufferPtr pSrc);
+ void calcVolume(double *pBuffer, int numSamples, double volume);
+
+ AudioParams m_AP;
+ AudioBufferPtr m_pTempBuffer;
+ double * m_pMixBuffer;
+ IProcessor<double>* m_pLimiter;
+ boost::mutex m_Mutex;
+
+ static SDLAudioEngine* s_pInstance;
+};
+
+}
+
+#endif //_SDLAudioEngine_H_
diff --git a/src/audio/testlimiter.cpp b/src/audio/testlimiter.cpp
new file mode 100644
index 0000000..1813bef
--- /dev/null
+++ b/src/audio/testlimiter.cpp
@@ -0,0 +1,112 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Dynamics.h"
+
+#include "../base/TestSuite.h"
+#include "../base/MathHelper.h"
+
+#include <stdlib.h>
+#include <iostream>
+
+using namespace avg;
+using namespace std;
+
+class LimiterTest: public Test {
+public:
+ LimiterTest()
+ : Test("LimiterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ const int CHANNELS = 2;
+ double fs = 44100.;
+ int numSamples = int(fs * 0.1);
+
+ // Setup a brickwall limiter
+ typedef Dynamics<double, CHANNELS> TStereoLimiter;
+ TStereoLimiter* d = new TStereoLimiter(fs);
+ d->setThreshold(0.); // in dB
+ d->setAttackTime(0.); // in seconds
+ d->setReleaseTime(0.05); // in seconds
+ d->setRmsTime(0.); // in seconds
+ d->setRatio(std::numeric_limits<double>::infinity());
+ d->setMakeupGain(0.); // in dB
+
+ // Generate input and output test data
+ double* pSamples = new double[CHANNELS*numSamples];
+ for (int j = 0; j < numSamples; j++) {
+ for (int i = 0; i < CHANNELS; i++) {
+ pSamples[j*CHANNELS+i] = 2*sin(j*(440./44100)*M_PI);
+ }
+ }
+
+ // Let the limiter work.
+ for (int i=0; i<numSamples; ++i) {
+ d->process(pSamples+i*CHANNELS);
+ }
+
+ // Check if everything is ok.
+ bool bDiscontinuities = false;
+ bool bAboveThreshold = false;
+ for (int j = 1; j < numSamples; j++) {
+ for (int i = 0; i < CHANNELS; i++) {
+ // Test if anything is above the threshold.
+ if (pSamples[j*CHANNELS+i] > 1) {
+ bAboveThreshold = true;
+ }
+ if (fabs(pSamples[j*CHANNELS+i]-pSamples[(j-1)*CHANNELS+i]) > 0.05) {
+ bDiscontinuities = true;
+// cerr << j << ": " << outSamples[j*OUT_CHANNELS+i] << ", " <<
+// outSamples[(j-1)*OUT_CHANNELS+i] << endl;
+ }
+ }
+ }
+ TEST(!bAboveThreshold);
+ TEST(!bDiscontinuities);
+/*
+ // Save data to ascii file.
+ FILE * pFile = fopen("data.txt", "w");
+ for (int j = 0; j < numSamples; j++) {
+ fprintf(pFile, "%f\n", pSamples[j*OUT_CHANNELS]);
+ }
+ fclose(pFile);
+*/
+ // Free memory
+ delete d;
+ delete[] pSamples;
+ }
+};
+
+int main(int nargs, char** args)
+{
+ LimiterTest test;
+ test.runTests();
+ bool bOK = test.isOk();
+
+ if (bOK) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
diff --git a/src/avgconfig.h.in b/src/avgconfig.h.in
new file mode 100644
index 0000000..9868511
--- /dev/null
+++ b/src/avgconfig.h.in
@@ -0,0 +1,111 @@
+/* src/avgconfig.h.in. Generated from configure.in by autoheader. */
+
+/* Enable firewire camera support v.2 */
+#undef AVG_ENABLE_1394_2
+
+/* Enable Linux kernel multitouch */
+#undef AVG_ENABLE_MTDEV
+
+/* Enable parallel port support */
+#undef AVG_ENABLE_PARPORT
+
+/* Enable Video4Linux2 camera support */
+#undef AVG_ENABLE_V4L2
+
+/* Enable VDPAU support */
+#undef AVG_ENABLE_VDPAU
+
+/* Use the Apple OpenGL framework. */
+#undef HAVE_APPLE_OPENGL_FRAMEWORK
+
+/* define if the Boost::Thread library is available */
+#undef HAVE_BOOST_THREAD
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the <libavcodec/vdpau.h> header file. */
+#undef HAVE_LIBAVCODEC_VDPAU_H
+
+/* Define to 1 if you have the <libavformat/avformat.h> header file. */
+#undef HAVE_LIBAVFORMAT_AVFORMAT_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* define if the compiler implements namespaces */
+#undef HAVE_NAMESPACES
+
+/* Define if you have POSIX threads libraries and header files. */
+#undef HAVE_PTHREAD
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <vdpau/vdpau.h> header file. */
+#undef HAVE_VDPAU_VDPAU_H
+
+/* Define to 1 if you have the <windows.h> header file. */
+#undef HAVE_WINDOWS_H
+
+/* XI2_1 available */
+#undef HAVE_XI2_1
+
+/* XI2_2 available */
+#undef HAVE_XI2_2
+
+/* Define to the sub-directory in which libtool stores uninstalled libraries.
+ */
+#undef LT_OBJDIR
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Define to the necessary symbol if this constant uses a non-standard name on
+ your system. */
+#undef PTHREAD_CREATE_JOINABLE
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Version number of package */
+#undef VERSION
diff --git a/src/avgconfig_win.h b/src/avgconfig_win.h
new file mode 100644
index 0000000..9b2bb31
--- /dev/null
+++ b/src/avgconfig_win.h
@@ -0,0 +1,28 @@
+/* src/avgconfig.h.in. Generated from configure.in by autoheader. */
+
+/* Enable DirectShow camera support */
+#define AVG_ENABLE_DSHOW
+
+/* Enable CMU 1394 Digital Camera Driver support */
+#define AVG_ENABLE_CMU1394
+
+/* Enable firewire camera support */
+#undef AVG_ENABLE_1394
+
+/* Enable firewire camera support v.2 */
+#undef AVG_ENABLE_1394_2
+
+/* ffmpeg >= 0.5.0 */
+#define HAVE_LIBAVFORMAT_AVFORMAT_H
+
+/* Enable Video4Linux2 camera support */
+#undef AVG_ENABLE_V4L2
+
+/* Enable parallel port support */
+#undef AVG_ENABLE_PARPORT
+
+/* Enable ffmpeg swscale support. */
+#define AVG_ENABLE_SWSCALE
+
+/* Name of package */
+#undef PACKAGE
diff --git a/src/avgconfigwrapper.h b/src/avgconfigwrapper.h
new file mode 100644
index 0000000..1e62d00
--- /dev/null
+++ b/src/avgconfigwrapper.h
@@ -0,0 +1,37 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "api.h"
+#ifdef _WIN32
+#include "../avgconfig_win.h"
+#else
+#include "avgconfig.h"
+#endif
+
+// These defines regularly cause multiple definition warnings and are usually
+// completely unneeded.
+#undef PACKAGE
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+
diff --git a/src/avgrc b/src/avgrc
new file mode 100644
index 0000000..4d4c063
--- /dev/null
+++ b/src/avgrc
@@ -0,0 +1,16 @@
+<avgrc>
+ <scr>
+ <bpp>24</bpp>
+ <fullscreen>false</fullscreen>
+ <usepow2textures>false</usepow2textures>
+ <useshaders>true</useshaders>
+ <usepixelbuffers>true</usepixelbuffers>
+ <multisamplesamples>4</multisamplesamples>
+ <dotspermm>0</dotspermm>
+ </scr>
+ <aud>
+ <channels>2</channels>
+ <samplerate>44100</samplerate>
+ <outputbuffersamples>1024</outputbuffersamples>
+ </aud>
+</avgrc>
diff --git a/src/base/Backtrace.cpp b/src/base/Backtrace.cpp
new file mode 100644
index 0000000..f6d1d77
--- /dev/null
+++ b/src/base/Backtrace.cpp
@@ -0,0 +1,93 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Backtrace.h"
+
+#ifndef _WIN32
+#include <execinfo.h>
+#include <cxxabi.h>
+#endif
+
+#include <stdlib.h>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+void dumpBacktrace()
+{
+#ifndef _WIN32
+ vector<string> sFuncs;
+ getBacktrace(sFuncs);
+ int i=0;
+ vector<string>::iterator it = sFuncs.begin();
+ ++it;
+ for (; it != sFuncs.end(); ++it) {
+ cerr << " " << i << ": " << *it << endl;
+ i++;
+ }
+#endif
+}
+
+string funcNameFromLine(const string& sLine)
+{
+ try {
+#ifdef __APPLE__
+ string::size_type addressPos = sLine.find("0x");
+ string::size_type namePos = sLine.find(" ", addressPos);
+ namePos++;
+ string::size_type nameEndPos = sLine.find(" ", namePos);
+#else
+ string::size_type namePos = sLine.find("(");
+ namePos++;
+ string::size_type nameEndPos = sLine.find_first_of(")+", namePos);
+#endif
+ return sLine.substr(namePos, nameEndPos-namePos);
+ } catch (exception&) {
+ return sLine;
+ }
+}
+
+void getBacktrace(std::vector<std::string>& sFuncs)
+{
+#ifndef _WIN32
+ void* callstack[128];
+ int numFrames = backtrace(callstack, 128);
+ char** ppszLines = backtrace_symbols(callstack, numFrames);
+ for (int i = 1; i < numFrames; ++i) {
+ string sLine = ppszLines[i];
+ string sFuncName = funcNameFromLine(sLine);
+ int result;
+ char * pszDemangledFuncName = abi::__cxa_demangle(sFuncName.c_str(), 0, 0,
+ &result);
+ if (!result) {
+ sFuncName = pszDemangledFuncName;
+ free(pszDemangledFuncName);
+ }
+ sFuncs.push_back(sFuncName);
+ }
+ free(ppszLines);
+#endif
+}
+
+}
+
diff --git a/src/base/Backtrace.h b/src/base/Backtrace.h
new file mode 100644
index 0000000..cc49964
--- /dev/null
+++ b/src/base/Backtrace.h
@@ -0,0 +1,36 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Backtrace_H_
+#define _Backtrace_H_
+
+#include <vector>
+#include <string>
+
+namespace avg {
+
+void dumpBacktrace();
+
+void getBacktrace(std::vector<std::string>& sFuncs);
+
+}
+
+#endif
diff --git a/src/base/BezierCurve.cpp b/src/base/BezierCurve.cpp
new file mode 100644
index 0000000..3d1ea72
--- /dev/null
+++ b/src/base/BezierCurve.cpp
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "BezierCurve.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+BezierCurve::BezierCurve(const DPoint& p0, const DPoint& p1, const DPoint& p2,
+ const DPoint& p3)
+ : m_P0(p0),
+ m_P1(p1),
+ m_P2(p2),
+ m_P3(p3)
+{
+}
+
+DPoint BezierCurve::interpolate(double t) const
+{
+ return (1-t)*(1-t)*(1-t)*m_P0+
+ 3*t*(1-t)*(1-t) *m_P1+
+ 3*t*t*(1-t) *m_P2+
+ t*t*t *m_P3;
+}
+DPoint BezierCurve::getDeriv(double t) const
+{
+ return 3*(m_P1-m_P0)*(1-t)*(1-t)+
+ 6*(m_P2-m_P1)*(1-t)*t+
+ 3*(m_P3-m_P2)*t*t;
+}
+
+}
diff --git a/src/base/BezierCurve.h b/src/base/BezierCurve.h
new file mode 100644
index 0000000..b7e00f4
--- /dev/null
+++ b/src/base/BezierCurve.h
@@ -0,0 +1,54 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _BezierCurve_H_
+#define _BezierCurve_H_
+
+#include "../api.h"
+#include "Point.h"
+
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+namespace avg {
+
+class AVG_API BezierCurve {
+public:
+ BezierCurve(const DPoint& p0, const DPoint& p1, const DPoint& p2, const DPoint& p3);
+
+ DPoint interpolate(double t) const;
+ DPoint getDeriv(double t) const;
+
+private:
+ DPoint m_P0;
+ DPoint m_P1;
+ DPoint m_P2;
+ DPoint m_P3;
+};
+
+typedef boost::shared_ptr<BezierCurve> BezierCurvePtr;
+
+}
+
+#endif
+
+
+
diff --git a/src/base/CmdLine.cpp b/src/base/CmdLine.cpp
new file mode 100644
index 0000000..d081ec5
--- /dev/null
+++ b/src/base/CmdLine.cpp
@@ -0,0 +1,82 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "CmdLine.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+CmdLine::CmdLine(int argc, char **argv)
+{
+ for (int i = 1; i < argc; ++i) {
+ string sArg(argv[i]);
+ if (sArg.substr(0, 2) == "--") {
+ string::size_type DelimPos = sArg.find('=');
+ string sOptName;
+ string sOptVal;
+ if (DelimPos == sArg.npos) {
+ sOptName = sArg.substr(2);
+ sOptVal = "";
+ } else {
+ sOptName = sArg.substr(2, DelimPos-2);
+ sOptVal = sArg.substr(DelimPos+1);
+ }
+ m_Options[sOptName] = sOptVal;
+ } else {
+ m_Args.push_back(sArg);
+ }
+ }
+}
+
+const OptionMap& CmdLine::getOptions() const
+{
+ return m_Options;
+}
+
+const string* CmdLine::getOption(const string& sName) const
+{
+ OptionMap::const_iterator it = m_Options.find(sName);
+ if (it == m_Options.end()) {
+ return 0;
+ } else {
+ return &(*it).second;
+ }
+}
+
+int CmdLine::getNumArgs() const
+{
+ return int(m_Args.size());
+}
+
+const string* CmdLine::getArg(unsigned int i) const
+{
+ if (i>=m_Args.size()) {
+ return 0;
+ } else {
+ return &m_Args[i];
+ }
+}
+
+}
+
diff --git a/src/base/CmdLine.h b/src/base/CmdLine.h
new file mode 100644
index 0000000..db57104
--- /dev/null
+++ b/src/base/CmdLine.h
@@ -0,0 +1,50 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CmdLine_H_
+#define _CmdLine_H_
+
+#include "../api.h"
+#include <string>
+#include <vector>
+#include <map>
+
+namespace avg {
+
+typedef std::map<std::string, std::string> OptionMap;
+
+class AVG_API CmdLine {
+public:
+ CmdLine(int argc, char **argv);
+
+ const OptionMap& getOptions() const;
+ const std::string* getOption(const std::string& sName) const;
+ int getNumArgs() const;
+ const std::string* getArg(unsigned int i) const;
+
+private:
+ OptionMap m_Options;
+ std::vector<std::string> m_Args;
+};
+
+}
+#endif
+
diff --git a/src/base/CmdQueue.h b/src/base/CmdQueue.h
new file mode 100644
index 0000000..a2dc6a3
--- /dev/null
+++ b/src/base/CmdQueue.h
@@ -0,0 +1,49 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CmdQueue_H_
+#define _CmdQueue_H_
+
+#include "Command.h"
+#include "Queue.h"
+
+#include "../api.h"
+
+namespace avg {
+
+template<class RECEIVER>
+class AVG_TEMPLATE_API CmdQueue: public Queue<Command<RECEIVER> >
+{
+public:
+ typedef typename Queue<Command<RECEIVER> >::QElementPtr CmdPtr;
+ void pushCmd(typename Command<RECEIVER>::CmdFunc func);
+
+};
+
+template<class RECEIVER>
+void CmdQueue<RECEIVER>::pushCmd(typename Command<RECEIVER>::CmdFunc func)
+{
+ this->push(CmdPtr(new Command<RECEIVER>(func)));
+}
+
+}
+
+#endif
diff --git a/src/base/Command.h b/src/base/Command.h
new file mode 100644
index 0000000..79c48a6
--- /dev/null
+++ b/src/base/Command.h
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Command_H_
+#define _Command_H_
+
+#include "../api.h"
+#include <boost/function.hpp>
+
+namespace avg {
+
+template<class RECEIVER>
+class AVG_TEMPLATE_API Command {
+public:
+ typedef boost::function<void(RECEIVER*)> CmdFunc;
+
+ Command(CmdFunc Func);
+ void execute(RECEIVER* pTarget);
+
+private:
+ CmdFunc m_Func;
+};
+
+template<class RECEIVER>
+Command<RECEIVER>::Command(CmdFunc Func)
+ : m_Func(Func)
+{
+}
+
+template<class RECEIVER>
+void Command<RECEIVER>::execute(RECEIVER* pTarget)
+{
+ m_Func(pTarget);
+}
+
+}
+
+#endif
diff --git a/src/base/ConfigMgr.cpp b/src/base/ConfigMgr.cpp
new file mode 100644
index 0000000..04b756d
--- /dev/null
+++ b/src/base/ConfigMgr.cpp
@@ -0,0 +1,322 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ConfigMgr.h"
+#include "Logger.h"
+#include "Exception.h"
+#include "OSHelper.h"
+
+#include <libxml/xmlmemory.h>
+
+#include <iostream>
+#include <stdlib.h>
+#include <errno.h>
+
+#ifndef _WIN32
+#include <unistd.h>
+#else
+#include <io.h>
+#endif
+
+using namespace std;
+
+namespace avg {
+
+ConfigOption::ConfigOption(const string& sName, const string& sValue)
+ : m_sName(sName),
+ m_sValue(sValue)
+{
+}
+
+ConfigMgr* ConfigMgr::m_pGlobalConfigMgr = 0;
+
+void deleteConfigMgr()
+{
+ delete ConfigMgr::m_pGlobalConfigMgr;
+ ConfigMgr::m_pGlobalConfigMgr = 0;
+}
+
+ConfigMgr* ConfigMgr::get()
+{
+ if (!m_pGlobalConfigMgr) {
+ m_pGlobalConfigMgr = new ConfigMgr;
+ atexit(deleteConfigMgr);
+ }
+ return m_pGlobalConfigMgr;
+}
+
+ConfigMgr::ConfigMgr()
+{
+ addSubsys("scr");
+ addOption("scr", "bpp", "24");
+ addOption("scr", "fullscreen", "false");
+ addOption("scr", "windowwidth", "0");
+ addOption("scr", "windowheight", "0");
+ addOption("scr", "dotspermm", "0");
+ addOption("scr", "usepow2textures", "false");
+ addOption("scr", "useshaders", "true");
+ addOption("scr", "usepixelbuffers", "true");
+ addOption("scr", "multisamplesamples", "1");
+ addOption("scr", "gamma", "-1,-1,-1");
+ addOption("scr", "vsyncmode", "auto");
+
+ addSubsys("aud");
+ addOption("aud", "channels", "2");
+ addOption("aud", "samplerate", "44100");
+ addOption("aud", "outputbuffersamples", "1024");
+
+ m_sFName = "avgrc";
+ loadFile(getGlobalConfigDir()+m_sFName);
+ char * pHome = getenv("HOME");
+ if (!pHome) {
+ AVG_TRACE(Logger::WARNING, "No home directory set.");
+ } else {
+ loadFile(string(pHome)+"/."+m_sFName);
+ }
+}
+
+void ConfigMgr::addSubsys(const string& sName)
+{
+ m_SubsysOptionMap[sName] = ConfigOptionVector();
+}
+
+void ConfigMgr::addOption(const string& sSubsys, const string& sName,
+ const std::string& sDefault)
+{
+ ConfigOptionVector& Subsys = m_SubsysOptionMap[sSubsys];
+ Subsys.push_back(ConfigOption(sName, sDefault));
+}
+
+const ConfigOptionVector* ConfigMgr::getOptions(const string& sSubsys) const
+{
+ SubsysOptionMap::const_iterator it = m_SubsysOptionMap.find(sSubsys);
+ if (it == m_SubsysOptionMap.end()) {
+ return 0;
+ } else {
+ return &(*it).second;
+ }
+}
+
+const string* ConfigMgr::getOption(const string& sSubsys,
+ const string& sName) const
+{
+ const ConfigOptionVector* pOptionVector = getOptions(sSubsys);
+ if (!pOptionVector) {
+ return 0;
+ } else {
+ for (unsigned int i=0; i<pOptionVector->size(); i++) {
+ if ((*pOptionVector)[i].m_sName == sName) {
+ return &(*pOptionVector)[i].m_sValue;
+ }
+ }
+ return 0;
+ }
+}
+
+bool ConfigMgr::getBoolOption(const std::string& sSubsys,
+ const std::string& sName, bool bDefault) const
+{
+ const string * psOption = getOption(sSubsys, sName);
+ if (psOption == 0) {
+ return bDefault;
+ }
+ if (*psOption == "true") {
+ return true;
+ } else if (*psOption == "false") {
+ return false;
+ } else {
+ AVG_TRACE(Logger::ERROR,
+ m_sFName << ": Unrecognized value for option "<<sName<<": "
+ << *psOption << ". Must be true or false. Aborting.");
+ exit(-1);
+ }
+}
+
+int ConfigMgr::getIntOption(const std::string& sSubsys,
+ const std::string& sName, int Default) const
+{
+ errno = 0;
+ const string * psOption = getOption(sSubsys, sName);
+ if (psOption == 0) {
+ return Default;
+ }
+ int Result = strtol(psOption->c_str(), 0, 10);
+ int rc = errno;
+ if (rc == EINVAL || rc == ERANGE) {
+ AVG_TRACE(Logger::ERROR,
+ m_sFName << ": Unrecognized value for option "<<sName<<": "
+ << *psOption << ". Must be an integer. Aborting.");
+ exit(-1);
+ }
+ return Result;
+}
+
+void ConfigMgr::getGammaOption(const std::string& sSubsys,
+ const std::string& sName, double* Val) const
+{
+ const string * psOption = getOption(sSubsys, sName);
+ if (psOption == 0) {
+ return;
+ }
+ int rc = sscanf(psOption->c_str(), "%lf,%lf,%lf", Val, Val+1, Val+2);
+ if (rc < 3) {
+ AVG_TRACE(Logger::ERROR,
+ m_sFName << ": Unrecognized value for option "<<sName<<": "
+ << *psOption << ". Must be three comma-separated numbers. Aborting.");
+ exit(-1);
+ }
+}
+
+bool ConfigMgr::loadFile(const std::string& sPath)
+{
+ string sSubsys;
+ try {
+#ifndef _WIN32
+ // I don't think read permissions on config files are an issue under windows.
+ int err = access(sPath.c_str(), R_OK);
+ if (err == -1) {
+ if (errno == EACCES) {
+ AVG_TRACE(Logger::WARNING,
+ sPath+": File exists, but process doesn't have read permissions!");
+ }
+ return false;
+ }
+#else
+ // but this actually prevents ugly XML parsing errors when file does not exist
+ // and cygwin is used
+ int err = _access(sPath.c_str(), 0);
+ if (err == -1) {
+ return false;
+ }
+#endif
+ xmlDocPtr doc;
+ doc = xmlParseFile(sPath.c_str());
+ if (!doc) {
+ throw Exception(AVG_ERR_XML_VALID, "Error parsing "+sPath
+ +". File is not well-formed.");
+ }
+ xmlNodePtr pRoot = xmlDocGetRootElement(doc);
+ if (xmlStrcmp(pRoot->name, (const xmlChar *)(m_sFName.c_str()))) {
+ AVG_TRACE(Logger::ERROR,
+ sPath+": Root node must be <"+m_sFName+">, found "
+ << pRoot->name << ". Aborting.");
+ exit(255);
+ }
+ xmlNodePtr pSubsysNode = pRoot->xmlChildrenNode;
+ while (pSubsysNode) {
+ if (xmlStrcmp(pSubsysNode->name, (const xmlChar *)"text") &&
+ xmlStrcmp(pSubsysNode->name, (const xmlChar *)"comment"))
+ {
+ sSubsys = ((const char *)pSubsysNode->name);
+ xmlNodePtr pOptionNode = pSubsysNode->xmlChildrenNode;
+ if (!pOptionNode) {
+ AVG_TRACE(Logger::ERROR,
+ sPath << ": Option " << sSubsys
+ << " has no value. Ignoring.");
+ } else {
+ ConfigOptionVector& CurSubsys = getSubsys(sSubsys);
+ while (pOptionNode) {
+ if (xmlStrcmp(pOptionNode->name, (const xmlChar *)"text") &&
+ xmlStrcmp(pOptionNode->name, (const xmlChar *)"comment"))
+ {
+ setOption(CurSubsys, doc, pOptionNode);
+ }
+ pOptionNode = pOptionNode->next;
+ }
+ }
+ }
+ pSubsysNode = pSubsysNode->next;
+ }
+ xmlFreeDoc(doc);
+ } catch (Exception& e) {
+ switch (e.getCode()) {
+ case AVG_ERR_OPTION_SUBSYS_UNKNOWN:
+ AVG_TRACE(Logger::ERROR, "While parsing " << sPath
+ << ": Option group " << e.getStr() << " unknown. Aborting.");
+ exit(255);
+ case AVG_ERR_OPTION_UNKNOWN:
+ AVG_TRACE(Logger::ERROR, "While parsing " << sPath
+ << ": Option " << sSubsys << ":" << e.getStr()
+ << " unknown. Aborting.");
+ exit(255);
+ default:
+ throw;
+ }
+ }
+ return true;
+}
+
+ConfigOptionVector& ConfigMgr::getSubsys(const string& sName)
+{
+ SubsysOptionMap::iterator pos = m_SubsysOptionMap.find(sName);
+ if (pos == m_SubsysOptionMap.end()) {
+ throw Exception(AVG_ERR_OPTION_SUBSYS_UNKNOWN, sName);
+ } else {
+ return pos->second;
+ }
+}
+
+void ConfigMgr::setOption(ConfigOptionVector& optionVector,
+ xmlDocPtr doc, xmlNodePtr pNode)
+{
+ string sName = (const char *)pNode->name;
+ xmlChar * pVal = xmlNodeListGetString(doc, pNode->xmlChildrenNode, 1);
+ string sValue = (const char *)pVal;
+ xmlFree(pVal);
+ setOption(optionVector, sName, sValue);
+}
+
+void ConfigMgr::setOption(ConfigOptionVector& optionVector,
+ const string& sName, const string& sValue)
+{
+ for (unsigned int i = 0; i < optionVector.size(); i++) {
+ if (optionVector[i].m_sName == sName) {
+ optionVector[i].m_sValue = sValue;
+ return;
+ }
+ }
+ throw Exception(AVG_ERR_OPTION_UNKNOWN, sName);
+}
+
+void ConfigMgr::dump() const
+{
+ SubsysOptionMap::const_iterator it;
+ for (it = m_SubsysOptionMap.begin(); it != m_SubsysOptionMap.end(); ++it) {
+ cerr << (*it).first << ": " << endl;
+ const ConfigOptionVector& SubsysOptions = (*it).second;
+ for (unsigned int j = 0; j < SubsysOptions.size(); ++j) {
+ cerr << " " << SubsysOptions[j].m_sName << ": "
+ << SubsysOptions[j].m_sValue << endl;
+ }
+ }
+}
+
+string getGlobalConfigDir()
+{
+#ifdef _WIN32
+ return getAvgLibPath()+"/etc/";
+#else
+ return "/etc/";
+#endif
+}
+
+}
+
diff --git a/src/base/ConfigMgr.h b/src/base/ConfigMgr.h
new file mode 100644
index 0000000..421c399
--- /dev/null
+++ b/src/base/ConfigMgr.h
@@ -0,0 +1,89 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ConfigMgr_H_
+#define _ConfigMgr_H_
+
+#include "../api.h"
+#include "CmdLine.h"
+
+#include <libxml/parser.h>
+
+#include <string>
+#include <vector>
+#include <map>
+
+namespace avg {
+
+struct ConfigOption {
+ ConfigOption(const std::string& sName, const std::string& sValue);
+
+ std::string m_sName;
+ std::string m_sValue;
+};
+
+typedef std::vector<ConfigOption> ConfigOptionVector;
+
+class AVG_API ConfigMgr {
+public:
+ static ConfigMgr* get();
+
+ void addSubsys(const std::string& sName);
+ void addOption(const std::string& sSubsys, const std::string& sName,
+ const std::string& sDefault);
+
+ const ConfigOptionVector* getOptions(const std::string& sSubsys)
+ const;
+ const std::string* getOption(const std::string& sSubsys,
+ const std::string& sName) const;
+ bool getBoolOption(const std::string& sSubsys,
+ const std::string& sName, bool bDefault) const;
+ int getIntOption(const std::string& sSubsys,
+ const std::string& sName, int Default) const;
+ void getGammaOption(const std::string& sSubsys,
+ const std::string& sName, double* Val) const;
+
+ void dump() const;
+
+private:
+ ConfigMgr();
+
+ bool loadFile(const std::string& sPath);
+ ConfigOptionVector& getSubsys(const std::string& sName);
+ void setOption(ConfigOptionVector& optionVector,
+ xmlDocPtr doc, xmlNodePtr pNode);
+ void setOption(ConfigOptionVector& optionVector, const std::string& sName,
+ const std::string& sValue);
+
+ typedef std::map<std::string, ConfigOptionVector> SubsysOptionMap;
+ SubsysOptionMap m_SubsysOptionMap;
+
+ std::string m_sFName;
+
+ static ConfigMgr* m_pGlobalConfigMgr;
+ friend void deleteConfigMgr();
+};
+
+std::string getGlobalConfigDir();
+
+}
+#endif
+
diff --git a/src/base/CubicSpline.cpp b/src/base/CubicSpline.cpp
new file mode 100644
index 0000000..f03f7f5
--- /dev/null
+++ b/src/base/CubicSpline.cpp
@@ -0,0 +1,89 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "CubicSpline.h"
+#include "Exception.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+CubicSpline::CubicSpline(const vector<double>& x, const vector<double>& y)
+ : m_X(x),
+ m_Y(y)
+{
+ AVG_ASSERT(x.size() == y.size());
+ // Add fake points before the first and after the last point so all derivatives
+ // are defined.
+ double edgeX = 2*m_X[0]-m_X[1];
+ double edgeY = 2*m_Y[0]-m_Y[1];
+ m_X.insert(m_X.begin(), edgeX);
+ m_Y.insert(m_Y.begin(), edgeY);
+
+ int len = m_X.size();
+ edgeX = 2*m_X[len-1]-m_X[len-2];
+ edgeY = 2*m_Y[len-1]-m_Y[len-2];
+ m_X.push_back(edgeX);
+ m_Y.push_back(edgeY);
+}
+
+CubicSpline::~CubicSpline()
+{
+}
+
+double normedInterpolate(double y0, double y1, double y2, double y3, double mu)
+{
+ double mu2 = mu*mu;
+ double a0 = y3 - y2 - y0 + y1;
+ double a1 = y0 - y1 - a0;
+ double a2 = y2 - y0;
+ double a3 = y1;
+
+ return(a0*mu*mu2+a1*mu2+a2*mu+a3);
+}
+
+
+double CubicSpline::interpolate(double orig)
+{
+ unsigned i = 0;
+ if (m_X[m_X.size()-1] <= orig) {
+ i = m_X.size();
+ } else {
+ while (m_X[i] < orig) {
+ i++;
+ }
+ }
+ if (i < 2) {
+ double dxdy = (m_X[1]-m_X[0])/(m_Y[1]-m_Y[0]);
+ return m_Y[1]+(orig-m_X[1])/dxdy;
+ } else if (i > m_X.size()-2) {
+ unsigned len = m_X.size();
+ double dxdy = (m_X[len-1]-m_X[len-2])/(m_Y[len-1]-m_Y[len-2]);
+ return m_Y[len-2]+(orig-m_X[len-2])/dxdy;
+ } else {
+ double ratio = (orig-m_X[i-1])/(m_X[i]-m_X[i-1]);
+ return normedInterpolate(m_Y[i-2], m_Y[i-1], m_Y[i], m_Y[i+1], ratio);
+ }
+}
+
+}
diff --git a/src/base/CubicSpline.h b/src/base/CubicSpline.h
new file mode 100644
index 0000000..276f41c
--- /dev/null
+++ b/src/base/CubicSpline.h
@@ -0,0 +1,50 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CubicSpline_H_
+#define _CubicSpline_H_
+
+#include "../api.h"
+#include <boost/shared_ptr.hpp>
+#include <vector>
+
+namespace avg {
+
+class AVG_API CubicSpline {
+public:
+ CubicSpline(const std::vector<double>& x, const std::vector<double>& y);
+ virtual ~CubicSpline();
+
+ double interpolate(double orig);
+
+private:
+ std::vector<double> m_X;
+ std::vector<double> m_Y;
+};
+
+typedef boost::shared_ptr<CubicSpline> CubicSplinePtr;
+
+}
+
+#endif
+
+
+
diff --git a/src/base/DirEntry.cpp b/src/base/DirEntry.cpp
new file mode 100644
index 0000000..7da4edb
--- /dev/null
+++ b/src/base/DirEntry.cpp
@@ -0,0 +1,65 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "DirEntry.h"
+
+using namespace std;
+
+namespace avg {
+
+#ifdef _WIN32
+DirEntry::DirEntry(string sDirName, const _finddata_t& findData)
+ : m_sDirName(sDirName),
+ m_FindData(findData)
+{
+}
+
+#else
+DirEntry::DirEntry(string sDirName, dirent * pEntry)
+ : m_sDirName(sDirName),
+ m_pEntry(pEntry)
+{
+}
+#endif
+
+DirEntry::~DirEntry()
+{
+}
+
+std::string DirEntry::getName()
+{
+#ifdef _WIN32
+ return m_FindData.name;
+#else
+ return m_pEntry->d_name;
+#endif
+}
+
+void DirEntry::remove()
+{
+#ifdef _WIN32
+ ::_unlink((m_sDirName+"\\"+m_FindData.name).c_str());
+#else
+ ::unlink((m_sDirName+"/"+m_pEntry->d_name).c_str());
+#endif
+}
+
+}
diff --git a/src/base/DirEntry.h b/src/base/DirEntry.h
new file mode 100644
index 0000000..d23388d
--- /dev/null
+++ b/src/base/DirEntry.h
@@ -0,0 +1,67 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DirEntry_H_
+#define _DirEntry_H_
+
+#include "../api.h"
+#include <boost/shared_ptr.hpp>
+
+#ifdef _WIN32
+#include <io.h>
+#else
+#include <dirent.h>
+#endif
+#include <string>
+
+namespace avg {
+
+class AVG_API DirEntry {
+public:
+#ifdef _WIN32
+ DirEntry(std::string sDirName, const _finddata_t& findData);
+#else
+ DirEntry(std::string sDirName, dirent * pEntry);
+#endif
+ virtual ~DirEntry();
+
+ std::string getName();
+ void remove();
+
+private:
+ std::string m_sDirName;
+
+#ifdef _WIN32
+ _finddata_t m_FindData;
+#else
+ dirent * m_pEntry;
+#endif
+
+};
+
+typedef boost::shared_ptr<DirEntry> DirEntryPtr;
+
+}
+
+#endif
+
+
+
diff --git a/src/base/Directory.cpp b/src/base/Directory.cpp
new file mode 100644
index 0000000..dda1e8d
--- /dev/null
+++ b/src/base/Directory.cpp
@@ -0,0 +1,135 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Directory.h"
+
+#ifdef _WIN32
+#include <Windows.h>
+#endif
+#include <sys/stat.h>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+Directory::Directory(std::string sName)
+ : m_sName(sName)
+{
+#ifdef _WIN32
+ m_hFile = -1;
+#else
+ m_pDir = 0;
+#endif
+}
+
+Directory::~Directory()
+{
+#ifdef _WIN32
+ _findclose(m_hFile);
+#else
+ if (m_pDir) {
+ closedir(m_pDir);
+ }
+#endif
+}
+
+int Directory::open(bool bCreateIfMissing)
+{
+#ifdef _WIN32
+ m_hFile = _findfirst((m_sName+"/*").c_str(), &m_FindData);
+ if(m_hFile == -1L) {
+ if (bCreateIfMissing) {
+ int err = CreateDirectory(m_sName.c_str(), 0);
+ if (err == 0) {
+ return -1;
+ } else {
+ m_hFile = _findfirst((m_sName+"/*").c_str(), &m_FindData);
+ m_bFirstFile = true;
+ return 0;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ m_bFirstFile = true;
+ return 0;
+ }
+#else
+ m_pDir = opendir(m_sName.c_str());
+ if (!m_pDir) {
+ if (bCreateIfMissing) {
+ int err = mkdir(m_sName.c_str(),
+ S_IRWXU | S_IRWXG | S_IRWXO);
+ if (err) {
+ return err;
+ } else {
+ m_pDir = opendir(m_sName.c_str());
+ return 0;
+ }
+ } else {
+ return -1;
+ }
+ } else {
+ return 0;
+ }
+#endif
+}
+
+DirEntryPtr Directory::getNextEntry()
+{
+#ifdef _WIN32
+ if (!m_bFirstFile) {
+ int rc = _findnext(m_hFile, &m_FindData);
+ if (rc == -1) {
+ return DirEntryPtr();
+ }
+ }
+ m_bFirstFile = false;
+ return DirEntryPtr(new DirEntry(m_sName, m_FindData));
+#else
+ dirent * pDirent;
+ pDirent = readdir(m_pDir);
+ if (pDirent) {
+ return DirEntryPtr(new DirEntry(m_sName, pDirent));
+ } else {
+ return DirEntryPtr();
+ }
+#endif
+}
+
+const std::string& Directory::getName()
+{
+ return m_sName;
+}
+
+void Directory::empty()
+{
+ DirEntryPtr pEntry;
+ do {
+ pEntry = getNextEntry();
+ if (pEntry) {
+ pEntry->remove();
+ }
+ } while (pEntry);
+}
+
+}
diff --git a/src/base/Directory.h b/src/base/Directory.h
new file mode 100644
index 0000000..1edb139
--- /dev/null
+++ b/src/base/Directory.h
@@ -0,0 +1,64 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Directory_H_
+#define _Directory_H_
+
+#include "../api.h"
+#include "DirEntry.h"
+
+#ifdef _WIN32
+#include <io.h>
+#else
+#include <dirent.h>
+#endif
+
+#include <string>
+
+namespace avg {
+
+class AVG_API Directory {
+public:
+ Directory(std::string sName);
+ virtual ~Directory();
+
+ int open(bool bCreateIfMissing = false);
+ DirEntryPtr getNextEntry();
+ const std::string& getName();
+ void empty();
+
+private:
+ std::string m_sName;
+
+#ifdef _WIN32
+ _finddata_t m_FindData;
+ intptr_t m_hFile;
+ bool m_bFirstFile;
+#else
+ DIR * m_pDir;
+#endif
+};
+
+}
+
+#endif
+
+
diff --git a/src/base/DlfcnWrapper.cpp b/src/base/DlfcnWrapper.cpp
new file mode 100644
index 0000000..8dfbfbc
--- /dev/null
+++ b/src/base/DlfcnWrapper.cpp
@@ -0,0 +1,61 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "DlfcnWrapper.h"
+
+#include <sstream>
+#include <string.h>
+
+#ifndef WIN32_LEAN_AND_MEAN
+#define WIN32_LEAN_AND_MEAN
+#endif
+#include "windows.h"
+
+using namespace std;
+
+namespace avg {
+
+void* dlopen(const char *pszPath, int ignored)
+{
+ return LoadLibrary(pszPath);
+}
+
+void dlclose(void* handle)
+{
+ FreeLibrary((HMODULE)handle);
+}
+
+void* dlsym(void* handle, const char* functionName)
+{
+ return GetProcAddress((HMODULE)handle, functionName);
+}
+
+const char* dlerror()
+{
+ static char buffer[1024];
+ int err = GetLastError();
+ ostringstream ss;
+ ss << err;
+ strncpy(buffer,ss.str().c_str(),1023);
+ return buffer;
+}
+
+}
diff --git a/src/base/DlfcnWrapper.h b/src/base/DlfcnWrapper.h
new file mode 100644
index 0000000..4cc0e98
--- /dev/null
+++ b/src/base/DlfcnWrapper.h
@@ -0,0 +1,41 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DlfcnWrapper_h_
+#define _DlfcnWrapper_h_
+
+#ifdef _WIN32
+#define RTLD_LOCAL 0
+#define RTLD_NOW 0
+
+namespace avg {
+
+void* dlopen(const char *pszPath, int ignored);
+void dlclose(void* handle);
+void* dlsym(void* handle, const char* functionName);
+const char* dlerror();
+
+}
+#else
+#include <dlfcn.h>
+#endif
+
+#endif
diff --git a/src/base/Exception.cpp b/src/base/Exception.cpp
new file mode 100644
index 0000000..e694320
--- /dev/null
+++ b/src/base/Exception.cpp
@@ -0,0 +1,99 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Exception.h"
+#include "Backtrace.h"
+#include "Logger.h"
+#include "OSHelper.h"
+
+#include <cstdlib>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+Exception::Exception(int code, const string& sErr)
+ : m_Code (code),
+ m_sErr (sErr)
+{
+}
+
+Exception::Exception(const Exception& ex)
+ : m_Code (ex.getCode()),
+ m_sErr (ex.getStr())
+{
+}
+
+Exception::~Exception()
+{
+}
+
+int Exception::getCode() const
+{
+ return m_Code;
+}
+
+const string& Exception::getStr() const
+{
+ return m_sErr;
+}
+
+void fatalError(const string& sMsg)
+{
+ AVG_TRACE(Logger::ERROR, "Internal error: "+sMsg+" Aborting.");
+ exit(-1);
+}
+
+void debugBreak()
+{
+#ifdef _WIN32
+ __asm int 3;
+#elseifdef __x86_64
+ asm("int $3");
+#elseifdef __i386__
+ asm("int $3");
+#else
+ //deliberately dereferencing a null pointer should break in most debuggers
+ *((char *)0) = 0;
+#endif
+}
+
+void avgAssert(bool b, const char * pszFile, int line, const char * pszReason)
+{
+ if (!b) {
+ string sDummy;
+ static bool bBreak = getEnv("AVG_BREAK_ON_ASSERT", sDummy);
+ if (bBreak) {
+ debugBreak();
+ } else {
+ stringstream ss;
+ ss << "Assertion failed in " << pszFile << ": " << line << endl;
+ if (pszReason) {
+ ss << "Reason: " << pszReason << endl;
+ }
+ dumpBacktrace();
+ throw(Exception(AVG_ERR_ASSERT_FAILED, ss.str()));
+ }
+ }
+}
+
+}
diff --git a/src/base/Exception.h b/src/base/Exception.h
new file mode 100644
index 0000000..1524cb5
--- /dev/null
+++ b/src/base/Exception.h
@@ -0,0 +1,86 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Exception_H_
+#define _Exception_H_
+
+#include "../api.h"
+#include <string>
+
+#define AVG_ERR_UNKNOWN -1
+#define AVG_ERR_XML_PARSE 1
+#define AVG_ERR_XML_VALID 2
+#define AVG_ERR_XML_EMPTY 3
+#define AVG_ERR_XML_NODE_UNKNOWN 4
+#define AVG_ERR_XML_DUPLICATE_ID 5
+#define AVG_ERR_VIDEO_INIT_FAILED 6
+#define AVG_ERR_VIDEO_GENERAL 7
+#define AVG_ERR_FONT_INIT_FAILED 10
+#define AVG_ERR_VIDEO_LOAD_FAILED 11
+#define AVG_ERR_UNSUPPORTED 12
+#define AVG_ERR_OPTION_SUBSYS_UNKNOWN 13
+#define AVG_ERR_OPTION_UNKNOWN 14
+#define AVG_ERR_FILEIO 15
+#define AVG_ERR_NOT_IN_SCENE 16
+#define AVG_ERR_OUT_OF_RANGE 17
+#define AVG_ERR_ALREADY_CONNECTED 18
+#define AVG_ERR_LOAD_DURING_PLAYBACK 19
+#define AVG_ERR_CANT_PARSE_STRING 20
+#define AVG_ERR_INVALID_CAPTURE 21
+
+#define AVG_ERR_NO_NODE 23
+#define AVG_ERR_NO_ARG 24
+#define AVG_ERR_INVALID_ARGS 25
+#define AVG_ERR_NO_BUILDER 26
+#define AVG_ERR_TYPE 27
+#define AVG_ERR_CORRUPT_PLUGIN 28
+#define AVG_ERR_CAMERA_FATAL 29
+#define AVG_ERR_CAMERA_NONFATAL 30
+#define AVG_ERR_DEPRECATED 31
+#define AVG_ERR_ASSERT_FAILED 32
+#define AVG_ERR_MT_INIT 33
+
+namespace avg {
+
+class AVG_API Exception
+{
+ public:
+ Exception(int code, const std::string& sErr = "");
+ Exception(const Exception& ex);
+ virtual ~Exception();
+ virtual int getCode() const;
+ virtual const std::string& getStr() const;
+
+ private:
+ int m_Code;
+ std::string m_sErr;
+};
+
+void AVG_API fatalError(const std::string& sMsg);
+void AVG_API debugBreak();
+void AVG_API avgAssert(bool b, const char * pszFile, int line, const char * pszReason=0);
+
+#define AVG_ASSERT(b) avgAssert((b) != 0, __FILE__, __LINE__);
+#define AVG_ASSERT_MSG(b, pszReason) avgAssert((b) != 0, __FILE__, __LINE__, pszReason);
+
+}
+
+#endif
diff --git a/src/base/FileHelper.cpp b/src/base/FileHelper.cpp
new file mode 100644
index 0000000..9e38e51
--- /dev/null
+++ b/src/base/FileHelper.cpp
@@ -0,0 +1,163 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FileHelper.h"
+#include "ConfigMgr.h"
+#include "Exception.h"
+
+#ifndef _WIN32
+#include <libgen.h>
+#else
+#include <direct.h>
+#endif
+#include <stdio.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <map>
+#include <cstring>
+#include <iostream>
+#include <fstream>
+
+using namespace std;
+
+namespace avg {
+
+string getPath(const string& sFilename)
+{
+ if (sFilename.length() > 0 && sFilename.at(sFilename.length()-1) == '/') {
+ return sFilename;
+ }
+#ifdef _WIN32
+ int pos = int(sFilename.find_last_of("\\/"));
+ string dirName;
+ if (pos >= 0) {
+ dirName = sFilename.substr(0, pos+1);
+ } else {
+ dirName = sFilename;
+ }
+#else
+ char * pszBuffer = strdup(sFilename.c_str());
+
+ string dirName(dirname(pszBuffer));
+ free(pszBuffer);
+ dirName += "/";
+#endif
+
+ return dirName;
+}
+
+string getFilenamePart(const string& sFilename)
+{
+ if (sFilename.find_last_of("\\/") == 0) {
+ return sFilename;
+ }
+#ifdef _WIN32
+ int pos = int(sFilename.find_last_of("\\/"));
+ string BaseName(sFilename.substr(pos+1));
+#else
+ char * pszBuffer = strdup(sFilename.c_str());
+
+ string BaseName(basename(pszBuffer));
+ free(pszBuffer);
+#endif
+
+ return BaseName;
+}
+
+string getExtension(const string& sFilename)
+{
+ int pos = int(sFilename.find_last_of("."));
+ if (pos == 0) {
+ return "";
+ } else {
+ return sFilename.substr(pos+1);
+ }
+}
+
+string getCWD()
+{
+
+ char szBuf[1024];
+#ifdef _WIN32
+ char * pBuf = _getcwd(szBuf, 1024);
+#else
+ char * pBuf = getcwd(szBuf, 1024);
+#endif
+ return string(pBuf)+"/";
+}
+
+bool isAbsPath(const std::string& path)
+{
+#ifdef _WIN32
+ return ((path.length() != 0) && path[1] == ':') || path[0] == '\\' || path[0] == '/';
+#else
+ return path[0] == '/';
+#endif
+
+}
+
+bool fileExists(const string& sFilename)
+{
+ struct stat myStat;
+ return stat(sFilename.c_str(), &myStat) != -1;
+}
+
+void readWholeFile(const string& sFilename, string& sContent)
+{
+ ifstream file(sFilename.c_str());
+ if (!file) {
+ throw Exception(AVG_ERR_FILEIO, "Opening "+sFilename+
+ " for reading failed.");
+ }
+ vector<char> buffer(65536);
+ sContent.resize(0);
+ while (file) {
+ file.read(&(*buffer.begin()), (streamsize)(buffer.size()));
+ sContent.append(&(*buffer.begin()), (unsigned)file.gcount());
+ }
+ if (!file.eof() || file.bad()) {
+ throw Exception(AVG_ERR_FILEIO, "Reading "+sFilename+
+ " failed.");
+ }
+}
+
+void writeWholeFile(const string& sFilename, const string& sContent)
+{
+ ofstream outFile(sFilename.c_str());
+ if (!outFile) {
+ throw Exception(AVG_ERR_FILEIO, "Opening "+sFilename+
+ " for writing failed.");
+ }
+ outFile << sContent;
+}
+
+
+void copyFile(const string& sSourceFile, const string& sDestFile)
+{
+ string sData;
+
+ readWholeFile(sSourceFile, sData);
+ writeWholeFile(sDestFile, sData);
+}
+
+}
diff --git a/src/base/FileHelper.h b/src/base/FileHelper.h
new file mode 100644
index 0000000..c5724f5
--- /dev/null
+++ b/src/base/FileHelper.h
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FileHelper_H_
+#define _FileHelper_H_
+
+#include "../api.h"
+#include <string>
+
+namespace avg {
+
+std::string getPath(const std::string& sFilename);
+std::string getFilenamePart(const std::string& sFilename);
+std::string getExtension(const std::string& sFilename);
+std::string getCWD();
+
+bool isAbsPath(const std::string& path);
+
+bool fileExists(const std::string& sFilename);
+
+void readWholeFile(const std::string& sFilename, std::string& sContents);
+
+void writeWholeFile(const std::string& sFilename, const std::string& sContent);
+
+void copyFile(const std::string& sSourceFile, const std::string& sDestFile);
+
+
+#ifdef WIN32
+#define unlink _unlink
+#endif
+
+}
+
+#endif
+
diff --git a/src/base/GeomHelper.cpp b/src/base/GeomHelper.cpp
new file mode 100644
index 0000000..c1fa7a8
--- /dev/null
+++ b/src/base/GeomHelper.cpp
@@ -0,0 +1,178 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GeomHelper.h"
+
+#include <math.h>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+DLineSegment::DLineSegment(const DPoint& pt0, const DPoint& pt1)
+ : p0(pt0),
+ p1(pt1)
+{
+}
+
+bool DLineSegment::isPointOver(const DPoint& pt)
+{
+ DPoint c = pt - p0; // DPoint from a to Point
+ DPoint v = (p1 - p0);
+ double d = v.getNorm(); // Length of the line segment
+ v /= d; // Unit DPoint from a to b
+ double t = dotProduct(v, c); // Intersection point Distance from a
+
+ return (t >= 0 && t <= d);
+}
+
+// Code adapted from Antonio, Franklin, "Faster Line Segment Intersection,"
+// Graphics Gems III (David Kirk, ed.), Academic Press, pp. 199-202, 1992.
+bool lineSegmentsIntersect(const DLineSegment& l0, const DLineSegment& l1)
+{
+ double xdiff0 = l0.p1.x-l0.p0.x;
+ double xdiff1 = l1.p0.x-l1.p1.x;
+
+ double x1lo, x1hi;
+
+ /* X bound box test*/
+ if (xdiff0 < 0) {
+ x1lo=l0.p1.x;
+ x1hi=l0.p0.x;
+ } else {
+ x1hi=l0.p1.x;
+ x1lo=l0.p0.x;
+ }
+ if (xdiff1 > 0) {
+ if (x1hi < l1.p1.x || l1.p0.x < x1lo) {
+ return false;
+ }
+ } else {
+ if (x1hi < l1.p0.x || l1.p1.x < x1lo) {
+ return false;
+ }
+ }
+
+ double ydiff0 = l0.p1.y-l0.p0.y;
+ double ydiff1 = l1.p0.y-l1.p1.y;
+
+ double y1lo, y1hi;
+
+ /* Y bound box test*/
+ if (ydiff0 < 0) {
+ y1lo=l0.p1.y;
+ y1hi=l0.p0.y;
+ } else {
+ y1hi=l0.p1.y;
+ y1lo=l0.p0.y;
+ }
+ if (ydiff1 > 0) {
+ if (y1hi < l1.p1.y || l1.p0.y < y1lo) {
+ return false;
+ }
+ } else {
+ if (y1hi < l1.p0.y || l1.p1.y < y1lo) {
+ return false;
+ }
+ }
+
+ double Cx = l0.p0.x-l1.p0.x;
+ double Cy = l0.p0.y-l1.p0.y;
+ double d = ydiff1*Cx - xdiff1*Cy; /* alpha numerator*/
+ double f = ydiff0*xdiff1 - xdiff0*ydiff1; /* both denominator*/
+ if (f > 0) { /* alpha tests*/
+ if (d < 0 || d > f) {
+ return false;
+ }
+ } else {
+ if (d > 0 || d < f) {
+ return false;
+ }
+ }
+
+ double e = xdiff0*Cy - ydiff0*Cx; /* beta numerator*/
+ if(f > 0) { /* beta tests*/
+ if (e < 0 || e > f) {
+ return false;
+ }
+ } else {
+ if (e > 0 || e < f) {
+ return false;
+ }
+ }
+
+ if (f == 0) {
+ // Theoretically, lines could still intersect in this case, but we don't care
+ // because given numerical inaccuracies, the result is random anyway :-).
+ return false;
+ }
+
+// /*compute intersection coordinates*/
+// double num = d*xdiff0; /* numerator */
+// offset = SAME_SIGNS(num,f) ? f/2 : -f/2; /* round direction*/
+// *x = x1 + (num+offset) / f; /* intersection x */
+//
+// num = d*ydiff0;
+// offset = SAME_SIGNS(num,f) ? f/2 : -f/2;
+// *y = y1 + (num+offset) / f; /* intersection y */
+
+ return true;
+}
+
+// Original code from:
+// http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html.
+// Precomputing a bounding box for the polygon would speed this up a lot,
+// but the function hasn't shown up on any profiles so far.
+bool pointInPolygon(const DPoint& pt, const vector<DPoint>& poly)
+{
+ if (poly.size() < 3) {
+ return false;
+ }
+ bool bPtInPoly = false;
+ for (unsigned i = 0, j = poly.size()-1; i < poly.size(); j = i++) {
+ if (((poly[i].y > pt.y) != (poly[j].y > pt.y)) &&
+ (pt.x < (poly[j].x-poly[i].x)*(pt.y-poly[i].y) / (poly[j].y-poly[i].y)
+ +poly[i].x))
+ {
+ bPtInPoly = !bPtInPoly;
+ }
+ }
+ return bPtInPoly;
+}
+
+DPoint getLineLineIntersection(const DPoint& p1, const DPoint& v1, const DPoint& p2,
+ const DPoint& v2)
+{
+ double denom = v2.y*v1.x-v2.x*v1.y;
+ if (fabs(denom) < 0.0000001) {
+ // If the lines are parallel or coincident, we just return p2!
+ return p2;
+ }
+ double numer = v2.x*(p1.y-p2.y) - v2.y*(p1.x-p2.x);
+ double ua = numer/denom;
+
+ return p1+ua*v1;
+
+}
+
+
+}
diff --git a/src/base/GeomHelper.h b/src/base/GeomHelper.h
new file mode 100644
index 0000000..272a8ef
--- /dev/null
+++ b/src/base/GeomHelper.h
@@ -0,0 +1,50 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GeomHelper_H_
+#define _GeomHelper_H_
+
+#include "../api.h"
+#include "Point.h"
+
+#include <vector>
+
+namespace avg {
+
+struct AVG_API DLineSegment {
+public:
+ DLineSegment(const DPoint& pt0, const DPoint& pt1);
+ DPoint p0;
+ DPoint p1;
+
+ bool isPointOver(const DPoint& pt);
+};
+
+bool AVG_API lineSegmentsIntersect(const DLineSegment& l0, const DLineSegment& l1);
+
+bool AVG_API pointInPolygon(const DPoint& pt, const std::vector<DPoint>& poly);
+
+DPoint AVG_API getLineLineIntersection(const DPoint& p1, const DPoint& v1, const DPoint& p2,
+ const DPoint& v2);
+
+}
+#endif
+
diff --git a/src/base/IFrameEndListener.h b/src/base/IFrameEndListener.h
new file mode 100644
index 0000000..5f172d2
--- /dev/null
+++ b/src/base/IFrameEndListener.h
@@ -0,0 +1,37 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _IFrameEndListener_H_
+#define _IFrameEndListener_H_
+
+#include "../api.h"
+
+namespace avg {
+
+class AVG_API IFrameEndListener {
+public:
+ virtual ~IFrameEndListener() {};
+ virtual void onFrameEnd() = 0;
+};
+
+}
+
+#endif
diff --git a/src/base/IPlaybackEndListener.h b/src/base/IPlaybackEndListener.h
new file mode 100644
index 0000000..08d8c41
--- /dev/null
+++ b/src/base/IPlaybackEndListener.h
@@ -0,0 +1,38 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _IPlaybackEndListener_H_
+#define _IPlaybackEndListener_H_
+
+#include "../api.h"
+
+namespace avg {
+
+class AVG_API IPlaybackEndListener {
+public:
+ virtual ~IPlaybackEndListener() {};
+ virtual void onPlaybackEnd() = 0;
+};
+
+}
+
+#endif
+
diff --git a/src/base/IPreRenderListener.h b/src/base/IPreRenderListener.h
new file mode 100644
index 0000000..5fe4d82
--- /dev/null
+++ b/src/base/IPreRenderListener.h
@@ -0,0 +1,35 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _IPreRenderListener_H_
+#define _IPreRenderListener_H_
+
+namespace avg {
+
+class AVG_API IPreRenderListener {
+public:
+ virtual ~IPreRenderListener() {};
+ virtual void onPreRender() = 0;
+};
+
+}
+
+#endif
diff --git a/src/base/Logger.cpp b/src/base/Logger.cpp
new file mode 100644
index 0000000..286f76c
--- /dev/null
+++ b/src/base/Logger.cpp
@@ -0,0 +1,213 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Logger.h"
+
+#include "OSHelper.h"
+#include "Exception.h"
+
+#ifdef _WIN32
+#include <Winsock2.h>
+#undef ERROR
+#undef WARNING
+#include <time.h>
+#include <Mmsystem.h>
+#else
+#include <sys/time.h>
+#include <syslog.h>
+#endif
+#include <iostream>
+#include <iomanip>
+#include <boost/thread.hpp>
+
+using namespace std;
+
+namespace avg {
+
+const long Logger::NONE=0;
+const long Logger::BLTS=1;
+const long Logger::PROFILE=2;
+const long Logger::PROFILE_LATEFRAMES=4;
+const long Logger::PROFILE_VIDEO=8;
+const long Logger::EVENTS=16;
+const long Logger::EVENTS2=32;
+const long Logger::CONFIG=64;
+const long Logger::WARNING=128;
+const long Logger::ERROR=256;
+const long Logger::MEMORY=512;
+const long Logger::APP=1024;
+const long Logger::PLUGIN=2048;
+const long Logger::PLAYER=4096;
+
+Logger* Logger::m_pLogger = 0;
+boost::mutex log_Mutex;
+
+Logger * Logger::get()
+{
+
+ if (!m_pLogger) {
+ boost::mutex::scoped_lock Lock(log_Mutex);
+ m_pLogger = new Logger;
+ }
+ return m_pLogger;
+}
+
+Logger::Logger()
+{
+ m_Flags = ERROR | WARNING | APP;
+ string sEnvCategories;
+ bool bEnvSet = getEnv("AVG_LOG_CATEGORIES", sEnvCategories);
+ if (bEnvSet) {
+ m_Flags = ERROR | APP;
+ bool bDone = false;
+ string sCategory;
+ do {
+ string::size_type pos = sEnvCategories.find(":");
+ if (pos == string::npos) {
+ sCategory = sEnvCategories;
+ bDone = true;
+ } else {
+ sCategory = sEnvCategories.substr(0, pos);
+ sEnvCategories = sEnvCategories.substr(pos+1);
+ }
+ long category = stringToCategory(sCategory);
+ m_Flags |= category;
+ } while (!bDone);
+ }
+}
+
+Logger::~Logger()
+{
+}
+
+void Logger::setCategories(int flags)
+{
+ boost::mutex::scoped_lock Lock(log_Mutex);
+ m_Flags = flags | ERROR | WARNING;
+}
+
+void Logger::pushCategories()
+{
+ m_FlagStack.push_back(m_Flags);
+}
+
+void Logger::popCategories()
+{
+ if (m_FlagStack.empty()) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE, "popCategories: Nothing to pop.");
+ }
+ m_Flags = m_FlagStack.back();
+ m_FlagStack.pop_back();
+}
+
+void Logger::trace(int category, const UTF8String& sMsg)
+{
+ boost::mutex::scoped_lock Lock(log_Mutex);
+ if (category & m_Flags) {
+ struct tm* pTime;
+#ifdef _WIN32
+ __int64 now;
+ _time64(&now);
+ pTime = _localtime64(&now);
+ DWORD tms = timeGetTime();
+ unsigned millis = unsigned(tms % 1000);
+#else
+ struct timeval time;
+ gettimeofday(&time, NULL);
+ pTime = localtime(&time.tv_sec);
+ unsigned millis = time.tv_usec/1000;
+#endif
+ char timeString[256];
+ strftime(timeString, sizeof(timeString), "%y-%m-%d %H:%M:%S", pTime);
+ cerr << "[" << timeString << "." <<
+ setw(3) << setfill('0') << millis << setw(0) << "] ";
+ cerr << categoryToString(category) << ": ";
+ cerr << sMsg << endl;
+ cerr.flush();
+ }
+}
+
+const char * Logger::categoryToString(int category)
+{
+ switch(category) {
+ case BLTS:
+ return "BLTS";
+ case PROFILE:
+ case PROFILE_LATEFRAMES:
+ case PROFILE_VIDEO:
+ return "PROFILE";
+ case EVENTS:
+ case EVENTS2:
+ return "EVENTS";
+ case CONFIG:
+ return "CONFIG";
+ case WARNING:
+ return "WARNING";
+ case ERROR:
+ return "ERROR";
+ case MEMORY:
+ return "MEMORY";
+ case APP:
+ return "APP";
+ case PLUGIN:
+ return "PLUGIN";
+ case PLAYER:
+ return "PLAYER";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+int Logger::stringToCategory(const string& sCategory)
+{
+ if (sCategory == "BLTS") {
+ return BLTS;
+ } else if (sCategory == "PROFILE") {
+ return PROFILE;
+ } else if (sCategory == "PROFILE_LATEFRAMES") {
+ return PROFILE_LATEFRAMES;
+ } else if (sCategory == "PROFILE_VIDEO") {
+ return PROFILE_VIDEO;
+ } else if (sCategory == "EVENTS") {
+ return EVENTS;
+ } else if (sCategory == "EVENTS2") {
+ return EVENTS2;
+ } else if (sCategory == "CONFIG") {
+ return CONFIG;
+ } else if (sCategory == "WARNING") {
+ return WARNING;
+ } else if (sCategory == "ERROR") {
+ return ERROR;
+ } else if (sCategory == "MEMORY") {
+ return MEMORY;
+ } else if (sCategory == "APP") {
+ return APP;
+ } else if (sCategory == "PLUGIN") {
+ return PLUGIN;
+ } else if (sCategory == "PLAYER") {
+ return PLAYER;
+ } else {
+ throw Exception (AVG_ERR_INVALID_ARGS, "Unknown logger category " + sCategory
+ + " set using AVG_LOG_CATEGORIES.");
+ }
+}
+
+}
diff --git a/src/base/Logger.h b/src/base/Logger.h
new file mode 100644
index 0000000..34be8b8
--- /dev/null
+++ b/src/base/Logger.h
@@ -0,0 +1,86 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Logger_H_
+#define _Logger_H_
+
+#include "../api.h"
+#include "UTF8String.h"
+
+#include <string>
+#include <vector>
+#include <sstream>
+
+namespace avg {
+
+#ifdef ERROR
+#undef ERROR
+#endif
+
+class AVG_API Logger {
+public:
+ static Logger* get();
+ virtual ~Logger();
+
+ void setCategories(int flags);
+ void pushCategories();
+ void popCategories();
+ void trace(int category, const UTF8String& sMsg);
+ inline bool isFlagSet(int category) {
+ return (category & m_Flags) != 0;
+ }
+
+ static const long NONE;
+ static const long BLTS;
+ static const long PROFILE;
+ static const long PROFILE_LATEFRAMES;
+ static const long PROFILE_VIDEO;
+ static const long EVENTS;
+ static const long EVENTS2;
+ static const long CONFIG;
+ static const long WARNING;
+ static const long ERROR;
+ static const long MEMORY;
+ static const long APP;
+ static const long PLUGIN;
+ static const long PLAYER;
+
+private:
+ Logger();
+ static const char * categoryToString(int category);
+ int stringToCategory(const std::string& sCategory);
+
+ static Logger* m_pLogger;
+
+ int m_Flags;
+ std::vector<int> m_FlagStack;
+};
+
+#define AVG_TRACE(category, sMsg) { \
+ if (Logger::get()->isFlagSet(category)) { \
+ std::stringstream tmp(std::stringstream::in | std::stringstream::out); \
+ tmp << sMsg; \
+ Logger::get()->trace(category, tmp.str()); \
+ }\
+}
+
+}
+#endif
diff --git a/src/base/Makefile.am b/src/base/Makefile.am
new file mode 100644
index 0000000..5fe4c94
--- /dev/null
+++ b/src/base/Makefile.am
@@ -0,0 +1,31 @@
+
+INCLUDES = -I.. @XML2_CFLAGS@ @PTHREAD_CFLAGS@
+ALL_H = FileHelper.h CmdLine.h Exception.h Logger.h ConfigMgr.h ObjectCounter.h \
+ XMLHelper.h TimeSource.h ProfilingZone.h ThreadProfiler.h \
+ ScopeTimer.h IFrameEndListener.h IPreRenderListener.h IPlaybackEndListener.h \
+ Test.h TestSuite.h OSHelper.h Queue.h WorkerThread.h Command.h ObjectCounter.h \
+ Point.h Rect.h Directory.h DirEntry.h StringHelper.h MathHelper.h GeomHelper.h \
+ CubicSpline.h BezierCurve.h UTF8String.h Triangle.h \
+ Triangulate.h WideLine.h Triple.h DlfcnWrapper.h Signal.h Backtrace.h \
+ CmdQueue.h Matrix3x4.h ProfilingZoneID.h
+
+TESTS=testbase
+
+EXTRA_DIST = DlfcnWrapper.cpp
+
+noinst_LTLIBRARIES = libbase.la
+libbase_la_SOURCES = FileHelper.cpp CmdLine.cpp Exception.cpp Logger.cpp \
+ ConfigMgr.cpp XMLHelper.cpp TimeSource.cpp OSHelper.cpp \
+ ProfilingZone.cpp ThreadProfiler.cpp ScopeTimer.cpp Test.cpp \
+ TestSuite.cpp ObjectCounter.cpp Point.cpp Directory.cpp DirEntry.cpp \
+ StringHelper.cpp MathHelper.cpp GeomHelper.cpp CubicSpline.cpp \
+ BezierCurve.cpp UTF8String.cpp Triangle.cpp Triangulate.cpp WideLine.cpp \
+ Triple.cpp Backtrace.cpp Matrix3x4.cpp ProfilingZoneID.cpp \
+ $(ALL_H)
+libbase_a_CXXFLAGS = -Wno-format-y2k
+
+noinst_PROGRAMS=testbase
+testbase_SOURCES=testbase.cpp $(ALL_H)
+testbase_LDADD = ./libbase.la -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@
+# -rdynamic needed only for testBacktrace to work under linux.
+testbase_LDFLAGS = -rdynamic
diff --git a/src/base/Makefile.in b/src/base/Makefile.in
new file mode 100644
index 0000000..cc935b7
--- /dev/null
+++ b/src/base/Makefile.in
@@ -0,0 +1,753 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+TESTS = testbase$(EXEEXT)
+noinst_PROGRAMS = testbase$(EXEEXT)
+subdir = src/base
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libbase_la_LIBADD =
+am__objects_1 =
+am_libbase_la_OBJECTS = FileHelper.lo CmdLine.lo Exception.lo \
+ Logger.lo ConfigMgr.lo XMLHelper.lo TimeSource.lo OSHelper.lo \
+ ProfilingZone.lo ThreadProfiler.lo ScopeTimer.lo Test.lo \
+ TestSuite.lo ObjectCounter.lo Point.lo Directory.lo \
+ DirEntry.lo StringHelper.lo MathHelper.lo GeomHelper.lo \
+ CubicSpline.lo BezierCurve.lo UTF8String.lo Triangle.lo \
+ Triangulate.lo WideLine.lo Triple.lo Backtrace.lo Matrix3x4.lo \
+ ProfilingZoneID.lo $(am__objects_1)
+libbase_la_OBJECTS = $(am_libbase_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+PROGRAMS = $(noinst_PROGRAMS)
+am_testbase_OBJECTS = testbase.$(OBJEXT) $(am__objects_1)
+testbase_OBJECTS = $(am_testbase_OBJECTS)
+testbase_DEPENDENCIES = ./libbase.la
+testbase_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(testbase_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libbase_la_SOURCES) $(testbase_SOURCES)
+DIST_SOURCES = $(libbase_la_SOURCES) $(testbase_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.. @XML2_CFLAGS@ @PTHREAD_CFLAGS@
+ALL_H = FileHelper.h CmdLine.h Exception.h Logger.h ConfigMgr.h ObjectCounter.h \
+ XMLHelper.h TimeSource.h ProfilingZone.h ThreadProfiler.h \
+ ScopeTimer.h IFrameEndListener.h IPreRenderListener.h IPlaybackEndListener.h \
+ Test.h TestSuite.h OSHelper.h Queue.h WorkerThread.h Command.h ObjectCounter.h \
+ Point.h Rect.h Directory.h DirEntry.h StringHelper.h MathHelper.h GeomHelper.h \
+ CubicSpline.h BezierCurve.h UTF8String.h Triangle.h \
+ Triangulate.h WideLine.h Triple.h DlfcnWrapper.h Signal.h Backtrace.h \
+ CmdQueue.h Matrix3x4.h ProfilingZoneID.h
+
+EXTRA_DIST = DlfcnWrapper.cpp
+noinst_LTLIBRARIES = libbase.la
+libbase_la_SOURCES = FileHelper.cpp CmdLine.cpp Exception.cpp Logger.cpp \
+ ConfigMgr.cpp XMLHelper.cpp TimeSource.cpp OSHelper.cpp \
+ ProfilingZone.cpp ThreadProfiler.cpp ScopeTimer.cpp Test.cpp \
+ TestSuite.cpp ObjectCounter.cpp Point.cpp Directory.cpp DirEntry.cpp \
+ StringHelper.cpp MathHelper.cpp GeomHelper.cpp CubicSpline.cpp \
+ BezierCurve.cpp UTF8String.cpp Triangle.cpp Triangulate.cpp WideLine.cpp \
+ Triple.cpp Backtrace.cpp Matrix3x4.cpp ProfilingZoneID.cpp \
+ $(ALL_H)
+
+libbase_a_CXXFLAGS = -Wno-format-y2k
+testbase_SOURCES = testbase.cpp $(ALL_H)
+testbase_LDADD = ./libbase.la -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@
+# -rdynamic needed only for testBacktrace to work under linux.
+testbase_LDFLAGS = -rdynamic
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/base/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/base/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libbase.la: $(libbase_la_OBJECTS) $(libbase_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libbase_la_OBJECTS) $(libbase_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+testbase$(EXEEXT): $(testbase_OBJECTS) $(testbase_DEPENDENCIES)
+ @rm -f testbase$(EXEEXT)
+ $(AM_V_CXXLD)$(testbase_LINK) $(testbase_OBJECTS) $(testbase_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Backtrace.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BezierCurve.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CmdLine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConfigMgr.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CubicSpline.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DirEntry.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Directory.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Exception.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FileHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GeomHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Logger.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MathHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Matrix3x4.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OSHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ObjectCounter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Point.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ProfilingZone.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ProfilingZoneID.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ScopeTimer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/StringHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Test.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TestSuite.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ThreadProfiler.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TimeSource.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Triangle.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Triangulate.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Triple.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UTF8String.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WideLine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XMLHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testbase.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/base/MathHelper.cpp b/src/base/MathHelper.cpp
new file mode 100644
index 0000000..ea7093e
--- /dev/null
+++ b/src/base/MathHelper.cpp
@@ -0,0 +1,88 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "MathHelper.h"
+
+#include <math.h>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+bool ispow2(int n)
+{
+ return ((n & (n-1)) == 0);
+}
+
+int nextpow2(int n)
+{
+ int ret=1;
+ while (ret < n) {
+ ret *= 2;
+ }
+ return ret;
+/* TODO: Fix this fast version :-).
+ int RetVal = 1;
+ __asm__ __volatile__(
+ "xorl %%ecx, %%ecx\n\t"
+ "bsrl %1, %%ecx\n\t"
+ "incl %%ecx\n\t"
+ "shlb %%cl, %0\n\t"
+ : "=m" (RetVal)
+ : "m" (n)
+ : "cc", "ecx"
+ );
+ return RetVal;
+*/
+}
+
+int safeCeil(double d)
+{
+ if (fabs(d-int(d)) < EPSILON) {
+ return int(d);
+ } else {
+ return int(d)+1;
+ }
+}
+
+float invSqrt(float x)
+{
+#if 0
+ // TODO: This gives incorrect results on Athlon X2, gcc 4.2.
+ float xhalf = 0.5f*x;
+ int i = *(int*)&x; // get bits for floating value
+ i = 0x5f3759d5 - (i>>1); // give initial guess y0
+ x = *(float*)&i; // convert bits back to float
+ x *= 1.5f - xhalf*x*x; // newton step, repeating this step
+ // increases accuracy
+ x *= 1.5f - xhalf*x*x;
+ return x;
+#endif
+ return 1/sqrt(x);
+}
+
+bool almostEqual(double d1, double d2, double epsilon)
+{
+ return (fabs(d1-d2)<epsilon);
+}
+
+}
diff --git a/src/base/MathHelper.h b/src/base/MathHelper.h
new file mode 100644
index 0000000..16132c4
--- /dev/null
+++ b/src/base/MathHelper.h
@@ -0,0 +1,91 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _MathHelper_H_
+#define _MathHelper_H_
+
+#include "../api.h"
+#include <vector>
+
+#include <math.h>
+#ifndef M_PI
+#define M_PI 3.14159265358979323846
+#endif
+
+namespace avg {
+
+static const double EPSILON = 0.00001;
+
+bool ispow2(int n);
+
+int nextpow2(int n);
+
+int safeCeil(double d);
+
+bool almostEqual(double d1, double d2, double epsilon=EPSILON);
+
+float invSqrt(float x);
+
+template<class T>
+T sqr(T d)
+{
+ return d*d;
+}
+
+template<class T>
+int sgn(T val)
+{
+ return int(val/fabs(val));
+}
+
+template<class T>
+std::vector<T> vectorFromCArray(int n, T* pData)
+{
+ std::vector<T> v;
+ for (int i=0; i<n; ++i) {
+ v.push_back(*(pData+i));
+ }
+ return v;
+}
+
+template<class T>
+std::vector<std::vector<T> > vector2DFromCArray(int n, int m, T* pData)
+{
+ std::vector<std::vector<T> > v(4, std::vector<T>());
+ for (int i=0; i<n; ++i) {
+ for (int j=0; j<m; ++j) {
+ v[i].push_back(*(pData+j+i*m));
+ }
+ }
+ return v;
+}
+
+#ifndef round
+template<class T>
+T round(T d)
+{
+ return floor( d + 0.5 );
+}
+#endif
+
+}
+#endif
+
diff --git a/src/base/Matrix3x4.cpp b/src/base/Matrix3x4.cpp
new file mode 100644
index 0000000..e065d2b
--- /dev/null
+++ b/src/base/Matrix3x4.cpp
@@ -0,0 +1,128 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Matrix3x4.h"
+#include "MathHelper.h"
+
+#include <math.h>
+
+using namespace std;
+
+namespace avg {
+
+Matrix3x4::Matrix3x4()
+{
+ setIdent();
+}
+
+Matrix3x4::Matrix3x4(const float *v)
+{
+ for (int x=0; x<3; ++x) {
+ for (int y=0; y<4; ++y) {
+ val[x][y] = v[x*4+y];
+ }
+ }
+}
+
+Matrix3x4 Matrix3x4::createTranslate(float x, float y, float z)
+{
+ Matrix3x4 mat;
+ mat.val[0][3] = x;
+ mat.val[1][3] = y;
+ mat.val[2][3] = z;
+ return mat;
+}
+
+Matrix3x4 Matrix3x4::createTranslate(const DTriple& tr)
+{
+ return createTranslate(float(tr.x), float(tr.y), float(tr.z));
+}
+
+Matrix3x4 Matrix3x4::createScale(float x, float y, float z)
+{
+ Matrix3x4 mat;
+ mat.val[0][0] = x;
+ mat.val[1][1] = y;
+ mat.val[2][2] = z;
+ return mat;
+}
+
+Matrix3x4 Matrix3x4::createScale(const DTriple& tr)
+{
+ return createScale(float(tr.x), float(tr.y), float(tr.z));
+}
+
+const Matrix3x4& Matrix3x4::operator *=(const Matrix3x4& mat)
+{
+ for (int x=0; x<3; ++x) {
+ float t0 = val[x][0] * mat.val[0][0] + val[x][1] * mat.val[1][0]
+ + val[x][2] * mat.val[2][0];
+ float t1 = val[x][0] * mat.val[0][1] + val[x][1] * mat.val[1][1]
+ + val[x][2] * mat.val[2][1];
+ float t2 = val[x][0] * mat.val[0][2] + val[x][1] * mat.val[1][2]
+ + val[x][2] * mat.val[2][2];
+ val[x][3] = val[x][0] * mat.val[0][3] + val[x][1] * mat.val[1][3]
+ + val[x][2] * mat.val[2][3] + val[x][3];
+ val[x][0] = t0;
+ val[x][1] = t1;
+ val[x][2] = t2;
+ }
+ return *this;
+}
+
+void Matrix3x4::setIdent()
+{
+ for (int x=0; x<3; ++x) {
+ for (int y=0; y<4; ++y) {
+ val[x][y] = 0.0;
+ }
+ }
+ val[0][0] = 1.0;
+ val[1][1] = 1.0;
+ val[2][2] = 1.0;
+}
+
+bool almostEqual(const Matrix3x4& mat1, const Matrix3x4& mat2)
+{
+ for (int x=0; x<3; ++x) {
+ for (int y=0; y<4; ++y) {
+ if (!almostEqual(mat1.val[x][y], mat2.val[x][y])) {
+ return false;
+ }
+ }
+ }
+ return true;
+}
+
+std::ostream& operator<<(ostream& os, const Matrix3x4& mat)
+{
+ os << "{" << endl;
+ for (int y=0; y<4; ++y) {
+ os << " {" << mat.val[0][y] << "," << mat.val[1][y] << "," << mat.val[2][y]
+ << "}" << endl;
+ }
+ os << "}" << endl;
+ return os;
+}
+
+
+}
+
diff --git a/src/base/Matrix3x4.h b/src/base/Matrix3x4.h
new file mode 100644
index 0000000..62a0222
--- /dev/null
+++ b/src/base/Matrix3x4.h
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Matrix3x4_H_
+#define _Matrix3x4_H_
+
+#include "../api.h"
+
+#include "Triple.h"
+
+#include <iostream>
+
+namespace avg {
+
+class AVG_API Matrix3x4 {
+public:
+ float val[3][4];
+
+ Matrix3x4();
+ Matrix3x4(const float *);
+ static Matrix3x4 createTranslate(float x, float y, float z);
+ static Matrix3x4 createTranslate(const DTriple& tr);
+ static Matrix3x4 createScale(float x, float y, float z);
+ static Matrix3x4 createScale(const DTriple& tr);
+
+ const Matrix3x4& operator *=(const Matrix3x4& mat);
+
+private:
+ void setIdent();
+};
+
+bool almostEqual(const Matrix3x4& mat1, const Matrix3x4& mat2);
+
+std::ostream& operator<<(std::ostream& os, const Matrix3x4& mat);
+
+}
+
+#endif
diff --git a/src/base/OSHelper.cpp b/src/base/OSHelper.cpp
new file mode 100644
index 0000000..852a7f0
--- /dev/null
+++ b/src/base/OSHelper.cpp
@@ -0,0 +1,182 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "OSHelper.h"
+#include "FileHelper.h"
+#include "Logger.h"
+#include "FileHelper.h"
+#include "Exception.h"
+
+#if defined(_WIN32)
+#include <windows.h>
+#include <psapi.h>
+#undef ERROR
+#undef WARNING
+#elif defined(__APPLE__)
+#include <mach-o/dyld.h>
+#include <mach/mach.h>
+#elif defined(__linux)
+#include <fstream>
+#include <unistd.h>
+#endif
+
+#include <stdlib.h>
+#include <cstdlib>
+
+using namespace std;
+
+namespace avg {
+
+#ifdef _WIN32
+string getWinErrMsg(unsigned err)
+{
+ LPVOID lpMsgBuf;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, err, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &lpMsgBuf,
+ 0, NULL );
+ string sMsg((char*)lpMsgBuf);
+ LocalFree(lpMsgBuf);
+ return sMsg;
+}
+#endif
+
+string getAvgLibPath()
+{
+#if defined(_WIN32)
+ HMODULE hModule = GetModuleHandle("avg.pyd");
+ char szFilename[1024];
+ DWORD ok = GetModuleFileName(hModule, szFilename, sizeof(szFilename));
+ if (ok == 0) {
+ AVG_TRACE(Logger::ERROR, "getAvgLibPath(): " << getWinErrMsg(GetLastError()));
+ exit(5);
+ }
+ string sPath=getPath(szFilename);
+ return sPath;
+#elif defined(__APPLE__)
+ // We need to iterate through all images attached to the current executable
+ // and figure out which one is the one we are interested in.
+ uint32_t numImages = _dyld_image_count();
+ for (uint32_t i=0; i<numImages; i++) {
+ const char * pszImageName = _dyld_get_image_name(i);
+ string sFilePart=getFilenamePart(pszImageName);
+ if (sFilePart == "avg.so" || sFilePart == "avg.0.so"
+ || sFilePart == "avg.0.0.0.so")
+ {
+ return getPath(pszImageName);
+ }
+ }
+ char path[1024];
+ uint32_t pathLen = sizeof(path);
+ _NSGetExecutablePath(path, &pathLen);
+ return getPath(path);
+#else
+ // For a linux solution, see http://www.autopackage.org/docs/binreloc/
+ return "";
+#endif
+}
+
+bool getEnv(const string & sName, string & sVal)
+{
+ const char * pszVal = getenv(sName.c_str());
+ if (pszVal) {
+ sVal = pszVal;
+ }
+ return (pszVal != 0);
+}
+
+void setEnv(const string & sName, const string & sVal)
+{
+#ifdef _WIN32
+ SetEnvironmentVariable(sName.c_str(), sVal.c_str());
+#else
+ setenv(sName.c_str(), sVal.c_str(), true);
+#endif
+}
+
+size_t getMemoryUsage()
+{
+#ifdef __APPLE__
+ kern_return_t rc;
+ mach_port_t task;
+ rc = task_for_pid(mach_task_self(), getpid(), &task);
+ AVG_ASSERT(rc == KERN_SUCCESS);
+ struct task_basic_info taskInfo;
+ mach_msg_type_number_t count = TASK_BASIC_INFO_COUNT;
+ rc = task_info(task, TASK_BASIC_INFO, (task_info_t)&taskInfo, &count);
+ AVG_ASSERT(rc == KERN_SUCCESS);
+ return taskInfo.resident_size;
+#else
+#ifdef _WIN32
+ DWORD pid = GetCurrentProcessId();
+ HANDLE hProcess;
+ PROCESS_MEMORY_COUNTERS pmc;
+ hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid);
+ BOOL bOk = GetProcessMemoryInfo(hProcess, &pmc, sizeof(pmc));
+ CloseHandle(hProcess);
+ return pmc.WorkingSetSize;
+#else
+ unsigned vmsize;
+ unsigned rssize;
+ // See 'man proc' for a documentation of this file's contents.
+ std::ifstream f("/proc/self/statm");
+ f >> vmsize >> rssize;
+ return rssize*(size_t)(getpagesize());
+#endif
+#endif
+}
+
+std::string convertUTF8ToFilename(const std::string & sName)
+{
+#ifdef _WIN32
+ // Conversion from utf-8 to something windows can use:
+ // utf-8 long filename -> utf-16 long filename -> utf-16 short filename (8.3)
+ // -> utf-8 short filename (= ASCII short filename).
+ wchar_t wideString[2048];
+ int err1 = MultiByteToWideChar(CP_UTF8, 0, sName.c_str(), sName.size()+1,
+ wideString, 2048);
+ if (err1 == 0) {
+ AVG_TRACE(Logger::WARNING,
+ "Error in unicode conversion (MultiByteToWideChar): " <<
+ getWinErrMsg(GetLastError()));
+ return sName;
+ }
+ wchar_t wideShortFName[2048];
+ DWORD err2 = GetShortPathNameW(wideString, wideShortFName, 1024);
+ if (err2 != 0) {
+ char pShortName[1024];
+ err1 = WideCharToMultiByte(CP_UTF8, 0, wideShortFName, -1, pShortName,
+ 1024, 0, 0);
+ if (err1 == 0) {
+ AVG_TRACE(Logger::WARNING,
+ "Error in unicode conversion (MultiByteToWideChar): " <<
+ getWinErrMsg(GetLastError()));
+ }
+ return pShortName;
+ } else {
+ return sName;
+ }
+#else
+ return sName;
+#endif
+}
+
+}
diff --git a/src/base/OSHelper.h b/src/base/OSHelper.h
new file mode 100644
index 0000000..de6924b
--- /dev/null
+++ b/src/base/OSHelper.h
@@ -0,0 +1,48 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _OSHelper_H_
+#define _OSHelper_H_
+
+#include "../api.h"
+#include <string>
+
+namespace avg {
+
+#ifdef _WIN32
+std::string getWinErrMsg(unsigned err);
+#endif
+
+std::string getAvgLibPath();
+
+bool getEnv(const std::string & sName, std::string & sVal);
+void setEnv(const std::string & sName, const std::string & sVal);
+
+size_t getMemoryUsage();
+
+// Converts a utf-8-encoded filename to something windows can use.
+// Under other operating systems, returns the input string.
+AVG_API std::string convertUTF8ToFilename(const std::string & sName);
+
+}
+
+#endif
+
diff --git a/src/base/ObjectCounter.cpp b/src/base/ObjectCounter.cpp
new file mode 100644
index 0000000..00015aa
--- /dev/null
+++ b/src/base/ObjectCounter.cpp
@@ -0,0 +1,182 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ObjectCounter.h"
+#include "Exception.h"
+
+#include <boost/thread/mutex.hpp>
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+#include <algorithm>
+
+#ifdef WIN32
+#include <windows.h>
+#include <Dbghelp.h>
+#else
+#include <cxxabi.h>
+#endif
+
+#define DEBUG_ALLOC 1
+
+namespace avg {
+
+using namespace std;
+
+ObjectCounter* ObjectCounter::s_pObjectCounter = 0;
+bool ObjectCounter::s_bDeleted = false;
+boost::mutex * pCounterMutex;
+
+void deleteObjectCounter()
+{
+ delete ObjectCounter::s_pObjectCounter;
+ delete pCounterMutex;
+ ObjectCounter::s_pObjectCounter = 0;
+}
+
+ObjectCounter::ObjectCounter()
+{
+}
+
+ObjectCounter::~ObjectCounter()
+{
+ s_bDeleted = true;
+}
+
+ObjectCounter * ObjectCounter::get()
+{
+ if (!s_pObjectCounter) {
+ if (s_bDeleted) {
+ // This is _after_ the deleteObjectCounter has been called.
+ return 0;
+ } else {
+ s_pObjectCounter = new ObjectCounter;
+ pCounterMutex = new boost::mutex;
+ atexit(deleteObjectCounter);
+ }
+ }
+ return s_pObjectCounter;
+}
+
+void ObjectCounter::incRef(const std::type_info* pType)
+{
+#ifdef DEBUG_ALLOC
+ boost::mutex::scoped_lock Lock(*pCounterMutex);
+ TypeMap::iterator MapEntry = m_TypeMap.find(pType);
+ if (MapEntry == m_TypeMap.end()) {
+ m_TypeMap[pType] = 1;
+ } else {
+ (MapEntry->second)++;
+ }
+// cerr << "incRef " << demangle(pType->name()) << ":" << m_TypeMap[pType] << endl;
+#endif
+}
+
+void ObjectCounter::decRef(const std::type_info* pType)
+{
+#ifdef DEBUG_ALLOC
+ if (!this) {
+ // This happens if there are counted static objects that are deleted after
+ // s_pObjectCounter has been deleted.
+ return;
+ }
+ boost::mutex::scoped_lock Lock(*pCounterMutex);
+ TypeMap::iterator MapEntry = m_TypeMap.find(pType);
+ if (MapEntry == m_TypeMap.end()) {
+ cerr << "ObjectCounter for " << demangle(pType->name())
+ << " does not exist." << endl;
+ // Can't decref a type that hasn't been incref'd.
+ AVG_ASSERT(false);
+ } else {
+ (MapEntry->second)--;
+ if (MapEntry->second < 0) {
+ cerr << "ObjectCounter: refcount for " <<
+ demangle(MapEntry->first->name()) <<
+ " < 0" << endl;
+ AVG_ASSERT(false);
+ }
+ }
+// cerr << "decRef " << demangle(pType->name()) << ":" << MapEntry->second << endl;
+#endif
+}
+
+int ObjectCounter::getCount(const std::type_info* pType)
+{
+ TypeMap::iterator MapEntry = m_TypeMap.find(pType);
+ if (MapEntry == m_TypeMap.end()) {
+ return 0;
+ } else {
+ return MapEntry->second;
+ }
+
+}
+
+std::string ObjectCounter::dump()
+{
+ stringstream ss;
+ ss << "Object dump: " << endl;
+ TypeMap::iterator it;
+ vector<string> strings;
+ for (it = m_TypeMap.begin(); it != m_TypeMap.end(); ++it) {
+ stringstream tempStream;
+ if (it->second > 0) {
+ tempStream << " " << demangle(it->first->name()) << ": " << it->second;
+ strings.push_back(tempStream.str());
+ }
+ }
+ sort(strings.begin(), strings.end());
+ for (vector<string>::iterator it=strings.begin(); it != strings.end(); ++it) {
+ ss << *it << endl;
+ }
+ return ss.str();
+}
+
+string ObjectCounter::demangle(string s)
+{
+ int rc;
+ string sResult;
+#ifdef _WIN32
+ char szDemangledName[2048];
+ rc = int(UnDecorateSymbolName(s.c_str(), szDemangledName, sizeof(szDemangledName),
+ UNDNAME_COMPLETE));
+ if (rc) {
+ sResult = szDemangledName;
+ } else {
+ int error = GetLastError();
+ printf("UnDecorateSymbolName returned error %d\n", error);
+ sResult = s;
+ }
+#else
+ char * pszDemangled = abi::__cxa_demangle(s.c_str(), 0, 0, &rc);
+ if (rc) {
+ sResult = s;
+ } else {
+ sResult = pszDemangled;
+ }
+ if (pszDemangled) {
+ free(pszDemangled);
+ }
+#endif
+ return sResult;
+}
+
+}
diff --git a/src/base/ObjectCounter.h b/src/base/ObjectCounter.h
new file mode 100644
index 0000000..506a3c9
--- /dev/null
+++ b/src/base/ObjectCounter.h
@@ -0,0 +1,58 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ObjectCounter_H_
+#define _ObjectCounter_H_
+
+#include "../api.h"
+#include <string>
+#include <map>
+#include <typeinfo>
+
+namespace avg {
+
+class AVG_API ObjectCounter {
+public:
+ static ObjectCounter* get();
+ virtual ~ObjectCounter();
+
+ void incRef(const std::type_info* pType);
+ void decRef(const std::type_info* pType);
+
+ int getCount(const std::type_info* pType);
+ std::string dump();
+
+private:
+ ObjectCounter();
+ std::string demangle(std::string s);
+ static void deleteSingleton();
+
+ typedef std::map<const std::type_info *, int> TypeMap;
+ TypeMap m_TypeMap;
+
+ static ObjectCounter* s_pObjectCounter;
+ static bool s_bDeleted;
+ friend void deleteObjectCounter();
+};
+
+}
+#endif
+
diff --git a/src/base/Point.cpp b/src/base/Point.cpp
new file mode 100644
index 0000000..24208ca
--- /dev/null
+++ b/src/base/Point.cpp
@@ -0,0 +1,325 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Point.h"
+
+#include "MathHelper.h"
+#include "Exception.h"
+
+#if defined(__SSE__) || defined(_WIN32)
+#include <xmmintrin.h>
+#endif
+
+#include <math.h>
+#include <float.h>
+
+#include <string>
+
+namespace avg {
+
+template<class NUM>
+Point<NUM>::Point()
+{
+// ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+template<class NUM>
+Point<NUM>::Point(NUM X, NUM Y)
+{
+// ObjectCounter::get()->incRef(&typeid(*this));
+ x = X;
+ y = Y;
+}
+
+template<class NUM>
+Point<NUM>::Point(const Point<NUM>& p)
+{
+// ObjectCounter::get()->incRef(&typeid(*this));
+ x = p.x;
+ y = p.y;
+}
+
+template<class NUM>
+Point<NUM>::Point(const std::vector<NUM>& v)
+{
+ AVG_ASSERT_MSG(v.size() == 2,
+ "Point can only be constructed from 2-component vector");
+ x = v[0];
+ y = v[1];
+}
+
+template<class NUM>
+Point<NUM>::~Point()
+{
+// ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+template<class NUM>
+double Point<NUM>::getNorm() const
+{
+ return sqrt(double(x*x+y*y));
+}
+
+template<class NUM>
+bool Point<NUM>::isNaN() const
+{
+ return isnan(x) || isnan(y);
+}
+
+template<class NUM>
+bool Point<NUM>::isInf() const
+{
+ return isinf(x) || isinf(y);
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::getRotated(double angle) const
+{
+ double cosVal = cos(angle);
+ double sinVal = sin(angle);
+ return Point<NUM>(NUM(x*cosVal - y*sinVal), NUM(x*sinVal + y*cosVal));
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::getRotatedPivot(double angle, const Point<NUM>& pivot) const
+{
+ // translate pivot to origin
+ Point<NUM> translated = *this - pivot;
+
+ // calculate rotated coordinates about the origin
+ Point<NUM> rotated = translated.getRotated(angle);
+
+ // re-translate pivot to original position
+ rotated += pivot;
+
+ return rotated;
+}
+
+template<class NUM>
+Point<NUM>& Point<NUM>::operator =(const Point<NUM>& p)
+{
+ x = p.x;
+ y = p.y;
+ return *this;
+}
+
+template<class NUM>
+bool Point<NUM>::operator ==(const Point<NUM> & pt) const
+{
+ return (x == pt.x && y == pt.y);
+}
+
+template<class NUM>
+bool Point<NUM>::operator !=(const Point<NUM> & pt) const
+{
+ return (x != pt.x || y != pt.y);
+}
+
+template<class NUM>
+void Point<NUM>::operator +=(const Point<NUM>& pt)
+{
+ x += pt.x;
+ y += pt.y;
+}
+
+template<class NUM>
+void Point<NUM>::operator -=(const Point<NUM> & pt)
+{
+ x -= pt.x;
+ y -= pt.y;
+}
+
+template<class NUM>
+void Point<NUM>::operator *=(NUM f)
+{
+ x *= f;
+ y *= f;
+}
+
+template<class NUM>
+void Point<NUM>::operator /=(NUM f)
+{
+ x /= f;
+ y /= f;
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::operator -() const
+{
+ return Point<NUM>(-x, -y);
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::operator +(const Point<NUM> & pt) const
+{
+ return Point<NUM>(x + pt.x, y + pt.y);
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::operator -(const Point<NUM> & pt) const
+{
+ return Point<NUM>(x - pt.x, y - pt.y);
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::operator /(double f) const
+{
+ return Point<NUM> (NUM(x/f), NUM(y/f));
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::operator *(double f) const
+{
+ return Point<NUM> (NUM(x*f), NUM(y*f));
+}
+
+template<class NUM>
+Point<NUM> Point<NUM>::operator *(const Point<NUM>& pt) const
+{
+ return Point<NUM> (x*pt.x, y*pt.y);
+}
+
+template<>
+Point<int> Point<int>::fromPolar(double angle, double radius)
+{
+ AVG_ASSERT_MSG(false, "fromPolar undefined for IntPoint");
+ return Point<int>(0,0);
+}
+
+template<>
+Point<double> Point<double>::fromPolar(double angle, double radius)
+{
+ return Point<double>(cos(angle)*radius, sin(angle)*radius);
+}
+
+template<class NUM>
+double Point<NUM>::getAngle() const
+{
+ return atan2(double(y), double(x));
+}
+
+template<>
+Point<int> Point<int>::getNormalized() const
+{
+ AVG_ASSERT_MSG(false, "getNormalized undefined for IntPoint");
+ return Point<int>(0,0);
+}
+
+template<>
+Point<double> Point<double>::getNormalized() const
+{
+ // This is imprecise but fast
+#if defined(__SSE__) || defined(_WIN32)
+#pragma pack(16)
+ float result[4];
+ float normSqr = float(x*x+y*y);
+ __m128 src = _mm_setr_ps(float(x), float(y), 0, 0);
+ __m128 normSqrVec = _mm_set_ps1(normSqr);
+ __m128 invSqrt = _mm_rsqrt_ps(normSqrVec);
+ __m128 resultVec = _mm_mul_ps(src, invSqrt);
+ _mm_storeu_ps(result, resultVec);
+ return Point<double>(result[0], result[1]);
+#pragma pack()
+#else
+ double invNorm = invSqrt(float(x*x+y*y));
+ if (invNorm != 0) {
+ return Point<double>(x*invNorm, y*invNorm);
+ } else {
+ return *this;
+ }
+#endif
+}
+
+template<>
+Point<double> Point<double>::safeGetNormalized() const
+{
+ // This is precise but slower, and the version exported to python
+ if (x==0 && y==0) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE, "Can't normalize (0,0).");
+ } else {
+ double invNorm = 1/sqrt(x*x+y*y);
+ return Point<double>(x*invNorm, y*invNorm);
+ }
+}
+
+template<>
+Point<int> Point<int>::safeGetNormalized() const
+{
+ // Not implemented - done to silence compiler warnings.
+ AVG_ASSERT(false);
+ return Point<int>(0,0);
+}
+
+template<class NUM>
+std::ostream& operator<<( std::ostream& os, const Point<NUM> &p)
+{
+ os << "(" << p.x << "," << p.y << ")";
+ return os;
+}
+
+template<class NUM>
+Point<NUM> operator *(double f, const Point<NUM>& pt)
+{
+ return pt*f;
+}
+
+template<class NUM>
+Point<NUM> operator /(double f, const Point<NUM>& pt)
+{
+ return pt/f;
+}
+
+bool almostEqual(const DPoint& pt1, const DPoint& pt2)
+{
+ return (fabs(pt1.x-pt2.x)+fabs(pt1.y-pt2.y)) < 0.0001;
+}
+
+double vecAngle(const DPoint& pt1, const DPoint pt2)
+{
+ double angle = fmod((atan2(pt1.y, pt1.x) - atan2(pt2.y, pt2.x)), 2*M_PI);
+ if (angle < 0) {
+ angle += 2*M_PI;
+ }
+ return angle;
+}
+
+template<class NUM>
+double calcDist(const Point<NUM>& pt1, const Point<NUM>& pt2)
+{
+ return sqrt(double(sqr(pt1.x-pt2.x)+sqr(pt1.y-pt2.y)));
+}
+
+// Explicit instantiations.
+template class Point<double>;
+template std::ostream& operator<<( std::ostream& os, const Point<double> &p);
+template Point<double> operator *(double f, const Point<double>& pt);
+template Point<double> operator /(double f, const Point<double>& pt);
+template double calcDist(const Point<double>& pt1, const Point<double>& pt2);
+template double calcDistSquared(const Point<double>& pt1, const Point<double>& pt2);
+
+template class Point<int>;
+template std::ostream& operator<<( std::ostream& os, const Point<int> &p);
+template Point<int> operator *(double f, const Point<int>& pt);
+template Point<int> operator /(double f, const Point<int>& pt);
+template double calcDist(const Point<int>& pt1, const Point<int>& pt2);
+template double calcDistSquared(const Point<int>& pt1, const Point<int>& pt2);
+
+}
diff --git a/src/base/Point.h b/src/base/Point.h
new file mode 100644
index 0000000..3156aed
--- /dev/null
+++ b/src/base/Point.h
@@ -0,0 +1,124 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Point_H_
+#define _Point_H_
+
+#include "../api.h"
+#include "MathHelper.h"
+
+#include <ostream>
+#include <vector>
+
+// Fix for non-C99 win compilers up to MSVC++2008
+#if defined _MSC_VER
+#define isinf(x) (!_finite(x))
+#define isnan(x) (_isnan(x))
+#endif
+
+namespace avg {
+
+template<class NUM>
+class AVG_TEMPLATE_API Point
+{
+public:
+ NUM x;
+ NUM y;
+
+ Point ();
+ template<class ORIGNUM> explicit Point(const Point<ORIGNUM>& p);
+ Point(NUM X, NUM Y);
+ Point(const Point<NUM>& p);
+ Point(const std::vector<NUM>& v);
+ ~Point();
+
+ Point<NUM> getNormalized() const;
+ Point<NUM> safeGetNormalized() const;
+ double getNorm() const;
+ bool isNaN() const;
+ bool isInf() const;
+ Point getRotated(double angle) const;
+ Point getRotatedPivot(double angle, const Point& pivot = Point(0,0)) const;
+
+ Point<NUM> & operator =(const Point<NUM>& p);
+
+ bool operator ==(const Point<NUM> & pt) const;
+ bool operator !=(const Point<NUM> & pt) const;
+ void operator +=(const Point<NUM> & pt);
+ void operator -=(const Point<NUM> & pt);
+ void operator *=(NUM f);
+ void operator /=(NUM f);
+ Point<NUM> operator -() const;
+ Point<NUM> operator +(const Point<NUM> & pt) const;
+ Point<NUM> operator -(const Point<NUM> & pt) const;
+ Point<NUM> operator /(double f) const;
+ Point<NUM> operator *(double f) const;
+ Point<NUM> operator *(const Point<NUM> & pt) const;
+
+ static Point<NUM> fromPolar(double angle, double radius);
+ double getAngle() const;
+};
+
+template<class NUM>
+std::ostream& operator<<( std::ostream& os, const Point<NUM> &p);
+
+template<class NUM>
+Point<NUM> operator *(double f, const Point<NUM>& pt);
+
+template<class NUM>
+Point<NUM> operator /(double f, const Point<NUM>& pt);
+
+template<class NUM>
+template<class ORIGNUM>
+Point<NUM>::Point(const Point<ORIGNUM>& p)
+ : x(NUM(p.x)),
+ y(NUM(p.y))
+{
+// ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+template<class NUM>
+double calcDist(const Point<NUM>& pt1, const Point<NUM>& pt2);
+
+template<class NUM>
+double calcDistSquared(const Point<NUM>& pt1, const Point<NUM>& pt2)
+{
+ return sqr(pt1.x-pt2.x)+sqr(pt1.y-pt2.y);
+}
+
+typedef Point<double> DPoint;
+typedef Point<int> IntPoint;
+
+bool almostEqual(const DPoint& pt1, const DPoint& pt2);
+
+inline
+double dotProduct(const DPoint& pt1, const DPoint pt2)
+{
+ return pt1.x*pt2.x+pt1.y*pt2.y;
+}
+
+double vecAngle(const DPoint& pt1, const DPoint pt2);
+
+typedef std::vector<DPoint> DPointVector;
+
+}
+
+#endif
diff --git a/src/base/ProfilingZone.cpp b/src/base/ProfilingZone.cpp
new file mode 100644
index 0000000..a12f5e3
--- /dev/null
+++ b/src/base/ProfilingZone.cpp
@@ -0,0 +1,85 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ProfilingZone.h"
+#include "ObjectCounter.h"
+
+#include <iostream>
+
+using namespace boost;
+using namespace std;
+
+namespace avg {
+
+ProfilingZone::ProfilingZone(const ProfilingZoneID& zoneID)
+ : m_ZoneID(zoneID),
+ m_TimeSum(0),
+ m_AvgTime(0),
+ m_NumFrames(0),
+ m_Indent(0),
+ m_bIsRegistered(false)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+ProfilingZone::~ProfilingZone()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void ProfilingZone::reset()
+{
+ m_NumFrames++;
+ m_AvgTime = (m_AvgTime*(m_NumFrames-1)+m_TimeSum)/m_NumFrames;
+ m_TimeSum = 0;
+}
+
+long long ProfilingZone::getUSecs() const
+{
+ return m_TimeSum;
+}
+
+long long ProfilingZone::getAvgUSecs() const
+{
+ return m_AvgTime;
+}
+
+void ProfilingZone::setIndentLevel(int indent)
+{
+ m_Indent = indent;
+}
+
+int ProfilingZone::getIndentLevel() const
+{
+ return m_Indent;
+}
+
+string ProfilingZone::getIndentString() const
+{
+ return string(m_Indent, ' ');
+}
+
+const string& ProfilingZone::getName() const
+{
+ return m_ZoneID.getName();
+}
+
+}
diff --git a/src/base/ProfilingZone.h b/src/base/ProfilingZone.h
new file mode 100644
index 0000000..f226d59
--- /dev/null
+++ b/src/base/ProfilingZone.h
@@ -0,0 +1,69 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ProfilingZone_H_
+#define _ProfilingZone_H_
+
+#include "../api.h"
+#include "ProfilingZoneID.h"
+#include "TimeSource.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API ProfilingZone
+{
+public:
+ ProfilingZone(const ProfilingZoneID& zoneID);
+ virtual ~ProfilingZone();
+
+ void start()
+ {
+ m_StartTime = TimeSource::get()->getCurrentMicrosecs();
+ };
+ void stop()
+ {
+ m_TimeSum += TimeSource::get()->getCurrentMicrosecs()-m_StartTime;
+ };
+ void reset();
+ long long getUSecs() const;
+ long long getAvgUSecs() const;
+ void setIndentLevel(int indent);
+ int getIndentLevel() const;
+ std::string getIndentString() const;
+ const std::string& getName() const;
+
+private:
+ const ProfilingZoneID& m_ZoneID;
+ long long m_TimeSum;
+ long long m_AvgTime;
+ long long m_StartTime;
+ int m_NumFrames;
+ int m_Indent;
+ bool m_bIsRegistered;
+};
+
+typedef boost::shared_ptr<ProfilingZone> ProfilingZonePtr;
+
+}
+
+#endif
diff --git a/src/base/ProfilingZoneID.cpp b/src/base/ProfilingZoneID.cpp
new file mode 100644
index 0000000..025be66
--- /dev/null
+++ b/src/base/ProfilingZoneID.cpp
@@ -0,0 +1,42 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ProfilingZoneID.h"
+
+using namespace std;
+
+namespace avg {
+
+ProfilingZoneID::ProfilingZoneID(const string& sName)
+ : m_sName(sName)
+{
+}
+
+ProfilingZoneID::~ProfilingZoneID()
+{
+}
+
+const string& ProfilingZoneID::getName() const
+{
+ return m_sName;
+}
+
+}
diff --git a/src/base/ProfilingZoneID.h b/src/base/ProfilingZoneID.h
new file mode 100644
index 0000000..c590b3d
--- /dev/null
+++ b/src/base/ProfilingZoneID.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ProfilingZoneID_H_
+#define _ProfilingZoneID_H_
+
+#include "../api.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API ProfilingZoneID
+{
+public:
+ ProfilingZoneID(const std::string& sName);
+ virtual ~ProfilingZoneID();
+
+ const std::string& getName() const;
+
+private:
+ std::string m_sName;
+};
+
+}
+
+#endif
diff --git a/src/base/Queue.h b/src/base/Queue.h
new file mode 100644
index 0000000..35c8d92
--- /dev/null
+++ b/src/base/Queue.h
@@ -0,0 +1,150 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Queue_H_
+#define _Queue_H_
+
+#include "../api.h"
+#include "Exception.h"
+
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/condition.hpp>
+#include <boost/shared_ptr.hpp>
+
+#include <deque>
+#include <iostream>
+
+namespace avg {
+
+typedef boost::mutex::scoped_lock scoped_lock;
+
+template<class QElement>
+class AVG_TEMPLATE_API Queue
+{
+public:
+ typedef boost::shared_ptr<QElement> QElementPtr;
+
+ Queue(int MaxSize=-1);
+ virtual ~Queue();
+
+ bool empty() const;
+ QElementPtr pop(bool bBlock = true);
+ void push(const QElementPtr& Elem);
+ QElementPtr peek(bool bBlock = true) const;
+ int size() const;
+ int getMaxSize() const;
+
+private:
+ QElementPtr getFrontElement(bool bBlock, scoped_lock& Lock) const;
+
+ std::deque<QElementPtr> m_pElements;
+ mutable boost::mutex m_Mutex;
+ mutable boost::condition m_Cond;
+ int m_MaxSize;
+};
+
+template<class QElement>
+Queue<QElement>::Queue(int MaxSize)
+ : m_MaxSize(MaxSize)
+{
+}
+
+template<class QElement>
+Queue<QElement>::~Queue()
+{
+}
+
+template<class QElement>
+bool Queue<QElement>::empty() const
+{
+ scoped_lock Lock(m_Mutex);
+ return m_pElements.empty();
+}
+
+template<class QElement>
+typename Queue<QElement>::QElementPtr Queue<QElement>::pop(bool bBlock)
+{
+ scoped_lock Lock(m_Mutex);
+ QElementPtr pElem = getFrontElement(bBlock, Lock);
+ if (pElem) {
+ m_pElements.pop_front();
+ m_Cond.notify_one();
+ }
+ return pElem;
+}
+
+template<class QElement>
+typename Queue<QElement>::QElementPtr Queue<QElement>::peek(bool bBlock) const
+{
+ scoped_lock Lock(m_Mutex);
+ QElementPtr pElem = getFrontElement(bBlock, Lock);
+ if (pElem) {
+ m_Cond.notify_one();
+ }
+ return pElem;
+}
+
+template<class QElement>
+void Queue<QElement>::push(const QElementPtr& pElem)
+{
+ assert(pElem);
+ scoped_lock Lock(m_Mutex);
+ if (m_pElements.size() == (unsigned)m_MaxSize) {
+ while (m_pElements.size() == (unsigned)m_MaxSize) {
+ m_Cond.wait(Lock);
+ }
+ }
+ m_pElements.push_back(pElem);
+ m_Cond.notify_one();
+}
+
+template<class QElement>
+int Queue<QElement>::size() const
+{
+ scoped_lock Lock(m_Mutex);
+ return int(m_pElements.size());
+}
+
+template<class QElement>
+int Queue<QElement>::getMaxSize() const
+{
+ scoped_lock Lock(m_Mutex);
+ return m_MaxSize;
+}
+
+template<class QElement>
+typename Queue<QElement>::QElementPtr
+ Queue<QElement>::getFrontElement(bool bBlock, scoped_lock& Lock) const
+{
+ if (m_pElements.empty()) {
+ if (bBlock) {
+ while (m_pElements.empty()) {
+ m_Cond.wait(Lock);
+ }
+ } else {
+ return QElementPtr();
+ }
+ }
+ return m_pElements.front();
+}
+
+}
+#endif
diff --git a/src/base/Rect.h b/src/base/Rect.h
new file mode 100644
index 0000000..25756de
--- /dev/null
+++ b/src/base/Rect.h
@@ -0,0 +1,210 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Rect_H_
+#define _Rect_H_
+
+#include "../api.h"
+#include "Point.h"
+
+#include <algorithm>
+
+namespace avg {
+
+// Simple rectangle class.
+// If NUM is an integer, contains all points from tl up to but not including
+// br.
+template<class NUM>
+class AVG_TEMPLATE_API Rect
+{
+public:
+ Point<NUM> tl;
+ Point<NUM> br;
+
+ Rect();
+ Rect(NUM left, NUM top, NUM right, NUM bottom);
+ Rect(const Point<NUM>& TL, const Point<NUM>& BR);
+ template<class ORIGNUM> Rect(const Rect<ORIGNUM>& rc);
+
+ bool operator ==(const Rect<NUM>& rect) const;
+ bool operator !=(const Rect<NUM> & rect) const;
+ NUM width() const;
+ NUM height() const;
+ Point<NUM> center() const;
+ void setWidth(NUM width);
+ void setHeight(NUM height);
+ void setSize(const Point<NUM>& size);
+ bool contains(const Point<NUM>& pt) const;
+ bool contains(const Rect<NUM>& rect) const;
+ bool intersects(const Rect<NUM>& rect) const;
+ void expand(const Rect<NUM>& rect);
+ void intersect(const Rect<NUM>& rect);
+ Point<NUM> size() const;
+ Point<NUM> cropPoint(const Point<NUM>& pt) const;
+};
+
+template<class NUM>
+std::ostream& operator<<( std::ostream& os, const Rect<NUM> &r)
+{
+ os << "(" << r.tl << "-" << r.br << ")";
+ return os;
+}
+
+
+typedef Rect<double> DRect;
+typedef Rect<int> IntRect;
+
+template<class NUM>
+Rect<NUM>::Rect()
+{}
+
+template<class NUM>
+Rect<NUM>::Rect(const Point<NUM>& TL, const Point<NUM>& BR)
+ : tl(TL), br(BR)
+{}
+
+template<class NUM>
+Rect<NUM>::Rect(NUM left, NUM top, NUM right, NUM bottom)
+ : tl(left, top),
+ br(right, bottom)
+{}
+
+template<class NUM>
+template<class ORIGNUM>
+Rect<NUM>::Rect(const Rect<ORIGNUM>& rc)
+ : tl (NUM(rc.tl.x), NUM(rc.tl.y)),
+ br (NUM(rc.br.x), NUM(rc.br.y))
+{
+}
+
+template<class NUM>
+bool Rect<NUM>::operator ==(const Rect<NUM> & rect) const
+{
+ return (tl == rect.tl && br == rect.br);
+}
+
+template<class NUM>
+bool Rect<NUM>::operator !=(const Rect<NUM> & rect) const
+{
+ return !(rect==*this);
+}
+
+template<class NUM>
+NUM Rect<NUM>::width() const
+{
+ return br.x-tl.x;
+}
+
+template<class NUM>
+NUM Rect<NUM>::height() const
+{
+ return br.y-tl.y;
+}
+
+template<class NUM>
+Point<NUM> Rect<NUM>::center() const
+{
+ return Point<NUM>(tl+br)/2;
+}
+
+template<class NUM>
+void Rect<NUM>::setWidth(NUM width)
+{
+ br.x = tl.x+width;
+}
+
+template<class NUM>
+void Rect<NUM>::setHeight(NUM height)
+{
+ br.y = tl.y+height;
+}
+
+template<class NUM>
+void Rect<NUM>::setSize(const Point<NUM>& size)
+{
+ setWidth(size.x);
+ setHeight(size.y);
+}
+
+template<class NUM>
+bool Rect<NUM>::contains(const Point<NUM>& pt) const
+{
+ return (pt.x >= tl.x && pt.x < br.x &&
+ pt.y >= tl.y && pt.y < br.y);
+}
+
+template<class NUM>
+bool Rect<NUM>::contains(const Rect<NUM>& rect) const
+{
+ Point<NUM> brpt (rect.br.x-1, rect.br.y-1);
+ return Contains(rect.tl) && Contains(brpt);
+}
+
+template<class NUM>
+bool Rect<NUM>::intersects(const Rect<NUM>& rect) const
+{
+ if (rect.br.x <= tl.x || rect.tl.x >= br.x ||
+ rect.br.y <= tl.y || rect.tl.y >= br.y)
+ return false;
+ else
+ return true;
+}
+
+template<class NUM>
+void Rect<NUM>::expand(const Rect<NUM>& rect)
+{
+ tl.x = std::min(tl.x, rect.tl.x);
+ tl.y = std::min(tl.y, rect.tl.y);
+ br.x = std::max(br.x, rect.br.x);
+ br.y = std::max(br.y, rect.br.y);
+}
+
+template<class NUM>
+void Rect<NUM>::intersect(const Rect<NUM>& rect)
+{
+ tl.x = std::max(tl.x, rect.tl.x);
+ tl.y = std::max(tl.y, rect.tl.y);
+ br.x = std::min(br.x, rect.br.x);
+ br.y = std::min(br.y, rect.br.y);
+}
+
+template<class NUM>
+Point<NUM> Rect<NUM>::size() const
+{
+ return Point<NUM>(width(), height());
+}
+
+template<class NUM>
+Point<NUM> Rect<NUM>::cropPoint(const Point<NUM>& pt) const
+{
+ Point<NUM> Result;
+ Result.x = std::min(std::max(pt.x, tl.x), br.x-1);
+ Result.y = std::min(std::max(pt.y, tl.y), br.y-1);
+ return Result;
+}
+
+#undef min
+#undef max
+
+}
+
+#endif
+
diff --git a/src/base/ScopeTimer.cpp b/src/base/ScopeTimer.cpp
new file mode 100644
index 0000000..1a353e8
--- /dev/null
+++ b/src/base/ScopeTimer.cpp
@@ -0,0 +1,40 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ScopeTimer.h"
+#include "ThreadProfiler.h"
+
+using namespace std;
+
+namespace avg {
+
+ScopeTimer::ScopeTimer(ProfilingZoneID& zoneID)
+ : m_ZoneID(zoneID)
+{
+ ThreadProfiler::get()->startZone(zoneID);
+}
+
+ScopeTimer::~ScopeTimer()
+{
+ ThreadProfiler::get()->stopZone(m_ZoneID);
+}
+
+}
diff --git a/src/base/ScopeTimer.h b/src/base/ScopeTimer.h
new file mode 100644
index 0000000..de62eb2
--- /dev/null
+++ b/src/base/ScopeTimer.h
@@ -0,0 +1,41 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ScopeTimer_H_
+#define _ScopeTimer_H_
+
+#include "../api.h"
+#include "ProfilingZoneID.h"
+
+namespace avg {
+
+class AVG_API ScopeTimer {
+public:
+ ScopeTimer(ProfilingZoneID& zoneID);
+ virtual ~ScopeTimer();
+
+private:
+ ProfilingZoneID& m_ZoneID;
+};
+
+}
+
+#endif
diff --git a/src/base/Signal.h b/src/base/Signal.h
new file mode 100644
index 0000000..0e6beb2
--- /dev/null
+++ b/src/base/Signal.h
@@ -0,0 +1,119 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Signal_H_
+#define _Signal_H_
+
+#include "../api.h"
+
+#include "Exception.h"
+
+#include <list>
+
+namespace avg {
+
+
+// Simple implementation of a signal/slot mechanism.
+// Might need to be replaced by boost::signal when things get more complicated.
+template <class LISTENEROBJ>
+class AVG_TEMPLATE_API Signal {
+public:
+ typedef void (LISTENEROBJ::*ListenerFunc)() ;
+ Signal(ListenerFunc pFunc);
+ virtual ~Signal();
+
+ void connect(LISTENEROBJ* pListener);
+ void disconnect(LISTENEROBJ* pListener);
+
+ void emit();
+ int getNumListeners() const;
+
+private:
+ ListenerFunc m_pFunc;
+ std::list<LISTENEROBJ*> m_Listeners;
+ typedef typename std::list<LISTENEROBJ*>::iterator ListenerIterator;
+ LISTENEROBJ* m_pCurrentListener;
+ bool m_bKillCurrentListener;
+};
+
+template<class LISTENEROBJ>
+Signal<LISTENEROBJ>::Signal(ListenerFunc pFunc)
+ : m_pFunc(pFunc),
+ m_pCurrentListener(0),
+ m_bKillCurrentListener(false)
+{
+}
+
+template<class LISTENEROBJ>
+Signal<LISTENEROBJ>::~Signal()
+{
+}
+
+template<class LISTENEROBJ>
+void Signal<LISTENEROBJ>::connect(LISTENEROBJ* pListener)
+{
+ ListenerIterator it;
+ it = find(m_Listeners.begin(), m_Listeners.end(), pListener);
+ // If the listener is already connected, something is wrong, unless we're
+ // deleting it at this very moment.
+ AVG_ASSERT(it == m_Listeners.end() ||
+ (*it == m_pCurrentListener && m_bKillCurrentListener));
+ m_Listeners.push_back(pListener);
+}
+
+template<class LISTENEROBJ>
+void Signal<LISTENEROBJ>::disconnect(LISTENEROBJ* pListener)
+{
+ if (m_pCurrentListener == pListener) {
+ m_bKillCurrentListener = true;
+ } else {
+ ListenerIterator it;
+ it = find(m_Listeners.begin(), m_Listeners.end(), pListener);
+ AVG_ASSERT(it != m_Listeners.end());
+ m_Listeners.erase(it);
+ }
+}
+
+template<class LISTENEROBJ>
+void Signal<LISTENEROBJ>::emit()
+{
+ ListenerIterator it;
+ for (it=m_Listeners.begin(); it != m_Listeners.end();) {
+ m_pCurrentListener = *it;
+ ((*it)->*m_pFunc)(); // This is the actual call to the listener.
+ if (m_bKillCurrentListener) {
+ it = m_Listeners.erase(it);
+ m_bKillCurrentListener = false;
+ } else {
+ ++it;
+ }
+ }
+ m_pCurrentListener = 0;
+}
+
+template<class LISTENEROBJ>
+int Signal<LISTENEROBJ>::getNumListeners() const
+{
+ return m_Listeners.size();
+}
+
+}
+#endif
diff --git a/src/base/StringHelper.cpp b/src/base/StringHelper.cpp
new file mode 100644
index 0000000..ba02038
--- /dev/null
+++ b/src/base/StringHelper.cpp
@@ -0,0 +1,147 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "StringHelper.h"
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <algorithm>
+#include <cstdio>
+#include <iterator>
+
+using namespace std;
+
+namespace avg {
+
+bool isWhitespace(const string& s)
+{
+ return s.find_first_not_of(" \n\r\t") == s.npos;
+}
+
+void skipWhitespace(std::istream& is)
+{
+ string sWhitespace(" \n\r\t");
+ bool bWhitespace;
+ do {
+ int i = is.peek();
+ if (i == EOF) {
+ bWhitespace = false;
+ } else {
+ bWhitespace = (sWhitespace.find(char(i)) != sWhitespace.npos);
+ }
+ if (bWhitespace) {
+ is.ignore();
+ }
+ } while (bWhitespace);
+}
+
+void skipToken(std::istream& is, char token)
+{
+ skipWhitespace(is);
+ int i = is.peek();
+ if (i == token) {
+ is.ignore();
+ } else {
+ is.setstate(ios::failbit);
+ }
+}
+
+int stringToInt(const string& s)
+{
+ int i;
+ fromString(s, i);
+ return i;
+}
+
+double stringToDouble(const string& s)
+{
+ double d;
+ fromString(s, d);
+ return d;
+}
+
+bool stringToBool(const string& s)
+{
+ // avg usually wants xml attributes in lowercase, but python only
+ // sees 'True' as true, so we'll accept that too. Also, python 2.3
+ // has 1 as true, so that has to be ok too.
+ if (s == "True" || s == "true" || s == "1") {
+ return true;
+ }
+ if (s == "False" || s == "false" || s == "0") {
+ return false;
+ }
+ throw (Exception(AVG_ERR_TYPE, string("Could not convert ")+s+" to bool."));
+}
+
+DPoint stringToDPoint(const std::string& s)
+{
+ DPoint pt;
+ fromString(s, pt);
+ return pt;
+}
+
+IntTriple stringToIntTriple(const std::string& s)
+{
+ IntTriple pt;
+ fromString(s, pt);
+ return pt;
+}
+
+std::string removeStartEndSpaces(const string& s)
+{
+ string sResult = s;
+ while (sResult[0] == ' ' || sResult[0] == '\n' || sResult[0] == '\r'
+ || sResult[0] == '\t')
+ {
+ sResult.erase(0, 1);
+ }
+ char c = sResult[sResult.length()-1];
+ while (c == ' ' || c == '\n' || c == '\r' || c == '\t') {
+ sResult.erase(sResult.length()-1, 1);
+ c = sResult[sResult.length()-1];
+ }
+ return sResult;
+}
+
+string toLowerCase(const string& s)
+{
+ string sResult;
+ for (unsigned i=0; i<s.length(); ++i) {
+ sResult.push_back(::tolower(s[i]));
+ }
+ return sResult;
+}
+
+bool equalIgnoreCase(const string& s1, const string& s2)
+{
+ if (s1.length() != s2.length()) {
+ return false;
+ }
+ string sUpper1;
+ string sUpper2;
+ transform(s1.begin(), s1.end(), std::back_inserter(sUpper1), (int(*)(int)) toupper);
+ transform(s2.begin(), s2.end(), std::back_inserter(sUpper2), (int(*)(int)) toupper);
+ return sUpper1 == sUpper2;
+}
+
+}
+
diff --git a/src/base/StringHelper.h b/src/base/StringHelper.h
new file mode 100644
index 0000000..154a5f0
--- /dev/null
+++ b/src/base/StringHelper.h
@@ -0,0 +1,145 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _StringHelper_H_
+#define _StringHelper_H_
+
+#include "../api.h"
+#include "Exception.h"
+#include "Point.h"
+#include "Triple.h"
+
+#include <string>
+#include <sstream>
+#include <typeinfo>
+#include <iostream>
+
+#ifdef __GNUC__
+#include <cxxabi.h>
+#endif
+
+namespace avg {
+
+bool isWhitespace(const std::string& s);
+void skipWhitespace(std::istream& is);
+void skipToken(std::istream& is, char token);
+
+template<class NUM>
+std::istream& operator>>(std::istream& is, Point<NUM>& p)
+{
+ skipToken(is, '(');
+ is >> p.x;
+ skipToken(is, ',');
+ is >> p.y;
+ skipToken(is, ')');
+ return is;
+}
+
+template<class T>
+std::istream& operator >>(std::istream& is, std::vector<T>& v)
+{
+ skipToken(is, '(');
+ skipWhitespace(is);
+ int c = is.peek();
+ if (c == ')') {
+ is.ignore();
+ return is;
+ }
+ bool bDone = false;
+ do {
+ T elem;
+ is >> elem;
+ v.push_back(elem);
+ skipWhitespace(is);
+ int c = is.peek();
+ switch(c) {
+ case ',':
+ is.ignore();
+ break;
+ case ')':
+ bDone = true;
+ is.ignore();
+ break;
+ default:
+ is.setstate(std::ios::failbit);
+ bDone = true;
+ }
+ } while (!bDone);
+ return is;
+}
+
+int stringToInt(const std::string& s);
+double stringToDouble(const std::string& s);
+bool stringToBool(const std::string& s);
+DPoint stringToDPoint(const std::string& s);
+IntTriple stringToIntTriple(const std::string& s);
+
+std::string removeStartEndSpaces(const std::string& s);
+
+std::string toLowerCase(const std::string& s);
+
+bool equalIgnoreCase(const std::string& s1, const std::string& s2);
+
+template<class T>
+std::string toString(const T& i)
+{
+ std::stringstream stream;
+ stream << i;
+ return stream.str();
+}
+
+template<class T>
+std::string getFriendlyTypeName(const T& dummy)
+{
+ std::string sTypeName = typeid(T).name();
+#ifdef __GNUC__
+ int status;
+ char* const pClearName = abi::__cxa_demangle (sTypeName.c_str(), 0, 0, &status);
+ if (status == 0) {
+ sTypeName = pClearName;
+ }
+#endif
+ return sTypeName;
+}
+
+template<class T>
+void fromString(const std::string& s, T& result)
+{
+ std::stringstream stream(s);
+ bool bOk = (stream >> result) != 0;
+ if (bOk) {
+ std::string sLeftover;
+ stream >> sLeftover;
+ bOk = isWhitespace(sLeftover);
+ }
+ if (!bOk) {
+ std::string sTypeName = getFriendlyTypeName(result);
+ throw (Exception(AVG_ERR_TYPE, std::string("Could not convert '")+s
+ + "' to "+sTypeName+"."));
+ }
+}
+
+
+}
+
+
+
+#endif
diff --git a/src/base/Test.cpp b/src/base/Test.cpp
new file mode 100644
index 0000000..8825d45
--- /dev/null
+++ b/src/base/Test.cpp
@@ -0,0 +1,114 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Test.h"
+
+#include "../base/OSHelper.h"
+
+#include <iostream>
+#include <stdlib.h>
+
+using namespace std;
+
+namespace avg {
+
+string Test::s_sSrcDirName;
+
+Test::Test(const string & sName, int indentLevel)
+ : m_IndentLevel(indentLevel),
+ m_NumSucceeded(0),
+ m_NumFailed(0),
+ m_sName(sName)
+{
+}
+
+Test::~Test()
+{
+}
+
+void Test::test (bool b, const char * pszFile, int line)
+{
+ if (b) {
+ m_NumSucceeded++;
+ } else {
+ cerr << string(m_IndentLevel, ' ') << " ---->> failed at " << pszFile
+ << ", " << line << endl;
+ m_NumFailed++;
+ }
+}
+
+
+bool Test::isOk()
+{
+ return m_NumFailed == 0;
+}
+
+void Test::setFailed()
+{
+ m_NumFailed++;
+}
+
+int Test::getNumSucceeded() const
+{
+ return m_NumSucceeded;
+}
+
+int Test::getNumFailed() const
+{
+ return m_NumFailed;
+}
+
+const std::string& Test::getName() const
+{
+ return m_sName;
+}
+
+void Test::aggregateStatistics(const Test& ChildTest)
+{
+ m_NumSucceeded += ChildTest.getNumSucceeded();
+ m_NumFailed += ChildTest.getNumFailed();
+}
+
+void Test::printResults()
+{
+ if (m_NumFailed == 0) {
+ cerr << string(m_IndentLevel, ' ') << m_sName << " succeeded." << endl;
+ } else {
+ cerr << string(m_IndentLevel, ' ') << "######## " << m_sName <<
+ " failed. ########" << endl;
+ }
+
+}
+
+const string& Test::getSrcDirName()
+{
+ if (s_sSrcDirName == "") {
+ bool bInEnviron = getEnv("srcdir", s_sSrcDirName);
+ if (!bInEnviron) {
+ s_sSrcDirName = ".";
+ }
+ s_sSrcDirName += "/";
+ }
+ return s_sSrcDirName;
+}
+
+}
+
diff --git a/src/base/Test.h b/src/base/Test.h
new file mode 100644
index 0000000..ef39bc5
--- /dev/null
+++ b/src/base/Test.h
@@ -0,0 +1,82 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Test_H_
+#define _Test_H_
+
+#include "../api.h"
+#include <boost/shared_ptr.hpp>
+
+#include <iostream>
+#include <sstream>
+#include <string>
+
+namespace avg {
+class AVG_API Test
+{
+public:
+ Test(const std::string & sName, int indentLevel);
+ virtual ~Test();
+
+ bool isOk();
+ virtual void runTests() = 0;
+
+ void test(bool b, const char * pszFile, int line);
+ void setFailed();
+
+ int getNumSucceeded() const;
+ int getNumFailed() const;
+ const std::string& getName() const;
+
+ void aggregateStatistics(const Test& childTest);
+ virtual void printResults();
+
+protected:
+ static const std::string& getSrcDirName();
+ static std::string s_sSrcDirName;
+
+ int m_IndentLevel;
+
+private:
+ bool m_bOk;
+ int m_NumSucceeded;
+ int m_NumFailed;
+ std::string m_sName;
+};
+
+typedef boost::shared_ptr<Test> TestPtr;
+
+#define TEST_FAILED(s) \
+ cerr << string(m_IndentLevel+6, ' ') << s << endl; \
+ test(false, __FILE__, __LINE__);
+
+#define TEST(b) \
+ cerr << string(m_IndentLevel+4, ' ') << " TEST(" << #b << ")" << endl; \
+ test(b, __FILE__, __LINE__);
+
+#define QUIET_TEST(b) \
+ if(!(b)) { \
+ cerr << string(m_IndentLevel+4, ' ') << " TEST(" << #b << ")" << endl; \
+ } \
+ test(b, __FILE__, __LINE__);
+}
+#endif
+
diff --git a/src/base/TestSuite.cpp b/src/base/TestSuite.cpp
new file mode 100644
index 0000000..87130da
--- /dev/null
+++ b/src/base/TestSuite.cpp
@@ -0,0 +1,68 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TestSuite.h"
+#include "Exception.h"
+
+using namespace std;
+
+namespace avg {
+
+TestSuite::TestSuite(const string& sName)
+ : Test(sName, 0)
+{
+}
+
+TestSuite::~TestSuite()
+{
+}
+
+void TestSuite::addTest(TestPtr pNewTest)
+{
+ m_Tests.push_back(pNewTest);
+}
+
+void TestSuite::runTests()
+{
+ cerr << string(m_IndentLevel, ' ') << "Running suite " << getName() << endl;
+ for (unsigned i = 0; i < m_Tests.size(); ++i) {
+ cerr << string(m_IndentLevel, ' ') << " Running "
+ << m_Tests[i]->getName() << endl;
+ try {
+ m_Tests[i]->runTests();
+ aggregateStatistics(*m_Tests[i]);
+ m_Tests[i]->printResults();
+ } catch (Exception& ex) {
+ cerr << string(m_IndentLevel, ' ') << ex.getStr() << endl;
+ setFailed();
+ } catch (...) {
+ cerr << string(m_IndentLevel, ' ') <<
+ " ---->> failed, exception caught" << endl;
+ setFailed();
+ }
+ }
+
+ printResults();
+}
+
+
+}
+
diff --git a/src/base/TestSuite.h b/src/base/TestSuite.h
new file mode 100644
index 0000000..d85eef8
--- /dev/null
+++ b/src/base/TestSuite.h
@@ -0,0 +1,49 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TestSuite_H_
+#define _TestSuite_H_
+
+#include "../api.h"
+#include "Test.h"
+
+#include <iostream>
+#include <sstream>
+#include <vector>
+
+namespace avg {
+class AVG_API TestSuite: public Test
+{
+public:
+ TestSuite(const std::string& sName);
+ virtual ~TestSuite();
+
+ void addTest(TestPtr pNewTest);
+
+ virtual void runTests();
+
+private:
+ std::vector<TestPtr> m_Tests;
+};
+
+}
+#endif
+
diff --git a/src/base/ThreadProfiler.cpp b/src/base/ThreadProfiler.cpp
new file mode 100644
index 0000000..12715c7
--- /dev/null
+++ b/src/base/ThreadProfiler.cpp
@@ -0,0 +1,187 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ThreadProfiler.h"
+#include "Logger.h"
+#include "Exception.h"
+
+#include <sstream>
+#include <iomanip>
+#include <iostream>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+thread_specific_ptr<ThreadProfilerPtr> ThreadProfiler::s_pInstance;
+
+ThreadProfilerPtr& ThreadProfiler::get()
+{
+ if (s_pInstance.get() == 0) {
+ s_pInstance.reset(new ThreadProfilerPtr(new ThreadProfiler()));
+ }
+ return *s_pInstance;
+}
+
+void ThreadProfiler::kill()
+{
+ s_pInstance.reset();
+}
+
+ThreadProfiler::ThreadProfiler()
+ : m_sName(""),
+ m_LogCategory(Logger::PROFILE)
+{
+ m_bRunning = false;
+}
+
+ThreadProfiler::~ThreadProfiler()
+{
+}
+
+void ThreadProfiler::setLogCategory(long category)
+{
+ AVG_ASSERT(!m_bRunning);
+ m_LogCategory = category;
+}
+
+void ThreadProfiler::start()
+{
+ m_bRunning = true;
+}
+
+bool ThreadProfiler::isRunning()
+{
+ return m_bRunning;
+}
+
+void ThreadProfiler::startZone(const ProfilingZoneID& zoneID)
+{
+ ZoneMap::iterator it = m_ZoneMap.find(&zoneID);
+ // Duplicated code to avoid instantiating a new smart pointer when it's not
+ // necessary.
+ if (it == m_ZoneMap.end()) {
+ ProfilingZonePtr pZone = addZone(zoneID);
+ pZone->start();
+ m_ActiveZones.push_back(pZone);
+ } else {
+ ProfilingZonePtr& pZone = it->second;
+ pZone->start();
+ m_ActiveZones.push_back(pZone);
+ }
+}
+
+void ThreadProfiler::stopZone(const ProfilingZoneID& zoneID)
+{
+ ZoneMap::iterator it = m_ZoneMap.find(&zoneID);
+ AVG_ASSERT(it != m_ZoneMap.end());
+ ProfilingZonePtr& pZone = it->second;
+ AVG_ASSERT(m_ActiveZones.back() == pZone);
+ pZone->stop();
+ m_ActiveZones.pop_back();
+}
+
+void ThreadProfiler::dumpFrame()
+{
+ AVG_TRACE(Logger::PROFILE_LATEFRAMES, "Frame Profile:");
+ ZoneList::iterator it;
+ for (it = m_Zones.begin(); it != m_Zones.end(); ++it) {
+ AVG_TRACE(Logger::PROFILE_LATEFRAMES,
+ std::setw(35) << std::left
+ << ((*it)->getIndentString() + (*it)->getName())
+ << std::setw(9) << std::right << (*it)->getUSecs());
+ }
+ AVG_TRACE(Logger::PROFILE_LATEFRAMES, "");
+}
+
+void ThreadProfiler::dumpStatistics()
+{
+ if (!m_Zones.empty()) {
+ AVG_TRACE(m_LogCategory, "Thread " << m_sName);
+ AVG_TRACE(m_LogCategory, "Zone name Avg. time");
+ AVG_TRACE(m_LogCategory, "--------- ---------");
+
+ ZoneList::iterator it;
+ for (it = m_Zones.begin(); it != m_Zones.end(); ++it) {
+ AVG_TRACE(m_LogCategory,
+ std::setw(35) << std::left
+ << ((*it)->getIndentString()+(*it)->getName())
+ << std::setw(9) << std::right << (*it)->getAvgUSecs());
+ }
+ AVG_TRACE(m_LogCategory, "");
+ }
+}
+
+void ThreadProfiler::reset()
+{
+ ZoneList::iterator it;
+ for (it = m_Zones.begin(); it != m_Zones.end(); ++it) {
+ (*it)->reset();
+ }
+}
+
+int ThreadProfiler::getNumZones()
+{
+ return m_Zones.size();
+}
+
+const std::string& ThreadProfiler::getName() const
+{
+ return m_sName;
+}
+
+void ThreadProfiler::setName(const std::string& sName)
+{
+ m_sName = sName;
+}
+
+
+ProfilingZonePtr ThreadProfiler::addZone(const ProfilingZoneID& zoneID)
+{
+ ProfilingZonePtr pZone(new ProfilingZone(zoneID));
+ m_ZoneMap[&zoneID] = pZone;
+ ZoneList::iterator it;
+ int parentIndent = -2;
+ if (m_ActiveZones.empty()) {
+ it = m_Zones.end();
+ } else {
+ ProfilingZonePtr pActiveZone = m_ActiveZones.back();
+ bool bParentFound = false;
+ for (it = m_Zones.begin(); it != m_Zones.end(); ++it)
+ {
+ if (pActiveZone == *it) {
+ bParentFound = true;
+ break;
+ }
+ }
+ AVG_ASSERT(bParentFound);
+ parentIndent = pActiveZone->getIndentLevel();
+ ++it;
+ for (; it != m_Zones.end() && (*it)->getIndentLevel() > parentIndent; ++it);
+ }
+ m_Zones.insert(it, pZone);
+ pZone->setIndentLevel(parentIndent+2);
+ return pZone;
+}
+
+}
+
diff --git a/src/base/ThreadProfiler.h b/src/base/ThreadProfiler.h
new file mode 100644
index 0000000..a571220
--- /dev/null
+++ b/src/base/ThreadProfiler.h
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ThreadProfiler_H_
+#define _ThreadProfiler_H_
+
+#include "../api.h"
+#include "ProfilingZone.h"
+
+#include <boost/thread.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/thread/tss.hpp>
+
+#include <list>
+#include <map>
+
+namespace avg {
+
+class ThreadProfiler;
+typedef boost::shared_ptr<ThreadProfiler> ThreadProfilerPtr;
+
+class AVG_API ThreadProfiler
+{
+public:
+ static ThreadProfilerPtr& get();
+ static void kill();
+ ThreadProfiler();
+ virtual ~ThreadProfiler();
+ void setLogCategory(long category);
+
+ void start();
+ bool isRunning();
+ void startZone(const ProfilingZoneID& zoneID);
+ void stopZone(const ProfilingZoneID& zoneID);
+ void dumpFrame();
+ void dumpStatistics();
+ void reset();
+ int getNumZones();
+
+ const std::string& getName() const;
+ void setName(const std::string& sName);
+
+private:
+ ProfilingZonePtr addZone(const ProfilingZoneID& zoneID);
+ std::string m_sName;
+
+ typedef std::map<const ProfilingZoneID*, ProfilingZonePtr> ZoneMap;
+ typedef std::list<ProfilingZonePtr> ZoneList;
+ ZoneMap m_ZoneMap;
+ ZoneList m_ActiveZones;
+ ZoneList m_Zones;
+ bool m_bRunning;
+ long m_LogCategory;
+
+ static boost::thread_specific_ptr<ThreadProfilerPtr> s_pInstance;
+};
+
+}
+
+#endif
diff --git a/src/base/TimeSource.cpp b/src/base/TimeSource.cpp
new file mode 100644
index 0000000..320b3ff
--- /dev/null
+++ b/src/base/TimeSource.cpp
@@ -0,0 +1,128 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TimeSource.h"
+
+#include "Logger.h"
+#include "Exception.h"
+
+#ifdef _WIN32
+#include <time.h>
+#include <sys/timeb.h>
+#include <windows.h>
+#include <Mmsystem.h>
+#else
+#include <sys/time.h>
+#endif
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#include <errno.h>
+#include <assert.h>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+TimeSource* TimeSource::m_pTimeSource = 0;
+
+TimeSource * TimeSource::get()
+{
+ if (!m_pTimeSource) {
+#ifdef _WIN32
+ TIMECAPS tc;
+ UINT wTimerRes;
+ MMRESULT err = timeGetDevCaps(&tc, sizeof(TIMECAPS));
+ AVG_ASSERT(err == TIMERR_NOERROR);
+ wTimerRes = max(tc.wPeriodMin, 1);
+ timeBeginPeriod(wTimerRes);
+#endif
+ m_pTimeSource = new TimeSource;
+ }
+ return m_pTimeSource;
+}
+
+TimeSource::TimeSource()
+{
+#ifdef __APPLE__
+ mach_timebase_info(&m_TimebaseInfo);
+#endif
+}
+
+TimeSource::~TimeSource()
+{
+}
+
+long long TimeSource::getCurrentMillisecs()
+{
+ return getCurrentMicrosecs()/1000;
+}
+
+long long TimeSource::getCurrentMicrosecs()
+{
+#ifdef _WIN32
+ return (long long)(timeGetTime())*1000;
+#else
+#ifdef __APPLE__
+ long long systemTime = mach_absolute_time();
+ return (systemTime * m_TimebaseInfo.numer/m_TimebaseInfo.denom)/1000;
+#else
+ struct timespec now;
+ int rc = clock_gettime(CLOCK_MONOTONIC, &now);
+ assert(rc == 0);
+ return ((long long)now.tv_sec)*1000000+now.tv_nsec/1000;
+#endif
+#endif
+}
+
+void TimeSource::sleepUntil(long long targetTime)
+{
+ long long now = getCurrentMillisecs();
+#ifdef __APPLE__
+ if (targetTime > now) {
+ msleep(targetTime-now);
+ }
+#else
+ while (now<targetTime) {
+ if (targetTime-now<=2) {
+ msleep(0);
+ } else {
+ msleep(int(targetTime-now-2));
+ }
+ now = getCurrentMillisecs();
+ }
+#endif
+}
+
+void msleep(int millisecs)
+{
+#if _WIN32
+ Sleep(millisecs);
+#else
+ usleep((long long)(millisecs)*1000);
+#endif
+}
+
+}
+
diff --git a/src/base/TimeSource.h b/src/base/TimeSource.h
new file mode 100644
index 0000000..63679fe
--- /dev/null
+++ b/src/base/TimeSource.h
@@ -0,0 +1,60 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TimeSource_H_
+#define _TimeSource_H_
+
+#include "../api.h"
+
+#ifdef __APPLE__
+#include <mach/mach_time.h>
+#endif
+
+namespace avg {
+
+
+// This class is a monotonic time source with an undefined start time. Time is guarranteed
+// to increase monotonically. The time source has no jumps and does not go backwards,
+// even if system time is changed.
+class AVG_API TimeSource {
+public:
+ static TimeSource* get();
+ virtual ~TimeSource();
+
+ long long getCurrentMillisecs();
+ long long getCurrentMicrosecs();
+
+ void sleepUntil(long long targetTime);
+
+private:
+ TimeSource();
+#ifdef __APPLE__
+ mach_timebase_info_data_t m_TimebaseInfo;
+#endif
+
+ static TimeSource* m_pTimeSource;
+};
+
+void AVG_API msleep(int millisecs);
+
+}
+
+#endif
diff --git a/src/base/Triangle.cpp b/src/base/Triangle.cpp
new file mode 100644
index 0000000..039c643
--- /dev/null
+++ b/src/base/Triangle.cpp
@@ -0,0 +1,103 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Triangle.h"
+
+#include <math.h>
+
+namespace avg {
+
+Triangle::Triangle(const DPoint& P0, const DPoint& P1, const DPoint& P2)
+ : p0(P0),
+ p1(P1),
+ p2(P2)
+{
+}
+
+Triangle::Triangle()
+{
+}
+
+bool Triangle::operator ==(const Triangle & tri) const
+{
+ return (p0 == tri.p0 && p1 == tri.p1 && p2 == tri.p2);
+}
+
+bool Triangle::isInside(const DPoint& pt) const
+{
+/* Slower func that only works for cw triangles.
+
+ DPoint a = p2-p1;
+ DPoint bp = pt-p1;
+ double aCROSSbp = a.x*bp.y - a.y*bp.x;
+ if (aCROSSbp < 0.0) {
+ return false;
+ }
+
+ DPoint b = p0-p2;
+ DPoint cp = pt-p2;
+ double bCROSScp = b.x*cp.y - b.y*cp.x;
+ if (bCROSScp < 0.0) {
+ return false;
+ }
+
+ DPoint c = p1-p0;
+ DPoint ap = pt-p0;
+ double cCROSSap = c.x*ap.y - c.y*ap.x;
+ return cCROSSap >= 0.0;
+*/
+ DPoint v0 = p2 - p0;
+ DPoint v1 = p1 - p0;
+ DPoint v2 = pt - p0;
+
+ double dot00 = dotProduct(v0, v0);
+ double dot01 = dotProduct(v0, v1);
+ double dot02 = dotProduct(v0, v2);
+ double dot11 = dotProduct(v1, v1);
+ double dot12 = dotProduct(v1, v2);
+
+ double invDenom = 1 / (dot00 * dot11 - dot01 * dot01);
+ double u = (dot11 * dot02 - dot01 * dot12) * invDenom;
+ double v = (dot00 * dot12 - dot01 * dot02) * invDenom;
+
+ return (u > 0) && (v > 0) && (u + v < 1);
+
+}
+
+double Triangle::getArea() const
+{
+ return fabs((((p1.x-p0.x)*(p2.y-p0.y)) - ((p1.y-p0.y)*(p2.x-p0.x)))/2);
+}
+
+bool Triangle::isClockwise() const
+{
+ return ((p1.x-p0.x)*(p2.y-p0.y)) - ((p1.y-p0.y)*(p2.x-p0.x)) < 0;
+}
+
+std::ostream& operator<<(std::ostream& os, const Triangle& tri)
+{
+ os << "(" << tri.p0 << "," << tri.p1 << "," << tri.p2 << ")";
+ return os;
+}
+
+
+}
+
diff --git a/src/base/Triangle.h b/src/base/Triangle.h
new file mode 100644
index 0000000..a9722fb
--- /dev/null
+++ b/src/base/Triangle.h
@@ -0,0 +1,50 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Triangle_H_
+#define _Triangle_H_
+
+#include "../api.h"
+
+#include "Point.h"
+
+namespace avg {
+
+struct AVG_API Triangle {
+public:
+ DPoint p0;
+ DPoint p1;
+ DPoint p2;
+
+ Triangle(const DPoint& P0, const DPoint& P1, const DPoint& P2);
+ Triangle();
+
+ bool operator ==(const Triangle & tri) const;
+ bool isInside(const DPoint& pt) const;
+ double getArea() const;
+ bool isClockwise() const;
+};
+
+std::ostream& operator<<(std::ostream& os, const Triangle& tri);
+
+}
+
+#endif
diff --git a/src/base/Triangulate.cpp b/src/base/Triangulate.cpp
new file mode 100644
index 0000000..bbd9ef5
--- /dev/null
+++ b/src/base/Triangulate.cpp
@@ -0,0 +1,139 @@
+// Original code by John W. Ratcliff presumed to be in the public domain. Found
+// at http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml.
+
+#include "Triangulate.h"
+#include "Exception.h"
+
+#include "../base/Exception.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <iostream>
+
+namespace avg {
+
+using namespace std;
+
+double getPolygonArea(const DPointVector &contour)
+{
+ int n = contour.size();
+
+ double A=0.0;
+
+ for (int p=n-1,q=0; q<n; p=q++) {
+ A += contour[p].x*contour[q].y - contour[q].x*contour[p].y;
+ }
+ return A*0.5;
+}
+
+
+bool snip(const DPointVector &contour,int u,int v,int w,int n,int *V)
+{
+ int p;
+ Triangle tri;
+ tri.p0 = contour[V[u]];
+ tri.p1 = contour[V[v]];
+ tri.p2 = contour[V[w]];
+
+// double area = tri.getArea();
+
+ if (tri.isClockwise()) {
+ return false;
+ }
+
+ for (p=0; p<n; p++) {
+ if( (p == u) || (p == v) || (p == w) ) {
+ continue;
+ }
+ if (tri.isInside(contour[V[p]])) {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
+// TODO: There's code that's probably faster in Graphics Gems V:
+// http://tog.acm.org/resources/GraphicsGems/gemsv/ch7-5/
+void triangulatePolygon(const DPointVector &contour, vector<int> &resultIndexes)
+{
+ /* allocate and initialize list of Vertices in polygon */
+
+ int n = contour.size();
+ AVG_ASSERT(n>2);
+
+ int *V = new int[n];
+
+ // we want a counter-clockwise polygon in V.
+ if (0.0 < getPolygonArea(contour)) {
+ for (int v=0; v<n; v++) {
+ V[v] = v;
+ }
+ } else {
+ for(int v=0; v<n; v++) {
+ V[v] = (n-1)-v;
+ }
+ }
+
+ int nv = n;
+
+ /* remove nv-2 Vertices, creating 1 triangle every time */
+ int count = 2*nv; /* error detection */
+
+ for(int m=0, v=nv-1; nv>2; )
+ {
+ if (count <= 0) {
+ delete V;
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Non-simple polygon: Self-intersecting polygons or degenerate polygons are not supported.");
+ }
+ count--;
+
+ /* three consecutive vertices in current polygon, <u,v,w> */
+ int u = v;
+ if (nv <= u) {
+ u = 0; /* previous */
+ }
+ v = u+1;
+ if (nv <= v) {
+ v = 0;
+ }
+ int w = v+1;
+ if (nv <= w) {
+ w = 0;
+ }
+
+ if (snip(contour,u,v,w,nv,V))
+ {
+ int a,b,c,s,t;
+
+ /* true names of the vertices */
+ a = V[u]; b = V[v]; c = V[w];
+
+ /* output Triangle */
+
+ resultIndexes.push_back(a);
+ resultIndexes.push_back(b);
+ resultIndexes.push_back(c);
+
+ m++;
+
+ /* remove v from remaining polygon */
+ for(s=v,t=v+1; t<nv; s++,t++) {
+ V[s] = V[t];
+ }
+ nv--;
+
+ /* resest error detection counter */
+ count = 2*nv;
+
+ }
+ }
+
+ delete[] V;
+}
+
+}
+
diff --git a/src/base/Triangulate.h b/src/base/Triangulate.h
new file mode 100644
index 0000000..d2b4ef6
--- /dev/null
+++ b/src/base/Triangulate.h
@@ -0,0 +1,22 @@
+// Original code by John W. Ratcliff presumed to be in the public domain. Found
+// at http://www.flipcode.com/archives/Efficient_Polygon_Triangulation.shtml.
+
+#ifndef _Triangulate_H_
+#define _Triangulate_H_
+
+#include "Point.h"
+#include "Triangle.h"
+
+#include <vector>
+
+namespace avg {
+
+// Result type is suitable for use in a Triangle Vertex Array.
+void triangulatePolygon(const DPointVector &contour, std::vector<int> &resultIndexes);
+
+double getPolygonArea(const DPointVector &contour);
+
+}
+
+#endif
+
diff --git a/src/base/Triple.cpp b/src/base/Triple.cpp
new file mode 100644
index 0000000..8249f72
--- /dev/null
+++ b/src/base/Triple.cpp
@@ -0,0 +1,107 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Triple.h"
+
+#include "MathHelper.h"
+#include "StringHelper.h"
+#include "Exception.h"
+
+#if defined(__SSE__) || defined(_WIN32)
+#include <xmmintrin.h>
+#endif
+
+#include <math.h>
+#include <float.h>
+
+#include <string>
+
+namespace avg {
+
+template<class NUM>
+Triple<NUM>::Triple()
+{
+ x = 0;
+ y = 0;
+ z = 0;
+}
+
+template<class NUM>
+Triple<NUM>::Triple(NUM X, NUM Y, NUM Z)
+{
+ x = X;
+ y = Y;
+ z = Z;
+}
+
+template<class NUM>
+Triple<NUM>::Triple(const Triple<NUM>& p)
+{
+ x = p.x;
+ y = p.y;
+ z = p.z;
+}
+
+
+template<class NUM>
+Triple<NUM>::Triple(const std::vector<NUM>& v)
+{
+ AVG_ASSERT(v.size() == 3);
+ x = v[0];
+ y = v[1];
+ z = v[2];
+}
+
+template<class NUM>
+Triple<NUM>::~Triple()
+{
+}
+
+template<class NUM>
+std::ostream& operator<<(std::ostream& os, const Triple<NUM> &p)
+{
+ os << "(" << p.x << "," << p.y << "," << p.z << ")";
+ return os;
+}
+
+template<class NUM>
+std::istream& operator>>(std::istream& is, Triple<NUM>& p)
+{
+ skipToken(is, '(');
+ is >> p.x;
+ skipToken(is, ',');
+ is >> p.y;
+ skipToken(is, ',');
+ is >> p.z;
+ skipToken(is, ')');
+ return is;
+}
+
+// Explicit instantiations.
+template class Triple<double>;
+template std::ostream& operator<<(std::ostream& os, const Triple<double> &p);
+template std::istream& operator>>(std::istream& is, Triple<double>& p);
+
+template class Triple<int>;
+template std::ostream& operator<<(std::ostream& os, const Triple<int> &p);
+template std::istream& operator>>(std::istream& is, Triple<int>& p);
+
+}
diff --git a/src/base/Triple.h b/src/base/Triple.h
new file mode 100644
index 0000000..879a809
--- /dev/null
+++ b/src/base/Triple.h
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Triple_H_
+#define _Triple_H_
+
+#include "../api.h"
+
+#include <ostream>
+#include <istream>
+#include <vector>
+
+// Fix for non-C99 win compilers up to MSVC++2008
+#if defined _MSC_VER && _MSC_VER <= 1500
+#define isinf(x) (!_finite(x))
+#define isnan(x) (_isnan(x))
+#endif
+
+namespace avg {
+
+template<class NUM>
+class AVG_TEMPLATE_API Triple
+{
+public:
+ NUM x;
+ NUM y;
+ NUM z;
+
+ Triple();
+ Triple(NUM X, NUM Y, NUM Z);
+ Triple(const Triple<NUM> & p);
+ Triple(const std::vector<NUM>& v);
+ ~Triple();
+
+};
+
+template<class NUM>
+std::ostream& operator<<(std::ostream& os, const Triple<NUM> &p);
+
+template<class NUM>
+std::istream& operator>>(std::istream& is, Triple<NUM>& p);
+
+typedef Triple<double> DTriple;
+typedef Triple<int> IntTriple;
+
+}
+
+#endif
diff --git a/src/base/UTF8String.cpp b/src/base/UTF8String.cpp
new file mode 100644
index 0000000..214901b
--- /dev/null
+++ b/src/base/UTF8String.cpp
@@ -0,0 +1,57 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "UTF8String.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+UTF8String::UTF8String()
+{
+}
+
+UTF8String::UTF8String(const string& s)
+ : string(s)
+{
+}
+
+UTF8String::UTF8String(const char * psz)
+ : string(psz)
+{
+
+}
+
+UTF8String& UTF8String::operator =(const string& s)
+{
+ *dynamic_cast<string*>(this) = s;
+ return *this;
+}
+
+UTF8String& UTF8String::operator =(const char* psz)
+{
+ *dynamic_cast<string*>(this) = psz;
+ return *this;
+}
+
+}
diff --git a/src/base/UTF8String.h b/src/base/UTF8String.h
new file mode 100644
index 0000000..2c0f1be
--- /dev/null
+++ b/src/base/UTF8String.h
@@ -0,0 +1,43 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _UTF8String_H_
+#define _UTF8String_H_
+
+#include "../api.h"
+#include <string>
+
+namespace avg {
+
+class AVG_TEMPLATE_API UTF8String: public std::string
+{
+public:
+ UTF8String();
+ UTF8String(const std::string& s);
+ UTF8String(const char * psz);
+
+ UTF8String& operator =(const std::string& s);
+ UTF8String& operator =(const char * psz);
+
+};
+
+}
+#endif
diff --git a/src/base/WideLine.cpp b/src/base/WideLine.cpp
new file mode 100644
index 0000000..04e3162
--- /dev/null
+++ b/src/base/WideLine.cpp
@@ -0,0 +1,51 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WideLine.h"
+
+namespace avg {
+
+WideLine::WideLine(const DPoint& p0, const DPoint& p1, double width)
+ : pt0(p0),
+ pt1(p1)
+{
+ DPoint m = (pt1-pt0).getNormalized();
+ DPoint w = DPoint(m.y, -m.x)*width/2;
+ pl0 = p0-w;
+ pr0 = p0+w;
+ pl1 = p1-w;
+ pr1 = p1+w;
+ dir = DPoint(w.y, -w.x);
+}
+
+double WideLine::getLen() const
+{
+ return calcDist(pt0, pt1);
+}
+
+std::ostream& operator<<(std::ostream& os, const WideLine& line)
+{
+ os << "(" << line.pt0 << "," << line.pt1 << ")";
+ return os;
+}
+
+}
+
diff --git a/src/base/WideLine.h b/src/base/WideLine.h
new file mode 100644
index 0000000..0235c20
--- /dev/null
+++ b/src/base/WideLine.h
@@ -0,0 +1,48 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _WideLine_H_
+#define _WideLine_H_
+
+#include "../api.h"
+
+#include "Point.h"
+
+#include <iostream>
+
+namespace avg {
+
+struct AVG_API WideLine {
+ WideLine(const DPoint& p0, const DPoint& p1, double width);
+
+ double getLen() const;
+
+ DPoint pt0, pt1;
+ DPoint pl0, pl1;
+ DPoint pr0, pr1;
+ DPoint dir;
+};
+
+std::ostream& operator<<(std::ostream& os, const WideLine& line);
+
+}
+
+#endif
diff --git a/src/base/WorkerThread.h b/src/base/WorkerThread.h
new file mode 100644
index 0000000..6e5dba0
--- /dev/null
+++ b/src/base/WorkerThread.h
@@ -0,0 +1,166 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _WorkerThread_H_
+#define _WorkerThread_H_
+
+#include "../api.h"
+#include "Command.h"
+#include "Exception.h"
+#include "Logger.h"
+#include "Queue.h"
+#include "ThreadProfiler.h"
+#include "ObjectCounter.h"
+#include "CmdQueue.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <iostream>
+
+namespace avg {
+
+
+template<class DERIVED_THREAD>
+class AVG_TEMPLATE_API WorkerThread {
+public:
+ typedef Command<DERIVED_THREAD> Cmd;
+ typedef typename boost::shared_ptr<Cmd> CmdPtr;
+ typedef CmdQueue<DERIVED_THREAD> CQueue;
+ typedef typename boost::shared_ptr<CQueue> CQueuePtr;
+
+ WorkerThread(const std::string& sName, CQueue& CmdQ,
+ long logCategory=Logger::PROFILE);
+ WorkerThread(WorkerThread const& other);
+ virtual ~WorkerThread();
+ void operator()();
+
+ void waitForCommand();
+ void stop();
+
+private:
+ virtual bool init();
+ virtual bool work() = 0;
+ virtual void deinit() {};
+
+ void processCommands();
+
+ std::string m_sName;
+ bool m_bShouldStop;
+ CQueue& m_CmdQ;
+ long m_LogCategory;
+};
+
+template<class DERIVED_THREAD>
+WorkerThread<DERIVED_THREAD>::WorkerThread(const std::string& sName, CQueue& CmdQ,
+ long logCategory)
+ : m_sName(sName),
+ m_bShouldStop(false),
+ m_CmdQ(CmdQ),
+ m_LogCategory(logCategory)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+template<class DERIVED_THREAD>
+WorkerThread<DERIVED_THREAD>::WorkerThread(WorkerThread const& other)
+ : m_CmdQ(other.m_CmdQ)
+{
+ m_sName = other.m_sName;
+ m_bShouldStop = other.m_bShouldStop;
+ m_LogCategory = other.m_LogCategory;
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+template<class DERIVED_THREAD>
+WorkerThread<DERIVED_THREAD>::~WorkerThread()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+template<class DERIVED_THREAD>
+void WorkerThread<DERIVED_THREAD>::operator()()
+{
+ try {
+ ThreadProfilerPtr pProfiler = ThreadProfiler::get();
+ pProfiler->setName(m_sName);
+ pProfiler->setLogCategory(m_LogCategory);
+ bool bOK;
+ bOK = init();
+ if (!bOK) {
+ return;
+ }
+ pProfiler->start();
+ while (!m_bShouldStop) {
+ bOK = work();
+ if (!bOK) {
+ m_bShouldStop = true;
+ } else {
+ processCommands();
+ }
+ }
+ deinit();
+ pProfiler->dumpStatistics();
+ pProfiler->kill();
+ } catch (const Exception& e) {
+ AVG_TRACE(Logger::ERROR, "Uncaught exception in thread " << m_sName << ": "
+ << e.getStr());
+ throw;
+ }
+}
+
+template<class DERIVED_THREAD>
+void WorkerThread<DERIVED_THREAD>::waitForCommand()
+{
+ CmdPtr pCmd = m_CmdQ.pop(true);
+ pCmd->execute(dynamic_cast<DERIVED_THREAD*>(this));
+}
+
+template<class DERIVED_THREAD>
+void WorkerThread<DERIVED_THREAD>::stop()
+{
+ m_bShouldStop = true;
+}
+
+template<class DERIVED_THREAD>
+bool WorkerThread<DERIVED_THREAD>::init()
+{
+ return true;
+}
+
+template<class DERIVED_THREAD>
+void WorkerThread<DERIVED_THREAD>::processCommands()
+{
+ try {
+ CmdPtr pCmd = m_CmdQ.pop(false);
+ while (pCmd) {
+ pCmd->execute(dynamic_cast<DERIVED_THREAD*>(this));
+ pCmd = m_CmdQ.pop(false);
+ }
+ } catch (const Exception& e) {
+ AVG_TRACE(Logger::ERROR, "Uncaught exception in thread "
+ << m_sName << ": " << e.getStr());
+ }
+
+}
+
+}
+
+#endif
diff --git a/src/base/XMLHelper.cpp b/src/base/XMLHelper.cpp
new file mode 100644
index 0000000..0fa6bdf
--- /dev/null
+++ b/src/base/XMLHelper.cpp
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "XMLHelper.h"
+
+#include <libxml/parserInternals.h>
+#include <cstring>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+string getXmlChildrenAsString(const xmlDocPtr xmlDoc, const xmlNodePtr& xmlNode)
+{
+ string s;
+ xmlBufferPtr pBuffer = xmlBufferCreate();
+ xmlNodeDump(pBuffer, xmlDoc, xmlNode, 0, 0);
+
+ s = (const char *)xmlBufferContent(pBuffer);
+ size_t StartPos = s.find('>')+1;
+ size_t EndPos = s.rfind('<')-1;
+ if (StartPos > EndPos) {
+ s = "";
+ } else {
+ s = s.substr(StartPos, EndPos-StartPos+1);
+ }
+ xmlBufferFree(pBuffer);
+ return s;
+}
+
+static xmlExternalEntityLoader DefaultLoaderProc = 0;
+static std::map<string, string> g_DTDMap;
+
+xmlParserInputPtr
+DTDExternalEntityLoader(const char *pURL, const char *pID, xmlParserCtxtPtr ctxt)
+{
+ xmlParserInputPtr ret;
+ /* lookup for the fileID depending on ID */
+ std::map<string, string>::iterator it = g_DTDMap.find(pURL);
+
+ if (it != g_DTDMap.end()) {
+ ret = xmlNewStringInputStream(ctxt, (const xmlChar *)(it->second.c_str()));
+ return(ret);
+ } else {
+ ret = DefaultLoaderProc(pURL, pID, ctxt);
+ return(ret);
+ }
+}
+
+void registerDTDEntityLoader(const string& sID, const string& sDTD)
+{
+ g_DTDMap[sID] = sDTD;
+ if (!DefaultLoaderProc) {
+ DefaultLoaderProc = xmlGetExternalEntityLoader();
+ }
+ xmlSetExternalEntityLoader(DTDExternalEntityLoader);
+}
+
+}
diff --git a/src/base/XMLHelper.h b/src/base/XMLHelper.h
new file mode 100644
index 0000000..5557faf
--- /dev/null
+++ b/src/base/XMLHelper.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _XMLHelper_H_
+#define _XMLHelper_H_
+
+#include "../api.h"
+#include "Point.h"
+
+#include <libxml/parser.h>
+#include <libxml/xmlwriter.h>
+
+#include <string>
+#include <map>
+#include <sstream>
+
+namespace avg {
+
+std::string getXmlChildrenAsString(const xmlDocPtr xmlDoc, const xmlNodePtr& xmlNode);
+
+void registerDTDEntityLoader(const std::string& sID, const std::string& sDTD);
+
+}
+
+#endif //_XMLHelper_H_
+
diff --git a/src/base/testbase.cpp b/src/base/testbase.cpp
new file mode 100644
index 0000000..656714e
--- /dev/null
+++ b/src/base/testbase.cpp
@@ -0,0 +1,769 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Queue.h"
+#include "Command.h"
+#include "WorkerThread.h"
+#include "ObjectCounter.h"
+#include "Point.h"
+#include "Matrix3x4.h"
+#include "Triangulate.h"
+#include "GeomHelper.h"
+#include "OSHelper.h"
+#include "FileHelper.h"
+#include "StringHelper.h"
+#include "MathHelper.h"
+#include "CubicSpline.h"
+#include "BezierCurve.h"
+#include "Signal.h"
+#include "Backtrace.h"
+
+#include "TestSuite.h"
+#include "TimeSource.h"
+
+#include <boost/thread/thread.hpp>
+
+#include <boost/bind.hpp>
+
+#include <iostream>
+#include <sstream>
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace avg;
+using namespace std;
+using namespace boost;
+
+class QueueTest: public Test
+{
+public:
+ QueueTest()
+ : Test("QueueTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runSingleThreadTests();
+ runMultiThreadTests();
+ }
+
+private:
+ void runSingleThreadTests()
+ {
+ Queue<string> q;
+ typedef Queue<string>::QElementPtr ElemPtr;
+ TEST(q.empty());
+ q.push(ElemPtr(new string("1")));
+ TEST(q.size() == 1);
+ TEST(!q.empty());
+ q.push(ElemPtr(new string("2")));
+ q.push(ElemPtr(new string("3")));
+ TEST(q.size() == 3);
+ TEST(*q.pop() == "1");
+ TEST(*q.pop() == "2");
+ q.push(ElemPtr(new string("4")));
+ TEST(*q.pop() == "3");
+ TEST(*q.peek() == "4");
+ TEST(*q.pop() == "4");
+ TEST(q.empty());
+ ElemPtr pElem = q.pop(false);
+ TEST(!pElem);
+ }
+
+ void runMultiThreadTests()
+ {
+ {
+ Queue<string> q(10);
+ thread pusher(boost::bind(&pushThread, &q, 100));
+ thread popper(boost::bind(&popThread, &q, 100));
+ pusher.join();
+ popper.join();
+ TEST(q.empty());
+ }
+ {
+ Queue<string> q(10);
+ thread pusher1(boost::bind(&pushThread, &q, 100));
+ thread pusher2(boost::bind(&pushThread, &q, 100));
+ thread popper(boost::bind(&popThread, &q, 200));
+ pusher1.join();
+ pusher2.join();
+ popper.join();
+ TEST(q.empty());
+ }
+ }
+
+ static void pushThread(Queue<string>* pq, int numPushes)
+ {
+ typedef Queue<string>::QElementPtr ElemPtr;
+ for (int i=0; i<numPushes; ++i) {
+ stringstream ss;
+ ss << i;
+ string s = ss.str();
+ pq->push(ElemPtr(new string(s)));
+ msleep(1);
+ }
+ }
+
+ static void popThread(Queue<string>* pq, int numPops)
+ {
+ for (int i=0; i<numPops; ++i) {
+ pq->peek();
+ pq->pop();
+ msleep(3);
+ }
+ }
+};
+
+class TestWorkerThread: public WorkerThread<TestWorkerThread>
+{
+public:
+ TestWorkerThread(CQueue& cmdQ, int* pNumFuncCalls, int* pIntParam,
+ string* pStringParam)
+ : WorkerThread<TestWorkerThread>("Thread1", cmdQ),
+ m_pNumFuncCalls(pNumFuncCalls),
+ m_pIntParam(pIntParam),
+ m_pStringParam(pStringParam)
+ {
+ }
+
+ bool init()
+ {
+ (*m_pNumFuncCalls)++;
+ return true;
+ }
+
+ bool work()
+ {
+ (*m_pNumFuncCalls)++;
+ waitForCommand();
+ return true;
+ }
+
+ void deinit()
+ {
+ (*m_pNumFuncCalls)++;
+ }
+
+ void doSomething(int i, std::string s)
+ {
+ *m_pIntParam = i;
+ *m_pStringParam = s;
+ }
+
+private:
+ int * m_pNumFuncCalls;
+ int * m_pIntParam;
+ std::string * m_pStringParam;
+};
+
+
+class WorkerThreadTest: public Test
+{
+public:
+ WorkerThreadTest()
+ : Test("WorkerThreadTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ typedef TestWorkerThread::CmdPtr CmdPtr;
+ TestWorkerThread::CQueue cmdQ;
+ boost::thread* pTestThread;
+ int numFuncCalls = 0;
+ int intParam = 0;
+ std::string stringParam;
+ cmdQ.pushCmd(boost::bind(&TestWorkerThread::doSomething, _1, 23, "foo"));
+ cmdQ.pushCmd(boost::bind(&TestWorkerThread::stop, _1));
+ pTestThread = new boost::thread(TestWorkerThread(cmdQ, &numFuncCalls,
+ &intParam, &stringParam));
+ pTestThread->join();
+ delete pTestThread;
+ TEST(numFuncCalls == 3);
+ TEST(intParam == 23);
+ TEST(stringParam == "foo");
+ }
+};
+
+
+class DummyClass
+{
+public:
+ DummyClass()
+ {
+ ObjectCounter::get()->incRef(&typeid(*this));
+ }
+
+ virtual ~DummyClass()
+ {
+ ObjectCounter::get()->decRef(&typeid(*this));
+ }
+
+ int i;
+};
+
+
+class ObjectCounterTest: public Test {
+public:
+ ObjectCounterTest()
+ : Test("ObjectCounterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ TEST(ObjectCounter::get()->getCount(&typeid(DummyClass)) == 0);
+ {
+ DummyClass dummy1;
+ DummyClass dummy2;
+ TEST(ObjectCounter::get()->getCount(&typeid(dummy1)) == 2);
+ }
+ TEST(ObjectCounter::get()->getCount(&typeid(DummyClass)) == 0);
+ }
+};
+
+
+// The following pragmas avoid a compiler warning (potential division by 0)
+#ifdef _MSC_VER
+#pragma optimize("", off)
+#pragma warning(push)
+#pragma warning(disable:4723)
+#endif
+class PointTest: public Test
+{
+public:
+ PointTest()
+ : Test("PointTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ double one = 1;
+ double zero = 0;
+
+ TEST(isinf(-one/zero) != 0);
+ TEST(isinf(one/zero) != 0);
+ TEST(isinf(one) == 0);
+ TEST(isnan(sqrt(-one)) != 0);
+ TEST(isnan(sqrt(one+one)) == 0);
+
+ // TODO: Move to a separate math test once we're done here.
+ TEST(almostEqual(invSqrt(1), 1));
+ TEST(almostEqual(invSqrt(4), 0.5));
+
+ // TODO: The point tests aren't complete!
+ DPoint pt1(0,0);
+ DPoint pt2(3,4);
+ TEST(calcDist(pt1, pt2)-5 < 0.0001);
+ TEST(!almostEqual(pt1, pt2));
+ TEST(almostEqual(pt1, pt1));
+ std::vector<double> v;
+ v.push_back(3);
+ v.push_back(4);
+ DPoint pt3(v);
+ TEST(almostEqual(pt2, pt3));
+ TEST(almostEqual(pt3.getNorm(), 5));
+ DPoint pt4 = pt3.getNormalized();
+ TEST(almostEqual(pt4.getNorm(), 1, 0.0001));
+ {
+ DLineSegment l1(DPoint(0,0), DPoint(2,2));
+ DLineSegment l2(DPoint(2,0), DPoint(0,2));
+ TEST(lineSegmentsIntersect(l1, l2));
+ TEST(lineSegmentsIntersect(l2, l1));
+ }
+ {
+ DLineSegment l1(DPoint(0,0), DPoint(0,2));
+ DLineSegment l2(DPoint(2,0), DPoint(2,2));
+ TEST(!lineSegmentsIntersect(l1, l2));
+ }
+ {
+ DLineSegment l1(DPoint(0,0), DPoint(2,0));
+ DLineSegment l2(DPoint(0,2), DPoint(2,2));
+ TEST(!lineSegmentsIntersect(l1, l2));
+ }
+ {
+ DLineSegment l1(DPoint(0,0), DPoint(2,0));
+ TEST(l1.isPointOver(DPoint(1,23)));
+ TEST(l1.isPointOver(DPoint(1.9,-5)));
+ TEST(!l1.isPointOver(DPoint(-1,1)));
+ TEST(!l1.isPointOver(DPoint(3,-1)));
+ }
+ {
+ DPoint pt0(DPoint(1,1));
+ DPoint pt1(DPoint(1,3));
+ DPoint pt2(DPoint(1,-2));
+ vector<DPoint> poly;
+ poly.push_back(DPoint(0,0));
+ poly.push_back(DPoint(2,0));
+ poly.push_back(DPoint(2,2));
+ poly.push_back(DPoint(0,2));
+ TEST(pointInPolygon(pt0, poly));
+ TEST(!pointInPolygon(pt1, poly));
+ TEST(!pointInPolygon(pt2, poly));
+ poly.push_back(DPoint(2,1));
+ TEST(!pointInPolygon(pt0, poly));
+ }
+ {
+ DPoint p1(DPoint(0,0));
+ DPoint v1(DPoint(1,1));
+ DPoint p2(DPoint(2,1));
+ DPoint v2(DPoint(1,0));
+ TEST(getLineLineIntersection(p1, v1, p2, v2) == DPoint(1,1));
+ }
+ TEST(almostEqual(DPoint(10,0).getRotatedPivot(M_PI, DPoint(15,5)), DPoint(20,10)));
+ TEST(almostEqual(DPoint(10,0).getRotatedPivot(M_PI*0.5, DPoint(15,5)),
+ DPoint(20,0)));
+ TEST(almostEqual(DPoint(10,0).getRotatedPivot(M_PI*1.5, DPoint(15,5)),
+ DPoint(10,10)));
+ TEST(almostEqual(DPoint(10,0).getRotatedPivot(M_PI*2, DPoint(15,5)),
+ DPoint(10,0)));
+ TEST(almostEqual(DPoint(23,0).getRotatedPivot(M_PI*0.5), DPoint(0,23)));
+
+ TEST(almostEqual(DPoint(10,0), DPoint::fromPolar(0, 10)));
+ TEST(almostEqual(DPoint(0,10), DPoint::fromPolar(M_PI*0.5, 10)));
+ TEST(almostEqual(DPoint(0,-1), DPoint::fromPolar(M_PI*1.5, 1)));
+ TEST(almostEqual(vecAngle(DPoint(0,1),DPoint(1,0)), M_PI*0.5));
+ TEST(almostEqual(vecAngle(DPoint(0,-1),DPoint(1,0)), M_PI*1.5));
+ TEST(almostEqual(vecAngle(DPoint(0,2),DPoint(1,0)), M_PI*0.5));
+ }
+};
+#ifdef _MSC_VER
+#pragma warning(pop)
+#pragma optimize("", on)
+#endif
+
+
+class Matrix3x4Test: public Test
+{
+public:
+ Matrix3x4Test()
+ : Test("Matrix3x4Test", 2)
+ {
+ }
+
+ void runTests()
+ {
+ Matrix3x4 mat1;
+ Matrix3x4 mat2;
+ mat1 *= mat2;
+ TEST(almostEqual(mat1, Matrix3x4()));
+
+ mat2 = Matrix3x4::createTranslate(0,0,0);
+ mat1 *= mat2;
+ TEST(almostEqual(mat1, Matrix3x4()));
+
+ mat2 = Matrix3x4::createScale(1,1,1);
+ mat1 *= mat2;
+ TEST(almostEqual(mat1, Matrix3x4()));
+ }
+};
+
+
+class TriangleTest: public Test
+{
+public:
+ TriangleTest()
+ : Test("TriangleTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ Triangle tri(DPoint(0,0), DPoint(4,4), DPoint(4,8));
+ TEST(tri.isInside(DPoint(3,4)));
+ TEST(!tri.isInside(DPoint(1,4)));
+ TEST(!tri.isInside(DPoint(2,1)));
+ TEST(!tri.isInside(DPoint(-2,5)));
+ TEST(!tri.isInside(DPoint(5,5)));
+ tri = Triangle(DPoint(0,0), DPoint(4,8), DPoint(4,4));
+ TEST(tri.isInside(DPoint(3,4)));
+
+ DPoint polyArray[] = {DPoint(0,0), DPoint(8,2), DPoint(9,0), DPoint(9,3),
+ DPoint(1,1), DPoint(0,3)};
+
+ DPointVector poly = vectorFromCArray(6, polyArray);
+
+ vector<int> triangulation;
+ triangulatePolygon(poly, triangulation);
+
+ TEST(triangulation.size() == 4*3);
+ int baselineIndexes[] = {1,2,3, 4,5,0, 0,1,3, 3,4,0};
+ TEST(triangulation == vectorFromCArray(12, baselineIndexes));
+/*
+ for (unsigned int i=0; i<triangulation.size(); i++) {
+ cerr << i << ":" << triangulation[i] << endl;
+ }
+*/
+ }
+
+};
+
+
+class FileTest: public Test
+{
+public:
+ FileTest()
+ : Test("FileTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ TEST(getPath("/foo/bar.txt") == "/foo/");
+ TEST(getFilenamePart("/foo/bar.txt") == "bar.txt");
+ }
+};
+
+
+class OSTest: public Test
+{
+public:
+ OSTest()
+ : Test("OSTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+#if defined(__APPLE__) || defined(_WIN32)
+ TEST(getAvgLibPath() != "");
+#endif
+#ifdef __APPLE__
+ TEST(getMemoryUsage() != 0);
+#endif
+ }
+};
+
+
+class StringTest: public Test
+{
+public:
+ StringTest()
+ : Test("StringTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ TEST(stringToInt("5") == 5);
+ TEST(almostEqual(stringToDouble("5.5"), 5.5));
+ TEST(stringToBool("False") == false);
+ bool bExceptionThrown = false;
+ try {
+ stringToInt("5a");
+ } catch (const Exception& e) {
+ if (e.getCode() == AVG_ERR_TYPE ) {
+ bExceptionThrown = true;
+ }
+ }
+ TEST(bExceptionThrown);
+ TEST(stringToDPoint(" ( 3.4 , 2.1 ) ") == DPoint(3.4, 2.1));
+ vector<double> v;
+ fromString("(1,2,3,4,5)", v);
+ TEST(v.size() == 5 && v[0] == 1 && v[4] == 5);
+ v.clear();
+ fromString("()", v);
+ TEST(v.size() == 0);
+ }
+};
+
+
+class SplineTest: public Test
+{
+public:
+ SplineTest()
+ : Test("SplineTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ {
+ double xd[] = {0,1,2,3};
+ vector<double> x = vectorFromCArray(4, xd);
+ double yd[] = {3,2,1,0};
+ vector<double> y = vectorFromCArray(4, yd);
+ CubicSpline spline(x, y);
+ TEST(almostEqual(spline.interpolate(-1), 4));
+ TEST(almostEqual(spline.interpolate(0), 3));
+ TEST(almostEqual(spline.interpolate(0.5), 2.5));
+ TEST(almostEqual(spline.interpolate(3), 0));
+ TEST(almostEqual(spline.interpolate(3.5), -0.5));
+ }
+ {
+ double xd[] = {2,4,6,8};
+ vector<double> x = vectorFromCArray(4, xd);
+ double yd[] = {0,1,3,6};
+ vector<double> y = vectorFromCArray(4, yd);
+ CubicSpline spline(x, y);
+ TEST(almostEqual(spline.interpolate(0), -1));
+ TEST(almostEqual(spline.interpolate(1), -0.5));
+ TEST(almostEqual(spline.interpolate(2), 0));
+ TEST(spline.interpolate(3) < 0.5);
+ TEST(almostEqual(spline.interpolate(8), 6));
+ TEST(almostEqual(spline.interpolate(9), 7.5));
+ TEST(almostEqual(spline.interpolate(10), 9));
+ }
+ }
+};
+
+
+class BezierCurveTest: public Test
+{
+public:
+ BezierCurveTest()
+ : Test("BezierCurveTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BezierCurve curve(DPoint(0,0), DPoint(1,0), DPoint(1,1), DPoint(0,1));
+ TEST(almostEqual(curve.interpolate(0), DPoint(0,0)));
+ TEST(almostEqual(curve.getDeriv(0), DPoint(3, 0)));
+ TEST(almostEqual(curve.interpolate(1), DPoint(0,1)));
+ TEST(almostEqual(curve.getDeriv(1), DPoint(-3, 0)));
+ TEST(almostEqual(curve.interpolate(0.5), DPoint(0.75,0.5)));
+ }
+};
+
+
+class Listener
+{
+public:
+ Listener(Signal<Listener>& signal)
+ : m_Signal(signal),
+ m_bFuncCalled(false)
+ {
+ }
+
+ virtual ~Listener()
+ {}
+
+ virtual void func()
+ {
+ m_bFuncCalled = true;
+ }
+
+ bool funcCalled() const
+ {
+ return m_bFuncCalled;
+ }
+
+ void reset()
+ {
+ m_bFuncCalled = false;
+ }
+
+protected:
+ Signal<Listener>& m_Signal;
+
+private:
+ bool m_bFuncCalled;
+};
+
+
+class DisconnectingSelfListener: public Listener
+{
+public:
+ DisconnectingSelfListener(Signal<Listener>& signal)
+ : Listener(signal)
+ {
+ }
+
+ virtual void func()
+ {
+ Listener::func();
+ m_Signal.disconnect(this);
+ }
+};
+
+
+class DisconnectingOtherListener: public Listener
+{
+public:
+ DisconnectingOtherListener(Signal<Listener>& signal, Listener* pOther)
+ : Listener(signal),
+ m_pOther(pOther)
+ {
+ }
+
+ virtual void func()
+ {
+ Listener::func();
+ if (m_pOther) {
+ m_Signal.disconnect(m_pOther);
+ m_pOther = 0;
+ }
+ }
+
+private:
+ Listener* m_pOther;
+};
+
+
+class ConnectingOtherListener: public Listener
+{
+public:
+ ConnectingOtherListener(Signal<Listener>& signal, Listener* pOther)
+ : Listener(signal),
+ m_pOther(pOther)
+ {
+ }
+
+ virtual void func()
+ {
+ Listener::func();
+ if (m_pOther) {
+ m_Signal.connect(m_pOther);
+ m_pOther = 0;
+ }
+ }
+
+private:
+ Listener* m_pOther;
+};
+
+
+class SignalTest: public Test
+{
+public:
+ SignalTest()
+ : Test("SignalTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ Signal<Listener> s(&Listener::func);
+ Listener l1(s);
+ Listener l2(s);
+ s.connect(&l1);
+ s.connect(&l2);
+ s.emit();
+ TEST(l1.funcCalled() && l2.funcCalled());
+ l1.reset();
+ l2.reset();
+
+ s.disconnect(&l1);
+ s.emit();
+ TEST(!(l1.funcCalled()) && l2.funcCalled());
+ l2.reset();
+
+ {
+ DisconnectingSelfListener disconnecter(s);
+ s.connect(&disconnecter);
+ s.emit();
+ TEST(l2.funcCalled() && disconnecter.funcCalled());
+ TEST(s.getNumListeners() == 1);
+ l2.reset();
+ disconnecter.reset();
+
+ s.emit();
+ TEST(l2.funcCalled() && !(disconnecter.funcCalled()));
+ l2.reset();
+ }
+ {
+ DisconnectingOtherListener disconnecter(s, &l2);
+ s.connect(&disconnecter);
+ s.emit();
+ TEST(l2.funcCalled() && disconnecter.funcCalled());
+ TEST(s.getNumListeners() == 1);
+ l2.reset();
+ disconnecter.reset();
+
+ s.emit();
+ TEST(!(l2.funcCalled()) && disconnecter.funcCalled());
+ s.disconnect(&disconnecter);
+ }
+ {
+ ConnectingOtherListener connecter(s, &l2);
+ s.connect(&connecter);
+ s.emit();
+ TEST(l2.funcCalled() && connecter.funcCalled());
+ TEST(s.getNumListeners() == 2);
+ l2.reset();
+ connecter.reset();
+
+ s.emit();
+ TEST(l2.funcCalled() && connecter.funcCalled());
+ }
+ }
+};
+
+
+class BacktraceTest: public Test
+{
+public:
+ BacktraceTest()
+ : Test("BacktraceTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ vector<string> sFuncs;
+ getBacktrace(sFuncs);
+#ifndef _WIN32
+ TEST(sFuncs[0].find("runTests") != string::npos);
+#endif
+ }
+};
+
+
+class BaseTestSuite: public TestSuite
+{
+public:
+ BaseTestSuite()
+ : TestSuite("BaseTestSuite")
+ {
+ addTest(TestPtr(new QueueTest));
+ addTest(TestPtr(new WorkerThreadTest));
+ addTest(TestPtr(new ObjectCounterTest));
+ addTest(TestPtr(new PointTest));
+ addTest(TestPtr(new Matrix3x4Test));
+ addTest(TestPtr(new TriangleTest));
+ addTest(TestPtr(new FileTest));
+ addTest(TestPtr(new OSTest));
+ addTest(TestPtr(new StringTest));
+ addTest(TestPtr(new SplineTest));
+ addTest(TestPtr(new BezierCurveTest));
+ addTest(TestPtr(new SignalTest));
+ addTest(TestPtr(new BacktraceTest));
+ }
+};
+
+
+int main(int nargs, char** args)
+{
+ BaseTestSuite suite;
+ suite.runTests();
+ bool bOK = suite.isOk();
+
+ if (bOK) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
diff --git a/src/conradrelais/ConradRelais.cpp b/src/conradrelais/ConradRelais.cpp
new file mode 100644
index 0000000..3fa4336
--- /dev/null
+++ b/src/conradrelais/ConradRelais.cpp
@@ -0,0 +1,179 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ConradRelais.h"
+#include "../base/Logger.h"
+
+#include <termios.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <math.h>
+#include <errno.h>
+#include <iostream>
+#include <sstream>
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+ConradRelais::ConradRelais(Player * pPlayer, int port)
+ : m_IsInitialized(false),
+ m_File(-1),
+ m_NumCards(0),
+ m_pPlayer(pPlayer)
+{
+ m_Port = port;
+ stringstream s;
+ s << "/dev/ttyS" << m_Port;
+ m_File = open(s.str().c_str(), O_RDWR | O_NOCTTY | O_NDELAY); //O_NONBLOCK);
+ if (m_File == -1) {
+ AVG_TRACE(Logger::ERROR, "Could not open " << s.str()
+ << " for conrad relais card (Reason:'" << strerror(errno)
+ << "'). Disabling.");
+ } else {
+ initBoard();
+ if (m_File != -1) {
+ pPlayer->registerFrameEndListener(this);
+ }
+ }
+}
+
+ConradRelais::~ConradRelais()
+{
+ if (m_File != -1) {
+ send();
+ m_pPlayer->unregisterFrameEndListener(this);
+ close(m_File);
+ m_File = -1;
+ }
+}
+
+int ConradRelais::getNumCards()
+{
+ return m_NumCards;
+}
+
+void ConradRelais::set(int card, int index, bool bOn)
+{
+ if (m_File != -1) {
+ unsigned char bitMask = (unsigned char)(pow((double)2, index));
+ if (bOn) {
+ m_State[card] |= bitMask;
+ } else {
+ m_State[card] &= 255-bitMask;
+ }
+ }
+}
+
+bool ConradRelais::get(int card, int index)
+{
+ unsigned char bitMask = (unsigned char)(pow((double)2, index));
+ return (bitMask & m_State[card]) == bitMask;
+}
+
+void ConradRelais::send()
+{
+ if (m_File != -1) {
+ for (int i=0; i<m_NumCards; i++) {
+ sendCmd(3,i+1,m_State[i]);
+ }
+ }
+}
+
+void ConradRelais::initBoard()
+{
+ fcntl(m_File, F_SETFL, 0);
+
+ /* get the current options */
+ struct termios options;
+ tcgetattr(m_File, &options);
+
+ /* set in and out speed */
+ cfsetispeed(&options, B19200);
+ cfsetospeed(&options, B19200);
+
+ options.c_cflag &= ~PARENB;
+ options.c_cflag &= ~CSTOPB;
+ options.c_cflag &= ~CSIZE; /* Mask the character size bits */
+ options.c_cflag |= CS8; /* Select 8 data bits */
+
+ /* set raw input, 1 second timeout */
+ options.c_cflag |= (CLOCAL | CREAD);
+ options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
+ options.c_oflag &= ~OPOST;
+ options.c_cc[VMIN] = 0;
+ options.c_cc[VTIME] = 10;
+
+ /* set the options */
+ tcsetattr(m_File, TCSAFLUSH, &options);
+
+ /*
+ * init the circuit board
+ */
+ sendCmd(1, 1, 0);
+ fcntl(m_File, F_SETFL, FNDELAY);
+ fcntl(m_File, F_SETFL, 0);
+ unsigned char rbuf[4];
+ m_NumCards = 0;
+ bool bOk = true;
+ // One read per card should succeed.
+ while (bOk) {
+ ssize_t rc = read(m_File, rbuf, 4);
+ if (rc != 4 || rbuf[0] != 254 || rbuf[1] != m_NumCards+1) {
+ bOk = false;
+ } else {
+ m_NumCards++;
+ }
+ }
+ if (m_NumCards == 0) {
+ AVG_TRACE(Logger::ERROR,
+ "No Conrad Relais cards detected. Disabling relais output.");
+ close(m_File);
+ m_File = -1;
+ }
+}
+
+void ConradRelais::sendCmd(unsigned char a, unsigned char b, unsigned char c)
+{
+ unsigned char Buffer[4];
+ Buffer[0] = a;
+ Buffer[1] = b;
+ Buffer[2] = c;
+ Buffer[3] = Buffer[0]^Buffer[1]^Buffer[2];
+
+ ssize_t BytesWritten = write(m_File, Buffer, 4);
+ if (BytesWritten != 4) {
+ AVG_TRACE(Logger::ERROR,
+ "Could not send data to conrad relais card. Disabling.");
+ close(m_File);
+ m_File = -1;
+ }
+}
+
+void ConradRelais::onFrameEnd()
+{
+ send();
+}
+
+}
diff --git a/src/conradrelais/ConradRelais.h b/src/conradrelais/ConradRelais.h
new file mode 100644
index 0000000..e133048
--- /dev/null
+++ b/src/conradrelais/ConradRelais.h
@@ -0,0 +1,74 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ConradRelais_H_
+#define _ConradRelais_H_
+
+#include "../api.h"
+#include "../base/IFrameEndListener.h"
+
+#include "../player/Player.h"
+
+namespace avg {
+
+/**
+ * Interface to one or more conrad relais card connected to a serial
+ * port. Per card, up to eight 220V devices can be turned on or off.
+ */
+class AVG_API ConradRelais: public IFrameEndListener
+{
+ public:
+ ConradRelais (Player * pPlayer, int port);
+ virtual ~ConradRelais ();
+
+ /**
+ * Returns the number of cards connected to the serial port.
+ */
+ int getNumCards();
+ /**
+ * Sets or resets one of the relais. index selects the relais
+ * to set.
+ */
+ void set(int card, int index, bool bOn);
+ /**
+ * Returns the state of one of the relais. index selects the
+ * relais to query.
+ */
+ bool get(int card, int index);
+
+ void send();
+
+ virtual void onFrameEnd();
+
+ private:
+ void sendCmd(unsigned char a, unsigned char b, unsigned char c);
+ void initBoard();
+ unsigned char m_State[256];
+ bool m_IsInitialized;
+ int m_Port;
+ int m_File;
+ int m_NumCards;
+
+ Player * m_pPlayer;
+};
+
+}
+#endif
diff --git a/src/conradrelais/Makefile.am b/src/conradrelais/Makefile.am
new file mode 100644
index 0000000..57eb05e
--- /dev/null
+++ b/src/conradrelais/Makefile.am
@@ -0,0 +1,7 @@
+
+INCLUDES = -I. @XML2_CFLAGS@ @PYTHON_INCLUDES@ @PTHREAD_CFLAGS@
+
+ALL_H = ConradRelais.h
+
+noinst_LTLIBRARIES = libconradrelais.la
+libconradrelais_la_SOURCES = ConradRelais.cpp $(ALL_H)
diff --git a/src/conradrelais/Makefile.in b/src/conradrelais/Makefile.in
new file mode 100644
index 0000000..8bce698
--- /dev/null
+++ b/src/conradrelais/Makefile.in
@@ -0,0 +1,576 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/conradrelais
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libconradrelais_la_LIBADD =
+am__objects_1 =
+am_libconradrelais_la_OBJECTS = ConradRelais.lo $(am__objects_1)
+libconradrelais_la_OBJECTS = $(am_libconradrelais_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libconradrelais_la_SOURCES)
+DIST_SOURCES = $(libconradrelais_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I. @XML2_CFLAGS@ @PYTHON_INCLUDES@ @PTHREAD_CFLAGS@
+ALL_H = ConradRelais.h
+noinst_LTLIBRARIES = libconradrelais.la
+libconradrelais_la_SOURCES = ConradRelais.cpp $(ALL_H)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/conradrelais/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/conradrelais/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libconradrelais.la: $(libconradrelais_la_OBJECTS) $(libconradrelais_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libconradrelais_la_OBJECTS) $(libconradrelais_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ConradRelais.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/graphics/Bitmap.cpp b/src/graphics/Bitmap.cpp
new file mode 100644
index 0000000..1755fd0
--- /dev/null
+++ b/src/graphics/Bitmap.cpp
@@ -0,0 +1,1823 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Bitmap.h"
+#include "Pixel24.h"
+#include "Pixel16.h"
+#include "Pixel8.h"
+#include "Filter3x3.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+#include "../base/StringHelper.h"
+#include "../base/MathHelper.h"
+#include "../base/FileHelper.h"
+#include "../base/OSHelper.h"
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <cstring>
+#include <iostream>
+#include <iomanip>
+#include <stdlib.h>
+
+using namespace std;
+
+namespace avg {
+
+template<class Pixel>
+void createTrueColorCopy(Bitmap& destBmp, const Bitmap & srcBmp);
+
+bool Bitmap::s_bGTKInitialized = false;
+
+Bitmap::Bitmap(DPoint size, PixelFormat pf, const UTF8String& sName, int stride)
+ : m_Size(size),
+ m_PF(pf),
+ m_pBits(0),
+ m_bOwnsBits(true),
+ m_sName(sName)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ allocBits(stride);
+}
+
+Bitmap::Bitmap(IntPoint size, PixelFormat pf, const UTF8String& sName, int stride)
+ : m_Size(size),
+ m_PF(pf),
+ m_pBits(0),
+ m_bOwnsBits(true),
+ m_sName(sName)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ allocBits(stride);
+}
+
+Bitmap::Bitmap(IntPoint size, PixelFormat pf, unsigned char* pBits,
+ int stride, bool bCopyBits, const UTF8String& sName)
+ : m_Size(size),
+ m_PF(pf),
+ m_pBits(0),
+ m_sName(sName)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ initWithData(pBits, stride, bCopyBits);
+}
+
+Bitmap::Bitmap(const Bitmap& origBmp)
+ : m_Size(origBmp.getSize()),
+ m_PF(origBmp.getPixelFormat()),
+ m_pBits(0),
+ m_bOwnsBits(origBmp.m_bOwnsBits),
+ m_sName(origBmp.getName()+" copy")
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ initWithData(const_cast<unsigned char *>(origBmp.getPixels()), origBmp.getStride(),
+ m_bOwnsBits);
+}
+
+Bitmap::Bitmap(const Bitmap& origBmp, bool bOwnsBits)
+ : m_Size(origBmp.getSize()),
+ m_PF(origBmp.getPixelFormat()),
+ m_pBits(0),
+ m_bOwnsBits(bOwnsBits),
+ m_sName(origBmp.getName()+" copy")
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ initWithData(const_cast<unsigned char *>(origBmp.getPixels()), origBmp.getStride(),
+ m_bOwnsBits);
+}
+
+// Creates a bitmap that is a rectangle in another bitmap. The pixels are
+// still owned by the original bitmap.
+Bitmap::Bitmap(Bitmap& origBmp, const IntRect& rect)
+ : m_Size(rect.size()),
+ m_PF(origBmp.getPixelFormat()),
+ m_pBits(0),
+ m_bOwnsBits(false)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ AVG_ASSERT(rect.br.x <= origBmp.getSize().x);
+ AVG_ASSERT(rect.br.y <= origBmp.getSize().y);
+ AVG_ASSERT(rect.tl.x >= 0 && rect.tl.y >= 0);
+ if (!origBmp.getName().empty()) {
+ m_sName = origBmp.getName()+" part";
+ } else {
+ m_sName = "";
+ }
+ unsigned char * pRegionStart = origBmp.getPixels()+rect.tl.y*origBmp.getStride()+
+ rect.tl.x*getBytesPerPixel();
+ initWithData(pRegionStart, origBmp.getStride(), false);
+}
+
+Bitmap::Bitmap(const UTF8String& sName)
+ : m_pBits(0),
+ m_sName(sName)
+{
+ if (!s_bGTKInitialized) {
+ g_type_init();
+ s_bGTKInitialized = true;
+ }
+
+ GError* pError = 0;
+ GdkPixbuf* pPixBuf = gdk_pixbuf_new_from_file(sName.c_str(), &pError);
+ if (!pPixBuf) {
+ string sErr = pError->message;
+ g_error_free(pError);
+ throw Exception(AVG_ERR_FILEIO, sErr);
+ }
+ m_Size = IntPoint(gdk_pixbuf_get_width(pPixBuf), gdk_pixbuf_get_height(pPixBuf));
+ if (gdk_pixbuf_get_has_alpha(pPixBuf)) {
+ m_PF = B8G8R8A8;
+ } else {
+ m_PF = B8G8R8X8;
+ }
+ int stride = gdk_pixbuf_get_rowstride(pPixBuf);
+ allocBits();
+ guchar* pSrc = gdk_pixbuf_get_pixels(pPixBuf);
+ for (int y = 0; y < m_Size.y; ++y) {
+ unsigned char* pDestLine = m_pBits+m_Stride*y;
+ guchar* pSrcLine = pSrc + y*stride;
+ if (m_PF == B8G8R8A8) {
+ unsigned char* pDestPixel = pDestLine;
+ guchar* pSrcPixel = pSrcLine;
+ for (int x = 0; x < m_Size.x; ++x) {
+ pDestPixel[0] = pSrcPixel[2];
+ pDestPixel[1] = pSrcPixel[1];
+ pDestPixel[2] = pSrcPixel[0];
+ pDestPixel[3] = pSrcPixel[3];
+ pDestPixel += 4;
+ pSrcPixel += 4;
+ }
+ } else {
+ unsigned char* pDestPixel = pDestLine;
+ guchar* pSrcPixel = pSrcLine;
+ for (int x = 0; x < m_Size.x; ++x) {
+ pDestPixel[0] = pSrcPixel[2];
+ pDestPixel[1] = pSrcPixel[1];
+ pDestPixel[2] = pSrcPixel[0];
+ pDestPixel[3] = 255;
+ pDestPixel += 4;
+ pSrcPixel += 3;
+ }
+ }
+ }
+ m_bOwnsBits = true;
+ g_object_unref(pPixBuf);
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+Bitmap::~Bitmap()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+ if (m_bOwnsBits) {
+ delete[] m_pBits;
+ m_pBits = 0;
+ }
+}
+
+Bitmap &Bitmap::operator =(const Bitmap& origBmp)
+{
+ if (this != &origBmp) {
+ if (m_bOwnsBits) {
+ delete[] m_pBits;
+ m_pBits = 0;
+ }
+ m_Size = origBmp.getSize();
+ m_PF = origBmp.getPixelFormat();
+ m_bOwnsBits = origBmp.m_bOwnsBits;
+ m_sName = origBmp.getName();
+ initWithData(const_cast<unsigned char *>(origBmp.getPixels()),
+ origBmp.getStride(), m_bOwnsBits);
+ }
+ return *this;
+}
+
+void Bitmap::copyPixels(const Bitmap& origBmp)
+{
+// cerr << "Bitmap::copyPixels(): " << getPixelFormatString(origBmp.getPixelFormat())
+// << "->" << getPixelFormatString(m_PF) << endl;
+ if (&origBmp == this || origBmp.getPixels() == m_pBits) {
+ return;
+ }
+ if (origBmp.getPixelFormat() == m_PF) {
+ const unsigned char * pSrc = origBmp.getPixels();
+ unsigned char * pDest = m_pBits;
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int LineLen = min(origBmp.getLineLen(), getLineLen());
+ int srcStride = origBmp.getStride();
+ for (int y = 0; y < height; ++y) {
+ memcpy(pDest, pSrc, LineLen);
+ pDest += m_Stride;
+ pSrc += srcStride;
+ }
+ } else {
+ switch (origBmp.getPixelFormat()) {
+ case YCbCr422:
+ case YUYV422:
+ case YCbCr411:
+ switch(m_PF) {
+ case B8G8R8X8:
+ YCbCrtoBGR(origBmp);
+ break;
+ case I8:
+ YCbCrtoI8(origBmp);
+ default: {
+ Bitmap TempBmp(getSize(), B8G8R8X8, "TempColorConversion");
+ TempBmp.YCbCrtoBGR(origBmp);
+ copyPixels(TempBmp);
+ }
+ break;
+ }
+ break;
+ case I16:
+ if (m_PF == I8) {
+ I16toI8(origBmp);
+ } else {
+ Bitmap TempBmp(getSize(), I8, "TempColorConversion");
+ TempBmp.I16toI8(origBmp);
+ copyPixels(TempBmp);
+ }
+ break;
+ case I8:
+ switch(m_PF) {
+ case I16:
+ I8toI16(origBmp);
+ break;
+ case B8G8R8X8:
+ case B8G8R8A8:
+ case R8G8B8X8:
+ case R8G8B8A8:
+ case B8G8R8:
+ case R8G8B8:
+ I8toRGB(origBmp);
+ break;
+ default:
+ // Unimplemented conversion.
+ AVG_ASSERT(false);
+ }
+ break;
+ case BAYER8_RGGB:
+ case BAYER8_GBRG:
+ case BAYER8_GRBG:
+ case BAYER8_BGGR:
+ switch(m_PF) {
+ case I8:
+ {
+ // Bayer patterns are saved as I8 bitmaps.
+ // So simply copy that.
+ const unsigned char * pSrc = origBmp.getPixels();
+ unsigned char * pDest = m_pBits;
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int lineLen = min(origBmp.getLineLen(), getLineLen());
+ int srcStride = origBmp.getStride();
+ for (int y = 0; y < height; ++y) {
+ memcpy(pDest, pSrc, lineLen);
+ pDest += m_Stride;
+ pSrc += srcStride;
+ }
+ }
+ break;
+ case B8G8R8X8:
+ case B8G8R8A8:
+ case R8G8B8X8:
+ case R8G8B8A8:
+ BY8toRGBBilinear(origBmp);
+ break;
+ default:
+ // Unimplemented conversion.
+ AVG_ASSERT(false);
+ }
+ break;
+ case R32G32B32A32F:
+ if (getBytesPerPixel() == 4) {
+ FloatRGBAtoByteRGBA(origBmp);
+ } else {
+ cerr << "Can't convert " << origBmp.getPixelFormat() << " to "
+ << getPixelFormat() << endl;
+ AVG_ASSERT(false);
+ }
+ break;
+ default:
+ switch(m_PF) {
+ case R32G32B32A32F:
+ if (origBmp.getBytesPerPixel() == 4) {
+ ByteRGBAtoFloatRGBA(origBmp);
+ } else {
+ cerr << "Can't convert " << origBmp.getPixelFormat() <<
+ " to " << getPixelFormat() << endl;
+ AVG_ASSERT(false);
+ }
+ break;
+ case B8G8R8A8:
+ case B8G8R8X8:
+ case A8B8G8R8:
+ case X8B8G8R8:
+ case R8G8B8A8:
+ case R8G8B8X8:
+ case A8R8G8B8:
+ case X8R8G8B8:
+ createTrueColorCopy<Pixel32>(*this, origBmp);
+ break;
+ case B8G8R8:
+ case R8G8B8:
+ createTrueColorCopy<Pixel24>(*this, origBmp);
+ break;
+ case B5G6R5:
+ case R5G6B5:
+ createTrueColorCopy<Pixel16>(*this, origBmp);
+ break;
+ case I8:
+ createTrueColorCopy<Pixel8>(*this, origBmp);
+ break;
+ default:
+ // Unimplemented conversion.
+ cerr << "Can't convert " << origBmp.getPixelFormat() << " to " <<
+ getPixelFormat() << endl;
+ AVG_ASSERT(false);
+ }
+ }
+ }
+}
+
+#if defined(__SSE__) || defined(_WIN32)
+ostream& operator<<(ostream& os, const __m64 &val)
+{
+ unsigned char * pVal = (unsigned char *)(&val);
+ for (int i = 0; i < 8; ++i) {
+ os << hex << setw(2) << setfill('0') << int(pVal[i]);
+ if (i%2 == 1) {
+ os << " ";
+ }
+ if (i%4 == 3) {
+ os << " ";
+ }
+ }
+ return os;
+}
+#endif
+
+#define YUV_TO_RGB_UNPACK \
+ /* Input: r, g, b contain 4 words each of the u and v inputs for the color */ \
+ /* channels. ylo and yhi contain 4 words each of the y input. */ \
+\
+ /* duplicate u and v channels and add y \
+ * each of r,g, b in the form [s1(16), s2(16), s3(16), s4(16)] \
+ * first interleave, so tmp is [s1(16), s1(16), s2(16), s2(16)] \
+ * then add y, then interleave again \
+ * then pack with saturation, to get the desired output of \
+ * [s1(8), s1(8), s2(8), s2(8), s3(8), s3(8), s4(8), s4(8)] \
+ */ \
+ tmp = _m_punpckhwd(r, r); \
+ tmp = _m_paddsw(tmp, yhi); \
+ tmp2 = _m_punpcklwd(r, r); \
+ tmp2 = _m_paddsw(tmp2, ylo); \
+ r = _m_packuswb(tmp2, tmp); \
+ \
+ tmp = _m_punpckhwd(g, g); \
+ tmp2 = _m_punpcklwd(g, g); \
+ tmp = _m_paddsw(tmp, yhi); \
+ tmp2 = _m_paddsw(tmp2, ylo); \
+ g = _m_packuswb(tmp2, tmp); \
+ \
+ tmp = _m_punpckhwd(b, b); \
+ tmp2 = _m_punpcklwd(b, b); \
+ tmp = _m_paddsw(tmp, yhi); \
+ tmp2 = _m_paddsw(tmp2, ylo); \
+ b = _m_packuswb(tmp2, tmp); \
+ \
+ /* now we have 8 8-bit r, g and b samples. we want these to be packed \
+ * into 32-bit values. \
+ */ \
+ imm = _mm_set1_pi32(0xFFFFFFFF); \
+ tmp = _m_punpcklbw(b, r); \
+ tmp2 = _m_punpcklbw(g, imm); \
+ *o++ = _m_punpcklbw(tmp, tmp2); \
+ *o++ = _m_punpckhbw(tmp, tmp2); \
+ tmp = _m_punpckhbw(b, r); \
+ tmp2 = _m_punpckhbw(g, imm); \
+ *o++ = _m_punpcklbw(tmp, tmp2); \
+ *o++ = _m_punpckhbw(tmp, tmp2);
+
+
+void Bitmap::copyYUVPixels(const Bitmap& yBmp, const Bitmap& uBmp, const Bitmap& vBmp,
+ bool bJPEG)
+{
+ int height = min(yBmp.getSize().y, m_Size.y);
+ int width = min(yBmp.getSize().x, m_Size.x);
+
+ int yStride = yBmp.getStride();
+ int uStride = uBmp.getStride();
+ int vStride = vBmp.getStride();
+ int destStride = m_Stride/getBytesPerPixel();
+ Pixel32 * pDestLine = (Pixel32*)m_pBits;
+
+#if defined(__SSE__) || defined(_WIN32)
+#pragma pack(16)
+ // Original SSE conversion code taken from liboggplay: oggplay_sse_x86.c
+ int i;
+ const unsigned char * ptry;
+ const unsigned char * ptru;
+ const unsigned char * ptrv;
+
+ register __m64 *o;
+ register __m64 y, ylo, yhi;
+ register __m64 zero, ut, vt, imm;
+ register __m64 r, g, b;
+ register __m64 tmp, tmp2;
+
+ zero = _mm_setzero_si64();
+
+ ptry = yBmp.getPixels();
+ ptru = uBmp.getPixels();
+ ptrv = vBmp.getPixels();
+
+ for (i = 0; i < height; i++) {
+ int j;
+ o = (__m64*)pDestLine;
+ pDestLine += destStride;
+ if (bJPEG) {
+ for (j = 0; j < width; j += 8) {
+ // ylo and yhi contain 4 pixels each
+ y = *(__m64*)(&(ptry[j]));
+ ylo = _m_punpcklbw(y, zero);
+
+ yhi = _m_punpckhbw(y, zero);
+
+ ut = _m_from_int(*(int *)(ptru + j/2));
+ vt = _m_from_int(*(int *)(ptrv + j/2));
+
+ ut = _m_punpcklbw(ut, zero);
+ vt = _m_punpcklbw(vt, zero);
+
+ /* subtract 128 from u and v */
+ imm = _mm_set1_pi16(128);
+ ut = _m_psubw(ut, imm);
+ vt = _m_psubw(vt, imm);
+
+ /* transfer and multiply into r, g, b registers */
+ imm = _mm_set1_pi16(-44);
+ g = _m_pmullw(ut, imm);
+ imm = _mm_set1_pi16(113);
+ b = _m_pmullw(ut, imm);
+ imm = _mm_set1_pi16(179);
+ r = _m_pmullw(vt, imm);
+ imm = _mm_set1_pi16(-91);
+ imm = _m_pmullw(vt, imm);
+ g = _m_paddsw(g, imm);
+
+ /* shift r, g and b registers to the right */
+ r = _m_psrawi(r, 7);
+ g = _m_psrawi(g, 7);
+ b = _m_psrawi(b, 6);
+ YUV_TO_RGB_UNPACK
+
+ }
+ } else {
+ for (j = 0; j < width; j += 8) {
+
+ // y' = (298*(y-16))
+ // ylo and yhi contain 4 pixels each
+ y = *(__m64*)(&(ptry[j]));
+ ylo = _m_punpcklbw(y, zero);
+ imm = _mm_set1_pi16(16);
+ ylo = _m_psubusw(ylo, imm);
+ imm = _mm_set1_pi16(149);
+ ylo = _m_pmullw(ylo, imm);
+ ylo = _mm_srli_pi16(ylo, 7);
+
+ yhi = _m_punpckhbw(y, zero);
+ imm = _mm_set1_pi16(16);
+ yhi = _m_psubusw(yhi, imm);
+ imm = _mm_set1_pi16(149);
+ yhi = _m_pmullw(yhi, imm);
+ yhi = _mm_srli_pi16(yhi, 7);
+
+ ut = _m_from_int(*(int *)(ptru + j/2));
+ vt = _m_from_int(*(int *)(ptrv + j/2));
+
+ ut = _m_punpcklbw(ut, zero);
+ vt = _m_punpcklbw(vt, zero);
+
+ /* subtract 128 from u and v */
+ imm = _mm_set1_pi16(128);
+ ut = _m_psubw(ut, imm);
+ vt = _m_psubw(vt, imm);
+
+ /* transfer and multiply into r, g, b registers */
+ imm = _mm_set1_pi16(-50);
+ g = _m_pmullw(ut, imm);
+ imm = _mm_set1_pi16(129);
+ b = _m_pmullw(ut, imm);
+ imm = _mm_set1_pi16(204);
+ r = _m_pmullw(vt, imm);
+ imm = _mm_set1_pi16(-104);
+ imm = _m_pmullw(vt, imm);
+ g = _m_paddsw(g, imm);
+
+ /* shift r, g and b registers to the right */
+ r = _m_psrawi(r, 7);
+ g = _m_psrawi(g, 7);
+ b = _m_psrawi(b, 6);
+ YUV_TO_RGB_UNPACK
+ }
+ }
+ if (i & 0x1) {
+ ptru += uStride;
+ ptrv += vStride;
+ }
+ ptry += yStride;
+ }
+ _m_empty();
+#pragma pack()
+#else
+ AVG_ASSERT(m_PF==B8G8R8X8);
+ const unsigned char * pYSrc = yBmp.getPixels();
+ const unsigned char * pUSrc = uBmp.getPixels();
+ const unsigned char * pVSrc = vBmp.getPixels();
+
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ YUVtoBGR32Pixel(pDestLine + x, pYSrc[x], pUSrc[x/2], pVSrc[x/2]);
+ }
+ pDestLine += destStride;
+ pYSrc += yStride;
+ if (y % 2 == 1) {
+ pUSrc += uStride;
+ pVSrc += vStride;
+ }
+ }
+#endif
+}
+
+void Bitmap::save(const UTF8String& sFilename)
+{
+ if (!s_bGTKInitialized) {
+ g_type_init();
+ s_bGTKInitialized = true;
+ }
+ Bitmap* pTempBmp;
+ switch (m_PF) {
+ case B8G8R8X8:
+ pTempBmp = new Bitmap(m_Size, R8G8B8);
+ for (int y = 0; y < m_Size.y; y++) {
+ unsigned char * pSrcLine = m_pBits+y * m_Stride;
+ unsigned char * pDestLine = pTempBmp->getPixels() +
+ y*pTempBmp->getStride();
+ for (int x = 0; x < m_Size.x; x++) {
+ pDestLine[x*3] = pSrcLine[x*4 + 2];
+ pDestLine[x*3 + 1] = pSrcLine[x*4 + 1];
+ pDestLine[x*3 + 2] = pSrcLine[x*4];
+ }
+ }
+ break;
+ case B8G8R8A8:
+ pTempBmp = new Bitmap(m_Size, R8G8B8A8);
+ for (int y = 0; y < m_Size.y; y++) {
+ unsigned char * pSrcLine = m_pBits+y * m_Stride;
+ unsigned char * pDestLine = pTempBmp->getPixels() +
+ y*pTempBmp->getStride();
+ for (int x = 0; x < m_Size.x; x++) {
+ pDestLine[x*4] = pSrcLine[x*4 + 2];
+ pDestLine[x*4 + 1] = pSrcLine[x*4 + 1];
+ pDestLine[x*4 + 2] = pSrcLine[x*4];
+ pDestLine[x*4 + 3] = pSrcLine[x*4+3];
+ }
+ }
+ break;
+ default:
+ if (hasAlpha()) {
+ pTempBmp = new Bitmap(m_Size, R8G8B8A8);
+ } else {
+ pTempBmp = new Bitmap(m_Size, R8G8B8);
+ }
+ pTempBmp->copyPixels(*this);
+ }
+ GdkPixbuf* pPixBuf = gdk_pixbuf_new_from_data(pTempBmp->getPixels(),
+ GDK_COLORSPACE_RGB, pTempBmp->hasAlpha(), 8, m_Size.x, m_Size.y,
+ pTempBmp->getStride(), 0, 0);
+
+ string sExt = getExtension(sFilename);
+
+ GError* pError = 0;
+ gboolean bOk = gdk_pixbuf_save(pPixBuf, sFilename.c_str(), sExt.c_str(), &pError, NULL);
+ if (!bOk) {
+ string sErr = pError->message;
+ g_error_free(pError);
+ throw Exception(AVG_ERR_FILEIO, sErr);
+ }
+
+ delete pTempBmp;
+}
+
+IntPoint Bitmap::getSize() const
+{
+ return m_Size;
+}
+
+int Bitmap::getStride() const
+{
+ return m_Stride;
+}
+
+PixelFormat Bitmap::getPixelFormat() const
+{
+ return m_PF;
+}
+
+void Bitmap::setPixelFormat(PixelFormat pf)
+{
+ m_PF = pf;
+}
+
+unsigned char * Bitmap::getPixels()
+{
+ return m_pBits;
+}
+
+const unsigned char * Bitmap::getPixels() const
+{
+ return m_pBits;
+}
+
+string Bitmap::getPixelsAsString() const
+{
+ return string((char*)m_pBits, getMemNeeded());
+}
+
+void Bitmap::setPixels(const unsigned char * pPixels)
+{
+ memcpy(m_pBits, pPixels, getMemNeeded());
+}
+
+void Bitmap::setPixelsFromString(const string& sPixels)
+{
+ memcpy(m_pBits, sPixels.c_str(), getMemNeeded());
+}
+
+
+const string& Bitmap::getName() const
+{
+ return m_sName;
+}
+
+bool Bitmap::ownsBits() const
+{
+ return m_bOwnsBits;
+}
+
+int Bitmap::getBytesPerPixel() const
+{
+ return avg::getBytesPerPixel(m_PF);
+}
+
+int Bitmap::getLineLen() const
+{
+ if (m_PF == YCbCr411) {
+ return int(m_Size.x*1.5);
+ } else {
+ return m_Size.x*getBytesPerPixel();
+ }
+}
+
+int Bitmap::getMemNeeded() const
+{
+ // This assumes a positive value for stride.
+ return m_Stride*m_Size.y;
+}
+
+bool Bitmap::hasAlpha() const
+{
+ return pixelFormatHasAlpha(m_PF);
+}
+
+HistogramPtr Bitmap::getHistogram(int stride) const
+{
+ AVG_ASSERT (m_PF == I8);
+ HistogramPtr pHist(new Histogram(256,0));
+ const unsigned char * pSrcLine = m_pBits;
+ for (int y = 0; y < m_Size.y; y += stride) {
+ const unsigned char * pSrc = pSrcLine;
+ for (int x = 0; x < m_Size.x; x += stride) {
+ (*pHist)[(*pSrc)]++;
+ pSrc += stride;
+ }
+ pSrcLine += m_Stride*stride;
+ }
+ return pHist;
+}
+
+void Bitmap::getMinMax(int stride, int& min, int& max) const
+{
+ AVG_ASSERT (m_PF == I8);
+ const unsigned char * pSrcLine = m_pBits;
+ min = 255;
+ max = 0;
+ for (int y = 0; y < m_Size.y; y += stride) {
+ const unsigned char * pSrc = pSrcLine;
+ for (int x = 0; x < m_Size.x; x += stride) {
+ if (*pSrc < min) {
+ min = *pSrc;
+ }
+ if (*pSrc > max) {
+ max = *pSrc;
+ }
+ pSrc += stride;
+ }
+ pSrcLine += m_Stride*stride;
+ }
+}
+
+void Bitmap::setAlpha(const Bitmap& alphaBmp)
+{
+ AVG_ASSERT(hasAlpha());
+ AVG_ASSERT(alphaBmp.getPixelFormat() == I8);
+ unsigned char * pLine = m_pBits;
+ const unsigned char * pAlphaLine = alphaBmp.getPixels();
+ for (int y = 0; y < m_Size.y; y++) {
+ unsigned char * pPixel = pLine;
+ const unsigned char * pAlphaPixel = pAlphaLine;
+ for (int x = 0; x < m_Size.x; x++) {
+ pPixel[ALPHAPOS] = *pAlphaPixel;
+ pPixel+=4;
+ pAlphaPixel++;
+ }
+ pLine += m_Stride;
+ pAlphaLine += alphaBmp.getStride();
+ }
+}
+
+Pixel32 Bitmap::getPythonPixel(const DPoint& pos)
+{
+ IntPoint intPos(pos);
+ if (intPos.x < 0 || intPos.y < 0 || intPos.x >= m_Size.x || intPos.y >= m_Size.y) {
+ stringstream ss;
+ ss << "Bitmap.getPixel(): intPos " << intPos <<
+ " is out of range. Bitmap size is " << m_Size << endl;
+ throw Exception(AVG_ERR_OUT_OF_RANGE, ss.str());
+ }
+ const unsigned char * pPixel = m_pBits+intPos.y*m_Stride+intPos.x*getBytesPerPixel();
+ switch(getPixelFormat()) {
+ case B8G8R8A8:
+ return Pixel32(pPixel[2], pPixel[1], pPixel[0], pPixel[3]);
+ case B8G8R8X8:
+ return Pixel32(pPixel[2], pPixel[1], pPixel[0], 255);
+ case B8G8R8:
+ return Pixel32(pPixel[2], pPixel[1], pPixel[0]);
+ case I8:
+ return Pixel32(pPixel[0], pPixel[0], pPixel[0]);
+ default:
+ cerr << getPixelFormat() << endl;
+ AVG_ASSERT(false);
+ return Pixel32();
+ }
+}
+
+bool Bitmap::operator ==(const Bitmap& otherBmp)
+{
+ // We allow Name, Stride and bOwnsBits to be different here, since we're looking for
+ // equal value only.
+ if (m_Size != otherBmp.m_Size || m_PF != otherBmp.m_PF)
+ {
+ return false;
+ }
+
+ const unsigned char * pSrc = otherBmp.getPixels();
+ unsigned char * pDest = m_pBits;
+ int LineLen = getLineLen();
+ for (int y = 0; y < getSize().y; ++y) {
+ switch(m_PF) {
+ case R8G8B8X8:
+ case B8G8R8X8:
+ for (int x = 0; x < getSize().x; ++x) {
+ const unsigned char * pSrcPixel = pSrc+x*getBytesPerPixel();
+ unsigned char * pDestPixel = pDest+x*getBytesPerPixel();
+ if (*((Pixel24*)(pDestPixel)) != *((Pixel24*)(pSrcPixel))) {
+ return false;
+ }
+ }
+ break;
+ default:
+ if (memcmp(pDest, pSrc, LineLen) != 0) {
+ return false;
+ }
+ }
+ pDest += m_Stride;
+ pSrc += otherBmp.getStride();
+ }
+ return true;
+}
+
+BitmapPtr Bitmap::subtract(const Bitmap& otherBmp)
+{
+ if (m_PF != otherBmp.getPixelFormat())
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ string("Bitmap::subtract: pixel formats differ(")
+ + getPixelFormatString(m_PF)+", "
+ + getPixelFormatString(otherBmp.getPixelFormat())+")");
+ if (m_Size != otherBmp.getSize())
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ string("Bitmap::subtract: bitmap sizes differ (this=")
+ + toString(m_Size) + ", other=" + toString(otherBmp.getSize()) + ")");
+ BitmapPtr pResultBmp = BitmapPtr(new Bitmap(m_Size, m_PF));
+ const unsigned char * pSrcLine1 = otherBmp.getPixels();
+ const unsigned char * pSrcLine2 = m_pBits;
+ unsigned char * pDestLine = pResultBmp->getPixels();
+ int stride = getStride();
+ int lineLen = getLineLen();
+
+ for (int y = 0; y < getSize().y; ++y) {
+ switch(m_PF) {
+ case I16:
+ {
+ const unsigned short * pSrc1 = (const unsigned short *)pSrcLine1;
+ const unsigned short * pSrc2 = (const unsigned short *)pSrcLine2;
+ unsigned short * pDest= (unsigned short *)pDestLine;
+ for (int x=0; x<m_Size.x; ++x) {
+ *pDest = abs(*pSrc1-*pSrc2);
+ pSrc1++;
+ pSrc2++;
+ pDest++;
+ }
+ }
+ break;
+ default:
+ {
+ const unsigned char * pSrc1 = pSrcLine1;
+ const unsigned char * pSrc2 = pSrcLine2;
+ unsigned char * pDest= pDestLine;
+ for (int x=0; x<lineLen; ++x) {
+ *pDest = abs(*pSrc1-*pSrc2);
+ pSrc1++;
+ pSrc2++;
+ pDest++;
+ }
+ }
+ }
+ pSrcLine1 += stride;
+ pSrcLine2 += stride;
+ pDestLine += stride;
+ }
+ return pResultBmp;
+}
+
+void Bitmap::blt(const Bitmap& otherBmp, const IntPoint& pos)
+{
+ AVG_ASSERT(getBytesPerPixel() == 4);
+
+ IntRect destRect(pos.x, pos.y, pos.x+otherBmp.getSize().x,
+ pos.y+otherBmp.getSize().y);
+ destRect.intersect(IntRect(IntPoint(0,0), getSize()));
+ for (int y = 0; y < destRect.height(); y++) {
+ unsigned char * pSrcPixel = getPixels()+(pos.y+y)*getStride()+pos.x*4;
+ const unsigned char * pOtherPixel = otherBmp.getPixels()+
+ y*otherBmp.getStride();
+ if (otherBmp.hasAlpha()) {
+ for (int x = 0; x < destRect.width(); x++) {
+ int srcAlpha = 255-pOtherPixel[3];
+ pSrcPixel[0] =
+ (srcAlpha*pSrcPixel[0]+int(pOtherPixel[3])*pOtherPixel[0])/255;
+ pSrcPixel[1] =
+ (srcAlpha*pSrcPixel[1]+int(pOtherPixel[3])*pOtherPixel[1])/255;
+ pSrcPixel[2] =
+ (srcAlpha*pSrcPixel[2]+int(pOtherPixel[3])*pOtherPixel[2])/255;
+ pSrcPixel += 4;
+ pOtherPixel += 4;
+ }
+ } else {
+ for (int x = 0; x < destRect.width(); x++) {
+ *(Pixel32*)pSrcPixel = *(Pixel32*)pOtherPixel;
+ pSrcPixel[3] = 255;
+ pSrcPixel += 4;
+ pOtherPixel += 4;
+ }
+ }
+ }
+}
+
+double Bitmap::getAvg() const
+{
+ double sum = 0;
+ unsigned char * pSrc = m_pBits;
+ int componentsPerPixel = getBytesPerPixel();
+ for (int y = 0; y < getSize().y; ++y) {
+ switch(m_PF) {
+ case R8G8B8X8:
+ case B8G8R8X8:
+ {
+ Pixel32 * pSrcPixel = (Pixel32 *)pSrc;
+ for (int x = 0; x < m_Size.x; ++x) {
+ sum += pSrcPixel->getR()+pSrcPixel->getG()+pSrcPixel->getB();
+ pSrcPixel++;
+ }
+ componentsPerPixel = 3;
+ }
+ break;
+ case I16:
+ {
+ componentsPerPixel = 1;
+ unsigned short * pSrcPixel = (unsigned short *)pSrc;
+ for (int x = 0; x < m_Size.x; ++x) {
+ sum += *pSrcPixel;
+ pSrcPixel++;
+ }
+ }
+ break;
+ case R8G8B8A8:
+ case B8G8R8A8:
+ {
+ Pixel32 * pSrcPixel = (Pixel32 *)pSrc;
+ for (int x = 0; x < m_Size.x; ++x) {
+ int a = pSrcPixel->getA();
+ if (a > 0) {
+ sum += ((pSrcPixel->getR()+pSrcPixel->getG()+
+ pSrcPixel->getB())*a)/255+pSrcPixel->getA();
+ }
+ pSrcPixel++;
+ }
+ componentsPerPixel = 4;
+ }
+ break;
+ default:
+ {
+ unsigned char * pSrcComponent = pSrc;
+ for (int x = 0; x < getLineLen(); ++x) {
+ sum += *pSrcComponent;
+ pSrcComponent++;
+ }
+ }
+ }
+ pSrc += m_Stride;
+ }
+ sum /= componentsPerPixel;
+ return sum/(getSize().x*getSize().y);
+}
+
+double Bitmap::getChannelAvg(int channel) const
+{
+ AVG_ASSERT(!pixelFormatIsPlanar(m_PF) && !pixelFormatIsBayer(m_PF) && !(m_PF == I16));
+ int bytesPerPixel = getBytesPerPixel();
+ AVG_ASSERT(channel < bytesPerPixel);
+ double sum = 0;
+ unsigned char * pSrcLine = m_pBits;
+ for (int y = 0; y < getSize().y; ++y) {
+ unsigned char * pSrcPixel = pSrcLine;
+ for (int x = 0; x < m_Size.x; ++x) {
+ sum += *(pSrcPixel+channel);
+ pSrcPixel += bytesPerPixel;
+ }
+ pSrcLine += m_Stride;
+ }
+ return sum/(getSize().x*getSize().y);
+}
+
+double Bitmap::getStdDev() const
+{
+ double average = getAvg();
+ double sum = 0;
+
+ unsigned char * pSrc = m_pBits;
+ int componentsPerPixel = getBytesPerPixel();
+ for (int y = 0; y < getSize().y; ++y) {
+ switch(m_PF) {
+ case R8G8B8X8:
+ case B8G8R8X8:
+ {
+ componentsPerPixel = 3;
+ Pixel32 * pSrcPixel = (Pixel32 *)pSrc;
+ for (int x = 0; x < m_Size.x; ++x) {
+ sum += sqr(pSrcPixel->getR()-average);
+ sum += sqr(pSrcPixel->getG()-average);
+ sum += sqr(pSrcPixel->getB()-average);
+ pSrcPixel++;
+ }
+ }
+ break;
+ case R8G8B8A8:
+ case B8G8R8A8:
+ {
+ componentsPerPixel = 4;
+ Pixel32 * pSrcPixel = (Pixel32 *)pSrc;
+ for (int x = 0; x < m_Size.x; ++x) {
+ int a = pSrcPixel->getA();
+ if (a > 0) {
+ sum += sqr((pSrcPixel->getR()*a)/255-average);
+ sum += sqr((pSrcPixel->getG()*a)/255-average);
+ sum += sqr((pSrcPixel->getB()*a)/255-average);
+ sum += sqr(pSrcPixel->getA()-average);
+ }
+ pSrcPixel++;
+ }
+ }
+ break;
+ case I16:
+ {
+ componentsPerPixel = 1;
+ unsigned short * pSrcPixel = (unsigned short *)pSrc;
+ for (int x = 0; x < m_Size.x; ++x) {
+ sum += sqr(*pSrcPixel-average);
+ pSrcPixel++;
+ }
+ }
+ break;
+ default:
+ {
+ unsigned char * pSrcComponent = pSrc;
+ for (int x = 0; x < getLineLen(); ++x) {
+ sum += sqr(*pSrcComponent-average);
+ pSrcComponent++;
+ }
+ }
+ }
+ pSrc += m_Stride;
+ }
+ sum /= componentsPerPixel;
+ sum /= (getSize().x*getSize().y);
+ return sqrt(sum);
+}
+
+void Bitmap::dump(bool bDumpPixels) const
+{
+ cerr << "Bitmap: " << m_sName << endl;
+ cerr << " m_Size: " << m_Size.x << "x" << m_Size.y << endl;
+ cerr << " m_Stride: " << m_Stride << endl;
+ cerr << " m_PF: " << getPixelFormatString(m_PF) << endl;
+ cerr << " m_pBits: " << (void *)m_pBits << endl;
+ cerr << " m_bOwnsBits: " << m_bOwnsBits << endl;
+ IntPoint max;
+ if (bDumpPixels) {
+ max = m_Size;
+ } else {
+ max = IntPoint(16,1);
+ }
+ cerr << " Pixel data: " << endl;
+ for (int y = 0; y < max.y; ++y) {
+ unsigned char * pLine = m_pBits+m_Stride*y;
+ cerr << " ";
+ for (int x = 0; x < max.x; ++x) {
+ if (m_PF == R32G32B32A32F) {
+ float * pPixel = (float*)(pLine+getBytesPerPixel()*x);
+ cerr << "[";
+ for (int i = 0; i < 4; ++i) {
+ cerr << setw(4) << setprecision(2) << pPixel[i] << " ";
+ }
+ cerr << "]";
+ } else {
+ unsigned char * pPixel = pLine+getBytesPerPixel()*x;
+ cerr << "[";
+ for (int i = 0; i < getBytesPerPixel(); ++i) {
+ cerr << hex << setw(2) << (int)(pPixel[i]) << " ";
+ }
+ cerr << "]";
+ }
+ }
+ cerr << endl;
+ }
+ cerr << dec;
+}
+
+void Bitmap::initWithData(unsigned char * pBits, int stride, bool bCopyBits)
+{
+// cerr << "Bitmap::initWithData()" << endl;
+ if (m_PF == A8) {
+ m_PF = I8;
+ }
+ if (m_PF == YCbCr422) {
+ if (m_Size.x%2 == 1) {
+ AVG_TRACE(Logger::WARNING, "Odd size for YCbCr bitmap.");
+ m_Size.x++;
+ }
+ if (m_Size.y%2 == 1) {
+ AVG_TRACE(Logger::WARNING, "Odd size for YCbCr bitmap.");
+ m_Size.y++;
+ }
+ if (m_Size.x%2 == 1 || m_Size.y%2 == 1) {
+ AVG_TRACE(Logger::ERROR, "Odd size for YCbCr bitmap.");
+ }
+ }
+ if (bCopyBits) {
+ allocBits();
+ if (m_Stride == stride && stride == (m_Size.x*getBytesPerPixel())) {
+ memcpy(m_pBits, pBits, stride*m_Size.y);
+ } else {
+ for (int y = 0; y < m_Size.y; ++y) {
+ memcpy(m_pBits+m_Stride*y, pBits+stride*y, m_Stride);
+ }
+ }
+ m_bOwnsBits = true;
+ } else {
+ m_pBits = pBits;
+ m_Stride = stride;
+ m_bOwnsBits = false;
+ }
+}
+
+void Bitmap::allocBits(int stride)
+{
+ AVG_ASSERT(!m_pBits);
+ AVG_ASSERT(!pixelFormatIsPlanar(m_PF));
+ AVG_ASSERT(m_Size.x > 0 && m_Size.y > 0);
+// cerr << "Bitmap::allocBits():" << m_Size << endl;
+ if (stride == 0) {
+ m_Stride = getLineLen();
+ } else {
+ m_Stride = stride;
+ }
+ if (m_PF == A8) {
+ m_PF = I8;
+ }
+ if (m_PF == YCbCr422) {
+ if (m_Size.x%2 == 1) {
+ AVG_TRACE(Logger::WARNING, "Odd width for YCbCr bitmap.");
+ m_Size.x++;
+ }
+ if (m_Size.y%2 == 1) {
+ AVG_TRACE(Logger::WARNING, "Odd height for YCbCr bitmap.");
+ m_Size.y++;
+ }
+ //XXX: We allocate more than nessesary here because ffmpeg seems to
+ // overwrite memory after the bits - probably during yuv conversion.
+ // Yuck.
+ m_pBits = new unsigned char[(m_Stride+1)*(m_Size.y+1)];
+ } else {
+ m_pBits = new unsigned char[m_Stride*m_Size.y];
+ }
+}
+
+void YUYV422toBGR32Line(const unsigned char* pSrcLine, Pixel32* pDestLine, int width)
+{
+ Pixel32 * pDestPixel = pDestLine;
+
+ // We need the previous and next values to interpolate between the
+ // sampled u and v values.
+ int v = *(pSrcLine+3);
+ int v0; // Previous v
+ int u;
+ int u1; // Next u;
+ const unsigned char * pSrcPixels = pSrcLine;
+
+ for (int x = 0; x < width/2-1; x++) {
+ // Two pixels at a time.
+ // Source format is YUYV.
+ u = pSrcPixels[1];
+ v0 = v;
+ v = pSrcPixels[3];
+ u1 = pSrcPixels[5];
+
+ YUVtoBGR32Pixel(pDestPixel, pSrcPixels[0], u, (v0+v)/2);
+ YUVtoBGR32Pixel(pDestPixel+1, pSrcPixels[2], (u+u1)/2, v);
+
+ pSrcPixels+=4;
+ pDestPixel+=2;
+ }
+ // Last pixels.
+ u = pSrcPixels[1];
+ v0 = v;
+ v = pSrcPixels[3];
+ YUVtoBGR32Pixel(pDestPixel, pSrcPixels[0], u, v0/2+v/2);
+ YUVtoBGR32Pixel(pDestPixel+1, pSrcPixels[2], u, v);
+}
+
+void UYVY422toBGR32Line(const unsigned char* pSrcLine, Pixel32* pDestLine, int width)
+{
+ Pixel32 * pDestPixel = pDestLine;
+
+ // We need the previous and next values to interpolate between the
+ // sampled u and v values.
+ int v = *(pSrcLine+2);
+ int v0; // Previous v
+ int u;
+ int u1; // Next u;
+ const unsigned char * pSrcPixels = pSrcLine;
+
+ for (int x = 0; x < width/2-1; x++) {
+ // Two pixels at a time.
+ // Source format is UYVY.
+ u = pSrcPixels[0];
+ v0 = v;
+ v = pSrcPixels[2];
+ u1 = pSrcPixels[4];
+
+ YUVtoBGR32Pixel(pDestPixel, pSrcPixels[1], u, (v0+v)/2);
+ YUVtoBGR32Pixel(pDestPixel+1, pSrcPixels[3], (u+u1)/2, v);
+
+ pSrcPixels+=4;
+ pDestPixel+=2;
+ }
+ // Last pixels.
+ u = pSrcPixels[0];
+ v0 = v;
+ v = pSrcPixels[2];
+ YUVtoBGR32Pixel(pDestPixel, pSrcPixels[1], u, v0/2+v/2);
+ YUVtoBGR32Pixel(pDestPixel+1, pSrcPixels[3], u, v);
+}
+
+void YUV411toBGR32Line(const unsigned char* pSrcLine, Pixel32* pDestLine, int width)
+{
+ Pixel32 * pDestPixel = pDestLine;
+
+ // We need the previous and next values to interpolate between the
+ // sampled u and v values.
+ int v = *(pSrcLine+3);
+ int v0; // Previous v
+ int v1; // Next v;
+ int u;
+ int u1; // Next u;
+ const unsigned char * pSrcPixels = pSrcLine;
+
+ for (int x = 0; x < width/4; x++) {
+ // Four pixels at a time.
+ // Source format is UYYVYY.
+ u = pSrcPixels[0];
+ v0 = v;
+ v = pSrcPixels[3];
+
+ if (x < width/4-1) {
+ u1 = pSrcPixels[6];
+ v1 = pSrcPixels[9];
+ } else {
+ u1 = u;
+ v1 = v;
+ }
+
+ YUVtoBGR32Pixel(pDestPixel, pSrcPixels[1], u, v0/2+v/2);
+ YUVtoBGR32Pixel(pDestPixel+1, pSrcPixels[2], (u*3)/4+u1/4, v0/4+(v*3)/4);
+ YUVtoBGR32Pixel(pDestPixel+2, pSrcPixels[4], u/2+u1/2, v);
+ YUVtoBGR32Pixel(pDestPixel+3, pSrcPixels[5], u/4+(u1*3)/4, (v*3)/4+v1/4);
+
+ pSrcPixels+=6;
+ pDestPixel+=4;
+ }
+}
+
+void Bitmap::YCbCrtoBGR(const Bitmap& origBmp)
+{
+ AVG_ASSERT(m_PF==B8G8R8X8);
+ const unsigned char * pSrc = origBmp.getPixels();
+ Pixel32 * pDest = (Pixel32*)m_pBits;
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+ int StrideInPixels = m_Stride/getBytesPerPixel();
+ switch(origBmp.m_PF) {
+ case YCbCr422:
+ for (int y = 0; y < height; ++y) {
+ UYVY422toBGR32Line(pSrc, pDest, width);
+ pDest += StrideInPixels;
+ pSrc += origBmp.getStride();
+ }
+ break;
+ case YUYV422:
+ for (int y = 0; y < height; ++y) {
+ YUYV422toBGR32Line(pSrc, pDest, width);
+ pDest += StrideInPixels;
+ pSrc += origBmp.getStride();
+ }
+ break;
+ case YCbCr411:
+ for (int y = 0; y < height; ++y) {
+ YUV411toBGR32Line(pSrc, pDest, width);
+ pDest += StrideInPixels;
+ pSrc += origBmp.getStride();
+ }
+ break;
+ default:
+ // This routine shouldn't be called with other pixel formats.
+ AVG_ASSERT(false);
+ }
+}
+
+void YUYV422toI8Line(const unsigned char* pSrcLine, unsigned char* pDestLine, int width)
+{
+ const unsigned char * pSrc = pSrcLine;
+ unsigned char * pDest = pDestLine;
+ for (int x = 0; x < width; x++) {
+ *pDest = *pSrc;
+ pDest++;
+ pSrc+=2;
+ }
+}
+
+void YUV411toI8Line(const unsigned char* pSrcLine, unsigned char* pDestLine, int width)
+{
+ const unsigned char * pSrc = pSrcLine;
+ unsigned char * pDest = pDestLine;
+ for (int x = 0; x < width/2; x++) {
+ *pDest++ = *pSrc++;
+ *pDest++ = *pSrc++;
+ pSrc++;
+ }
+}
+
+void Bitmap::YCbCrtoI8(const Bitmap& origBmp)
+{
+ AVG_ASSERT(m_PF==I8);
+ const unsigned char * pSrc = origBmp.getPixels();
+ unsigned char * pDest = m_pBits;
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+ switch(origBmp.m_PF) {
+ case YCbCr422:
+ for (int y = 0; y < height; ++y) {
+ // src shifted by one byte to account for UYVY to YUYV
+ // difference in pixel order.
+ YUYV422toI8Line(pSrc+1, pDest, width);
+ pDest += m_Stride;
+ pSrc += origBmp.getStride();
+ }
+ break;
+ case YUYV422:
+ for (int y = 0; y < height; ++y) {
+ YUYV422toI8Line(pSrc, pDest, width);
+ pDest += m_Stride;
+ pSrc += origBmp.getStride();
+ }
+ break;
+ case YCbCr411:
+ for (int y = 0; y < height; ++y) {
+ YUV411toI8Line(pSrc, pDest, width);
+ pDest += m_Stride;
+ pSrc += origBmp.getStride();
+ }
+ break;
+ default:
+ // This routine shouldn't be called with other pixel formats.
+ AVG_ASSERT(false);
+ }
+}
+
+void Bitmap::I16toI8(const Bitmap& origBmp)
+{
+ AVG_ASSERT(m_PF == I8);
+ AVG_ASSERT(origBmp.getPixelFormat() == I16);
+ const unsigned short * pSrc = (const unsigned short *)origBmp.getPixels();
+ unsigned char * pDest = m_pBits;
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+ int srcStrideInPixels = origBmp.getStride()/origBmp.getBytesPerPixel();
+ for (int y = 0; y < height; ++y) {
+ const unsigned short * pSrcPixel = pSrc;
+ unsigned char * pDestPixel = pDest;
+ for (int x=0; x<width; ++x) {
+ *pDestPixel++ = *pSrcPixel++ >> 8;
+ }
+ pDest += m_Stride;
+ pSrc += srcStrideInPixels;
+ }
+}
+
+void Bitmap::I8toI16(const Bitmap& origBmp)
+{
+ AVG_ASSERT(m_PF == I16);
+ AVG_ASSERT(origBmp.getPixelFormat() == I8);
+ const unsigned char * pSrc = origBmp.getPixels();
+ unsigned short * pDest = (unsigned short *)m_pBits;
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+ int destStrideInPixels = m_Stride/getBytesPerPixel();
+ for (int y=0; y<height; ++y) {
+ const unsigned char * pSrcPixel = pSrc;
+ unsigned short * pDestPixel = pDest;
+ for (int x=0; x<width; ++x) {
+ *pDestPixel++ = *pSrcPixel++ << 8;
+ }
+ pDest += destStrideInPixels;
+ pSrc += origBmp.getStride();
+ }
+}
+
+void Bitmap::I8toRGB(const Bitmap& origBmp)
+{
+ AVG_ASSERT(getBytesPerPixel() == 4 || getBytesPerPixel() == 3);
+ AVG_ASSERT(origBmp.getPixelFormat() == I8);
+ const unsigned char * pSrc = origBmp.getPixels();
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+ if (getBytesPerPixel() == 4) {
+ unsigned int * pDest = (unsigned int *)m_pBits;
+ int destStrideInPixels = m_Stride/getBytesPerPixel();
+ for (int y = 0; y < height; ++y) {
+ const unsigned char * pSrcPixel = pSrc;
+ unsigned int * pDestPixel = pDest;
+ for (int x = 0; x < width; ++x) {
+ *pDestPixel = (((((255 << 8)+(*pSrcPixel)) << 8)+
+ *pSrcPixel) << 8) +(*pSrcPixel);
+ pDestPixel ++;
+ pSrcPixel++;
+ }
+ pDest += destStrideInPixels;
+ pSrc += origBmp.getStride();
+ }
+ } else {
+ unsigned char * pDest = m_pBits;
+ for (int y = 0; y < height; ++y) {
+ const unsigned char * pSrcPixel = pSrc;
+ unsigned char * pDestPixel = pDest;
+ for (int x = 0; x < width; ++x) {
+ *pDestPixel++ = *pSrcPixel;
+ *pDestPixel++ = *pSrcPixel;
+ *pDestPixel++ = *pSrcPixel;
+ pSrcPixel++;
+ }
+ pDest += getStride();
+ pSrc += origBmp.getStride();
+ }
+ }
+}
+
+void Bitmap::ByteRGBAtoFloatRGBA(const Bitmap& origBmp)
+{
+ AVG_ASSERT(getPixelFormat() == R32G32B32A32F);
+ AVG_ASSERT(origBmp.getBytesPerPixel() == 4);
+ const unsigned char * pSrc = origBmp.getPixels();
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+ float * pDest = (float *)m_pBits;
+ for (int y = 0; y < height; ++y) {
+ const unsigned char * pSrcPixel = pSrc;
+ float * pDestPixel = pDest;
+ for (int x = 0; x < width*4; ++x) {
+ *pDestPixel = float(*pSrcPixel)/255;
+ pDestPixel ++;
+ pSrcPixel++;
+ }
+ pDest += m_Stride/sizeof(float);
+ pSrc += origBmp.getStride();
+ }
+}
+
+void Bitmap::FloatRGBAtoByteRGBA(const Bitmap& origBmp)
+{
+ AVG_ASSERT(getBytesPerPixel() == 4);
+ AVG_ASSERT(origBmp.getPixelFormat() == R32G32B32A32F);
+ const float * pSrc = (const float *)origBmp.getPixels();
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+ unsigned char * pDest = m_pBits;
+ for (int y = 0; y < height; ++y) {
+ const float * pSrcPixel = pSrc;
+ unsigned char * pDestPixel = pDest;
+ for (int x = 0; x < width*4; ++x) {
+ *pDestPixel = (unsigned char)(*pSrcPixel*255+0.5);
+ pDestPixel++;
+ pSrcPixel++;
+ }
+ pDest += m_Stride;
+ pSrc += origBmp.getStride()/sizeof(float);
+ }
+}
+
+/*
+// Nearest Neighbour Bayer Pattern de-mosaicking
+// Code has been taken and adapted from libdc1394 Bayer conversion
+// TODO: adapt it for RGB24, not just for RGB32
+// TODO: add more CFA patterns (now only the GBRG is defined and used)
+void Bitmap::BY8toRGBNearest(const Bitmap& origBmp)
+{
+ AVG_ASSERT(getBytesPerPixel() == 4);
+ AVG_ASSERT(origBmp.getPixelFormat() == BAYER8_GBRG);
+
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+
+ const int srcStride = width;
+ const int destStride = 4 * width;
+ int width = width;
+ int height = height;
+
+ // CFA Pattern selection: BGGR: blue=-1, swg=0; GRBG: blue=1, swg=1
+ // Assuming GBRG
+ int blue = 1;
+ int greenFirst = 1;
+
+ const unsigned char *pSrcPixel = origBmp.getPixels();
+ unsigned char *pDestPixel = (unsigned char *) getPixels();
+
+ pDestPixel += 1;
+ width -= 1;
+ height -= 1;
+
+ while (--height) {
+
+ const unsigned char *pSrcEndBoundary = pSrcPixel + width;
+
+ if (greenFirst) {
+ pDestPixel[-blue] = pSrcPixel[1];
+ pDestPixel[0] = pSrcPixel[srcStride + 1];
+ pDestPixel[blue] = pSrcPixel[srcStride];
+ pDestPixel[2] = 255; // Alpha channel
+ ++pSrcPixel;
+ pDestPixel += 4;
+ }
+
+ if (blue > 0) {
+ while (pSrcPixel <= pSrcEndBoundary - 2) {
+ pDestPixel[-1] = pSrcPixel[0];
+ pDestPixel[0] = pSrcPixel[1];
+ pDestPixel[1] = pSrcPixel[srcStride + 1];
+ pDestPixel[2] = 255; // Alpha channel
+
+ pDestPixel[3] = pSrcPixel[2];
+ pDestPixel[4] = pSrcPixel[srcStride + 2];
+ pDestPixel[5] = pSrcPixel[srcStride + 1];
+ pDestPixel[6] = 255; // Alpha channel
+
+ pSrcPixel += 2;
+ pDestPixel += 8;
+ }
+ } else {
+ while (pSrcPixel <= pSrcEndBoundary - 2) {
+ pDestPixel[1] = pSrcPixel[0];
+ pDestPixel[0] = pSrcPixel[1];
+ pDestPixel[-1] = pSrcPixel[srcStride + 1];
+
+ pDestPixel[6] = 255; // Alpha channel
+ pDestPixel[5] = pSrcPixel[2];
+ pDestPixel[4] = pSrcPixel[srcStride + 2];
+ pDestPixel[3] = pSrcPixel[srcStride + 1];
+ pDestPixel[2] = 255; // Alpha channel
+
+ pSrcPixel += 2;
+ pDestPixel += 8;
+ }
+ }
+
+ if (pSrcPixel < pSrcEndBoundary) {
+ pDestPixel[-blue] = pSrcPixel[0];
+ pDestPixel[0] = pSrcPixel[1];
+ pDestPixel[blue] = pSrcPixel[srcStride + 1];
+ pDestPixel[2] = 255; // Alpha channel
+ ++pSrcPixel;
+ pDestPixel += 4;
+ }
+
+ pSrcPixel -= width;
+ pDestPixel -= width * 4;
+
+ blue = -blue;
+ greenFirst = !greenFirst;
+
+ pSrcPixel += srcStride;
+ pDestPixel += destStride;
+ }
+}
+*/
+
+// Bilinear Bayer Pattern de-mosaicking
+// Code has been taken and adapted from libdc1394 Bayer conversion
+// Original source is OpenCV Bayer pattern decoding
+// TODO: adapt it for RGB24, not just for RGB32
+void Bitmap::BY8toRGBBilinear(const Bitmap& origBmp)
+{
+ AVG_ASSERT(getBytesPerPixel() == 4);
+ AVG_ASSERT(pixelFormatIsBayer(origBmp.getPixelFormat()));
+
+ int height = min(origBmp.getSize().y, m_Size.y);
+ int width = min(origBmp.getSize().x, m_Size.x);
+
+ const int srcStride = width;
+ const int doubleSrcStride = srcStride * 2;
+ const int destStride = 4 * width;
+
+ // CFA Pattern selection
+ PixelFormat pf = origBmp.getPixelFormat();
+ int blue;
+ int greenFirst;
+ if (pf == BAYER8_BGGR || pf == BAYER8_GBRG) {
+ blue = -1;
+ } else {
+ blue = 1;
+ }
+
+ if (pf == BAYER8_GBRG || pf == BAYER8_GRBG) {
+ greenFirst = 1;
+ } else {
+ greenFirst = 0;
+ }
+
+ const unsigned char *pSrcPixel = origBmp.getPixels();
+ unsigned char *pDestPixel = (unsigned char *) getPixels();
+
+ pDestPixel += destStride + 4 + 1;
+ height -= 2;
+ width -= 2;
+
+ while (height--) {
+ int t0, t1;
+ const unsigned char *pSrcEndBoundary = pSrcPixel + width;
+
+ if (greenFirst) {
+ t0 = (pSrcPixel[1] + pSrcPixel[doubleSrcStride + 1] + 1) >> 1;
+ t1 = (pSrcPixel[srcStride] + pSrcPixel[srcStride + 2] + 1) >> 1;
+ pDestPixel[-blue] = (unsigned char) t0;
+ pDestPixel[0] = pSrcPixel[srcStride + 1];
+ pDestPixel[blue] = (unsigned char) t1;
+ pDestPixel[2] = 255; // Alpha channel
+ ++pSrcPixel;
+ pDestPixel += 4;
+ }
+
+ if (blue > 0) {
+ while (pSrcPixel <= pSrcEndBoundary - 2) {
+ t0 = (pSrcPixel[0] + pSrcPixel[2] + pSrcPixel[doubleSrcStride] +
+ pSrcPixel[doubleSrcStride + 2] + 2) >> 2;
+ t1 = (pSrcPixel[1] + pSrcPixel[srcStride] +
+ pSrcPixel[srcStride + 2] + pSrcPixel[doubleSrcStride + 1] +
+ 2) >> 2;
+ pDestPixel[-1] = (unsigned char) t0;
+ pDestPixel[0] = (unsigned char) t1;
+ pDestPixel[1] = pSrcPixel[srcStride + 1];
+ pDestPixel[2] = 255; // Alpha channel
+
+ t0 = (pSrcPixel[2] + pSrcPixel[doubleSrcStride + 2] + 1) >> 1;
+ t1 = (pSrcPixel[srcStride + 1] + pSrcPixel[srcStride + 3] +
+ 1) >> 1;
+ pDestPixel[3] = (unsigned char) t0;
+ pDestPixel[4] = pSrcPixel[srcStride + 2];
+ pDestPixel[5] = (unsigned char) t1;
+ pDestPixel[6] = 255; // Alpha channel
+
+ pSrcPixel += 2;
+ pDestPixel += 8;
+ }
+ } else {
+ while (pSrcPixel <= pSrcEndBoundary - 2) {
+ t0 = (pSrcPixel[0] + pSrcPixel[2] + pSrcPixel[doubleSrcStride] +
+ pSrcPixel[doubleSrcStride + 2] + 2) >> 2;
+ t1 = (pSrcPixel[1] + pSrcPixel[srcStride] +
+ pSrcPixel[srcStride + 2] + pSrcPixel[doubleSrcStride + 1] +
+ 2) >> 2;
+ pDestPixel[1] = (unsigned char) t0;
+ pDestPixel[0] = (unsigned char) t1;
+ pDestPixel[-1] = pSrcPixel[srcStride + 1];
+ pDestPixel[2] = 255; // Alpha channel
+
+ t0 = (pSrcPixel[2] + pSrcPixel[doubleSrcStride + 2] + 1) >> 1;
+ t1 = (pSrcPixel[srcStride + 1] + pSrcPixel[srcStride + 3] +
+ 1) >> 1;
+ pDestPixel[5] = (unsigned char) t0;
+ pDestPixel[4] = pSrcPixel[srcStride + 2];
+ pDestPixel[3] = (unsigned char) t1;
+ pDestPixel[6] = 255; // Alpha channel
+
+ pSrcPixel += 2;
+ pDestPixel += 8;
+ }
+ }
+
+ if (pSrcPixel < pSrcEndBoundary) {
+ t0 = (pSrcPixel[0] + pSrcPixel[2] + pSrcPixel[doubleSrcStride] +
+ pSrcPixel[doubleSrcStride + 2] + 2) >> 2;
+ t1 = (pSrcPixel[1] + pSrcPixel[srcStride] +
+ pSrcPixel[srcStride + 2] + pSrcPixel[doubleSrcStride + 1] +
+ 2) >> 2;
+ pDestPixel[-blue] = (unsigned char) t0;
+ pDestPixel[0] = (unsigned char) t1;
+ pDestPixel[blue] = pSrcPixel[srcStride + 1];
+ pDestPixel[2] = 255; // Alpha channel
+ pSrcPixel++;
+ pDestPixel += 4;
+ }
+
+ pSrcPixel -= width;
+ pDestPixel -= width * 4;
+
+ blue = -blue;
+ greenFirst = !greenFirst;
+
+ pSrcPixel += srcStride;
+ pDestPixel += destStride;
+ }
+}
+
+template<class DESTPIXEL, class SRCPIXEL>
+void createTrueColorCopy(Bitmap& destBmp, const Bitmap& srcBmp)
+{
+ SRCPIXEL * pSrcLine = (SRCPIXEL*) srcBmp.getPixels();
+ DESTPIXEL * pDestLine = (DESTPIXEL*) destBmp.getPixels();
+ int height = min(srcBmp.getSize().y, destBmp.getSize().y);
+ int width = min(srcBmp.getSize().x, destBmp.getSize().x);
+ for (int y = 0; y < height; ++y) {
+ SRCPIXEL * pSrcPixel = pSrcLine;
+ DESTPIXEL * pDestPixel = pDestLine;
+ for (int x = 0; x < width; ++x) {
+ *pDestPixel = *pSrcPixel;
+ ++pSrcPixel;
+ ++pDestPixel;
+ }
+ pSrcLine = (SRCPIXEL *)((unsigned char *)pSrcLine + srcBmp.getStride());
+ pDestLine = (DESTPIXEL *)((unsigned char *)pDestLine + destBmp.getStride());
+ }
+}
+
+template<>
+void createTrueColorCopy<Pixel32, Pixel8>(Bitmap& destBmp, const Bitmap& srcBmp)
+{
+ const unsigned char * pSrcLine = srcBmp.getPixels();
+ unsigned char * pDestLine = destBmp.getPixels();
+ int height = min(srcBmp.getSize().y, destBmp.getSize().y);
+ int width = min(srcBmp.getSize().x, destBmp.getSize().x);
+ int srcStride = srcBmp.getStride();
+ int destStride = destBmp.getStride();
+ for (int y = 0; y < height; ++y) {
+ const unsigned char * pSrcPixel = pSrcLine;
+ unsigned char * pDestPixel = pDestLine;
+ for (int x = 0; x < width; ++x) {
+ pDestPixel[0] =
+ pDestPixel[1] =
+ pDestPixel[2] = *pSrcPixel;
+ pDestPixel[3] = 255;
+ ++pSrcPixel;
+ pDestPixel+=4;
+ }
+ pSrcLine = pSrcLine + srcStride;
+ pDestLine = pDestLine + destStride;
+ }
+}
+
+template<>
+void createTrueColorCopy<Pixel8, Pixel32>(Bitmap& destBmp, const Bitmap& srcBmp)
+{
+ const unsigned char * pSrcLine = srcBmp.getPixels();
+ unsigned char * pDestLine = destBmp.getPixels();
+ int height = min(srcBmp.getSize().y, destBmp.getSize().y);
+ int width = min(srcBmp.getSize().x, destBmp.getSize().x);
+ int srcStride = srcBmp.getStride();
+ int destStride = destBmp.getStride();
+ bool bRedFirst = (srcBmp.getPixelFormat() == R8G8B8A8) ||
+ (srcBmp.getPixelFormat() == R8G8B8X8);
+ for (int y = 0; y<height; ++y) {
+ const unsigned char * pSrcPixel = pSrcLine;
+ unsigned char * pDestPixel = pDestLine;
+ if (bRedFirst) {
+ for (int x = 0; x < width; ++x) {
+ *pDestPixel = ((pSrcPixel[0]*54+pSrcPixel[1]*183+pSrcPixel[2]*19)/256);
+ pSrcPixel+=4;
+ ++pDestPixel;
+ }
+ } else {
+ for (int x = 0; x < width; ++x) {
+ *pDestPixel = ((pSrcPixel[0]*19+pSrcPixel[1]*183+pSrcPixel[2]*54)/256);
+ pSrcPixel+=4;
+ ++pDestPixel;
+ }
+ }
+ pSrcLine = pSrcLine + srcStride;
+ pDestLine = pDestLine + destStride;
+ }
+}
+
+
+template<class PIXEL>
+void createTrueColorCopy(Bitmap& destBmp, const Bitmap& srcBmp)
+{
+ switch(srcBmp.getPixelFormat()) {
+ case B8G8R8A8:
+ case B8G8R8X8:
+ case A8B8G8R8:
+ case X8B8G8R8:
+ case R8G8B8A8:
+ case R8G8B8X8:
+ case A8R8G8B8:
+ case X8R8G8B8:
+ createTrueColorCopy<PIXEL, Pixel32>(destBmp, srcBmp);
+ break;
+ case B8G8R8:
+ case R8G8B8:
+ createTrueColorCopy<PIXEL, Pixel24>(destBmp, srcBmp);
+ break;
+ case B5G6R5:
+ case R5G6B5:
+ createTrueColorCopy<PIXEL, Pixel16>(destBmp, srcBmp);
+ break;
+ case I8:
+ case BAYER8_RGGB:
+ case BAYER8_GBRG:
+ case BAYER8_GRBG:
+ case BAYER8_BGGR:
+ createTrueColorCopy<PIXEL, Pixel8>(destBmp, srcBmp);
+ break;
+ default:
+ // Unimplemented conversion.
+ AVG_ASSERT(false);
+ }
+}
+
+};
diff --git a/src/graphics/Bitmap.h b/src/graphics/Bitmap.h
new file mode 100644
index 0000000..cd6e318
--- /dev/null
+++ b/src/graphics/Bitmap.h
@@ -0,0 +1,185 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Bitmap_H_
+#define _Bitmap_H_
+
+#include "../api.h"
+#include "Pixel32.h"
+#include "PixelFormat.h"
+
+#include "../base/Point.h"
+#include "../base/Rect.h"
+#include "../base/UTF8String.h"
+
+#include <boost/shared_ptr.hpp>
+
+#if defined(__SSE__) || defined(_WIN32)
+#include <xmmintrin.h>
+#endif
+
+#include <stdlib.h>
+#include <string>
+#include <vector>
+#include <algorithm>
+#include <iostream>
+
+namespace avg {
+
+typedef std::vector<int> Histogram;
+typedef boost::shared_ptr<Histogram> HistogramPtr;
+
+class Bitmap;
+typedef boost::shared_ptr<Bitmap> BitmapPtr;
+
+class AVG_API Bitmap
+{
+public:
+ Bitmap(DPoint size, PixelFormat pf, const UTF8String& sName="", int stride=0);
+ Bitmap(IntPoint size, PixelFormat pf, const UTF8String& sName="", int stride=0);
+ Bitmap(IntPoint size, PixelFormat pf, unsigned char * pBits,
+ int stride, bool bCopyBits, const UTF8String& sName="");
+ Bitmap(const Bitmap& origBmp);
+ Bitmap(const Bitmap& origBmp, bool bOwnsBits);
+ Bitmap(Bitmap& origBmp, const IntRect& rect);
+ Bitmap(const UTF8String& sName);
+ virtual ~Bitmap();
+
+ Bitmap &operator =(const Bitmap & origBmp);
+
+ // Does pixel format conversion if nessesary.
+ void copyPixels(const Bitmap& origBmp);
+ void copyYUVPixels(const Bitmap& yBmp, const Bitmap& uBmp, const Bitmap& vBmp,
+ bool bJPEG);
+ void save(const UTF8String& sName);
+
+ IntPoint getSize() const;
+ int getStride() const;
+ PixelFormat getPixelFormat() const;
+ void setPixelFormat(PixelFormat pf);
+ unsigned char* getPixels();
+ const unsigned char* getPixels() const;
+ std::string getPixelsAsString() const;
+ void setPixels(const unsigned char* pPixels);
+ void setPixelsFromString(const std::string& sPixels);
+ bool ownsBits() const;
+ const std::string& getName() const;
+ int getBytesPerPixel() const;
+ int getLineLen() const;
+ int getMemNeeded() const;
+ bool hasAlpha() const;
+ HistogramPtr getHistogram(int stride = 1) const;
+ void getMinMax(int stride, int& min, int& max) const;
+ void setAlpha(const Bitmap& alphaBmp);
+
+ Pixel32 getPythonPixel(const DPoint& pos);
+ template<class PIXEL>
+ void setPixel(const IntPoint& p, PIXEL color);
+ template<class PIXEL>
+ void drawLine(IntPoint p0, IntPoint p1, PIXEL color);
+
+ BitmapPtr subtract(const Bitmap& pOtherBmp);
+ void blt(const Bitmap& otherBmp, const IntPoint& pos);
+ double getAvg() const;
+ double getChannelAvg(int channel) const;
+ double getStdDev() const;
+
+ bool operator ==(const Bitmap& otherBmp);
+ void dump(bool bDumpPixels=false) const;
+
+private:
+ void initWithData(unsigned char* pBits, int stride, bool bCopyBits);
+ void allocBits(int stride=0);
+ void YCbCrtoBGR(const Bitmap& origBmp);
+ void YCbCrtoI8(const Bitmap& origBmp);
+ void I8toI16(const Bitmap& origBmp);
+ void I8toRGB(const Bitmap& origBmp);
+ void I16toI8(const Bitmap& origBmp);
+ void BGRtoB5G6R5(const Bitmap& origBmp);
+ void ByteRGBAtoFloatRGBA(const Bitmap& origBmp);
+ void FloatRGBAtoByteRGBA(const Bitmap& origBmp);
+ void BY8toRGBNearest(const Bitmap& origBmp);
+ void BY8toRGBBilinear(const Bitmap& origBmp);
+
+ IntPoint m_Size;
+ int m_Stride;
+ PixelFormat m_PF;
+ unsigned char* m_pBits;
+ bool m_bOwnsBits;
+ UTF8String m_sName;
+
+ static bool s_bMagickInitialized;
+ static bool s_bGTKInitialized;
+};
+
+BitmapPtr YCbCr2RGBBitmap(BitmapPtr pYBmp, BitmapPtr pUBmp, BitmapPtr pVBmp);
+
+template<class PIXEL>
+void Bitmap::setPixel(const IntPoint& p, PIXEL color)
+{
+ *(PIXEL*)(&(m_pBits[p.y*m_Stride+p.x*getBytesPerPixel()])) = color;
+}
+
+// TODO: This is slow, and it clips incorrectly. Replace with external lib?
+template<class PIXEL>
+void Bitmap::drawLine(IntPoint p0, IntPoint p1, PIXEL color)
+{
+ IntRect BmpRect(IntPoint(0,0), m_Size);
+ p0 = BmpRect.cropPoint(p0);
+ p1 = BmpRect.cropPoint(p1);
+
+ bool bSteep = abs(p1.y - p0.y) > abs(p1.x - p0.x);
+ if (bSteep) {
+ std::swap(p0.x, p0.y);
+ std::swap(p1.x, p1.y);
+ }
+ if (p0.x > p1.x) {
+ std::swap(p0, p1);
+ }
+ int deltax = p1.x - p0.x;
+ int deltay = abs(p1.y - p0.y);
+ int error = -deltax/2;
+ int ystep;
+ int y = p0.y;
+ if (p0.y < p1.y) {
+ ystep = 1;
+ } else {
+ ystep = -1;
+ }
+ for (int x = p0.x; x <= p1.x; x++) {
+ if (bSteep) {
+ setPixel(IntPoint(y, x), color);
+ } else {
+ setPixel(IntPoint(x, y), color);
+ }
+ error += deltay;
+ if (error > 0) {
+ y += ystep;
+ error -= deltax;
+ }
+ }
+}
+#if defined(__SSE__) || defined(_WIN32)
+std::ostream& operator<<(std::ostream& os, const __m64 &val);
+#endif
+
+}
+#endif
diff --git a/src/graphics/BitmapManager.cpp b/src/graphics/BitmapManager.cpp
new file mode 100644
index 0000000..d1d3676
--- /dev/null
+++ b/src/graphics/BitmapManager.cpp
@@ -0,0 +1,117 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "BitmapManager.h"
+
+#ifdef WIN32
+#include <io.h>
+#endif
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "../base/OSHelper.h"
+
+
+namespace avg {
+
+BitmapManager * BitmapManager::s_pBitmapManager=0;
+
+BitmapManager::BitmapManager()
+{
+ if (s_pBitmapManager) {
+ throw Exception(AVG_ERR_UNKNOWN, "BitmapMananger has already been instantiated.");
+ }
+
+ m_pCmdQueue = BitmapManagerThread::CQueuePtr(new BitmapManagerThread::CQueue);
+ m_pMsgQueue = BitmapManagerMsgQueuePtr(new BitmapManagerMsgQueue(8));
+ m_pBitmapManagerThread = new boost::thread(
+ BitmapManagerThread(*m_pCmdQueue, *m_pMsgQueue));
+
+ s_pBitmapManager = this;
+}
+
+BitmapManager::~BitmapManager()
+{
+ while (!m_pCmdQueue->empty()) {
+ m_pCmdQueue->pop();
+ }
+ while (!m_pMsgQueue->empty()) {
+ m_pMsgQueue->pop();
+ }
+ m_pCmdQueue->pushCmd(boost::bind(&BitmapManagerThread::stop, _1));
+ if (m_pBitmapManagerThread) {
+ m_pBitmapManagerThread->join();
+ delete m_pBitmapManagerThread;
+ }
+
+ s_pBitmapManager = 0;
+}
+
+BitmapManager* BitmapManager::get()
+{
+ if (!s_pBitmapManager) {
+ s_pBitmapManager = new BitmapManager();
+ }
+ return s_pBitmapManager;
+}
+
+void BitmapManager::loadBitmap(const UTF8String& sUtf8FileName,
+ const boost::python::object& pyFunc)
+{
+ std::string sFileName = convertUTF8ToFilename(sUtf8FileName);
+
+#ifdef WIN32
+ int rc = _access(sFileName.c_str(), 04);
+#else
+ int rc = access(sFileName.c_str(), R_OK);
+#endif
+
+ BitmapManagerMsgPtr msg = BitmapManagerMsgPtr(new BitmapManagerMsg());
+ msg->setRequest(sUtf8FileName, pyFunc);
+
+ if (rc != 0) {
+ msg->setError(Exception(AVG_ERR_FILEIO,
+ std::string("BitmapManager can't open output file '") +
+ sFileName + "'. Reason: " +
+ strerror(errno)));
+ m_pMsgQueue->push(msg);
+ } else {
+ m_pCmdQueue->pushCmd(boost::bind(&BitmapManagerThread::loadBitmap, _1, msg));
+ }
+}
+
+void BitmapManager::onFrameEnd()
+{
+ while (!m_pMsgQueue->empty()) {
+ BitmapManagerMsgPtr pMsg = m_pMsgQueue->pop();
+
+ try {
+ pMsg->executeCallback();
+ } catch (boost::python::error_already_set &) {
+ std::cerr << "Python exception in execute callback." << std::endl;
+ PyErr_Print();
+ exit(5);
+ }
+ }
+}
+
+
+}
diff --git a/src/graphics/BitmapManager.h b/src/graphics/BitmapManager.h
new file mode 100644
index 0000000..2599ba9
--- /dev/null
+++ b/src/graphics/BitmapManager.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _BitmapManager_H_
+#define _BitmapManager_H_
+
+#include "BitmapManagerThread.h"
+#include "BitmapManagerMsg.h"
+
+#include "../api.h"
+#include "Bitmap.h"
+#include "../base/Queue.h"
+#include "../base/IFrameEndListener.h"
+
+#include <boost/thread.hpp>
+
+
+namespace avg {
+
+class AVG_API BitmapManager : public IFrameEndListener
+{
+ public:
+ BitmapManager();
+ ~BitmapManager();
+ static BitmapManager* get();
+ void loadBitmap(const UTF8String& sUtf8FileName,
+ const boost::python::object& pyFunc);
+
+ virtual void onFrameEnd();
+
+ private:
+ static BitmapManager * s_pBitmapManager;
+
+ boost::thread* m_pBitmapManagerThread;
+ BitmapManagerThread::CQueuePtr m_pCmdQueue;
+ BitmapManagerMsgQueuePtr m_pMsgQueue;
+};
+
+}
+
+#endif
diff --git a/src/graphics/BitmapManagerMsg.cpp b/src/graphics/BitmapManagerMsg.cpp
new file mode 100644
index 0000000..986c4c4
--- /dev/null
+++ b/src/graphics/BitmapManagerMsg.cpp
@@ -0,0 +1,91 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "BitmapManagerMsg.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+
+namespace avg {
+
+BitmapManagerMsg::BitmapManagerMsg()
+ : m_MsgType(NONE),
+ m_pEx(0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+BitmapManagerMsg::~BitmapManagerMsg()
+{
+ if (m_pEx) {
+ delete m_pEx;
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void BitmapManagerMsg::setRequest(const UTF8String& sFilename,
+ const boost::python::object& onLoadedCb)
+{
+ AVG_ASSERT(m_MsgType == NONE);
+ m_sFilename = sFilename;
+ m_OnLoadedCb = onLoadedCb;
+ m_MsgType = REQUEST;
+}
+
+void BitmapManagerMsg::executeCallback()
+{
+ AVG_ASSERT(m_MsgType != NONE);
+ switch (m_MsgType) {
+ case BITMAP:
+ boost::python::call<void>(m_OnLoadedCb.ptr(), m_pBmp);
+ break;
+
+ case ERROR:
+ boost::python::call<void>(m_OnLoadedCb.ptr(), m_pEx);
+ break;
+
+ default:
+ AVG_ASSERT(false);
+ }
+}
+
+const UTF8String BitmapManagerMsg::getFilename()
+{
+ AVG_ASSERT(m_MsgType != NONE);
+ return m_sFilename;
+}
+
+void BitmapManagerMsg::setBitmap(BitmapPtr pBmp)
+{
+ AVG_ASSERT(m_MsgType == REQUEST);
+ m_pBmp = pBmp;
+ m_MsgType = BITMAP;
+}
+
+void BitmapManagerMsg::setError(const Exception& ex)
+{
+ AVG_ASSERT(m_MsgType == REQUEST);
+ m_MsgType = ERROR;
+ m_pEx = new Exception(ex);
+}
+
+}
diff --git a/src/graphics/BitmapManagerMsg.h b/src/graphics/BitmapManagerMsg.h
new file mode 100644
index 0000000..1a2ff38
--- /dev/null
+++ b/src/graphics/BitmapManagerMsg.h
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _BitmapManagerMsg_H_
+#define _BitmapManagerMsg_H_
+
+#include "../player/WrapPython.h"
+
+#include "../api.h"
+#include "../base/Queue.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/python.hpp>
+
+
+namespace avg {
+
+class AVG_API BitmapManagerMsg
+{
+public:
+ enum MsgType {NONE, REQUEST, BITMAP, ERROR};
+
+ BitmapManagerMsg();
+ virtual ~BitmapManagerMsg();
+
+ void executeCallback();
+ void setRequest(const UTF8String& sFilename, const boost::python::object& onLoadedCb);
+ const UTF8String getFilename();
+ void setBitmap(BitmapPtr pBmp);
+ void setError(const Exception& ex);
+
+ MsgType getType() { return m_MsgType; };
+
+private:
+ UTF8String m_sFilename;
+ BitmapPtr m_pBmp;
+ boost::python::object m_OnLoadedCb;
+ MsgType m_MsgType;
+ Exception* m_pEx;
+};
+
+typedef boost::shared_ptr<BitmapManagerMsg> BitmapManagerMsgPtr;
+typedef Queue<BitmapManagerMsg> BitmapManagerMsgQueue;
+typedef boost::shared_ptr<BitmapManagerMsgQueue> BitmapManagerMsgQueuePtr;
+}
+
+#endif
diff --git a/src/graphics/BitmapManagerThread.cpp b/src/graphics/BitmapManagerThread.cpp
new file mode 100644
index 0000000..fa84882
--- /dev/null
+++ b/src/graphics/BitmapManagerThread.cpp
@@ -0,0 +1,61 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "BitmapManagerThread.h"
+
+#include "Bitmap.h"
+#include "../base/Exception.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+namespace avg {
+
+static ProfilingZoneID ProfilingZoneLoadBitmap("BitmapManager loadBitmap");
+
+BitmapManagerThread::BitmapManagerThread(CQueue& cmdQ,
+ BitmapManagerMsgQueue& MsgQueue)
+ : WorkerThread<BitmapManagerThread>("BitmapManager", cmdQ),
+ m_MsgQueue(MsgQueue)
+{
+}
+
+bool BitmapManagerThread::work()
+{
+ waitForCommand();
+ return true;
+}
+
+void BitmapManagerThread::loadBitmap(BitmapManagerMsgPtr pRequest)
+{
+ BitmapPtr pBmp;
+
+ try {
+ pBmp = BitmapPtr(new Bitmap(pRequest->getFilename()));
+ pRequest->setBitmap(pBmp);
+ } catch (const Exception& ex) {
+ pRequest->setError(ex);
+ }
+
+ m_MsgQueue.push(pRequest);
+}
+
+}
diff --git a/src/graphics/BitmapManagerThread.h b/src/graphics/BitmapManagerThread.h
new file mode 100644
index 0000000..af86be5
--- /dev/null
+++ b/src/graphics/BitmapManagerThread.h
@@ -0,0 +1,51 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _BitmapManagerThread_H_
+#define _BitmapManagerThread_H_
+
+#include "../api.h"
+
+#include "BitmapManagerMsg.h"
+
+#include "../base/WorkerThread.h"
+#include "Bitmap.h"
+
+#include <boost/thread.hpp>
+
+
+namespace avg {
+
+class AVG_API BitmapManagerThread : public WorkerThread<BitmapManagerThread>
+{
+ public:
+ BitmapManagerThread(CQueue& cmdQ, BitmapManagerMsgQueue& MsgQueue);
+
+ void loadBitmap(BitmapManagerMsgPtr pRequest);
+
+ private:
+ virtual bool work();
+ BitmapManagerMsgQueue& m_MsgQueue;
+};
+
+}
+
+#endif
diff --git a/src/graphics/BmpTextureMover.cpp b/src/graphics/BmpTextureMover.cpp
new file mode 100644
index 0000000..6a2cd9b
--- /dev/null
+++ b/src/graphics/BmpTextureMover.cpp
@@ -0,0 +1,107 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "BmpTextureMover.h"
+
+#include "Bitmap.h"
+#include "GLTexture.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <cstring>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+BmpTextureMover::BmpTextureMover(const IntPoint& size, PixelFormat pf)
+ : TextureMover(size, pf)
+{
+ m_pBmp = BitmapPtr(new Bitmap(size, pf));
+}
+
+BmpTextureMover::~BmpTextureMover()
+{
+}
+
+void BmpTextureMover::moveBmpToTexture(BitmapPtr pBmp, GLTexture& tex)
+{
+ AVG_ASSERT(pBmp->getSize() == tex.getSize());
+ AVG_ASSERT(getSize() == pBmp->getSize());
+ AVG_ASSERT(pBmp->getPixelFormat() == getPF());
+ tex.activate();
+ unsigned char * pStartPos = pBmp->getPixels();
+ IntPoint size = tex.getSize();
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size.x, size.y,
+ tex.getGLFormat(getPF()), tex.getGLType(getPF()),
+ pStartPos);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "BmpTextureMover::moveBmpToTexture: glTexSubImage2D()");
+}
+
+BitmapPtr BmpTextureMover::moveTextureToBmp(GLTexture& tex, int mipmapLevel)
+{
+ AVG_ASSERT(getSize() == tex.getGLSize());
+ BitmapPtr pBmp;
+ IntPoint activeSize;
+ if (mipmapLevel == 0) {
+ activeSize = tex.getSize();
+ pBmp = BitmapPtr(new Bitmap(tex.getGLSize(), getPF()));
+ } else {
+ activeSize = tex.getMipmapSize(mipmapLevel);
+ pBmp = BitmapPtr(new Bitmap(activeSize, getPF()));
+ }
+
+ tex.activate(GL_TEXTURE0);
+
+ unsigned char * pStartPos = pBmp->getPixels();
+ glGetTexImage(GL_TEXTURE_2D, mipmapLevel, GLTexture::getGLFormat(getPF()),
+ GLTexture::getGLType(getPF()), pStartPos);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "BmpTextureMover::moveTextureToBmp: glGetTexImage()");
+
+ if (activeSize != tex.getGLSize()) {
+ BitmapPtr pTempBmp = pBmp;
+ pBmp = BitmapPtr(new Bitmap(activeSize, getPF(), pStartPos,
+ pTempBmp->getStride(), true));
+ }
+
+ return pBmp;
+}
+
+BitmapPtr BmpTextureMover::lock()
+{
+ return m_pBmp;
+}
+
+void BmpTextureMover::unlock()
+{
+}
+
+void BmpTextureMover::moveToTexture(GLTexture& tex)
+{
+ moveBmpToTexture(m_pBmp, tex);
+}
+
+}
diff --git a/src/graphics/BmpTextureMover.h b/src/graphics/BmpTextureMover.h
new file mode 100644
index 0000000..1c16513
--- /dev/null
+++ b/src/graphics/BmpTextureMover.h
@@ -0,0 +1,54 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _BmpTextureMover_H_
+#define _BmpTextureMover_H_
+
+#include "../api.h"
+#include "TextureMover.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API BmpTextureMover: public TextureMover {
+public:
+ BmpTextureMover(const IntPoint& size, PixelFormat pf);
+ virtual ~BmpTextureMover();
+
+ virtual void moveBmpToTexture(BitmapPtr pBmp, GLTexture& tex);
+ virtual BitmapPtr moveTextureToBmp(GLTexture& tex, int mipmapLevel=0);
+
+ virtual BitmapPtr lock();
+ virtual void unlock();
+ virtual void moveToTexture(GLTexture& tex);
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+typedef boost::shared_ptr<BmpTextureMover> BmpTextureMoverPtr;
+
+}
+
+#endif
+
+
diff --git a/src/graphics/ContribDefs.h b/src/graphics/ContribDefs.h
new file mode 100644
index 0000000..4e9e808
--- /dev/null
+++ b/src/graphics/ContribDefs.h
@@ -0,0 +1,75 @@
+// Fast and accurate bitmap scaling. Original code by Eran Yariv and Jake Montgomery,
+// posted on codeguru.com.
+
+#ifndef _ContribDefs_h_
+#define _ContribDefs_h_
+
+#include "../base/MathHelper.h"
+
+#include <math.h>
+
+namespace avg {
+
+class ContribDef
+{
+public:
+ ContribDef(double dWidth)
+ : m_dWidth (dWidth)
+ {}
+
+ virtual ~ContribDef() {}
+
+ double GetWidth() const
+ {
+ return m_dWidth;
+ }
+
+ void SetWidth(double dWidth)
+ {
+ m_dWidth = dWidth;
+ }
+
+ virtual double Filter(double dVal) const = 0;
+
+protected:
+ double m_dWidth;
+};
+
+class BilinearContribDef : public ContribDef
+{
+public:
+ BilinearContribDef(double dWidth = 1.0)
+ : ContribDef(dWidth)
+ {}
+
+ virtual ~BilinearContribDef() {}
+
+ virtual double Filter(double dVal) const
+ {
+ dVal = fabs(dVal);
+ return (dVal < m_dWidth ? m_dWidth - dVal : 0.0);
+ }
+};
+
+class GaussianContribDef : public ContribDef
+{
+public:
+ GaussianContribDef(double dWidth = 3.0)
+ : ContribDef(dWidth)
+ {}
+
+ virtual ~GaussianContribDef() {}
+
+ virtual double Filter(double dVal) const
+ {
+ if (fabs (dVal) > m_dWidth)
+ {
+ return 0.0;
+ }
+ return exp (-dVal * dVal / m_dWidth-1) / sqrt (2*M_PI);
+ }
+};
+
+}
+
+#endif
diff --git a/src/graphics/FBO.cpp b/src/graphics/FBO.cpp
new file mode 100644
index 0000000..de3eb6a
--- /dev/null
+++ b/src/graphics/FBO.cpp
@@ -0,0 +1,344 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FBO.h"
+
+#include "OGLHelper.h"
+#include "GLContext.h"
+
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+#include "../base/ObjectCounter.h"
+
+#include <stdio.h>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+FBO::FBO(const IntPoint& size, PixelFormat pf, unsigned numTextures,
+ unsigned multisampleSamples, bool bUsePackedDepthStencil, bool bMipmap)
+ : m_Size(size),
+ m_PF(pf),
+ m_MultisampleSamples(multisampleSamples),
+ m_bUsePackedDepthStencil(bUsePackedDepthStencil),
+ m_bMipmap(bMipmap)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ AVG_ASSERT(numTextures == 1 || multisampleSamples == 1);
+ if (multisampleSamples > 1 && !(isMultisampleFBOSupported())) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Multisample offscreen rendering is not supported by this OpenGL driver/card combination.");
+ }
+
+ for (unsigned i=0; i<numTextures; ++i) {
+ GLTexturePtr pTex = GLTexturePtr(new GLTexture(size, pf, bMipmap));
+ // Workaround for NVidia driver bug - GL_TEX_MIN_FILTER without
+ // glGenerateMipmaps causes FBO creation to fail(?!).
+ pTex->generateMipmaps();
+ m_pTextures.push_back(pTex);
+ }
+ init();
+}
+
+FBO::~FBO()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+
+ unsigned oldFBOID;
+ glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, (GLint*)&oldFBOID);
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, m_FBO);
+
+ for (unsigned i=0; i<m_pTextures.size(); ++i) {
+ glproc::FramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT+i,
+ GL_TEXTURE_2D, 0, 0);
+ }
+
+ GLContext* pContext = GLContext::getCurrent();
+ if (pContext) {
+ pContext->returnFBOToCache(m_FBO);
+ if (m_MultisampleSamples > 1) {
+ glproc::DeleteRenderbuffers(1, &m_ColorBuffer);
+ pContext->returnFBOToCache(m_OutputFBO);
+ }
+ if (m_bUsePackedDepthStencil && isPackedDepthStencilSupported()) {
+ glproc::DeleteRenderbuffers(1, &m_StencilBuffer);
+ glproc::FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, 0);
+ glproc::FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, 0);
+ if (m_MultisampleSamples > 1) {
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, m_OutputFBO);
+ glproc::FramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, 0, 0);
+ }
+ }
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, oldFBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "~FBO");
+ }
+}
+
+void FBO::activate() const
+{
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, m_FBO);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::activate: BindFramebuffer()");
+ checkError("activate");
+}
+
+PixelFormat FBO::getPF() const
+{
+ return m_PF;
+}
+
+unsigned FBO::getNumTextures() const
+{
+ return m_pTextures.size();
+}
+
+void FBO::copyToDestTexture() const
+{
+ if (m_MultisampleSamples != 1) {
+ // Copy Multisample FBO to destination fbo
+ glproc::BindFramebuffer(GL_READ_FRAMEBUFFER_EXT, m_FBO);
+ glproc::BindFramebuffer(GL_DRAW_FRAMEBUFFER_EXT, m_OutputFBO);
+ glproc::BlitFramebuffer(0, 0, m_Size.x, m_Size.y, 0, 0, m_Size.x, m_Size.y,
+ GL_COLOR_BUFFER_BIT, GL_LINEAR);
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+ }
+ if (m_bMipmap) {
+ for (unsigned i=0; i< m_pTextures.size(); ++i) {
+ m_pTextures[i]->generateMipmaps();
+ }
+ }
+}
+
+BitmapPtr FBO::getImage(int i) const
+{
+ moveToPBO(i);
+ return getImageFromPBO();
+}
+
+void FBO::moveToPBO(int i) const
+{
+ // Get data directly from the FBO using glReadBuffer. At least on NVidia/Linux, this
+ // is faster than reading stuff from the texture.
+ copyToDestTexture();
+ if (m_MultisampleSamples != 1) {
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, m_OutputFBO);
+ } else {
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, m_FBO);
+ }
+ PixelFormat pf = m_pOutputPBO->getPF();
+ IntPoint size = m_pOutputPBO->getSize();
+
+ m_pOutputPBO->activate();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::moveToPBO BindBuffer()");
+ glReadBuffer(GL_COLOR_ATTACHMENT0_EXT+i);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::moveToPBO ReadBuffer()");
+
+ glReadPixels(0, 0, size.x, size.y, GLTexture::getGLFormat(pf),
+ GLTexture::getGLType(pf), 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::moveToPBO ReadPixels()");
+}
+
+BitmapPtr FBO::getImageFromPBO() const
+{
+ m_pOutputPBO->activate();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::getImageFromPBO BindBuffer()");
+ PixelFormat pf = m_pOutputPBO->getPF();
+ IntPoint size = m_pOutputPBO->getSize();
+ BitmapPtr pBmp(new Bitmap(size, pf));
+ void * pPBOPixels = glproc::MapBuffer(GL_PIXEL_PACK_BUFFER_EXT, GL_READ_ONLY);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::getImageFromPBO MapBuffer()");
+ Bitmap PBOBitmap(size, pf, (unsigned char *)pPBOPixels,
+ size.x*getBytesPerPixel(pf), false);
+ pBmp->copyPixels(PBOBitmap);
+ glproc::UnmapBuffer(GL_PIXEL_PACK_BUFFER_EXT);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::getImageFromPBO UnmapBuffer()");
+ return pBmp;
+}
+
+GLTexturePtr FBO::getTex(int i) const
+{
+ return m_pTextures[i];
+}
+
+const IntPoint& FBO::getSize() const
+{
+ return m_Size;
+}
+
+void FBO::init()
+{
+ GLContext* pContext = GLContext::getCurrent();
+ if (m_bUsePackedDepthStencil && !isPackedDepthStencilSupported()) {
+ throw Exception(AVG_ERR_UNSUPPORTED, "OpenGL implementation does not support offscreen cropping (GL_EXT_packed_depth_stencil).");
+ }
+ if (m_MultisampleSamples > 1 && !isMultisampleFBOSupported()) {
+ throw Exception(AVG_ERR_UNSUPPORTED, "OpenGL implementation does not support multisample offscreen rendering (GL_EXT_framebuffer_multisample).");
+ }
+ m_pOutputPBO = PBOPtr(new PBO(m_Size, m_PF, GL_STREAM_READ));
+
+ m_FBO = pContext->genFBO();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::init: GenFramebuffers()");
+
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, m_FBO);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::init: BindFramebuffer()");
+
+ if (m_MultisampleSamples == 1) {
+ glDisable(GL_MULTISAMPLE);
+ for (unsigned i=0; i<m_pTextures.size(); ++i) {
+ glproc::FramebufferTexture2D(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT+i, GL_TEXTURE_2D,
+ m_pTextures[i]->getID(), 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO: glFramebufferTexture2D()");
+ }
+ if (m_bUsePackedDepthStencil) {
+ glproc::GenRenderbuffers(1, &m_StencilBuffer);
+ glproc::BindRenderbuffer(GL_RENDERBUFFER_EXT, m_StencilBuffer);
+ glproc::RenderbufferStorage(GL_RENDERBUFFER_EXT, GL_DEPTH_STENCIL_EXT,
+ m_Size.x, m_Size.y);
+ glproc::FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, m_StencilBuffer);
+ glproc::FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, m_StencilBuffer);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "FBO::init: FramebufferRenderbuffer(STENCIL)");
+ }
+ } else {
+ glEnable(GL_MULTISAMPLE);
+ glproc::GenRenderbuffers(1, &m_ColorBuffer);
+ glproc::BindRenderbuffer(GL_RENDERBUFFER_EXT, m_ColorBuffer);
+ glproc::RenderbufferStorageMultisample(GL_RENDERBUFFER_EXT, m_MultisampleSamples,
+ GL_RGBA8, m_Size.x, m_Size.y);
+ GLenum err = glGetError();
+ if (err == GL_INVALID_VALUE) {
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+ glproc::DeleteFramebuffers(1, &m_FBO);
+ glproc::DeleteRenderbuffers(1, &m_ColorBuffer);
+ m_pOutputPBO = PBOPtr();
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ string("Unsupported value for number of multisample samples (")
+ + toString(m_MultisampleSamples) + ")."));
+ }
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::init: RenderbufferStorageMultisample");
+ glproc::FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_RENDERBUFFER_EXT, m_ColorBuffer);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::init: FramebufferRenderbuffer");
+ if (m_bUsePackedDepthStencil) {
+ glproc::GenRenderbuffers(1, &m_StencilBuffer);
+ glproc::BindRenderbuffer(GL_RENDERBUFFER_EXT, m_StencilBuffer);
+ glproc::RenderbufferStorageMultisample(GL_RENDERBUFFER_EXT,
+ m_MultisampleSamples, GL_DEPTH_STENCIL_EXT, m_Size.x, m_Size.y);
+ glproc::FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, m_StencilBuffer);
+ glproc::FramebufferRenderbuffer(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT,
+ GL_RENDERBUFFER_EXT, m_StencilBuffer);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "FBO::init: FramebufferRenderbuffer(STENCIL)");
+ }
+ checkError("init multisample");
+ m_OutputFBO = pContext->genFBO();
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, m_OutputFBO);
+ glproc::FramebufferTexture2D(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+ GL_TEXTURE_2D, m_pTextures[0]->getID(), 0);
+
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "FBO::init: Multisample init");
+ }
+
+ checkError("init");
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+}
+
+bool FBO::isFBOSupported()
+{
+ return queryOGLExtension("GL_EXT_framebuffer_object");
+}
+
+bool FBO::isMultisampleFBOSupported()
+{
+ int maxSamples;
+ glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
+ // For some reason, this fails on Linux/i945 and similar setups. Multisample
+ // FBO is broken anyway on these machines, so we just return false...
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR) {
+ return false;
+ }
+ return queryOGLExtension("GL_EXT_framebuffer_multisample") &&
+ queryOGLExtension("GL_EXT_framebuffer_blit") && maxSamples > 1;
+}
+
+bool FBO::isPackedDepthStencilSupported()
+{
+ return queryOGLExtension("GL_EXT_packed_depth_stencil");
+}
+
+void FBO::checkError(const string& sContext) const
+{
+ GLenum status = glproc::CheckFramebufferStatus(GL_FRAMEBUFFER_EXT);
+ string sErr;
+ switch (status) {
+ case GL_FRAMEBUFFER_COMPLETE_EXT:
+ return;
+ case GL_FRAMEBUFFER_UNSUPPORTED_EXT:
+ sErr = "GL_FRAMEBUFFER_UNSUPPORTED_EXT";
+ throw Exception(AVG_ERR_UNSUPPORTED, string("Framebuffer error: ")+sErr);
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT:
+ sErr = "GL_INCOMPLETE_ATTACHMENT";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT:
+ sErr = "GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT:
+ sErr = "GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT";
+ break;
+#ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT
+ // Missing in some versions of glext.h
+ case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT:
+ sErr = "GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT";
+ break;
+#endif
+ case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT:
+ sErr = "GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT:
+ sErr = "GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT";
+ break;
+ case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT:
+ sErr = "GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT";
+ break;
+ case GL_FRAMEBUFFER_BINDING_EXT:
+ sErr = "GL_FRAMEBUFFER_BINDING_EXT";
+ break;
+ default:
+ sErr = "Unknown error";
+ break;
+ }
+ cerr << "Framebuffer error (" << sContext << "): " << sErr << endl;
+ AVG_ASSERT(false);
+}
+
+}
+
+
diff --git a/src/graphics/FBO.h b/src/graphics/FBO.h
new file mode 100644
index 0000000..680adf0
--- /dev/null
+++ b/src/graphics/FBO.h
@@ -0,0 +1,90 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FBO_H_
+#define _FBO_H_
+
+#include "../api.h"
+
+#include "GLTexture.h"
+#include "PBO.h"
+#include "VertexArray.h"
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <vector>
+
+namespace avg {
+
+class AVG_API FBO
+{
+public:
+ FBO(const IntPoint& size, PixelFormat pf, unsigned numTextures=1,
+ unsigned multisampleSamples=1, bool bUsePackedDepthStencil=false,
+ bool bMipmap=false);
+ virtual ~FBO();
+
+ void activate() const;
+ PixelFormat getPF() const;
+ unsigned getNumTextures() const;
+
+ void copyToDestTexture() const;
+ BitmapPtr getImage(int i=0) const;
+ void moveToPBO(int i=0) const;
+ BitmapPtr getImageFromPBO() const;
+ GLTexturePtr getTex(int i=0) const;
+ const IntPoint& getSize() const;
+
+ static bool isFBOSupported();
+ static bool isMultisampleFBOSupported();
+ static bool isPackedDepthStencilSupported();
+
+ void initCache();
+ static void deleteCache();
+
+private:
+ void init();
+ void checkError(const std::string& sContext) const;
+
+ IntPoint m_Size;
+ PixelFormat m_PF;
+ unsigned m_MultisampleSamples;
+ bool m_bUsePackedDepthStencil;
+ bool m_bMipmap;
+
+ PBOPtr m_pOutputPBO;
+ unsigned m_FBO;
+ std::vector<GLTexturePtr> m_pTextures;
+ unsigned m_StencilBuffer;
+
+ // Multisample support
+ unsigned m_ColorBuffer;
+ unsigned m_OutputFBO;
+
+};
+
+typedef boost::shared_ptr<FBO> FBOPtr;
+
+}
+
+#endif
diff --git a/src/graphics/Filter.cpp b/src/graphics/Filter.cpp
new file mode 100644
index 0000000..bdb4e8d
--- /dev/null
+++ b/src/graphics/Filter.cpp
@@ -0,0 +1,55 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filter.h"
+#include "Bitmap.h"
+
+#include "../base/ObjectCounter.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+Filter::Filter()
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+Filter::~Filter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void Filter::applyInPlace(BitmapPtr pBmp)
+{
+ *pBmp = *(apply(pBmp));
+}
+
+BitmapPtr Filter::apply(BitmapPtr pBmpSource)
+{
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(*pBmpSource));
+ applyInPlace(pBmpDest);
+ return pBmpDest;
+}
+
+}
diff --git a/src/graphics/Filter.h b/src/graphics/Filter.h
new file mode 100644
index 0000000..eb04e53
--- /dev/null
+++ b/src/graphics/Filter.h
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filter_H_
+#define _Filter_H_
+
+#include "../api.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+// Base class for filters that operate on bitmaps. Derived classes need
+// to override either the applyInPlace or the apply function. The base-class
+// versions of these functions simply implement one function in terms of the
+// other.
+class AVG_API Filter
+{
+public:
+ Filter();
+ virtual ~Filter();
+
+ // In-Place Apply. Applies the filter to pBmp. The base-class
+ // version copies the bitmap after calling Apply (pBmp, pTempBmp).
+ virtual void applyInPlace(BitmapPtr pBmp);
+
+ // Applies the Filter to pBmpSource and returns the result
+ // The base-class version copies the bitmap before calling
+ // applyInPlace.
+ virtual BitmapPtr apply(BitmapPtr pBmpSource);
+};
+
+typedef boost::shared_ptr<Filter> FilterPtr;
+
+}
+
+#endif
diff --git a/src/graphics/Filter3x3.cpp b/src/graphics/Filter3x3.cpp
new file mode 100644
index 0000000..b58c80a
--- /dev/null
+++ b/src/graphics/Filter3x3.cpp
@@ -0,0 +1,68 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filter3x3.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+
+namespace avg {
+
+Filter3x3::Filter3x3(double Mat[3][3])
+ : Filter()
+{
+ for (int y = 0; y < 3; y++) {
+ for (int x = 0; x < 3; x++) {
+ m_Mat[y][x] = Mat[y][x];
+ }
+ }
+}
+
+Filter3x3::~Filter3x3()
+{
+
+}
+
+BitmapPtr Filter3x3::apply(BitmapPtr pBmpSource)
+{
+ IntPoint newSize(pBmpSource->getSize().x-2, pBmpSource->getSize().y-2);
+ BitmapPtr pNewBmp(new Bitmap(newSize, pBmpSource->getPixelFormat(),
+ pBmpSource->getName()+"_filtered"));
+
+ for (int y = 0; y < newSize.y; y++) {
+ const unsigned char * pSrc = pBmpSource->getPixels()+y*pBmpSource->getStride();
+ unsigned char * pDest = pNewBmp->getPixels()+y*pNewBmp->getStride();
+ switch (pBmpSource->getBytesPerPixel()) {
+ case 4:
+ convolveLine<Pixel32>(pSrc, pDest, newSize.x, pBmpSource->getStride());
+ break;
+ case 3:
+ convolveLine<Pixel24>(pSrc, pDest, newSize.x, pBmpSource->getStride());
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ }
+ return pNewBmp;
+}
+
+}
diff --git a/src/graphics/Filter3x3.h b/src/graphics/Filter3x3.h
new file mode 100644
index 0000000..5d00070
--- /dev/null
+++ b/src/graphics/Filter3x3.h
@@ -0,0 +1,82 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filter3x3_H
+#define _Filter3x3_H
+
+#include "../api.h"
+#include "Filter.h"
+
+#include "Pixel8.h"
+#include "Pixel24.h"
+#include "Pixel32.h"
+
+#include <iostream>
+
+namespace avg {
+
+// Filter that applies a 3x3 kernel to the bitmap.
+class AVG_API Filter3x3 : public Filter
+{
+public:
+ Filter3x3(double Mat[3][3]);
+ virtual ~Filter3x3();
+ virtual BitmapPtr apply(BitmapPtr pBmpSource);
+
+private:
+ template<class PIXEL>
+ void convolveLine(const unsigned char * pSrc, unsigned char * pDest,
+ int lineLen, int stride) const;
+ double m_Mat[3][3];
+};
+
+template<class PIXEL>
+void Filter3x3::convolveLine(const unsigned char * pSrc, unsigned char * pDest,
+ int lineLen, int stride) const
+{
+ PIXEL * pSrcPixel = (PIXEL *)pSrc;
+ PIXEL * pDestPixel = (PIXEL *)pDest;
+ for (int x = 0; x < lineLen; ++x) {
+ double newR = 0;
+ double newG = 0;
+ double newB = 0;
+
+ for (int i = 0; i < 3; i++) {
+ for (int j = 0; j < 3; j++) {
+ unsigned char * pLineStart = (unsigned char *)pSrcPixel+i*stride;
+ PIXEL SrcPixel = *((PIXEL *)pLineStart+j);
+ newR += SrcPixel.getR()*m_Mat[i][j];
+ newG += SrcPixel.getG()*m_Mat[i][j];
+ newB += SrcPixel.getB()*m_Mat[i][j];
+ }
+ }
+ *pDestPixel = PIXEL((unsigned char)newR, (unsigned char)newG,
+ (unsigned char)newB);
+
+ pSrcPixel++;
+ pDestPixel++;
+ }
+}
+
+}
+
+#endif
+
diff --git a/src/graphics/FilterBandpass.cpp b/src/graphics/FilterBandpass.cpp
new file mode 100644
index 0000000..393b03b
--- /dev/null
+++ b/src/graphics/FilterBandpass.cpp
@@ -0,0 +1,77 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterBandpass.h"
+#include "Filterfill.h"
+#include "Pixel8.h"
+#include "Bitmap.h"
+
+#include <iostream>
+#include <math.h>
+
+using namespace std;
+
+namespace avg {
+
+FilterBandpass::FilterBandpass(double lowWidth, double highWidth)
+ : m_HighpassFilter(highWidth),
+ m_LowpassFilter(lowWidth)
+{
+ m_FilterWidthDiff = int(ceil(highWidth))-int(ceil(lowWidth));
+}
+
+FilterBandpass::~FilterBandpass()
+{
+}
+
+BitmapPtr FilterBandpass::apply(BitmapPtr pBmpSrc)
+{
+ BitmapPtr pLPBmp = m_LowpassFilter.apply(pBmpSrc);
+ BitmapPtr pHPBmp = m_HighpassFilter.apply(pBmpSrc);
+
+ IntPoint Size = pHPBmp->getSize();
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(Size, I8, pBmpSrc->getName()));
+
+ int lpStride = pLPBmp->getStride();
+ int hpStride = pHPBmp->getStride();
+ int destStride = pDestBmp->getStride();
+ unsigned char * pLPLine = pLPBmp->getPixels()+m_FilterWidthDiff*lpStride;
+ unsigned char * pHPLine = pHPBmp->getPixels();
+ unsigned char * pDestLine = pDestBmp->getPixels();
+ for (int y = 0; y < Size.y; ++y) {
+ unsigned char * pLPPixel = pLPLine+m_FilterWidthDiff;
+ unsigned char * pHPPixel = pHPLine;
+ unsigned char * pDestPixel = pDestLine;
+ for (int x = 0; x < Size.x; ++x) {
+ *pDestPixel = (int(*pLPPixel)-*pHPPixel)+128;
+ ++pLPPixel;
+ ++pHPPixel;
+ ++pDestPixel;
+ }
+ pLPLine += lpStride;
+ pHPLine += hpStride;
+ pDestLine += destStride;
+ }
+ return pDestBmp;
+}
+
+
+}
diff --git a/src/graphics/FilterBandpass.h b/src/graphics/FilterBandpass.h
new file mode 100644
index 0000000..a6d24f3
--- /dev/null
+++ b/src/graphics/FilterBandpass.h
@@ -0,0 +1,52 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterBandpass_H_
+#define _FilterBandpass_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "FilterGauss.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+// XXX: Warning, possibly buggy.
+class AVG_API FilterBandpass: public Filter {
+public:
+ FilterBandpass(double lowWidth, double highWidth);
+ virtual ~FilterBandpass();
+
+ virtual BitmapPtr apply(BitmapPtr pBmpSrc);
+
+private:
+ FilterGauss m_HighpassFilter;
+ FilterGauss m_LowpassFilter;
+ int m_FilterWidthDiff;
+};
+
+typedef boost::shared_ptr<FilterBandpass> FilterBandpassPtr;
+
+}
+
+#endif
diff --git a/src/graphics/FilterBlur.cpp b/src/graphics/FilterBlur.cpp
new file mode 100644
index 0000000..98f9307
--- /dev/null
+++ b/src/graphics/FilterBlur.cpp
@@ -0,0 +1,69 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterBlur.h"
+#include "Filterfill.h"
+#include "Pixel8.h"
+#include "Bitmap.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <math.h>
+
+using namespace std;
+
+namespace avg {
+
+FilterBlur::FilterBlur()
+{
+}
+
+FilterBlur::~FilterBlur()
+{
+}
+
+BitmapPtr FilterBlur::apply(BitmapPtr pBmpSrc)
+{
+ AVG_ASSERT(pBmpSrc->getPixelFormat() == I8);
+
+ IntPoint Size(pBmpSrc->getSize().x-2, pBmpSrc->getSize().y-2);
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(Size, I8, pBmpSrc->getName()));
+ int srcStride = pBmpSrc->getStride();
+ int destStride = pDestBmp->getStride();
+ unsigned char * pSrcLine = pBmpSrc->getPixels()+srcStride+1;
+ unsigned char * pDestLine = pDestBmp->getPixels();
+ for (int y = 0; y < Size.y; ++y) {
+ unsigned char * pSrcPixel = pSrcLine;
+ unsigned char * pDestPixel = pDestLine;
+ for (int x = 0; x < Size.x; ++x) {
+ *pDestPixel = (*(pSrcPixel-1) + *(pSrcPixel)*4 + *(pSrcPixel+1)
+ +*(pSrcPixel-srcStride)+*(pSrcPixel+srcStride)+4)/8;
+ ++pSrcPixel;
+ ++pDestPixel;
+ }
+ pSrcLine += srcStride;
+ pDestLine += destStride;
+ }
+ return pDestBmp;
+}
+
+}
diff --git a/src/graphics/FilterBlur.h b/src/graphics/FilterBlur.h
new file mode 100644
index 0000000..a558897
--- /dev/null
+++ b/src/graphics/FilterBlur.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterBlur_H_
+#define _FilterBlur_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API FilterBlur: public Filter {
+ public:
+ FilterBlur();
+ virtual ~FilterBlur();
+
+ virtual BitmapPtr apply(BitmapPtr pBmpSrc);
+
+ private:
+};
+
+typedef boost::shared_ptr<FilterBlur> FilterBlurPtr;
+}
+#endif
diff --git a/src/graphics/FilterConvol.h b/src/graphics/FilterConvol.h
new file mode 100644
index 0000000..f6f3efd
--- /dev/null
+++ b/src/graphics/FilterConvol.h
@@ -0,0 +1,141 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterConvol_H
+#define _FilterConvol_H
+
+#include "../api.h"
+#include "Filter.h"
+
+#include "Pixel8.h"
+#include "Pixel24.h"
+#include "Pixel32.h"
+
+#include <iostream>
+
+namespace avg {
+
+// Filter that applies a 3x3 kernel to the bitmap.
+template<class Pixel>
+class AVG_API FilterConvol : public Filter
+{
+public:
+ FilterConvol(double *Mat,int n,int m, int offset=0);
+ virtual ~FilterConvol();
+ virtual BitmapPtr apply(BitmapPtr pBmpSource);
+
+private:
+ void convolveLine(const unsigned char* pSrc, unsigned char* pDest,
+ int lineLen, int stride, int offset = 0) const;
+ int m_N;
+ int m_M;
+ int m_Offset;
+ double *m_Mat;
+};
+template <class Pixel>
+void FilterConvol<Pixel>::convolveLine(const unsigned char* pSrc, unsigned char* pDest,
+ int lineLen, int stride, int offset) const
+{
+ Pixel * pSrcPixel = (Pixel *)pSrc;
+ Pixel * pDestPixel = (Pixel *)pDest;
+ for (int x=0; x<lineLen; ++x) {
+ double NewR = 0;
+ double NewG = 0;
+ double NewB = 0;
+
+ for (int i=0; i<m_N; i++) {
+ for (int j=0; j<m_N; j++) {
+ unsigned char * pLineStart = (unsigned char *)pSrcPixel+i*stride;
+ Pixel SrcPixel = *((Pixel *)pLineStart+j);
+ NewR += SrcPixel.getR()*m_Mat[m_N*i+j];
+ NewG += SrcPixel.getG()*m_Mat[m_N*i+j];
+ NewB += SrcPixel.getB()*m_Mat[m_N*i+j];
+ }
+ }
+ *pDestPixel = Pixel((unsigned char)(NewR+offset), (unsigned char)(NewG+offset),
+ (unsigned char)(NewB+offset));
+
+ pSrcPixel++;
+ pDestPixel++;
+ }
+}
+template <>
+void FilterConvol<Pixel8>::convolveLine(const unsigned char* pSrc, unsigned char* pDest,
+ int lineLen, int stride, int offset) const
+{
+ Pixel8 * pSrcPixel = (Pixel8 *)pSrc;
+ Pixel8 * pDestPixel = (Pixel8 *)pDest;
+ for (int x=0; x<lineLen; ++x) {
+ double New = 0;
+
+ for (int i=0; i<m_N; i++) {
+ for (int j=0; j<m_N; j++) {
+ unsigned char * pLineStart = (unsigned char *)pSrcPixel+i*stride;
+ Pixel8 SrcPixel = *((Pixel8 *)pLineStart+j);
+ New += SrcPixel.get()*m_Mat[m_N*i+j];
+ }
+ }
+ *pDestPixel = Pixel8((unsigned char)(New+offset));
+
+ pSrcPixel++;
+ pDestPixel++;
+ }
+}
+template <class Pixel>
+FilterConvol<Pixel>::FilterConvol(double *Mat, int n, int m, int offset)
+ : Filter(),
+ m_N(n),
+ m_M(m),
+ m_Offset(offset)
+{
+ m_Mat = new double[n*m];
+ for (int y=0; y<n; y++) {
+ for (int x=0; x<m; x++) {
+ m_Mat[m_N*y+x] = Mat[m_N*y+x];
+ }
+ }
+}
+template <class Pixel>
+FilterConvol<Pixel>::~FilterConvol()
+{
+ delete[] m_Mat;
+
+}
+template <class Pixel>
+BitmapPtr FilterConvol<Pixel>::apply(BitmapPtr pBmpSource)
+{
+ IntPoint NewSize(pBmpSource->getSize().x-m_N+1, pBmpSource->getSize().y-m_M+1);
+ BitmapPtr pNewBmp(new Bitmap(NewSize, pBmpSource->getPixelFormat(),
+ pBmpSource->getName()+"_filtered"));
+
+ for (int y = 0; y < NewSize.y; y++) {
+ const unsigned char * pSrc = pBmpSource->getPixels()+y*pBmpSource->getStride();
+ unsigned char * pDest = pNewBmp->getPixels()+y*pNewBmp->getStride();
+ convolveLine(pSrc, pDest, NewSize.x, pBmpSource->getStride(), m_Offset);
+ }
+ return pNewBmp;
+}
+
+
+}
+
+#endif
+
diff --git a/src/graphics/FilterDilation.cpp b/src/graphics/FilterDilation.cpp
new file mode 100644
index 0000000..44fbc6e
--- /dev/null
+++ b/src/graphics/FilterDilation.cpp
@@ -0,0 +1,71 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterDilation.h"
+
+#include "../base/Exception.h"
+
+#include <algorithm>
+
+using namespace std;
+
+namespace avg {
+
+FilterDilation::FilterDilation()
+ : Filter()
+{
+}
+
+FilterDilation::~FilterDilation()
+{
+
+}
+
+BitmapPtr FilterDilation::apply(BitmapPtr pSrcBmp)
+{
+ AVG_ASSERT(pSrcBmp->getPixelFormat() == I8);
+ IntPoint size = pSrcBmp->getSize();
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(size, I8, pSrcBmp->getName()));
+ unsigned char * pSrcLine = pSrcBmp->getPixels();
+ unsigned char * pNextSrcLine;
+ unsigned char * pDestLine = pDestBmp->getPixels();
+ for (int y = 0; y < size.y; y++) {
+ pDestLine = pDestBmp->getPixels()+y*pDestBmp->getStride();
+ unsigned char * pLastSrcLine = pSrcLine;
+ pSrcLine = pSrcBmp->getPixels()+y*pSrcBmp->getStride();
+ if (y < size.y-1) {
+ pNextSrcLine = pSrcBmp->getPixels()+(y+1)*pSrcBmp->getStride();
+ } else {
+ pNextSrcLine = pSrcBmp->getPixels()+y*pSrcBmp->getStride();
+ }
+ pDestLine[0] = max(pSrcLine[0], max(pSrcLine[1],
+ max(pLastSrcLine[0], pNextSrcLine[0])));
+ for (int x = 1; x < size.x-1; x++) {
+ pDestLine[x] = max(pSrcLine[x], max(pSrcLine[x-1], max(pSrcLine[x+1],
+ max(pLastSrcLine[x], pNextSrcLine[x]))));
+ }
+ pDestLine[size.x-1] = max(pSrcLine[size.x-2], max(pSrcLine[size.x-1],
+ max(pLastSrcLine[size.x-1], pNextSrcLine[size.x-1])));
+ }
+ return pDestBmp;
+}
+
+} // namespace
diff --git a/src/graphics/FilterDilation.h b/src/graphics/FilterDilation.h
new file mode 100644
index 0000000..fecd0f6
--- /dev/null
+++ b/src/graphics/FilterDilation.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterDilation_H_
+#define _FilterDilation_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Grayscale 4-neighborhood dilation. Replaces each pixel with the maximum of
+// its neighbors.
+class AVG_API FilterDilation : public Filter
+{
+public:
+ FilterDilation();
+ virtual ~FilterDilation();
+ virtual BitmapPtr apply(BitmapPtr pBmp);
+
+private:
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/FilterErosion.cpp b/src/graphics/FilterErosion.cpp
new file mode 100644
index 0000000..3f44ade
--- /dev/null
+++ b/src/graphics/FilterErosion.cpp
@@ -0,0 +1,71 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterErosion.h"
+
+#include "../base/Exception.h"
+
+#include <algorithm>
+
+using namespace std;
+
+namespace avg {
+
+FilterErosion::FilterErosion()
+ : Filter()
+{
+}
+
+FilterErosion::~FilterErosion()
+{
+
+}
+
+BitmapPtr FilterErosion::apply(BitmapPtr pSrcBmp)
+{
+ AVG_ASSERT(pSrcBmp->getPixelFormat() == I8);
+ IntPoint size = pSrcBmp->getSize();
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(size, I8, pSrcBmp->getName()));
+ unsigned char * pSrcLine = pSrcBmp->getPixels();
+ unsigned char * pNextSrcLine;
+ unsigned char * pDestLine = pDestBmp->getPixels();
+ for (int y = 0; y < size.y; y++) {
+ pDestLine = pDestBmp->getPixels()+y*pDestBmp->getStride();
+ unsigned char * pLastSrcLine = pSrcLine;
+ pSrcLine = pSrcBmp->getPixels()+y*pSrcBmp->getStride();
+ if (y < size.y-1) {
+ pNextSrcLine = pSrcBmp->getPixels()+(y+1)*pSrcBmp->getStride();
+ } else {
+ pNextSrcLine = pSrcBmp->getPixels()+y*pSrcBmp->getStride();
+ }
+ pDestLine[0] = min(pSrcLine[0], min(pSrcLine[1],
+ min(pLastSrcLine[0], pNextSrcLine[0])));
+ for (int x = 1; x < size.x-1; x++) {
+ pDestLine[x] = min(pSrcLine[x], min(pSrcLine[x-1], min(pSrcLine[x+1],
+ min(pLastSrcLine[x], pNextSrcLine[x]))));
+ }
+ pDestLine[size.x-1] = min(pSrcLine[size.x-2], min(pSrcLine[size.x-1],
+ min(pLastSrcLine[size.x-1], pNextSrcLine[size.x-1])));
+ }
+ return pDestBmp;
+}
+
+} // namespace
diff --git a/src/graphics/FilterErosion.h b/src/graphics/FilterErosion.h
new file mode 100644
index 0000000..539fd75
--- /dev/null
+++ b/src/graphics/FilterErosion.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterErosion_H_
+#define _FilterErosion_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Grayscale 4-neighborhood erosion. Replaces each pixel with the minimum of
+// its neighbors.
+class AVG_API FilterErosion : public Filter
+{
+public:
+ FilterErosion();
+ virtual ~FilterErosion();
+ virtual BitmapPtr apply(BitmapPtr pBmp);
+
+private:
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/FilterFastBandpass.cpp b/src/graphics/FilterFastBandpass.cpp
new file mode 100644
index 0000000..83c4634
--- /dev/null
+++ b/src/graphics/FilterFastBandpass.cpp
@@ -0,0 +1,92 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterFastBandpass.h"
+#include "FilterBlur.h"
+#include "Filterfill.h"
+#include "Pixel8.h"
+#include "Bitmap.h"
+
+#include "../base/Exception.h"
+
+#include <cstring>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+FilterFastBandpass::FilterFastBandpass()
+{
+}
+
+FilterFastBandpass::~FilterFastBandpass()
+{
+}
+
+BitmapPtr FilterFastBandpass::apply(BitmapPtr pBmpSrc)
+{
+ AVG_ASSERT(pBmpSrc->getPixelFormat() == I8);
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(pBmpSrc->getSize(), I8,
+ pBmpSrc->getName()));
+ int srcStride = pBmpSrc->getStride();
+ int destStride = pBmpDest->getStride();
+ unsigned char * pSrcLine = pBmpSrc->getPixels()+3*srcStride;
+ unsigned char * pDestLine = pBmpDest->getPixels()+3*destStride;
+ IntPoint size = pBmpDest->getSize();
+ for (int y = 3; y < size.y-3; ++y) {
+ unsigned char * pSrcPixel = pSrcLine+3;
+ unsigned char * pDstPixel = pDestLine;
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ for (int x = 3; x < size.x-3; ++x) {
+ // Convolution Matrix is
+ // 0 0 0 0 0 0 0
+ // 0 -2 0 0 0 -2 0
+ // 0 0 1 0 1 0 0
+ // 0 0 0 4 0 0 0
+ // 0 0 1 0 1 0 0
+ // 0 -2 0 0 0 -2 0
+ // 0 0 0 0 0 0 0
+ *pDstPixel = 128
+ - int(*(pSrcPixel-2*srcStride-2)*2 + *(pSrcPixel-2*srcStride+2)*2 -
+ *(pSrcPixel-srcStride-1) - *(pSrcPixel-1*srcStride+1) -
+ *(pSrcPixel+srcStride-1) - *(pSrcPixel+1*srcStride+1) +
+ *(pSrcPixel+2*srcStride-2)*2 + *(pSrcPixel+2*srcStride+2)*2+2)/4
+ + *pSrcPixel;
+ ++pSrcPixel;
+ ++pDstPixel;
+ }
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ pSrcLine += srcStride;
+ pDestLine += destStride;
+ }
+ // Set top and bottom borders.
+ memset(pBmpDest->getPixels(), 128, destStride*3);
+ memset(pBmpDest->getPixels()+destStride*(size.y-3), 128, destStride*3);
+ return pBmpDest;
+}
+
+}
diff --git a/src/graphics/FilterFastBandpass.h b/src/graphics/FilterFastBandpass.h
new file mode 100644
index 0000000..f75e336
--- /dev/null
+++ b/src/graphics/FilterFastBandpass.h
@@ -0,0 +1,46 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterFastBandpass_H_
+#define _FilterFastBandpass_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+// This is a fast and sloppy bandpass filter that uses a 7x7 kernel.
+class AVG_API FilterFastBandpass: public Filter{
+ public:
+ FilterFastBandpass();
+ virtual ~FilterFastBandpass();
+
+ virtual BitmapPtr apply(BitmapPtr pBmpSrc);
+
+ private:
+};
+
+typedef boost::shared_ptr<FilterFastBandpass> FilterFastBandpassPtr;
+}
+#endif
diff --git a/src/graphics/FilterFastDownscale.cpp b/src/graphics/FilterFastDownscale.cpp
new file mode 100644
index 0000000..95f7378
--- /dev/null
+++ b/src/graphics/FilterFastDownscale.cpp
@@ -0,0 +1,98 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterFastDownscale.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+
+namespace avg {
+
+using namespace std;
+
+FilterFastDownscale::FilterFastDownscale(int factor)
+ : Filter(),
+ m_Factor(factor)
+{
+}
+
+FilterFastDownscale::~FilterFastDownscale()
+{
+
+}
+
+BitmapPtr FilterFastDownscale::apply(BitmapPtr pBmpSrc)
+{
+ AVG_ASSERT(pBmpSrc->getPixelFormat() == I8);
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(pBmpSrc->getSize()/m_Factor, I8,
+ pBmpSrc->getName()));
+ unsigned char * pSrcLine = pBmpSrc->getPixels();
+ unsigned char * pDestLine = pBmpDest->getPixels();
+ IntPoint size = pBmpDest->getSize();
+ int srcStride = pBmpSrc->getStride();
+ for (int y = 0; y < size.y; ++y) {
+ unsigned char * pSrcPixel = pSrcLine;
+ unsigned char * pDstPixel = pDestLine;
+ switch (m_Factor) {
+ case 2:
+ for (int x = 0; x < size.x; ++x) {
+ int dstPixel= int(*pSrcPixel)+int(*(pSrcPixel+1))
+ +int(*(pSrcPixel+srcStride))+int(*(pSrcPixel+srcStride+1));
+ *pDstPixel = (dstPixel+2)/4;
+ pSrcPixel += 2;
+ pDstPixel++;
+ }
+ break;
+ case 3:
+ for (int x = 0; x < size.x; ++x) {
+ int dstPixel= int(*pSrcPixel)+int(*(pSrcPixel+1))+int(*(pSrcPixel+2))
+ +int(*(pSrcPixel+srcStride))+int(*(pSrcPixel+srcStride+1))
+ +int(*(pSrcPixel+srcStride+2))
+ +int(*(pSrcPixel+srcStride*2))+int(*(pSrcPixel+srcStride*2+1))
+ +int(*(pSrcPixel+srcStride*2+2));
+ *pDstPixel = (dstPixel+4)/9;
+ pSrcPixel += 3;
+ pDstPixel++;
+ }
+ break;
+ default:
+ for (int x = 0; x < size.x; ++x) {
+ int dstPixel=0;
+ for (int y1 = 0; y1 < m_Factor; y1++) {
+ for (int x1 = 0; x1 < m_Factor; x1++) {
+ dstPixel+= (int)(*(pSrcPixel+srcStride*y1+x1));
+ }
+ }
+ *pDstPixel = (dstPixel+(m_Factor*m_Factor)/2)/(m_Factor*m_Factor);
+ pSrcPixel += m_Factor;
+ pDstPixel++;
+ }
+ break;
+ }
+ pSrcLine = pSrcLine + pBmpSrc->getStride()*m_Factor;
+ pDestLine = pDestLine + pBmpDest->getStride();
+ }
+ return pBmpDest;
+}
+
+} // namespace
diff --git a/src/graphics/FilterFastDownscale.h b/src/graphics/FilterFastDownscale.h
new file mode 100644
index 0000000..6ca6826
--- /dev/null
+++ b/src/graphics/FilterFastDownscale.h
@@ -0,0 +1,47 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterFastDownscale_H_
+#define _FilterFastDownscale_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+// Returns a bitmap that is scaled downward by Scale in both x and y directions
+// using simple box sampling.
+class AVG_API FilterFastDownscale : public Filter
+{
+public:
+ FilterFastDownscale(int Factor);
+ virtual ~FilterFastDownscale();
+ virtual BitmapPtr apply(BitmapPtr pBmpSource) ;
+
+private:
+ int m_Factor;
+};
+
+} // namespace
+
+#endif
+
diff --git a/src/graphics/FilterFloodfill.h b/src/graphics/FilterFloodfill.h
new file mode 100644
index 0000000..41fb18f
--- /dev/null
+++ b/src/graphics/FilterFloodfill.h
@@ -0,0 +1,165 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#ifndef _FilterFloodfill_H_
+#define _FilterFloodfill_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+#include "../base/Point.h"
+
+#include <stack>
+
+namespace avg {
+
+struct Segment {
+ Segment(int iy, int ix1, int ix2, int idy)
+ : y(iy),
+ x1(ix1),
+ x2(ix2),
+ dy(idy)
+ {}
+
+ int y;
+ int x1;
+ int x2;
+ int dy;
+};
+
+class ColorTester {
+public:
+ ColorTester(Pixel32 color)
+ : m_Color(color)
+ {
+ }
+
+ bool operator()(unsigned char * pPixel)
+ {
+ return *(Pixel32*)(pPixel) == m_Color;
+ }
+
+private:
+ Pixel32 m_Color;
+};
+
+// Flood fill filter. The comparison functor used to determine whether a pixel
+// belongs to the area is passed as template parameter. Pixels in the flooded area
+// are made transparent.
+template<class PixelTester>
+class AVG_TEMPLATE_API FilterFloodfill : public Filter
+{
+public:
+ FilterFloodfill(PixelTester tester, const IntPoint& pt);
+ virtual ~FilterFloodfill();
+
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ void pushSeg(BitmapPtr pBmp, std::stack<Segment>& segments,
+ int y, int x1, int x2, int dy);
+ void setTransparent(unsigned char* pPixel);
+
+ PixelTester m_Tester;
+ IntPoint m_Pt;
+};
+
+template<class PixelTester>
+FilterFloodfill<PixelTester>::FilterFloodfill(PixelTester tester, const IntPoint& pt)
+ : m_Tester(tester),
+ m_Pt(pt)
+{
+}
+
+template<class PixelTester>
+FilterFloodfill<PixelTester>::~FilterFloodfill()
+{
+}
+
+template<class PixelTester>
+void FilterFloodfill<PixelTester>::applyInPlace(BitmapPtr pBmp)
+{
+ // Algorithm from Graphics Gems I, pp 296ff.
+ std::stack<Segment> segments;
+ unsigned char * pPixels = (unsigned char *)(pBmp->getPixels());
+ int stride = pBmp->getStride();
+ pushSeg(pBmp, segments, m_Pt.y, m_Pt.x, m_Pt.x, 1);
+ pushSeg(pBmp, segments, m_Pt.y+1, m_Pt.x, m_Pt.x, -1);
+ int l;
+ while (!segments.empty()) {
+ Segment seg = segments.top();
+ seg.y += seg.dy;
+ segments.pop();
+ int x = seg.x1;
+ unsigned char * pCurPixel = pPixels+x*4+seg.y*stride;
+ for (; x>=0 && m_Tester(pCurPixel); x--) {
+ setTransparent(pCurPixel);
+ pCurPixel-=4;
+ }
+ if (x >= seg.x1) {
+ goto skip;
+ }
+ l = x+1;
+ if (l<seg.x1) {
+ pushSeg(pBmp, segments, seg.y, l, seg.x1-1, -seg.dy);
+ }
+ x = seg.x1+1;
+ do {
+ pCurPixel = pPixels+x*4+seg.y*stride;
+ for (; x<pBmp->getSize().x && m_Tester(pCurPixel); x++) {
+ setTransparent(pCurPixel);
+ pCurPixel+=4;
+ }
+ pushSeg(pBmp, segments, seg.y, l, x-1, seg.dy);
+ if (x>seg.x2+1) {
+ pushSeg(pBmp, segments, seg.y, seg.x2+1, x-1, -seg.dy);
+ }
+skip: x++;
+ pCurPixel = pPixels+x*4+seg.y*stride;
+ for (; x<=seg.x2 && !m_Tester(pCurPixel); x++) {
+ pCurPixel+=4;
+ }
+ l = x;
+ } while (x<=seg.x2);
+
+ }
+}
+
+template<class PixelTester>
+void FilterFloodfill<PixelTester>::pushSeg(BitmapPtr pBmp, std::stack<Segment>& segments,
+ int y, int x1, int x2, int dy)
+{
+ if (y+dy >= 0 && y+dy < pBmp->getSize().y) {
+ segments.push(Segment(y, x1, x2, dy));
+ }
+}
+
+template<class PixelTester>
+void FilterFloodfill<PixelTester>::setTransparent(unsigned char* pPixel)
+{
+ *(Pixel32*)(pPixel) = Pixel32(0,0,255,0);
+}
+
+
+}
+
+#endif
diff --git a/src/graphics/FilterGauss.cpp b/src/graphics/FilterGauss.cpp
new file mode 100644
index 0000000..370c4f4
--- /dev/null
+++ b/src/graphics/FilterGauss.cpp
@@ -0,0 +1,203 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterGauss.h"
+#include "Filterfill.h"
+#include "Pixel8.h"
+#include "Bitmap.h"
+
+#include "../base/MathHelper.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <math.h>
+
+using namespace std;
+
+namespace avg {
+
+FilterGauss::FilterGauss(double radius)
+ : m_Radius(radius)
+{
+ calcKernel();
+}
+
+FilterGauss::~FilterGauss()
+{
+}
+
+BitmapPtr FilterGauss::apply(BitmapPtr pBmpSrc)
+{
+ AVG_ASSERT(pBmpSrc->getPixelFormat() == I8);
+ int intRadius = int(ceil(m_Radius));
+
+ // Convolve in x-direction
+ IntPoint tempSize(pBmpSrc->getSize().x-2*intRadius, pBmpSrc->getSize().y);
+ BitmapPtr pTempBmp = BitmapPtr(new Bitmap(tempSize, I8, pBmpSrc->getName()));
+ int srcStride = pBmpSrc->getStride();
+ int tempStride = pTempBmp->getStride();
+ unsigned char * pSrcLine = pBmpSrc->getPixels();
+ unsigned char * pTempLine = pTempBmp->getPixels();
+ for (int y = 0; y < tempSize.y; ++y) {
+ unsigned char * pSrcPixel = pSrcLine+intRadius;
+ unsigned char * pTempPixel = pTempLine;
+ switch (intRadius) {
+ case 3:
+ for (int x = 0; x < tempSize.x; ++x) {
+ *pTempPixel = (*(pSrcPixel-3)*m_Kernel[0] +
+ *(pSrcPixel-2)*m_Kernel[1] +
+ *(pSrcPixel-1)*m_Kernel[2] +
+ *(pSrcPixel)*m_Kernel[3] +
+ *(pSrcPixel+1)*m_Kernel[4] +
+ *(pSrcPixel+2)*m_Kernel[5] +
+ *(pSrcPixel+3)*m_Kernel[6])/256;
+ ++pSrcPixel;
+ ++pTempPixel;
+ }
+ break;
+ case 2:
+ for (int x = 0; x < tempSize.x; ++x) {
+ *pTempPixel = (*(pSrcPixel-2)*m_Kernel[0] +
+ *(pSrcPixel-1)*m_Kernel[1] +
+ *(pSrcPixel)*m_Kernel[2] +
+ *(pSrcPixel+1)*m_Kernel[3] +
+ *(pSrcPixel+2)*m_Kernel[4])/256;
+ ++pSrcPixel;
+ ++pTempPixel;
+ }
+ break;
+ case 1:
+ for (int x = 0; x < tempSize.x; ++x) {
+ *pTempPixel = (*(pSrcPixel-1)*m_Kernel[0] +
+ *(pSrcPixel)*m_Kernel[1] +
+ *(pSrcPixel+1)*m_Kernel[2])/256;
+ ++pSrcPixel;
+ ++pTempPixel;
+ }
+ break;
+ default:
+ // This is _really_ slow!
+ for (int x = 0; x < tempSize.x; ++x) {
+ *pTempPixel = 0;
+ unsigned char * pKernelPixel = pSrcPixel-intRadius;
+ for (int w=0; w <= intRadius*2; ++w) {
+ *pTempPixel += ((*pKernelPixel)*m_Kernel[w])/256;
+ pKernelPixel++;
+ }
+ ++pSrcPixel;
+ ++pTempPixel;
+ }
+ }
+ pSrcLine += srcStride;
+ pTempLine += tempStride;
+ }
+
+ // Convolve in y-direction
+ IntPoint destSize(tempSize.x, tempSize.y-2*intRadius);
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(destSize, I8, pBmpSrc->getName()));
+ int destStride = pDestBmp->getStride();
+ pTempLine = pTempBmp->getPixels()+intRadius*tempStride;
+ unsigned char * pDestLine = pDestBmp->getPixels();
+ for (int y = 0; y < destSize.y; ++y) {
+ unsigned char * pTempPixel = pTempLine;
+ unsigned char * pDestPixel = pDestLine;
+ switch (intRadius) {
+ case 3:
+ for (int x = 0; x < destSize.x; ++x) {
+ *pDestPixel = (*(pTempPixel-3*tempStride)*m_Kernel[0] +
+ *(pTempPixel-2*tempStride)*m_Kernel[1] +
+ *(pTempPixel-1*tempStride)*m_Kernel[2] +
+ *(pTempPixel)*m_Kernel[3] +
+ *(pTempPixel+1*tempStride)*m_Kernel[4] +
+ *(pTempPixel+2*tempStride)*m_Kernel[5] +
+ *(pTempPixel+3*tempStride)*m_Kernel[6])/256;
+ ++pTempPixel;
+ ++pDestPixel;
+ }
+ break;
+ case 2:
+ for (int x = 0; x < destSize.x; ++x) {
+ *pDestPixel = (*(pTempPixel-2*tempStride)*m_Kernel[0] +
+ *(pTempPixel-1*tempStride)*m_Kernel[1] +
+ *(pTempPixel)*m_Kernel[2] +
+ *(pTempPixel+1*tempStride)*m_Kernel[3] +
+ *(pTempPixel+2*tempStride)*m_Kernel[4])/256;
+ ++pTempPixel;
+ ++pDestPixel;
+ }
+ break;
+ case 1:
+ for (int x = 0; x < destSize.x; ++x) {
+ *pDestPixel = (*(pTempPixel-1*tempStride)*m_Kernel[0] +
+ *(pTempPixel)*m_Kernel[1] +
+ *(pTempPixel+1*tempStride)*m_Kernel[2])/256;
+ ++pTempPixel;
+ ++pDestPixel;
+ }
+ break;
+ default:
+ // This is _really_ slow!
+ for (int x = 0; x < tempSize.x; ++x) {
+ *pDestPixel = 0;
+ unsigned char * pKernelPixel = pTempPixel-intRadius*tempStride;
+ for (int w = 0; w <= intRadius*2; ++w) {
+ *pDestPixel += (*pKernelPixel*m_Kernel[w])/256;
+ pKernelPixel += tempStride;
+ }
+ ++pTempPixel;
+ ++pDestPixel;
+ }
+ }
+ pTempLine += tempStride;
+ pDestLine += destStride;
+ }
+ return pDestBmp;
+}
+
+void FilterGauss::dumpKernel()
+{
+ cerr << "Gauss, radius " << m_Radius << endl;
+ cerr << " Kernel width: " << m_KernelWidth << endl;
+ for (int i = 0; i < m_KernelWidth; ++i) {
+ cerr << " " << m_Kernel[i] << endl;
+ }
+}
+
+void FilterGauss::calcKernel()
+{
+ double FloatKernel[15];
+ double Sum = 0;
+ int intRadius = int(ceil(m_Radius));
+ m_KernelWidth = intRadius*2+1;
+ for (int i = 0; i <= intRadius; ++i) {
+ FloatKernel[intRadius+i] = exp(-i*i/m_Radius-1)/sqrt(2*M_PI);
+ FloatKernel[intRadius-i] = FloatKernel[intRadius+i];
+ Sum += FloatKernel[intRadius+i];
+ if (i != 0) {
+ Sum += FloatKernel[intRadius-i];
+ }
+ }
+ for (int i = 0; i < m_KernelWidth; ++i) {
+ m_Kernel[i] = int(FloatKernel[i]*256/Sum+0.5);
+ }
+}
+
+}
diff --git a/src/graphics/FilterGauss.h b/src/graphics/FilterGauss.h
new file mode 100644
index 0000000..9577cc5
--- /dev/null
+++ b/src/graphics/FilterGauss.h
@@ -0,0 +1,52 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterGauss_H_
+#define _FilterGauss_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API FilterGauss: public Filter{
+ public:
+ FilterGauss(double Radius);
+ virtual ~FilterGauss();
+
+ virtual BitmapPtr apply(BitmapPtr pBmpSrc);
+
+ void dumpKernel();
+
+ private:
+ void calcKernel();
+
+ double m_Radius;
+ int m_KernelWidth;
+ int m_Kernel[15];
+};
+
+typedef boost::shared_ptr<FilterGauss> FilterGaussPtr;
+}
+#endif
diff --git a/src/graphics/FilterGetAlpha.cpp b/src/graphics/FilterGetAlpha.cpp
new file mode 100644
index 0000000..efc1126
--- /dev/null
+++ b/src/graphics/FilterGetAlpha.cpp
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterGetAlpha.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+
+namespace avg {
+
+using namespace std;
+
+FilterGetAlpha::FilterGetAlpha()
+ : Filter()
+{
+}
+
+FilterGetAlpha::~FilterGetAlpha()
+{
+
+}
+
+BitmapPtr FilterGetAlpha::apply(BitmapPtr pBmpSrc)
+{
+ PixelFormat pf = pBmpSrc->getPixelFormat();
+ AVG_ASSERT(pf == R8G8B8A8 || pf == B8G8R8A8);
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(pBmpSrc->getSize(), I8,
+ pBmpSrc->getName()+"alpha"));
+ unsigned char * pSrcLine = pBmpSrc->getPixels();
+ unsigned char * pDestLine = pBmpDest->getPixels();
+ IntPoint size = pBmpDest->getSize();
+ for (int y = 0; y < size.y; ++y) {
+ unsigned char * pSrcPixel = pSrcLine;
+ unsigned char * pDstPixel = pDestLine;
+ for (int x = 0; x < size.x; ++x) {
+ *pDstPixel = pSrcPixel[ALPHAPOS];
+ pSrcPixel += 4;
+ ++pDstPixel;
+ }
+ pSrcLine = pSrcLine + pBmpSrc->getStride();
+ pDestLine = pDestLine + pBmpDest->getStride();
+ }
+ return pBmpDest;
+}
+
+}
diff --git a/src/graphics/FilterGetAlpha.h b/src/graphics/FilterGetAlpha.h
new file mode 100644
index 0000000..6a3afd6
--- /dev/null
+++ b/src/graphics/FilterGetAlpha.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterGetAlpha_H_
+#define _FilterGetAlpha_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+// Extracts the alpha channel of a 32 bpp bitmap.
+class AVG_API FilterGetAlpha : public Filter
+{
+public:
+ FilterGetAlpha();
+ virtual ~FilterGetAlpha();
+ virtual BitmapPtr apply(BitmapPtr pBmpSource);
+
+private:
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/FilterHighpass.cpp b/src/graphics/FilterHighpass.cpp
new file mode 100644
index 0000000..eee48f5
--- /dev/null
+++ b/src/graphics/FilterHighpass.cpp
@@ -0,0 +1,94 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterHighpass.h"
+#include "Filterfill.h"
+#include "Pixel8.h"
+#include "Bitmap.h"
+
+#include "../base/Exception.h"
+
+#include <cstring>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+FilterHighpass::FilterHighpass()
+{
+}
+
+FilterHighpass::~FilterHighpass()
+{
+}
+
+BitmapPtr FilterHighpass::apply(BitmapPtr pBmpSrc)
+{
+ AVG_ASSERT(pBmpSrc->getPixelFormat() == I8);
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(pBmpSrc->getSize(), I8,
+ pBmpSrc->getName()));
+ int srcStride = pBmpSrc->getStride();
+ int destStride = pBmpDest->getStride();
+ unsigned char * pSrcLine = pBmpSrc->getPixels()+3*srcStride;
+ unsigned char * pDestLine = pBmpDest->getPixels()+3*destStride;
+ IntPoint size = pBmpDest->getSize();
+ for (int y = 3; y < size.y-3; ++y) {
+ unsigned char * pSrcPixel = pSrcLine+3;
+ unsigned char * pDstPixel = pDestLine;
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ for (int x = 3; x < size.x-3; ++x) {
+ // Convolution Matrix is
+ // -1 0 0 0 -1
+ // 0 -1 0 -1 0
+ // 0 0 8 0 0
+ // 0 -1 0 -1 0
+ // -1 0 0 0 -1
+ // Actually, it's 7x7, but you get the idea.
+ *pDstPixel = 128 - int(*(pSrcPixel-3*srcStride-3)
+ + *(pSrcPixel-3*srcStride+3) + *(pSrcPixel+3*srcStride-3)
+ + *(pSrcPixel+3*srcStride+3))/16;
+ *pDstPixel +=
+ - int(*(pSrcPixel-2*srcStride-2) + *(pSrcPixel-2*srcStride+2) +
+ *(pSrcPixel-srcStride-1) + *(pSrcPixel-1*srcStride+1) +
+ *(pSrcPixel+srcStride-1) + *(pSrcPixel+1*srcStride+1) +
+ *(pSrcPixel+2*srcStride-2) + *(pSrcPixel+2*srcStride+2))/16
+ + *(pSrcPixel)*3/4;
+
+ ++pSrcPixel;
+ ++pDstPixel;
+ }
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ *pDstPixel++ = 128;
+ pSrcLine += srcStride;
+ pDestLine += destStride;
+ }
+ // Set top and bottom borders.
+ memset(pBmpDest->getPixels(), 128, destStride*3);
+ memset(pBmpDest->getPixels()+destStride*(size.y-3), 128, destStride*3);
+ return pBmpDest;
+}
+
+}
diff --git a/src/graphics/FilterHighpass.h b/src/graphics/FilterHighpass.h
new file mode 100644
index 0000000..cdb41b2
--- /dev/null
+++ b/src/graphics/FilterHighpass.h
@@ -0,0 +1,46 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterHighpass_H_
+#define _FilterHighpass_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+// This is a highpass filter that uses a 7x7 kernel.
+class AVG_API FilterHighpass: public Filter{
+ public:
+ FilterHighpass();
+ virtual ~FilterHighpass();
+
+ virtual BitmapPtr apply(BitmapPtr pBmpSrc);
+
+ private:
+};
+
+typedef boost::shared_ptr<FilterHighpass> FilterHighpassPtr;
+}
+#endif
diff --git a/src/graphics/FilterId.h b/src/graphics/FilterId.h
new file mode 100644
index 0000000..5b97e5b
--- /dev/null
+++ b/src/graphics/FilterId.h
@@ -0,0 +1,46 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org.
+//
+
+#ifndef _FilterId_H_
+#define _FilterId_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API FilterId: public Filter
+{
+ public:
+ FilterId(){};
+ virtual void applyInPlace(BitmapPtr img) {};
+ virtual ~FilterId(){};
+};
+
+typedef boost::shared_ptr<FilterId> FilterIdPtr;
+
+}
+#endif
diff --git a/src/graphics/FilterIntensity.cpp b/src/graphics/FilterIntensity.cpp
new file mode 100644
index 0000000..bbeb7a2
--- /dev/null
+++ b/src/graphics/FilterIntensity.cpp
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterIntensity.h"
+
+#include "../base/Exception.h"
+
+#include <math.h>
+
+namespace avg {
+
+FilterIntensity::FilterIntensity(int offset, double factor)
+ : m_Offset(offset),
+ m_Factor(factor)
+{
+}
+
+FilterIntensity::~FilterIntensity()
+{
+}
+
+void FilterIntensity::applyInPlace(BitmapPtr pBmp)
+{
+ AVG_ASSERT(pBmp->getPixelFormat() == I8);
+ unsigned char * pLine = pBmp->getPixels();
+ IntPoint size = pBmp->getSize();
+ for (int y = 0; y < size.y; ++y) {
+ unsigned char * pPixel = pLine;
+ for (int x = 0; x < size.x; ++x) {
+ *pPixel = (unsigned char)((*pPixel+m_Offset)*m_Factor);
+ ++pPixel;
+ }
+ pLine = pLine + pBmp->getStride();
+ }
+}
+
+}
+
diff --git a/src/graphics/FilterIntensity.h b/src/graphics/FilterIntensity.h
new file mode 100644
index 0000000..27dfd9d
--- /dev/null
+++ b/src/graphics/FilterIntensity.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterIntensity_H_
+#define _FilterIntensity_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+class AVG_API FilterIntensity : public Filter
+{
+public:
+ FilterIntensity(int offset, double factor);
+ virtual ~FilterIntensity();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ int m_Offset;
+ double m_Factor;
+};
+
+} // namespace
+
+#endif
+
diff --git a/src/graphics/FilterMask.cpp b/src/graphics/FilterMask.cpp
new file mode 100644
index 0000000..b843f26
--- /dev/null
+++ b/src/graphics/FilterMask.cpp
@@ -0,0 +1,84 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterMask.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+#include <stdio.h>
+
+namespace avg {
+
+using namespace std;
+
+FilterMask::FilterMask(BitmapPtr pMaskBmp)
+ : Filter(),
+ m_pMaskBmp(pMaskBmp)
+{
+ AVG_ASSERT(m_pMaskBmp->getPixelFormat() == I8);
+}
+
+FilterMask::~FilterMask()
+{
+
+}
+
+void FilterMask::applyInPlace(BitmapPtr pBmp)
+{
+ IntPoint size = pBmp->getSize();
+ AVG_ASSERT(size == m_pMaskBmp->getSize());
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pMaskLine = m_pMaskBmp->getPixels()+y*m_pMaskBmp->getStride();
+ unsigned char * pLine = pBmp->getPixels()+y*pBmp->getStride();
+ switch (pBmp->getBytesPerPixel()) {
+ case 4:
+ for (int x = 0; x < size.x; x++) {
+ unsigned char src = *(pMaskLine+x);
+ unsigned char * pPixel = pLine + x*4;
+ *pPixel = (*pPixel*src)/255;
+ *(pPixel+1) = (*(pPixel+1)*src)/255;
+ *(pPixel+2) = (*(pPixel+2)*src)/255;
+ }
+ break;
+ case 3:
+ for (int x = 0; x < size.x; x++) {
+ unsigned char src = *(pMaskLine+x);
+ unsigned char * pPixel = pLine + x*3;
+ *pPixel = (*pPixel*src)/255;
+ *(pPixel+1) = (*(pPixel+1)*src)/255;
+ *(pPixel+2) = (*(pPixel+2)*src)/255;
+ }
+ break;
+ case 1:
+ for (int x = 0; x < size.x; x++) {
+ unsigned char src = *(pMaskLine+x);
+ unsigned char * pPixel = pLine + x;
+ *pPixel = (*pPixel*src)/255;
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ }
+}
+
+}
diff --git a/src/graphics/FilterMask.h b/src/graphics/FilterMask.h
new file mode 100644
index 0000000..761b0ce
--- /dev/null
+++ b/src/graphics/FilterMask.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterMask_H
+#define _FilterMask_H
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Filter that applies a greyscale mask to an image.
+class AVG_API FilterMask : public Filter
+{
+public:
+ FilterMask(BitmapPtr pMaskBmp);
+ virtual ~FilterMask();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ BitmapPtr m_pMaskBmp;
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/FilterNormalize.cpp b/src/graphics/FilterNormalize.cpp
new file mode 100644
index 0000000..985cb82
--- /dev/null
+++ b/src/graphics/FilterNormalize.cpp
@@ -0,0 +1,55 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterNormalize.h"
+#include "FilterIntensity.h"
+
+#include <math.h>
+
+namespace avg {
+
+FilterNormalize::FilterNormalize(int stride)
+ : m_Stride(stride)
+{
+}
+
+FilterNormalize::~FilterNormalize()
+{
+}
+
+void FilterNormalize::applyInPlace(BitmapPtr pBmp)
+{
+ int min;
+ int max;
+ pBmp->getMinMax(m_Stride, min, max);
+ if (m_Stride > 1) {
+ min -= 2;
+ max += 2;
+ }
+ double factor = 255./(max-min);
+ if (factor > 10) {
+ factor = 10;
+ }
+ FilterIntensity(-min, factor).applyInPlace(pBmp);
+}
+
+}
+
diff --git a/src/graphics/FilterNormalize.h b/src/graphics/FilterNormalize.h
new file mode 100644
index 0000000..ad51cf2
--- /dev/null
+++ b/src/graphics/FilterNormalize.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterNormalize_H_
+#define _FilterNormalize_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+class AVG_API FilterNormalize : public Filter
+{
+public:
+ FilterNormalize(int stride);
+ virtual ~FilterNormalize();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ int m_Stride;
+};
+
+} // namespace
+
+#endif
+
diff --git a/src/graphics/FilterResizeBilinear.cpp b/src/graphics/FilterResizeBilinear.cpp
new file mode 100644
index 0000000..cfc96e7
--- /dev/null
+++ b/src/graphics/FilterResizeBilinear.cpp
@@ -0,0 +1,77 @@
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterResizeBilinear.h"
+#include "Bitmap.h"
+#include "TwoPassScale.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+FilterResizeBilinear::FilterResizeBilinear(const IntPoint& newSize)
+ : m_NewSize(newSize)
+{
+}
+
+BitmapPtr FilterResizeBilinear::apply(BitmapPtr pBmpSrc)
+{
+ int bpp = pBmpSrc->getBytesPerPixel();
+ AVG_ASSERT(bpp==4 || bpp==3 || bpp==1);
+
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(m_NewSize,
+ pBmpSrc->getPixelFormat(), pBmpSrc->getName()+"_resized"));
+
+ BilinearContribDef f(0.64);
+ switch (bpp) {
+ case 4:
+ {
+ TwoPassScale<CDataRGBA_UBYTE> sS(f);
+ sS.Scale((CDataRGBA_UBYTE::PixelClass *) pBmpSrc->getPixels(),
+ pBmpSrc->getSize(), pBmpSrc->getStride(),
+ (CDataRGBA_UBYTE::PixelClass *) pBmpDest->getPixels(),
+ pBmpDest->getSize(), pBmpDest->getStride());
+ }
+ break;
+ case 3:
+ {
+ TwoPassScale <CDataRGB_UBYTE> sS(f);
+ sS.Scale((CDataRGB_UBYTE::PixelClass *) pBmpSrc->getPixels(),
+ pBmpSrc->getSize(), pBmpSrc->getStride(),
+ (CDataRGB_UBYTE::PixelClass *) pBmpDest->getPixels(),
+ pBmpDest->getSize(), pBmpDest->getStride());
+ }
+ break;
+ case 1:
+ {
+ TwoPassScale <CDataA_UBYTE> sS(f);
+ sS.Scale((CDataA_UBYTE::PixelClass *) pBmpSrc->getPixels(),
+ pBmpSrc->getSize(), pBmpSrc->getStride(),
+ (CDataA_UBYTE::PixelClass *) pBmpDest->getPixels(),
+ pBmpDest->getSize(), pBmpDest->getStride());
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ return pBmpDest;
+}
+
+}
+
diff --git a/src/graphics/FilterResizeBilinear.h b/src/graphics/FilterResizeBilinear.h
new file mode 100644
index 0000000..8bbddf0
--- /dev/null
+++ b/src/graphics/FilterResizeBilinear.h
@@ -0,0 +1,39 @@
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterResizeBilinear_h_
+#define _FilterResizeBilinear_h_
+
+#include "Filter.h"
+
+namespace avg {
+
+class AVG_API FilterResizeBilinear : public Filter
+{
+public:
+ FilterResizeBilinear(const IntPoint& newSize);
+ virtual BitmapPtr apply(BitmapPtr pBmpSrc);
+
+private:
+ IntPoint m_NewSize;
+};
+
+}
+
+#endif
diff --git a/src/graphics/FilterResizeGaussian.cpp b/src/graphics/FilterResizeGaussian.cpp
new file mode 100644
index 0000000..13e2b96
--- /dev/null
+++ b/src/graphics/FilterResizeGaussian.cpp
@@ -0,0 +1,78 @@
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterResizeGaussian.h"
+#include "Bitmap.h"
+#include "TwoPassScale.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+FilterResizeGaussian::FilterResizeGaussian(const IntPoint& newSize, double radius)
+ : m_NewSize(newSize),
+ m_Radius(radius)
+{
+}
+
+BitmapPtr FilterResizeGaussian::apply(BitmapPtr pBmpSrc)
+{
+ int bpp = pBmpSrc->getBytesPerPixel();
+ AVG_ASSERT(bpp==4 || bpp==3 || bpp==1);
+
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(m_NewSize,
+ pBmpSrc->getPixelFormat(), pBmpSrc->getName()+"_resized"));
+
+ GaussianContribDef f(m_Radius);
+ switch (bpp) {
+ case 4:
+ {
+ TwoPassScale<CDataRGBA_UBYTE> sS(f);
+ sS.Scale((CDataRGBA_UBYTE::PixelClass *) pBmpSrc->getPixels(),
+ pBmpSrc->getSize(), pBmpSrc->getStride(),
+ (CDataRGBA_UBYTE::PixelClass *) pBmpDest->getPixels(),
+ pBmpDest->getSize(), pBmpDest->getStride());
+ }
+ break;
+ case 3:
+ {
+ TwoPassScale <CDataRGB_UBYTE> sS(f);
+ sS.Scale((CDataRGB_UBYTE::PixelClass *) pBmpSrc->getPixels(),
+ pBmpSrc->getSize(), pBmpSrc->getStride(),
+ (CDataRGB_UBYTE::PixelClass *) pBmpDest->getPixels(),
+ pBmpDest->getSize(), pBmpDest->getStride());
+ }
+ break;
+ case 1:
+ {
+ TwoPassScale <CDataA_UBYTE> sS(f);
+ sS.Scale((CDataA_UBYTE::PixelClass *) pBmpSrc->getPixels(),
+ pBmpSrc->getSize(), pBmpSrc->getStride(),
+ (CDataA_UBYTE::PixelClass *) pBmpDest->getPixels(),
+ pBmpDest->getSize(), pBmpDest->getStride());
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ return pBmpDest;
+}
+
+}
+
diff --git a/src/graphics/FilterResizeGaussian.h b/src/graphics/FilterResizeGaussian.h
new file mode 100644
index 0000000..0afd926
--- /dev/null
+++ b/src/graphics/FilterResizeGaussian.h
@@ -0,0 +1,41 @@
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterResizeGaussian_H_
+#define _FilterResizeGaussian_H_
+
+#include "Filter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+class AVG_API FilterResizeGaussian : public Filter
+{
+public:
+ FilterResizeGaussian(const IntPoint& newSize, double radius);
+ virtual BitmapPtr apply(BitmapPtr pBmpSrc);
+
+private:
+ IntPoint m_NewSize;
+ double m_Radius;
+};
+
+}
+#endif
+
diff --git a/src/graphics/FilterThreshold.cpp b/src/graphics/FilterThreshold.cpp
new file mode 100644
index 0000000..0c5d1c6
--- /dev/null
+++ b/src/graphics/FilterThreshold.cpp
@@ -0,0 +1,61 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterThreshold.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+#include <stdio.h>
+
+namespace avg {
+
+using namespace std;
+
+FilterThreshold::FilterThreshold(int threshold)
+ : Filter(),
+ m_Threshold(threshold)
+{
+}
+
+FilterThreshold::~FilterThreshold()
+{
+
+}
+
+void FilterThreshold::applyInPlace(BitmapPtr pBmp)
+{
+ IntPoint size = pBmp->getSize();
+ AVG_ASSERT(pBmp->getPixelFormat() == I8);
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pLine = pBmp->getPixels()+y*pBmp->getStride();
+ for (int x = 0; x < size.x; x++) {
+ unsigned char * pPixel = pLine + x;
+ if (*pPixel >= m_Threshold) {
+ *pPixel = 255;
+ } else {
+ *pPixel = 0;
+ }
+ }
+ }
+}
+
+}
diff --git a/src/graphics/FilterThreshold.h b/src/graphics/FilterThreshold.h
new file mode 100644
index 0000000..2dec300
--- /dev/null
+++ b/src/graphics/FilterThreshold.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterThreshold_H
+#define _FilterThreshold_H
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+class AVG_API FilterThreshold : public Filter
+{
+public:
+ FilterThreshold(int threshold);
+ virtual ~FilterThreshold();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ int m_Threshold;
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/FilterUnmultiplyAlpha.cpp b/src/graphics/FilterUnmultiplyAlpha.cpp
new file mode 100644
index 0000000..568be00
--- /dev/null
+++ b/src/graphics/FilterUnmultiplyAlpha.cpp
@@ -0,0 +1,57 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterUnmultiplyAlpha.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+FilterUnmultiplyAlpha::FilterUnmultiplyAlpha()
+ : Filter()
+{
+}
+
+FilterUnmultiplyAlpha::~FilterUnmultiplyAlpha()
+{
+
+}
+
+void FilterUnmultiplyAlpha::applyInPlace(BitmapPtr pBmp)
+{
+ AVG_ASSERT(pBmp->getBytesPerPixel() == 4);
+ IntPoint size = pBmp->getSize();
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pPixel = pBmp->getPixels()+y*pBmp->getStride();
+ for (int x = 0; x < size.x; x++) {
+ int alpha = *(pPixel+ALPHAPOS);
+ if (alpha != 0) {
+ *(pPixel+REDPOS) = (int(*(pPixel+REDPOS))*255)/alpha;
+ *(pPixel+GREENPOS) = (int(*(pPixel+GREENPOS))*255)/alpha;
+ *(pPixel+BLUEPOS) = (int(*(pPixel+BLUEPOS))*255)/alpha;
+ }
+ pPixel += 4;
+ }
+ }
+}
+
+}
diff --git a/src/graphics/FilterUnmultiplyAlpha.h b/src/graphics/FilterUnmultiplyAlpha.h
new file mode 100644
index 0000000..628e27c
--- /dev/null
+++ b/src/graphics/FilterUnmultiplyAlpha.h
@@ -0,0 +1,43 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filterfliprgba_H
+#define _Filterfliprgba_H
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+class AVG_API FilterUnmultiplyAlpha : public Filter
+{
+public:
+ FilterUnmultiplyAlpha();
+ virtual ~FilterUnmultiplyAlpha();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/Filtercolorize.cpp b/src/graphics/Filtercolorize.cpp
new file mode 100644
index 0000000..867def3
--- /dev/null
+++ b/src/graphics/Filtercolorize.cpp
@@ -0,0 +1,145 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filtercolorize.h"
+#include "Filtergrayscale.h"
+#include "Pixel24.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+// From Foley, van Dam p. 596 incl. addendum fixes.
+unsigned char hls_value(double n1, double n2, double hue)
+{
+ if (hue>360)
+ hue-=360;
+ if (hue<0)
+ hue+=360;
+
+ double rv;
+ if (hue<60)
+ rv = n1+(n2-n1)*hue/60.0;
+ else if (hue<180)
+ rv = n2;
+ else if (hue<240)
+ rv = n1+(n2-n1)*(240.0-hue)/60.0;
+ else
+ rv = n1;
+
+ return (unsigned char)(rv*255);
+}
+
+Pixel24 hls2rgb (double h, double l, double s)
+{
+ double m1, m2;
+ l /= 255;
+ s /= 100;
+ // Warning: Foley, van Dam has a typo on the next line!
+ m2 = (l<=0.5)?(l*(1.0+s)):(l+s-l*s);
+ m1 = 2.0*l-m2;
+ if (s<0.001) {
+ return Pixel24((unsigned char)(l*255), (unsigned char)(l*255),
+ (unsigned char)(l*255));
+ } else {
+ return Pixel24(hls_value(m1,m2,h+120.0),
+ hls_value(m1,m2,h),
+ hls_value(m1,m2,h-120.0));
+ }
+}
+
+FilterColorize::FilterColorize(double hue, double saturation)
+ : m_Hue(hue),
+ m_Saturation(saturation)
+{
+}
+
+FilterColorize::~FilterColorize()
+{
+
+}
+
+void FilterColorize::applyInPlace(BitmapPtr pBmp)
+{
+ BitmapPtr pTempBmp (FilterGrayscale().apply(pBmp));
+ Pixel24 colorTable[256];
+ for (int i=0; i<256; i++) {
+ colorTable[i] = hls2rgb(m_Hue, i, m_Saturation);
+ }
+
+ unsigned char * pSrcLine = pTempBmp->getPixels();
+ unsigned char * pDestLine = pBmp->getPixels();
+ IntPoint size = pTempBmp->getSize();
+ for (int y = 0; y < size.y; ++y) {
+ unsigned char * pSrcPixel = pSrcLine;
+ switch (pBmp->getPixelFormat()) {
+ case R8G8B8A8:
+ case R8G8B8X8:
+ {
+ Pixel32 * pDestPixel = (Pixel32 *)pDestLine;
+ for (int x = 0; x < size.x; ++x) {
+ *pDestPixel = colorTable[*pSrcPixel];
+ ++pSrcPixel;
+ ++pDestPixel;
+ }
+ }
+ break;
+ case R8G8B8:
+ {
+ Pixel24 * pDestPixel = (Pixel24 *)pDestLine;
+ for (int x = 0; x < size.x; ++x) {
+ *pDestPixel = colorTable[*pSrcPixel];
+ ++pSrcPixel;
+ ++pDestPixel;
+ }
+ }
+ break;
+ case B8G8R8A8:
+ case B8G8R8X8:
+ {
+ Pixel32 * pDestPixel = (Pixel32 *)pDestLine;
+ for (int x = 0; x < size.x; ++x) {
+ *pDestPixel = colorTable[*pSrcPixel];
+ ++pSrcPixel;
+ ++pDestPixel;
+ }
+ }
+ break;
+ case B8G8R8:
+ {
+ Pixel24 * pDestPixel = (Pixel24 *)pDestLine;
+ for (int x = 0; x < size.x; ++x) {
+ *pDestPixel = colorTable[*pSrcPixel];
+ ++pSrcPixel;
+ ++pDestPixel;
+ }
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ pSrcLine = pSrcLine + pTempBmp->getStride();
+ pDestLine = pDestLine + pBmp->getStride();
+ }
+}
+
+}
+
diff --git a/src/graphics/Filtercolorize.h b/src/graphics/Filtercolorize.h
new file mode 100644
index 0000000..0ef8448
--- /dev/null
+++ b/src/graphics/Filtercolorize.h
@@ -0,0 +1,48 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filtercolorize_H_
+#define _Filtercolorize_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Filter that colorizes a bitmap given a hue and saturation. Corresponds
+// loosely to the photoshop hue/saturation control when set to 'colorize'.
+// The range of hue is 0..359, the range of saturation is 0..100.
+class AVG_API FilterColorize : public Filter
+{
+public:
+ FilterColorize(double hue, double saturation);
+ virtual ~FilterColorize();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ double m_Hue;
+ double m_Saturation;
+};
+
+} // namespace
+
+#endif
+
diff --git a/src/graphics/Filterfill.h b/src/graphics/Filterfill.h
new file mode 100644
index 0000000..aa81219
--- /dev/null
+++ b/src/graphics/Filterfill.h
@@ -0,0 +1,68 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#ifndef _Filterfill_H_
+#define _Filterfill_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Filterfillrect.h"
+
+#include "../base/Rect.h"
+
+namespace avg {
+
+// Filter that fills a bitmap with a color.
+template<class PixelC>
+class AVG_TEMPLATE_API FilterFill : public Filter
+{
+public:
+ FilterFill (const PixelC& Color);
+ virtual ~FilterFill();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ PixelC m_Color;
+};
+
+template<class PixelC>
+FilterFill<PixelC>::FilterFill(const PixelC& Color)
+ : m_Color (Color)
+{
+}
+
+template<class PixelC>
+FilterFill<PixelC>::~FilterFill()
+{
+}
+
+template<class PixelC>
+void FilterFill<PixelC>::applyInPlace(BitmapPtr pBmp)
+{
+ FilterFillRect<PixelC> RectFilter(
+ IntRect(0, 0, pBmp->getSize().x, pBmp->getSize().y), m_Color);
+ RectFilter.applyInPlace(pBmp);
+}
+
+}
+
+#endif
diff --git a/src/graphics/Filterfillrect.h b/src/graphics/Filterfillrect.h
new file mode 100644
index 0000000..5493fa2
--- /dev/null
+++ b/src/graphics/Filterfillrect.h
@@ -0,0 +1,75 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#ifndef _Filterfillrect_H_
+#define _Filterfillrect_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "../base/Rect.h"
+
+namespace avg {
+
+// Filter that fills a rectangle in a Bitmap with a color.
+template<class PixelC>
+ class AVG_TEMPLATE_API FilterFillRect: public Filter
+{
+public:
+ FilterFillRect (IntRect Rect, const PixelC& Color);
+ virtual ~FilterFillRect();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+ PixelC m_Color;
+ IntRect m_Rect;
+};
+
+template<class PixelC>
+FilterFillRect<PixelC>::FilterFillRect (IntRect Rect, const PixelC& Color)
+{
+ m_Rect = Rect;
+ m_Color = Color;
+}
+
+template<class PixelC>
+FilterFillRect<PixelC>::~FilterFillRect ()
+{
+}
+
+template<class PixelC>
+void FilterFillRect<PixelC>::applyInPlace (BitmapPtr pBmp)
+{
+ int Stride = pBmp->getStride()/pBmp->getBytesPerPixel();
+ PixelC * pLine = (PixelC*)(pBmp->getPixels())+(m_Rect.tl.y*Stride);
+ PixelC * pPixel;
+ for (int y=m_Rect.tl.y; y<m_Rect.br.y; ++y) {
+ pPixel = pLine+m_Rect.tl.x;
+ for (int x=m_Rect.tl.x; x<m_Rect.br.x; ++x) {
+ *pPixel = m_Color;
+ pPixel++;
+ }
+ pLine += Stride;
+ }
+}
+
+}
+#endif
diff --git a/src/graphics/Filterflip.cpp b/src/graphics/Filterflip.cpp
new file mode 100644
index 0000000..eae54c5
--- /dev/null
+++ b/src/graphics/Filterflip.cpp
@@ -0,0 +1,54 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filterflip.h"
+
+#include <cstring>
+
+namespace avg {
+
+FilterFlip::FilterFlip() : Filter()
+{
+}
+
+FilterFlip::~FilterFlip()
+{
+}
+
+BitmapPtr FilterFlip::apply(BitmapPtr pBmpSource)
+{
+ IntPoint size = pBmpSource->getSize();
+ BitmapPtr pBmpDest(new Bitmap(size, pBmpSource->getPixelFormat(),
+ pBmpSource->getName()));
+
+ unsigned char* pSrcLine = pBmpSource->getPixels();
+ unsigned char* pDestLine = pBmpDest->getPixels()+(size.y-1)*pBmpDest->getStride();
+ int lineLen = pBmpSource->getBytesPerPixel()*size.x;
+
+ for (int y = 0; y < size.y; y++) {
+ memcpy(pDestLine, pSrcLine, lineLen);
+ pSrcLine += pBmpSource->getStride();
+ pDestLine -= pBmpDest->getStride();
+ }
+ return pBmpDest;
+}
+
+} // namespace
diff --git a/src/graphics/Filterflip.h b/src/graphics/Filterflip.h
new file mode 100644
index 0000000..7c4f3b9
--- /dev/null
+++ b/src/graphics/Filterflip.h
@@ -0,0 +1,43 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#ifndef _Filterflip_H_
+#define _Filterflip_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Flips a bitmap upside-down
+class AVG_API FilterFlip: public Filter
+{
+public:
+ FilterFlip();
+ virtual ~FilterFlip();
+ virtual BitmapPtr apply(BitmapPtr pBmpSource) ;
+};
+
+} // namespace
+
+#endif
+
diff --git a/src/graphics/FilterflipX.cpp b/src/graphics/FilterflipX.cpp
new file mode 100644
index 0000000..11d16e6
--- /dev/null
+++ b/src/graphics/FilterflipX.cpp
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterflipX.h"
+#include "Pixel32.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+FilterFlipX::FilterFlipX()
+ : Filter()
+{
+}
+
+FilterFlipX::~FilterFlipX()
+{
+}
+
+BitmapPtr FilterFlipX::apply(BitmapPtr pBmpSource)
+{
+ IntPoint Size = pBmpSource->getSize();
+ BitmapPtr pBmpDest(new Bitmap(Size, pBmpSource->getPixelFormat(),
+ pBmpSource->getName()));
+
+ unsigned char* pSrcLine = pBmpSource->getPixels();
+ unsigned char* pDestLine = pBmpDest->getPixels();
+
+ for (int y = 0; y < Size.y; y++) {
+ switch (pBmpSource->getBytesPerPixel()) {
+ case 1: {
+ unsigned char * pSrc = pSrcLine;
+ unsigned char * pDest = pDestLine+Size.x-1;
+ for (int x = 0; x < Size.x; x++) {
+ *pDest = *pSrc;
+ pSrc++;
+ pDest--;
+ }
+ }
+ break;
+ case 4: {
+ Pixel32 * pSrc = (Pixel32*)pSrcLine;
+ Pixel32 * pDest = (Pixel32*)pDestLine+Size.x-1;
+ for (int x = 0; x < Size.x; x++) {
+ *pDest = *pSrc;
+ pSrc++;
+ pDest--;
+ }
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ pSrcLine += pBmpSource->getStride();
+ pDestLine += pBmpDest->getStride();
+ }
+ return pBmpDest;
+}
+
+}
diff --git a/src/graphics/FilterflipX.h b/src/graphics/FilterflipX.h
new file mode 100644
index 0000000..2952c26
--- /dev/null
+++ b/src/graphics/FilterflipX.h
@@ -0,0 +1,43 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#ifndef _FilterflipX_H_
+#define _FilterflipX_H_
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Flips a bitmap right-left
+class AVG_API FilterFlipX: public Filter
+{
+public:
+ FilterFlipX();
+ virtual ~FilterFlipX();
+ virtual BitmapPtr apply(BitmapPtr pBmpSource);
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/Filterfliprgb.cpp b/src/graphics/Filterfliprgb.cpp
new file mode 100644
index 0000000..d06dfaf
--- /dev/null
+++ b/src/graphics/Filterfliprgb.cpp
@@ -0,0 +1,84 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filterfliprgb.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+FilterFlipRGB::FilterFlipRGB()
+ : Filter()
+{
+}
+
+FilterFlipRGB::~FilterFlipRGB()
+{
+
+}
+
+void FilterFlipRGB::applyInPlace(BitmapPtr pBmp)
+{
+ PixelFormat PF = pBmp->getPixelFormat();
+ switch(PF) {
+ case B8G8R8A8:
+ pBmp->setPixelFormat(R8G8B8A8);
+ break;
+ case B8G8R8X8:
+ pBmp->setPixelFormat(R8G8B8X8);
+ break;
+ case R8G8B8A8:
+ pBmp->setPixelFormat(B8G8R8A8);
+ break;
+ case R8G8B8X8:
+ pBmp->setPixelFormat(B8G8R8X8);
+ break;
+ case R8G8B8:
+ pBmp->setPixelFormat(B8G8R8);
+ break;
+ case B8G8R8:
+ pBmp->setPixelFormat(R8G8B8);
+ break;
+ default:
+ // Only 24 and 32 bpp supported.
+ AVG_ASSERT(false);
+ }
+ IntPoint size = pBmp->getSize();
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pLine = pBmp->getPixels()+y*pBmp->getStride();
+ if (pBmp->getBytesPerPixel() == 4) {
+ for (int x = 0; x < size.x; x++) {
+ unsigned char tmp = pLine[x*4+REDPOS];
+ pLine[x*4+REDPOS] = pLine[x*4+BLUEPOS];
+ pLine[x*4+BLUEPOS] = tmp;
+ }
+ } else {
+ for (int x = 0; x < size.x; x++) {
+ unsigned char tmp = pLine[x*3+REDPOS];
+ pLine[x*3+REDPOS] = pLine[x*3+BLUEPOS];
+ pLine[x*3+BLUEPOS] = tmp;
+ }
+ }
+ }
+}
+
+} // namespace
diff --git a/src/graphics/Filterfliprgb.h b/src/graphics/Filterfliprgb.h
new file mode 100644
index 0000000..1705f9a
--- /dev/null
+++ b/src/graphics/Filterfliprgb.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filterfliprgb_H
+#define _Filterfliprgb_H
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Filter that flips the R and B components of a bitmap.
+class AVG_API FilterFlipRGB : public Filter
+{
+public:
+ FilterFlipRGB();
+ virtual ~FilterFlipRGB();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/Filterfliprgba.cpp b/src/graphics/Filterfliprgba.cpp
new file mode 100644
index 0000000..dc1bf90
--- /dev/null
+++ b/src/graphics/Filterfliprgba.cpp
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filterfliprgba.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+FilterFlipRGBA::FilterFlipRGBA()
+ : Filter()
+{
+}
+
+FilterFlipRGBA::~FilterFlipRGBA()
+{
+
+}
+
+void FilterFlipRGBA::applyInPlace(BitmapPtr pBmp)
+{
+ AVG_ASSERT(pBmp->getBytesPerPixel() == 4);
+ IntPoint size = pBmp->getSize();
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pLine = pBmp->getPixels()+y*pBmp->getStride();
+ for (int x = 0; x < size.x; x++) {
+ unsigned char tmp = pLine[x*4+REDPOS];
+ pLine[x*4+REDPOS] = pLine[x*4+ALPHAPOS];
+ pLine[x*4+ALPHAPOS] = tmp;
+ tmp = pLine[x*4+BLUEPOS];
+ pLine[x*4+BLUEPOS] = pLine[x*4+GREENPOS];
+ pLine[x*4+GREENPOS] = tmp;
+ }
+ }
+}
+
+} // namespace
diff --git a/src/graphics/Filterfliprgba.h b/src/graphics/Filterfliprgba.h
new file mode 100644
index 0000000..6654c74
--- /dev/null
+++ b/src/graphics/Filterfliprgba.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filterfliprgba_H
+#define _Filterfliprgba_H
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Filter that flips the R and B components of a bitmap.
+class AVG_API FilterFlipRGBA : public Filter
+{
+public:
+ FilterFlipRGBA();
+ virtual ~FilterFlipRGBA();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/Filterflipuv.cpp b/src/graphics/Filterflipuv.cpp
new file mode 100644
index 0000000..acd4f31
--- /dev/null
+++ b/src/graphics/Filterflipuv.cpp
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filterflipuv.h"
+#include "Pixeldefs.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+FilterFlipUV::FilterFlipUV()
+ : Filter()
+{
+}
+
+FilterFlipUV::~FilterFlipUV()
+{
+
+}
+
+void FilterFlipUV::applyInPlace(BitmapPtr pBmp)
+{
+ AVG_ASSERT(pBmp->getPixelFormat() == YCbCr422);
+ IntPoint size = pBmp->getSize();
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pLine = pBmp->getPixels()+y*pBmp->getStride();
+ for (int x = 0; x < size.x/2; x++) {
+ unsigned char tmp = pLine[x*4+1];
+ pLine[x*4+1] = pLine[x*4+3];
+ pLine[x*4+3] = tmp;
+ }
+ }
+}
+
+} // namespace
diff --git a/src/graphics/Filterflipuv.h b/src/graphics/Filterflipuv.h
new file mode 100644
index 0000000..c0733a1
--- /dev/null
+++ b/src/graphics/Filterflipuv.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filterflipuv_H
+#define _Filterflipuv_H
+
+#include "../api.h"
+#include "Filter.h"
+
+namespace avg {
+
+// Filter that flips the U and V components of a YCbCr422 bitmap.
+class AVG_API FilterFlipUV : public Filter
+{
+public:
+ FilterFlipUV();
+ virtual ~FilterFlipUV();
+ virtual void applyInPlace(BitmapPtr pBmp) ;
+
+private:
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/Filtergrayscale.cpp b/src/graphics/Filtergrayscale.cpp
new file mode 100644
index 0000000..883cd6e
--- /dev/null
+++ b/src/graphics/Filtergrayscale.cpp
@@ -0,0 +1,80 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Filtergrayscale.h"
+
+#include "Pixeldefs.h"
+
+#include <iostream>
+
+namespace avg {
+
+using namespace std;
+
+FilterGrayscale::FilterGrayscale()
+ : Filter()
+{
+}
+
+FilterGrayscale::~FilterGrayscale()
+{
+
+}
+
+BitmapPtr FilterGrayscale::apply(BitmapPtr pBmpSrc)
+{
+ PixelFormat PF = pBmpSrc->getPixelFormat();
+ if (PF == I8) {
+ return BitmapPtr(new Bitmap(*pBmpSrc));
+ }
+ BitmapPtr pBmpDest = BitmapPtr(new Bitmap(pBmpSrc->getSize(), I8,
+ pBmpSrc->getName()));
+ unsigned char * pSrcLine = pBmpSrc->getPixels();
+ unsigned char * pDestLine = pBmpDest->getPixels();
+ IntPoint size = pBmpDest->getSize();
+ int bpp = pBmpSrc->getBytesPerPixel();
+ for (int y = 0; y<size.y; ++y) {
+ unsigned char * pSrcPixel = pSrcLine;
+ unsigned char * pDstPixel = pDestLine;
+ for (int x = 0; x < size.x; ++x) {
+ // For the coefficients used, see http://www.inforamp.net/~poynton/
+ // Appoximations curtesy of libpng :-).
+ if (PF == R8G8B8A8 || PF == R8G8B8X8 || PF == R8G8B8) {
+ *pDstPixel = (unsigned char)((pSrcPixel[REDPOS]*54+
+ pSrcPixel[GREENPOS]*183+
+ pSrcPixel[BLUEPOS]*19)/256);
+ pSrcPixel += bpp;
+ ++pDstPixel;
+ } else {
+ *pDstPixel = (unsigned char)((pSrcPixel[BLUEPOS]*54+
+ pSrcPixel[GREENPOS]*183+
+ pSrcPixel[REDPOS]*19)/256);
+ pSrcPixel += bpp;
+ ++pDstPixel;
+ }
+ }
+ pSrcLine = pSrcLine + pBmpSrc->getStride();
+ pDestLine = pDestLine + pBmpDest->getStride();
+ }
+ return pBmpDest;
+}
+
+}
diff --git a/src/graphics/Filtergrayscale.h b/src/graphics/Filtergrayscale.h
new file mode 100644
index 0000000..ea53a56
--- /dev/null
+++ b/src/graphics/Filtergrayscale.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Filtergrayscale_H_
+#define _Filtergrayscale_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+// Creates a grayscale version of a 32 bpp bitmap.
+class AVG_API FilterGrayscale : public Filter
+{
+public:
+ FilterGrayscale();
+ virtual ~FilterGrayscale();
+ virtual BitmapPtr apply(BitmapPtr pBmpSource);
+
+private:
+};
+
+} // namespace
+
+#endif
+
diff --git a/src/graphics/GL/gl.h b/src/graphics/GL/gl.h
new file mode 100644
index 0000000..39ae7f3
--- /dev/null
+++ b/src/graphics/GL/gl.h
@@ -0,0 +1,2262 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * BRIAN PAUL 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.
+ */
+
+
+#ifndef __gl_h_
+#define __gl_h_
+
+#if defined(USE_MGL_NAMESPACE)
+#include "../../api.h"
+#include "gl_mangle.h"
+#endif
+
+
+/**********************************************************************
+ * Begin system-specific stuff. Do not do any of this when building
+ * for SciTech SNAP, as this is all done before this header file is
+ * included.
+ */
+#if !defined(__SCITECH_SNAP__)
+
+#if defined(__BEOS__)
+#include <stdlib.h> /* to get some BeOS-isms */
+#endif
+
+#if !defined(OPENSTEP) && (defined(NeXT) || defined(NeXT_PDO))
+#define OPENSTEP
+#endif
+
+#if defined(_WIN32) && !defined(__WIN32__) && !defined(__CYGWIN__)
+#define __WIN32__
+#endif
+
+#if !defined(OPENSTEP) && (defined(__WIN32__) && !defined(__CYGWIN__))
+# if (defined(_MSC_VER) || defined(__MINGW32__)) && defined(BUILD_GL32) /* tag specify we're building mesa as a DLL */
+# define GLAPI __declspec(dllexport)
+# elif (defined(_MSC_VER) || defined(__MINGW32__)) && defined(_DLL) /* tag specifying we're building for DLL runtime support */
+# define GLAPI __declspec(dllimport)
+# else /* for use with static link lib build of Win32 edition only */
+# define GLAPI extern
+# endif /* _STATIC_MESA support */
+# define GLAPIENTRY __stdcall
+#elif defined(__CYGWIN__) && defined(USE_OPENGL32) /* use native windows opengl32 */
+# define GLAPI extern
+# define GLAPIENTRY __stdcall
+#elif defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 303
+# define GLAPI __attribute__((visibility("default")))
+# define GLAPIENTRY
+#endif /* WIN32 && !CYGWIN */
+
+#if (defined(__BEOS__) && defined(__POWERPC__)) || defined(__QUICKDRAW__)
+# define PRAGMA_EXPORT_SUPPORTED 1
+#endif
+
+/*
+ * WINDOWS: Include windows.h here to define APIENTRY.
+ * It is also useful when applications include this file by
+ * including only glut.h, since glut.h depends on windows.h.
+ * Applications needing to include windows.h with parms other
+ * than "WIN32_LEAN_AND_MEAN" may include windows.h before
+ * glut.h or gl.h.
+ */
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#if defined(_WIN32) && !defined(_WINGDI_) && !defined(_GNU_H_WINDOWS32_DEFINES) && !defined(OPENSTEP) && !defined(__CYGWIN__)
+#include <GL/mesa_wgl.h>
+#endif
+
+#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED
+#pragma import on
+#endif
+
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY GLAPIENTRY
+#endif
+
+/* "P" suffix to be used for a pointer to a function */
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+
+#ifndef GLAPIENTRYP
+#define GLAPIENTRYP GLAPIENTRY *
+#endif
+
+#ifdef CENTERLINE_CLPP
+#define signed
+#endif
+
+#if defined(PRAGMA_EXPORT_SUPPORTED)
+#pragma export on
+#endif
+
+#endif /* !__SCITECH_SNAP__ */
+/*
+ * End system-specific stuff.
+ **********************************************************************/
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#define GL_VERSION_1_1 1
+#define GL_VERSION_1_2 1
+#define GL_VERSION_1_3 1
+#define GL_ARB_imaging 1
+
+
+/*
+ * Datatypes
+ */
+typedef unsigned int GLenum;
+typedef unsigned char GLboolean;
+typedef unsigned int GLbitfield;
+typedef void GLvoid;
+typedef signed char GLbyte; /* 1-byte signed */
+typedef short GLshort; /* 2-byte signed */
+typedef int GLint; /* 4-byte signed */
+typedef unsigned char GLubyte; /* 1-byte unsigned */
+typedef unsigned short GLushort; /* 2-byte unsigned */
+typedef unsigned int GLuint; /* 4-byte unsigned */
+typedef int GLsizei; /* 4-byte signed */
+typedef float GLfloat; /* single precision float */
+typedef float GLclampf; /* single precision float in [0,1] */
+typedef double GLdouble; /* double precision float */
+typedef double GLclampd; /* double precision float in [0,1] */
+
+
+
+/*
+ * Constants
+ */
+
+/* Boolean values */
+#define GL_FALSE 0x0
+#define GL_TRUE 0x1
+
+/* Data types */
+#define GL_BYTE 0x1400
+#define GL_UNSIGNED_BYTE 0x1401
+#define GL_SHORT 0x1402
+#define GL_UNSIGNED_SHORT 0x1403
+#define GL_INT 0x1404
+#define GL_UNSIGNED_INT 0x1405
+#define GL_FLOAT 0x1406
+#define GL_2_BYTES 0x1407
+#define GL_3_BYTES 0x1408
+#define GL_4_BYTES 0x1409
+#define GL_DOUBLE 0x140A
+
+/* Primitives */
+#define GL_POINTS 0x0000
+#define GL_LINES 0x0001
+#define GL_LINE_LOOP 0x0002
+#define GL_LINE_STRIP 0x0003
+#define GL_TRIANGLES 0x0004
+#define GL_TRIANGLE_STRIP 0x0005
+#define GL_TRIANGLE_FAN 0x0006
+#define GL_QUADS 0x0007
+#define GL_QUAD_STRIP 0x0008
+#define GL_POLYGON 0x0009
+
+/* Vertex Arrays */
+#define GL_VERTEX_ARRAY 0x8074
+#define GL_NORMAL_ARRAY 0x8075
+#define GL_COLOR_ARRAY 0x8076
+#define GL_INDEX_ARRAY 0x8077
+#define GL_TEXTURE_COORD_ARRAY 0x8078
+#define GL_EDGE_FLAG_ARRAY 0x8079
+#define GL_VERTEX_ARRAY_SIZE 0x807A
+#define GL_VERTEX_ARRAY_TYPE 0x807B
+#define GL_VERTEX_ARRAY_STRIDE 0x807C
+#define GL_NORMAL_ARRAY_TYPE 0x807E
+#define GL_NORMAL_ARRAY_STRIDE 0x807F
+#define GL_COLOR_ARRAY_SIZE 0x8081
+#define GL_COLOR_ARRAY_TYPE 0x8082
+#define GL_COLOR_ARRAY_STRIDE 0x8083
+#define GL_INDEX_ARRAY_TYPE 0x8085
+#define GL_INDEX_ARRAY_STRIDE 0x8086
+#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A
+#define GL_EDGE_FLAG_ARRAY_STRIDE 0x808C
+#define GL_VERTEX_ARRAY_POINTER 0x808E
+#define GL_NORMAL_ARRAY_POINTER 0x808F
+#define GL_COLOR_ARRAY_POINTER 0x8090
+#define GL_INDEX_ARRAY_POINTER 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER 0x8093
+#define GL_V2F 0x2A20
+#define GL_V3F 0x2A21
+#define GL_C4UB_V2F 0x2A22
+#define GL_C4UB_V3F 0x2A23
+#define GL_C3F_V3F 0x2A24
+#define GL_N3F_V3F 0x2A25
+#define GL_C4F_N3F_V3F 0x2A26
+#define GL_T2F_V3F 0x2A27
+#define GL_T4F_V4F 0x2A28
+#define GL_T2F_C4UB_V3F 0x2A29
+#define GL_T2F_C3F_V3F 0x2A2A
+#define GL_T2F_N3F_V3F 0x2A2B
+#define GL_T2F_C4F_N3F_V3F 0x2A2C
+#define GL_T4F_C4F_N3F_V4F 0x2A2D
+
+/* Matrix Mode */
+#define GL_MATRIX_MODE 0x0BA0
+#define GL_MODELVIEW 0x1700
+#define GL_PROJECTION 0x1701
+#define GL_TEXTURE 0x1702
+
+/* Points */
+#define GL_POINT_SMOOTH 0x0B10
+#define GL_POINT_SIZE 0x0B11
+#define GL_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_POINT_SIZE_RANGE 0x0B12
+
+/* Lines */
+#define GL_LINE_SMOOTH 0x0B20
+#define GL_LINE_STIPPLE 0x0B24
+#define GL_LINE_STIPPLE_PATTERN 0x0B25
+#define GL_LINE_STIPPLE_REPEAT 0x0B26
+#define GL_LINE_WIDTH 0x0B21
+#define GL_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_LINE_WIDTH_RANGE 0x0B22
+
+/* Polygons */
+#define GL_POINT 0x1B00
+#define GL_LINE 0x1B01
+#define GL_FILL 0x1B02
+#define GL_CW 0x0900
+#define GL_CCW 0x0901
+#define GL_FRONT 0x0404
+#define GL_BACK 0x0405
+#define GL_POLYGON_MODE 0x0B40
+#define GL_POLYGON_SMOOTH 0x0B41
+#define GL_POLYGON_STIPPLE 0x0B42
+#define GL_EDGE_FLAG 0x0B43
+#define GL_CULL_FACE 0x0B44
+#define GL_CULL_FACE_MODE 0x0B45
+#define GL_FRONT_FACE 0x0B46
+#define GL_POLYGON_OFFSET_FACTOR 0x8038
+#define GL_POLYGON_OFFSET_UNITS 0x2A00
+#define GL_POLYGON_OFFSET_POINT 0x2A01
+#define GL_POLYGON_OFFSET_LINE 0x2A02
+#define GL_POLYGON_OFFSET_FILL 0x8037
+
+/* Display Lists */
+#define GL_COMPILE 0x1300
+#define GL_COMPILE_AND_EXECUTE 0x1301
+#define GL_LIST_BASE 0x0B32
+#define GL_LIST_INDEX 0x0B33
+#define GL_LIST_MODE 0x0B30
+
+/* Depth buffer */
+#define GL_NEVER 0x0200
+#define GL_LESS 0x0201
+#define GL_EQUAL 0x0202
+#define GL_LEQUAL 0x0203
+#define GL_GREATER 0x0204
+#define GL_NOTEQUAL 0x0205
+#define GL_GEQUAL 0x0206
+#define GL_ALWAYS 0x0207
+#define GL_DEPTH_TEST 0x0B71
+#define GL_DEPTH_BITS 0x0D56
+#define GL_DEPTH_CLEAR_VALUE 0x0B73
+#define GL_DEPTH_FUNC 0x0B74
+#define GL_DEPTH_RANGE 0x0B70
+#define GL_DEPTH_WRITEMASK 0x0B72
+#define GL_DEPTH_COMPONENT 0x1902
+
+/* Lighting */
+#define GL_LIGHTING 0x0B50
+#define GL_LIGHT0 0x4000
+#define GL_LIGHT1 0x4001
+#define GL_LIGHT2 0x4002
+#define GL_LIGHT3 0x4003
+#define GL_LIGHT4 0x4004
+#define GL_LIGHT5 0x4005
+#define GL_LIGHT6 0x4006
+#define GL_LIGHT7 0x4007
+#define GL_SPOT_EXPONENT 0x1205
+#define GL_SPOT_CUTOFF 0x1206
+#define GL_CONSTANT_ATTENUATION 0x1207
+#define GL_LINEAR_ATTENUATION 0x1208
+#define GL_QUADRATIC_ATTENUATION 0x1209
+#define GL_AMBIENT 0x1200
+#define GL_DIFFUSE 0x1201
+#define GL_SPECULAR 0x1202
+#define GL_SHININESS 0x1601
+#define GL_EMISSION 0x1600
+#define GL_POSITION 0x1203
+#define GL_SPOT_DIRECTION 0x1204
+#define GL_AMBIENT_AND_DIFFUSE 0x1602
+#define GL_COLOR_INDEXES 0x1603
+#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52
+#define GL_LIGHT_MODEL_LOCAL_VIEWER 0x0B51
+#define GL_LIGHT_MODEL_AMBIENT 0x0B53
+#define GL_FRONT_AND_BACK 0x0408
+#define GL_SHADE_MODEL 0x0B54
+#define GL_FLAT 0x1D00
+#define GL_SMOOTH 0x1D01
+#define GL_COLOR_MATERIAL 0x0B57
+#define GL_COLOR_MATERIAL_FACE 0x0B55
+#define GL_COLOR_MATERIAL_PARAMETER 0x0B56
+#define GL_NORMALIZE 0x0BA1
+
+/* User clipping planes */
+#define GL_CLIP_PLANE0 0x3000
+#define GL_CLIP_PLANE1 0x3001
+#define GL_CLIP_PLANE2 0x3002
+#define GL_CLIP_PLANE3 0x3003
+#define GL_CLIP_PLANE4 0x3004
+#define GL_CLIP_PLANE5 0x3005
+
+/* Accumulation buffer */
+#define GL_ACCUM_RED_BITS 0x0D58
+#define GL_ACCUM_GREEN_BITS 0x0D59
+#define GL_ACCUM_BLUE_BITS 0x0D5A
+#define GL_ACCUM_ALPHA_BITS 0x0D5B
+#define GL_ACCUM_CLEAR_VALUE 0x0B80
+#define GL_ACCUM 0x0100
+#define GL_ADD 0x0104
+#define GL_LOAD 0x0101
+#define GL_MULT 0x0103
+#define GL_RETURN 0x0102
+
+/* Alpha testing */
+#define GL_ALPHA_TEST 0x0BC0
+#define GL_ALPHA_TEST_REF 0x0BC2
+#define GL_ALPHA_TEST_FUNC 0x0BC1
+
+/* Blending */
+#define GL_BLEND 0x0BE2
+#define GL_BLEND_SRC 0x0BE1
+#define GL_BLEND_DST 0x0BE0
+#define GL_ZERO 0x0
+#define GL_ONE 0x1
+#define GL_SRC_COLOR 0x0300
+#define GL_ONE_MINUS_SRC_COLOR 0x0301
+#define GL_SRC_ALPHA 0x0302
+#define GL_ONE_MINUS_SRC_ALPHA 0x0303
+#define GL_DST_ALPHA 0x0304
+#define GL_ONE_MINUS_DST_ALPHA 0x0305
+#define GL_DST_COLOR 0x0306
+#define GL_ONE_MINUS_DST_COLOR 0x0307
+#define GL_SRC_ALPHA_SATURATE 0x0308
+
+/* Render Mode */
+#define GL_FEEDBACK 0x1C01
+#define GL_RENDER 0x1C00
+#define GL_SELECT 0x1C02
+
+/* Feedback */
+#define GL_2D 0x0600
+#define GL_3D 0x0601
+#define GL_3D_COLOR 0x0602
+#define GL_3D_COLOR_TEXTURE 0x0603
+#define GL_4D_COLOR_TEXTURE 0x0604
+#define GL_POINT_TOKEN 0x0701
+#define GL_LINE_TOKEN 0x0702
+#define GL_LINE_RESET_TOKEN 0x0707
+#define GL_POLYGON_TOKEN 0x0703
+#define GL_BITMAP_TOKEN 0x0704
+#define GL_DRAW_PIXEL_TOKEN 0x0705
+#define GL_COPY_PIXEL_TOKEN 0x0706
+#define GL_PASS_THROUGH_TOKEN 0x0700
+#define GL_FEEDBACK_BUFFER_POINTER 0x0DF0
+#define GL_FEEDBACK_BUFFER_SIZE 0x0DF1
+#define GL_FEEDBACK_BUFFER_TYPE 0x0DF2
+
+/* Selection */
+#define GL_SELECTION_BUFFER_POINTER 0x0DF3
+#define GL_SELECTION_BUFFER_SIZE 0x0DF4
+
+/* Fog */
+#define GL_FOG 0x0B60
+#define GL_FOG_MODE 0x0B65
+#define GL_FOG_DENSITY 0x0B62
+#define GL_FOG_COLOR 0x0B66
+#define GL_FOG_INDEX 0x0B61
+#define GL_FOG_START 0x0B63
+#define GL_FOG_END 0x0B64
+#define GL_LINEAR 0x2601
+#define GL_EXP 0x0800
+#define GL_EXP2 0x0801
+
+/* Logic Ops */
+#define GL_LOGIC_OP 0x0BF1
+#define GL_INDEX_LOGIC_OP 0x0BF1
+#define GL_COLOR_LOGIC_OP 0x0BF2
+#define GL_LOGIC_OP_MODE 0x0BF0
+#define GL_CLEAR 0x1500
+#define GL_SET 0x150F
+#define GL_COPY 0x1503
+#define GL_COPY_INVERTED 0x150C
+#define GL_NOOP 0x1505
+#define GL_INVERT 0x150A
+#define GL_AND 0x1501
+#define GL_NAND 0x150E
+#define GL_OR 0x1507
+#define GL_NOR 0x1508
+#define GL_XOR 0x1506
+#define GL_EQUIV 0x1509
+#define GL_AND_REVERSE 0x1502
+#define GL_AND_INVERTED 0x1504
+#define GL_OR_REVERSE 0x150B
+#define GL_OR_INVERTED 0x150D
+
+/* Stencil */
+#define GL_STENCIL_TEST 0x0B90
+#define GL_STENCIL_WRITEMASK 0x0B98
+#define GL_STENCIL_BITS 0x0D57
+#define GL_STENCIL_FUNC 0x0B92
+#define GL_STENCIL_VALUE_MASK 0x0B93
+#define GL_STENCIL_REF 0x0B97
+#define GL_STENCIL_FAIL 0x0B94
+#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96
+#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95
+#define GL_STENCIL_CLEAR_VALUE 0x0B91
+#define GL_STENCIL_INDEX 0x1901
+#define GL_KEEP 0x1E00
+#define GL_REPLACE 0x1E01
+#define GL_INCR 0x1E02
+#define GL_DECR 0x1E03
+
+/* Buffers, Pixel Drawing/Reading */
+#define GL_NONE 0x0
+#define GL_LEFT 0x0406
+#define GL_RIGHT 0x0407
+/*GL_FRONT 0x0404 */
+/*GL_BACK 0x0405 */
+/*GL_FRONT_AND_BACK 0x0408 */
+#define GL_FRONT_LEFT 0x0400
+#define GL_FRONT_RIGHT 0x0401
+#define GL_BACK_LEFT 0x0402
+#define GL_BACK_RIGHT 0x0403
+#define GL_AUX0 0x0409
+#define GL_AUX1 0x040A
+#define GL_AUX2 0x040B
+#define GL_AUX3 0x040C
+#define GL_COLOR_INDEX 0x1900
+#define GL_RED 0x1903
+#define GL_GREEN 0x1904
+#define GL_BLUE 0x1905
+#define GL_ALPHA 0x1906
+#define GL_LUMINANCE 0x1909
+#define GL_LUMINANCE_ALPHA 0x190A
+#define GL_ALPHA_BITS 0x0D55
+#define GL_RED_BITS 0x0D52
+#define GL_GREEN_BITS 0x0D53
+#define GL_BLUE_BITS 0x0D54
+#define GL_INDEX_BITS 0x0D51
+#define GL_SUBPIXEL_BITS 0x0D50
+#define GL_AUX_BUFFERS 0x0C00
+#define GL_READ_BUFFER 0x0C02
+#define GL_DRAW_BUFFER 0x0C01
+#define GL_DOUBLEBUFFER 0x0C32
+#define GL_STEREO 0x0C33
+#define GL_BITMAP 0x1A00
+#define GL_COLOR 0x1800
+#define GL_DEPTH 0x1801
+#define GL_STENCIL 0x1802
+#define GL_DITHER 0x0BD0
+#define GL_RGB 0x1907
+#define GL_RGBA 0x1908
+
+/* Implementation limits */
+#define GL_MAX_LIST_NESTING 0x0B31
+#define GL_MAX_ATTRIB_STACK_DEPTH 0x0D35
+#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36
+#define GL_MAX_NAME_STACK_DEPTH 0x0D37
+#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38
+#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39
+#define GL_MAX_EVAL_ORDER 0x0D30
+#define GL_MAX_LIGHTS 0x0D31
+#define GL_MAX_CLIP_PLANES 0x0D32
+#define GL_MAX_TEXTURE_SIZE 0x0D33
+#define GL_MAX_PIXEL_MAP_TABLE 0x0D34
+#define GL_MAX_VIEWPORT_DIMS 0x0D3A
+#define GL_MAX_CLIENT_ATTRIB_STACK_DEPTH 0x0D3B
+
+/* Gets */
+#define GL_ATTRIB_STACK_DEPTH 0x0BB0
+#define GL_CLIENT_ATTRIB_STACK_DEPTH 0x0BB1
+#define GL_COLOR_CLEAR_VALUE 0x0C22
+#define GL_COLOR_WRITEMASK 0x0C23
+#define GL_CURRENT_INDEX 0x0B01
+#define GL_CURRENT_COLOR 0x0B00
+#define GL_CURRENT_NORMAL 0x0B02
+#define GL_CURRENT_RASTER_COLOR 0x0B04
+#define GL_CURRENT_RASTER_DISTANCE 0x0B09
+#define GL_CURRENT_RASTER_INDEX 0x0B05
+#define GL_CURRENT_RASTER_POSITION 0x0B07
+#define GL_CURRENT_RASTER_TEXTURE_COORDS 0x0B06
+#define GL_CURRENT_RASTER_POSITION_VALID 0x0B08
+#define GL_CURRENT_TEXTURE_COORDS 0x0B03
+#define GL_INDEX_CLEAR_VALUE 0x0C20
+#define GL_INDEX_MODE 0x0C30
+#define GL_INDEX_WRITEMASK 0x0C21
+#define GL_MODELVIEW_MATRIX 0x0BA6
+#define GL_MODELVIEW_STACK_DEPTH 0x0BA3
+#define GL_NAME_STACK_DEPTH 0x0D70
+#define GL_PROJECTION_MATRIX 0x0BA7
+#define GL_PROJECTION_STACK_DEPTH 0x0BA4
+#define GL_RENDER_MODE 0x0C40
+#define GL_RGBA_MODE 0x0C31
+#define GL_TEXTURE_MATRIX 0x0BA8
+#define GL_TEXTURE_STACK_DEPTH 0x0BA5
+#define GL_VIEWPORT 0x0BA2
+
+/* Evaluators */
+#define GL_AUTO_NORMAL 0x0D80
+#define GL_MAP1_COLOR_4 0x0D90
+#define GL_MAP1_INDEX 0x0D91
+#define GL_MAP1_NORMAL 0x0D92
+#define GL_MAP1_TEXTURE_COORD_1 0x0D93
+#define GL_MAP1_TEXTURE_COORD_2 0x0D94
+#define GL_MAP1_TEXTURE_COORD_3 0x0D95
+#define GL_MAP1_TEXTURE_COORD_4 0x0D96
+#define GL_MAP1_VERTEX_3 0x0D97
+#define GL_MAP1_VERTEX_4 0x0D98
+#define GL_MAP2_COLOR_4 0x0DB0
+#define GL_MAP2_INDEX 0x0DB1
+#define GL_MAP2_NORMAL 0x0DB2
+#define GL_MAP2_TEXTURE_COORD_1 0x0DB3
+#define GL_MAP2_TEXTURE_COORD_2 0x0DB4
+#define GL_MAP2_TEXTURE_COORD_3 0x0DB5
+#define GL_MAP2_TEXTURE_COORD_4 0x0DB6
+#define GL_MAP2_VERTEX_3 0x0DB7
+#define GL_MAP2_VERTEX_4 0x0DB8
+#define GL_MAP1_GRID_DOMAIN 0x0DD0
+#define GL_MAP1_GRID_SEGMENTS 0x0DD1
+#define GL_MAP2_GRID_DOMAIN 0x0DD2
+#define GL_MAP2_GRID_SEGMENTS 0x0DD3
+#define GL_COEFF 0x0A00
+#define GL_DOMAIN 0x0A02
+#define GL_ORDER 0x0A01
+
+/* Hints */
+#define GL_FOG_HINT 0x0C54
+#define GL_LINE_SMOOTH_HINT 0x0C52
+#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50
+#define GL_POINT_SMOOTH_HINT 0x0C51
+#define GL_POLYGON_SMOOTH_HINT 0x0C53
+#define GL_DONT_CARE 0x1100
+#define GL_FASTEST 0x1101
+#define GL_NICEST 0x1102
+
+/* Scissor box */
+#define GL_SCISSOR_TEST 0x0C11
+#define GL_SCISSOR_BOX 0x0C10
+
+/* Pixel Mode / Transfer */
+#define GL_MAP_COLOR 0x0D10
+#define GL_MAP_STENCIL 0x0D11
+#define GL_INDEX_SHIFT 0x0D12
+#define GL_INDEX_OFFSET 0x0D13
+#define GL_RED_SCALE 0x0D14
+#define GL_RED_BIAS 0x0D15
+#define GL_GREEN_SCALE 0x0D18
+#define GL_GREEN_BIAS 0x0D19
+#define GL_BLUE_SCALE 0x0D1A
+#define GL_BLUE_BIAS 0x0D1B
+#define GL_ALPHA_SCALE 0x0D1C
+#define GL_ALPHA_BIAS 0x0D1D
+#define GL_DEPTH_SCALE 0x0D1E
+#define GL_DEPTH_BIAS 0x0D1F
+#define GL_PIXEL_MAP_S_TO_S_SIZE 0x0CB1
+#define GL_PIXEL_MAP_I_TO_I_SIZE 0x0CB0
+#define GL_PIXEL_MAP_I_TO_R_SIZE 0x0CB2
+#define GL_PIXEL_MAP_I_TO_G_SIZE 0x0CB3
+#define GL_PIXEL_MAP_I_TO_B_SIZE 0x0CB4
+#define GL_PIXEL_MAP_I_TO_A_SIZE 0x0CB5
+#define GL_PIXEL_MAP_R_TO_R_SIZE 0x0CB6
+#define GL_PIXEL_MAP_G_TO_G_SIZE 0x0CB7
+#define GL_PIXEL_MAP_B_TO_B_SIZE 0x0CB8
+#define GL_PIXEL_MAP_A_TO_A_SIZE 0x0CB9
+#define GL_PIXEL_MAP_S_TO_S 0x0C71
+#define GL_PIXEL_MAP_I_TO_I 0x0C70
+#define GL_PIXEL_MAP_I_TO_R 0x0C72
+#define GL_PIXEL_MAP_I_TO_G 0x0C73
+#define GL_PIXEL_MAP_I_TO_B 0x0C74
+#define GL_PIXEL_MAP_I_TO_A 0x0C75
+#define GL_PIXEL_MAP_R_TO_R 0x0C76
+#define GL_PIXEL_MAP_G_TO_G 0x0C77
+#define GL_PIXEL_MAP_B_TO_B 0x0C78
+#define GL_PIXEL_MAP_A_TO_A 0x0C79
+#define GL_PACK_ALIGNMENT 0x0D05
+#define GL_PACK_LSB_FIRST 0x0D01
+#define GL_PACK_ROW_LENGTH 0x0D02
+#define GL_PACK_SKIP_PIXELS 0x0D04
+#define GL_PACK_SKIP_ROWS 0x0D03
+#define GL_PACK_SWAP_BYTES 0x0D00
+#define GL_UNPACK_ALIGNMENT 0x0CF5
+#define GL_UNPACK_LSB_FIRST 0x0CF1
+#define GL_UNPACK_ROW_LENGTH 0x0CF2
+#define GL_UNPACK_SKIP_PIXELS 0x0CF4
+#define GL_UNPACK_SKIP_ROWS 0x0CF3
+#define GL_UNPACK_SWAP_BYTES 0x0CF0
+#define GL_ZOOM_X 0x0D16
+#define GL_ZOOM_Y 0x0D17
+
+/* Texture mapping */
+#define GL_TEXTURE_ENV 0x2300
+#define GL_TEXTURE_ENV_MODE 0x2200
+#define GL_TEXTURE_1D 0x0DE0
+#define GL_TEXTURE_2D 0x0DE1
+#define GL_TEXTURE_WRAP_S 0x2802
+#define GL_TEXTURE_WRAP_T 0x2803
+#define GL_TEXTURE_MAG_FILTER 0x2800
+#define GL_TEXTURE_MIN_FILTER 0x2801
+#define GL_TEXTURE_ENV_COLOR 0x2201
+#define GL_TEXTURE_GEN_S 0x0C60
+#define GL_TEXTURE_GEN_T 0x0C61
+#define GL_TEXTURE_GEN_MODE 0x2500
+#define GL_TEXTURE_BORDER_COLOR 0x1004
+#define GL_TEXTURE_WIDTH 0x1000
+#define GL_TEXTURE_HEIGHT 0x1001
+#define GL_TEXTURE_BORDER 0x1005
+#define GL_TEXTURE_COMPONENTS 0x1003
+#define GL_TEXTURE_RED_SIZE 0x805C
+#define GL_TEXTURE_GREEN_SIZE 0x805D
+#define GL_TEXTURE_BLUE_SIZE 0x805E
+#define GL_TEXTURE_ALPHA_SIZE 0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE 0x8060
+#define GL_TEXTURE_INTENSITY_SIZE 0x8061
+#define GL_NEAREST_MIPMAP_NEAREST 0x2700
+#define GL_NEAREST_MIPMAP_LINEAR 0x2702
+#define GL_LINEAR_MIPMAP_NEAREST 0x2701
+#define GL_LINEAR_MIPMAP_LINEAR 0x2703
+#define GL_OBJECT_LINEAR 0x2401
+#define GL_OBJECT_PLANE 0x2501
+#define GL_EYE_LINEAR 0x2400
+#define GL_EYE_PLANE 0x2502
+#define GL_SPHERE_MAP 0x2402
+#define GL_DECAL 0x2101
+#define GL_MODULATE 0x2100
+#define GL_NEAREST 0x2600
+#define GL_REPEAT 0x2901
+#define GL_CLAMP 0x2900
+#define GL_S 0x2000
+#define GL_T 0x2001
+#define GL_R 0x2002
+#define GL_Q 0x2003
+#define GL_TEXTURE_GEN_R 0x0C62
+#define GL_TEXTURE_GEN_Q 0x0C63
+
+/* Utility */
+#define GL_VENDOR 0x1F00
+#define GL_RENDERER 0x1F01
+#define GL_VERSION 0x1F02
+#define GL_EXTENSIONS 0x1F03
+
+/* Errors */
+#define GL_NO_ERROR 0x0
+#define GL_INVALID_VALUE 0x0501
+#define GL_INVALID_ENUM 0x0500
+#define GL_INVALID_OPERATION 0x0502
+#define GL_STACK_OVERFLOW 0x0503
+#define GL_STACK_UNDERFLOW 0x0504
+#define GL_OUT_OF_MEMORY 0x0505
+
+/* glPush/PopAttrib bits */
+#define GL_CURRENT_BIT 0x00000001
+#define GL_POINT_BIT 0x00000002
+#define GL_LINE_BIT 0x00000004
+#define GL_POLYGON_BIT 0x00000008
+#define GL_POLYGON_STIPPLE_BIT 0x00000010
+#define GL_PIXEL_MODE_BIT 0x00000020
+#define GL_LIGHTING_BIT 0x00000040
+#define GL_FOG_BIT 0x00000080
+#define GL_DEPTH_BUFFER_BIT 0x00000100
+#define GL_ACCUM_BUFFER_BIT 0x00000200
+#define GL_STENCIL_BUFFER_BIT 0x00000400
+#define GL_VIEWPORT_BIT 0x00000800
+#define GL_TRANSFORM_BIT 0x00001000
+#define GL_ENABLE_BIT 0x00002000
+#define GL_COLOR_BUFFER_BIT 0x00004000
+#define GL_HINT_BIT 0x00008000
+#define GL_EVAL_BIT 0x00010000
+#define GL_LIST_BIT 0x00020000
+#define GL_TEXTURE_BIT 0x00040000
+#define GL_SCISSOR_BIT 0x00080000
+#define GL_ALL_ATTRIB_BITS 0x000FFFFF
+
+
+/* OpenGL 1.1 */
+#define GL_PROXY_TEXTURE_1D 0x8063
+#define GL_PROXY_TEXTURE_2D 0x8064
+#define GL_TEXTURE_PRIORITY 0x8066
+#define GL_TEXTURE_RESIDENT 0x8067
+#define GL_TEXTURE_BINDING_1D 0x8068
+#define GL_TEXTURE_BINDING_2D 0x8069
+#define GL_TEXTURE_INTERNAL_FORMAT 0x1003
+#define GL_ALPHA4 0x803B
+#define GL_ALPHA8 0x803C
+#define GL_ALPHA12 0x803D
+#define GL_ALPHA16 0x803E
+#define GL_LUMINANCE4 0x803F
+#define GL_LUMINANCE8 0x8040
+#define GL_LUMINANCE12 0x8041
+#define GL_LUMINANCE16 0x8042
+#define GL_LUMINANCE4_ALPHA4 0x8043
+#define GL_LUMINANCE6_ALPHA2 0x8044
+#define GL_LUMINANCE8_ALPHA8 0x8045
+#define GL_LUMINANCE12_ALPHA4 0x8046
+#define GL_LUMINANCE12_ALPHA12 0x8047
+#define GL_LUMINANCE16_ALPHA16 0x8048
+#define GL_INTENSITY 0x8049
+#define GL_INTENSITY4 0x804A
+#define GL_INTENSITY8 0x804B
+#define GL_INTENSITY12 0x804C
+#define GL_INTENSITY16 0x804D
+#define GL_R3_G3_B2 0x2A10
+#define GL_RGB4 0x804F
+#define GL_RGB5 0x8050
+#define GL_RGB8 0x8051
+#define GL_RGB10 0x8052
+#define GL_RGB12 0x8053
+#define GL_RGB16 0x8054
+#define GL_RGBA2 0x8055
+#define GL_RGBA4 0x8056
+#define GL_RGB5_A1 0x8057
+#define GL_RGBA8 0x8058
+#define GL_RGB10_A2 0x8059
+#define GL_RGBA12 0x805A
+#define GL_RGBA16 0x805B
+#define GL_CLIENT_PIXEL_STORE_BIT 0x00000001
+#define GL_CLIENT_VERTEX_ARRAY_BIT 0x00000002
+#define GL_ALL_CLIENT_ATTRIB_BITS 0xFFFFFFFF
+#define GL_CLIENT_ALL_ATTRIB_BITS 0xFFFFFFFF
+
+
+
+/*
+ * Miscellaneous
+ */
+
+GLAPI void GLAPIENTRY glClearIndex( GLfloat c );
+
+GLAPI void GLAPIENTRY glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha );
+
+GLAPI void GLAPIENTRY glClear( GLbitfield mask );
+
+GLAPI void GLAPIENTRY glIndexMask( GLuint mask );
+
+GLAPI void GLAPIENTRY glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha );
+
+GLAPI void GLAPIENTRY glAlphaFunc( GLenum func, GLclampf ref );
+
+GLAPI void GLAPIENTRY glBlendFunc( GLenum sfactor, GLenum dfactor );
+
+GLAPI void GLAPIENTRY glLogicOp( GLenum opcode );
+
+GLAPI void GLAPIENTRY glCullFace( GLenum mode );
+
+GLAPI void GLAPIENTRY glFrontFace( GLenum mode );
+
+GLAPI void GLAPIENTRY glPointSize( GLfloat size );
+
+GLAPI void GLAPIENTRY glLineWidth( GLfloat width );
+
+GLAPI void GLAPIENTRY glLineStipple( GLint factor, GLushort pattern );
+
+GLAPI void GLAPIENTRY glPolygonMode( GLenum face, GLenum mode );
+
+GLAPI void GLAPIENTRY glPolygonOffset( GLfloat factor, GLfloat units );
+
+GLAPI void GLAPIENTRY glPolygonStipple( const GLubyte *mask );
+
+GLAPI void GLAPIENTRY glGetPolygonStipple( GLubyte *mask );
+
+GLAPI void GLAPIENTRY glEdgeFlag( GLboolean flag );
+
+GLAPI void GLAPIENTRY glEdgeFlagv( const GLboolean *flag );
+
+GLAPI void GLAPIENTRY glScissor( GLint x, GLint y, GLsizei width, GLsizei height);
+
+GLAPI void GLAPIENTRY glClipPlane( GLenum plane, const GLdouble *equation );
+
+GLAPI void GLAPIENTRY glGetClipPlane( GLenum plane, GLdouble *equation );
+
+GLAPI void GLAPIENTRY glDrawBuffer( GLenum mode );
+
+GLAPI void GLAPIENTRY glReadBuffer( GLenum mode );
+
+GLAPI void GLAPIENTRY glEnable( GLenum cap );
+
+GLAPI void GLAPIENTRY glDisable( GLenum cap );
+
+GLAPI GLboolean GLAPIENTRY glIsEnabled( GLenum cap );
+
+
+GLAPI void GLAPIENTRY glEnableClientState( GLenum cap ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glDisableClientState( GLenum cap ); /* 1.1 */
+
+
+GLAPI void GLAPIENTRY glGetBooleanv( GLenum pname, GLboolean *params );
+
+GLAPI void GLAPIENTRY glGetDoublev( GLenum pname, GLdouble *params );
+
+GLAPI void GLAPIENTRY glGetFloatv( GLenum pname, GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetIntegerv( GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glPushAttrib( GLbitfield mask );
+
+GLAPI void GLAPIENTRY glPopAttrib( void );
+
+
+GLAPI void GLAPIENTRY glPushClientAttrib( GLbitfield mask ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glPopClientAttrib( void ); /* 1.1 */
+
+
+GLAPI GLint GLAPIENTRY glRenderMode( GLenum mode );
+
+GLAPI GLenum GLAPIENTRY glGetError( void );
+
+GLAPI const GLubyte * GLAPIENTRY glGetString( GLenum name );
+
+GLAPI void GLAPIENTRY glFinish( void );
+
+GLAPI void GLAPIENTRY glFlush( void );
+
+GLAPI void GLAPIENTRY glHint( GLenum target, GLenum mode );
+
+
+/*
+ * Depth Buffer
+ */
+
+GLAPI void GLAPIENTRY glClearDepth( GLclampd depth );
+
+GLAPI void GLAPIENTRY glDepthFunc( GLenum func );
+
+GLAPI void GLAPIENTRY glDepthMask( GLboolean flag );
+
+GLAPI void GLAPIENTRY glDepthRange( GLclampd near_val, GLclampd far_val );
+
+
+/*
+ * Accumulation Buffer
+ */
+
+GLAPI void GLAPIENTRY glClearAccum( GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha );
+
+GLAPI void GLAPIENTRY glAccum( GLenum op, GLfloat value );
+
+
+/*
+ * Transformation
+ */
+
+GLAPI void GLAPIENTRY glMatrixMode( GLenum mode );
+
+GLAPI void GLAPIENTRY glOrtho( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble near_val, GLdouble far_val );
+
+GLAPI void GLAPIENTRY glFrustum( GLdouble left, GLdouble right,
+ GLdouble bottom, GLdouble top,
+ GLdouble near_val, GLdouble far_val );
+
+GLAPI void GLAPIENTRY glViewport( GLint x, GLint y,
+ GLsizei width, GLsizei height );
+
+GLAPI void GLAPIENTRY glPushMatrix( void );
+
+GLAPI void GLAPIENTRY glPopMatrix( void );
+
+GLAPI void GLAPIENTRY glLoadIdentity( void );
+
+GLAPI void GLAPIENTRY glLoadMatrixd( const GLdouble *m );
+GLAPI void GLAPIENTRY glLoadMatrixf( const GLfloat *m );
+
+GLAPI void GLAPIENTRY glMultMatrixd( const GLdouble *m );
+GLAPI void GLAPIENTRY glMultMatrixf( const GLfloat *m );
+
+GLAPI void GLAPIENTRY glRotated( GLdouble angle,
+ GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glRotatef( GLfloat angle,
+ GLfloat x, GLfloat y, GLfloat z );
+
+GLAPI void GLAPIENTRY glScaled( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glScalef( GLfloat x, GLfloat y, GLfloat z );
+
+GLAPI void GLAPIENTRY glTranslated( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glTranslatef( GLfloat x, GLfloat y, GLfloat z );
+
+
+/*
+ * Display Lists
+ */
+
+GLAPI GLboolean GLAPIENTRY glIsList( GLuint list );
+
+GLAPI void GLAPIENTRY glDeleteLists( GLuint list, GLsizei range );
+
+GLAPI GLuint GLAPIENTRY glGenLists( GLsizei range );
+
+GLAPI void GLAPIENTRY glNewList( GLuint list, GLenum mode );
+
+GLAPI void GLAPIENTRY glEndList( void );
+
+GLAPI void GLAPIENTRY glCallList( GLuint list );
+
+GLAPI void GLAPIENTRY glCallLists( GLsizei n, GLenum type,
+ const GLvoid *lists );
+
+GLAPI void GLAPIENTRY glListBase( GLuint base );
+
+
+/*
+ * Drawing Functions
+ */
+
+GLAPI void GLAPIENTRY glBegin( GLenum mode );
+
+GLAPI void GLAPIENTRY glEnd( void );
+
+
+GLAPI void GLAPIENTRY glVertex2d( GLdouble x, GLdouble y );
+GLAPI void GLAPIENTRY glVertex2f( GLfloat x, GLfloat y );
+GLAPI void GLAPIENTRY glVertex2i( GLint x, GLint y );
+GLAPI void GLAPIENTRY glVertex2s( GLshort x, GLshort y );
+
+GLAPI void GLAPIENTRY glVertex3d( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glVertex3f( GLfloat x, GLfloat y, GLfloat z );
+GLAPI void GLAPIENTRY glVertex3i( GLint x, GLint y, GLint z );
+GLAPI void GLAPIENTRY glVertex3s( GLshort x, GLshort y, GLshort z );
+
+GLAPI void GLAPIENTRY glVertex4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
+GLAPI void GLAPIENTRY glVertex4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+GLAPI void GLAPIENTRY glVertex4i( GLint x, GLint y, GLint z, GLint w );
+GLAPI void GLAPIENTRY glVertex4s( GLshort x, GLshort y, GLshort z, GLshort w );
+
+GLAPI void GLAPIENTRY glVertex2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex2iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glVertex3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex3iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glVertex4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glVertex4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glVertex4iv( const GLint *v );
+GLAPI void GLAPIENTRY glVertex4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glNormal3b( GLbyte nx, GLbyte ny, GLbyte nz );
+GLAPI void GLAPIENTRY glNormal3d( GLdouble nx, GLdouble ny, GLdouble nz );
+GLAPI void GLAPIENTRY glNormal3f( GLfloat nx, GLfloat ny, GLfloat nz );
+GLAPI void GLAPIENTRY glNormal3i( GLint nx, GLint ny, GLint nz );
+GLAPI void GLAPIENTRY glNormal3s( GLshort nx, GLshort ny, GLshort nz );
+
+GLAPI void GLAPIENTRY glNormal3bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glNormal3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glNormal3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glNormal3iv( const GLint *v );
+GLAPI void GLAPIENTRY glNormal3sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glIndexd( GLdouble c );
+GLAPI void GLAPIENTRY glIndexf( GLfloat c );
+GLAPI void GLAPIENTRY glIndexi( GLint c );
+GLAPI void GLAPIENTRY glIndexs( GLshort c );
+GLAPI void GLAPIENTRY glIndexub( GLubyte c ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glIndexdv( const GLdouble *c );
+GLAPI void GLAPIENTRY glIndexfv( const GLfloat *c );
+GLAPI void GLAPIENTRY glIndexiv( const GLint *c );
+GLAPI void GLAPIENTRY glIndexsv( const GLshort *c );
+GLAPI void GLAPIENTRY glIndexubv( const GLubyte *c ); /* 1.1 */
+
+GLAPI void GLAPIENTRY glColor3b( GLbyte red, GLbyte green, GLbyte blue );
+GLAPI void GLAPIENTRY glColor3d( GLdouble red, GLdouble green, GLdouble blue );
+GLAPI void GLAPIENTRY glColor3f( GLfloat red, GLfloat green, GLfloat blue );
+GLAPI void GLAPIENTRY glColor3i( GLint red, GLint green, GLint blue );
+GLAPI void GLAPIENTRY glColor3s( GLshort red, GLshort green, GLshort blue );
+GLAPI void GLAPIENTRY glColor3ub( GLubyte red, GLubyte green, GLubyte blue );
+GLAPI void GLAPIENTRY glColor3ui( GLuint red, GLuint green, GLuint blue );
+GLAPI void GLAPIENTRY glColor3us( GLushort red, GLushort green, GLushort blue );
+
+GLAPI void GLAPIENTRY glColor4b( GLbyte red, GLbyte green,
+ GLbyte blue, GLbyte alpha );
+GLAPI void GLAPIENTRY glColor4d( GLdouble red, GLdouble green,
+ GLdouble blue, GLdouble alpha );
+GLAPI void GLAPIENTRY glColor4f( GLfloat red, GLfloat green,
+ GLfloat blue, GLfloat alpha );
+GLAPI void GLAPIENTRY glColor4i( GLint red, GLint green,
+ GLint blue, GLint alpha );
+GLAPI void GLAPIENTRY glColor4s( GLshort red, GLshort green,
+ GLshort blue, GLshort alpha );
+GLAPI void GLAPIENTRY glColor4ub( GLubyte red, GLubyte green,
+ GLubyte blue, GLubyte alpha );
+GLAPI void GLAPIENTRY glColor4ui( GLuint red, GLuint green,
+ GLuint blue, GLuint alpha );
+GLAPI void GLAPIENTRY glColor4us( GLushort red, GLushort green,
+ GLushort blue, GLushort alpha );
+
+
+GLAPI void GLAPIENTRY glColor3bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glColor3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glColor3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glColor3iv( const GLint *v );
+GLAPI void GLAPIENTRY glColor3sv( const GLshort *v );
+GLAPI void GLAPIENTRY glColor3ubv( const GLubyte *v );
+GLAPI void GLAPIENTRY glColor3uiv( const GLuint *v );
+GLAPI void GLAPIENTRY glColor3usv( const GLushort *v );
+
+GLAPI void GLAPIENTRY glColor4bv( const GLbyte *v );
+GLAPI void GLAPIENTRY glColor4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glColor4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glColor4iv( const GLint *v );
+GLAPI void GLAPIENTRY glColor4sv( const GLshort *v );
+GLAPI void GLAPIENTRY glColor4ubv( const GLubyte *v );
+GLAPI void GLAPIENTRY glColor4uiv( const GLuint *v );
+GLAPI void GLAPIENTRY glColor4usv( const GLushort *v );
+
+
+GLAPI void GLAPIENTRY glTexCoord1d( GLdouble s );
+GLAPI void GLAPIENTRY glTexCoord1f( GLfloat s );
+GLAPI void GLAPIENTRY glTexCoord1i( GLint s );
+GLAPI void GLAPIENTRY glTexCoord1s( GLshort s );
+
+GLAPI void GLAPIENTRY glTexCoord2d( GLdouble s, GLdouble t );
+GLAPI void GLAPIENTRY glTexCoord2f( GLfloat s, GLfloat t );
+GLAPI void GLAPIENTRY glTexCoord2i( GLint s, GLint t );
+GLAPI void GLAPIENTRY glTexCoord2s( GLshort s, GLshort t );
+
+GLAPI void GLAPIENTRY glTexCoord3d( GLdouble s, GLdouble t, GLdouble r );
+GLAPI void GLAPIENTRY glTexCoord3f( GLfloat s, GLfloat t, GLfloat r );
+GLAPI void GLAPIENTRY glTexCoord3i( GLint s, GLint t, GLint r );
+GLAPI void GLAPIENTRY glTexCoord3s( GLshort s, GLshort t, GLshort r );
+
+GLAPI void GLAPIENTRY glTexCoord4d( GLdouble s, GLdouble t, GLdouble r, GLdouble q );
+GLAPI void GLAPIENTRY glTexCoord4f( GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+GLAPI void GLAPIENTRY glTexCoord4i( GLint s, GLint t, GLint r, GLint q );
+GLAPI void GLAPIENTRY glTexCoord4s( GLshort s, GLshort t, GLshort r, GLshort q );
+
+GLAPI void GLAPIENTRY glTexCoord1dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord1fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord1iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord1sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord2iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord3iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glTexCoord4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glTexCoord4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glTexCoord4iv( const GLint *v );
+GLAPI void GLAPIENTRY glTexCoord4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glRasterPos2d( GLdouble x, GLdouble y );
+GLAPI void GLAPIENTRY glRasterPos2f( GLfloat x, GLfloat y );
+GLAPI void GLAPIENTRY glRasterPos2i( GLint x, GLint y );
+GLAPI void GLAPIENTRY glRasterPos2s( GLshort x, GLshort y );
+
+GLAPI void GLAPIENTRY glRasterPos3d( GLdouble x, GLdouble y, GLdouble z );
+GLAPI void GLAPIENTRY glRasterPos3f( GLfloat x, GLfloat y, GLfloat z );
+GLAPI void GLAPIENTRY glRasterPos3i( GLint x, GLint y, GLint z );
+GLAPI void GLAPIENTRY glRasterPos3s( GLshort x, GLshort y, GLshort z );
+
+GLAPI void GLAPIENTRY glRasterPos4d( GLdouble x, GLdouble y, GLdouble z, GLdouble w );
+GLAPI void GLAPIENTRY glRasterPos4f( GLfloat x, GLfloat y, GLfloat z, GLfloat w );
+GLAPI void GLAPIENTRY glRasterPos4i( GLint x, GLint y, GLint z, GLint w );
+GLAPI void GLAPIENTRY glRasterPos4s( GLshort x, GLshort y, GLshort z, GLshort w );
+
+GLAPI void GLAPIENTRY glRasterPos2dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos2fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos2iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos2sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glRasterPos3dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos3fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos3iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos3sv( const GLshort *v );
+
+GLAPI void GLAPIENTRY glRasterPos4dv( const GLdouble *v );
+GLAPI void GLAPIENTRY glRasterPos4fv( const GLfloat *v );
+GLAPI void GLAPIENTRY glRasterPos4iv( const GLint *v );
+GLAPI void GLAPIENTRY glRasterPos4sv( const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glRectd( GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2 );
+GLAPI void GLAPIENTRY glRectf( GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2 );
+GLAPI void GLAPIENTRY glRecti( GLint x1, GLint y1, GLint x2, GLint y2 );
+GLAPI void GLAPIENTRY glRects( GLshort x1, GLshort y1, GLshort x2, GLshort y2 );
+
+
+GLAPI void GLAPIENTRY glRectdv( const GLdouble *v1, const GLdouble *v2 );
+GLAPI void GLAPIENTRY glRectfv( const GLfloat *v1, const GLfloat *v2 );
+GLAPI void GLAPIENTRY glRectiv( const GLint *v1, const GLint *v2 );
+GLAPI void GLAPIENTRY glRectsv( const GLshort *v1, const GLshort *v2 );
+
+
+/*
+ * Vertex Arrays (1.1)
+ */
+
+GLAPI void GLAPIENTRY glVertexPointer( GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glNormalPointer( GLenum type, GLsizei stride,
+ const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glColorPointer( GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glIndexPointer( GLenum type, GLsizei stride,
+ const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glTexCoordPointer( GLint size, GLenum type,
+ GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glEdgeFlagPointer( GLsizei stride, const GLvoid *ptr );
+
+GLAPI void GLAPIENTRY glGetPointerv( GLenum pname, GLvoid **params );
+
+GLAPI void GLAPIENTRY glArrayElement( GLint i );
+
+GLAPI void GLAPIENTRY glDrawArrays( GLenum mode, GLint first, GLsizei count );
+
+GLAPI void GLAPIENTRY glDrawElements( GLenum mode, GLsizei count,
+ GLenum type, const GLvoid *indices );
+
+GLAPI void GLAPIENTRY glInterleavedArrays( GLenum format, GLsizei stride,
+ const GLvoid *pointer );
+
+/*
+ * Lighting
+ */
+
+GLAPI void GLAPIENTRY glShadeModel( GLenum mode );
+
+GLAPI void GLAPIENTRY glLightf( GLenum light, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glLighti( GLenum light, GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glLightfv( GLenum light, GLenum pname,
+ const GLfloat *params );
+GLAPI void GLAPIENTRY glLightiv( GLenum light, GLenum pname,
+ const GLint *params );
+
+GLAPI void GLAPIENTRY glGetLightfv( GLenum light, GLenum pname,
+ GLfloat *params );
+GLAPI void GLAPIENTRY glGetLightiv( GLenum light, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glLightModelf( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glLightModeli( GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glLightModelfv( GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glLightModeliv( GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glMaterialf( GLenum face, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glMateriali( GLenum face, GLenum pname, GLint param );
+GLAPI void GLAPIENTRY glMaterialfv( GLenum face, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glMaterialiv( GLenum face, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetMaterialfv( GLenum face, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetMaterialiv( GLenum face, GLenum pname, GLint *params );
+
+GLAPI void GLAPIENTRY glColorMaterial( GLenum face, GLenum mode );
+
+
+/*
+ * Raster functions
+ */
+
+GLAPI void GLAPIENTRY glPixelZoom( GLfloat xfactor, GLfloat yfactor );
+
+GLAPI void GLAPIENTRY glPixelStoref( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glPixelStorei( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glPixelTransferf( GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glPixelTransferi( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glPixelMapfv( GLenum map, GLsizei mapsize,
+ const GLfloat *values );
+GLAPI void GLAPIENTRY glPixelMapuiv( GLenum map, GLsizei mapsize,
+ const GLuint *values );
+GLAPI void GLAPIENTRY glPixelMapusv( GLenum map, GLsizei mapsize,
+ const GLushort *values );
+
+GLAPI void GLAPIENTRY glGetPixelMapfv( GLenum map, GLfloat *values );
+GLAPI void GLAPIENTRY glGetPixelMapuiv( GLenum map, GLuint *values );
+GLAPI void GLAPIENTRY glGetPixelMapusv( GLenum map, GLushort *values );
+
+GLAPI void GLAPIENTRY glBitmap( GLsizei width, GLsizei height,
+ GLfloat xorig, GLfloat yorig,
+ GLfloat xmove, GLfloat ymove,
+ const GLubyte *bitmap );
+
+GLAPI void GLAPIENTRY glReadPixels( GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glDrawPixels( GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glCopyPixels( GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLenum type );
+
+/*
+ * Stenciling
+ */
+
+GLAPI void GLAPIENTRY glStencilFunc( GLenum func, GLint ref, GLuint mask );
+
+GLAPI void GLAPIENTRY glStencilMask( GLuint mask );
+
+GLAPI void GLAPIENTRY glStencilOp( GLenum fail, GLenum zfail, GLenum zpass );
+
+GLAPI void GLAPIENTRY glClearStencil( GLint s );
+
+
+
+/*
+ * Texture mapping
+ */
+
+GLAPI void GLAPIENTRY glTexGend( GLenum coord, GLenum pname, GLdouble param );
+GLAPI void GLAPIENTRY glTexGenf( GLenum coord, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexGeni( GLenum coord, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexGendv( GLenum coord, GLenum pname, const GLdouble *params );
+GLAPI void GLAPIENTRY glTexGenfv( GLenum coord, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glTexGeniv( GLenum coord, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexGendv( GLenum coord, GLenum pname, GLdouble *params );
+GLAPI void GLAPIENTRY glGetTexGenfv( GLenum coord, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexGeniv( GLenum coord, GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexEnvf( GLenum target, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexEnvi( GLenum target, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexEnvfv( GLenum target, GLenum pname, const GLfloat *params );
+GLAPI void GLAPIENTRY glTexEnviv( GLenum target, GLenum pname, const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexEnvfv( GLenum target, GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexEnviv( GLenum target, GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexParameterf( GLenum target, GLenum pname, GLfloat param );
+GLAPI void GLAPIENTRY glTexParameteri( GLenum target, GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glTexParameterfv( GLenum target, GLenum pname,
+ const GLfloat *params );
+GLAPI void GLAPIENTRY glTexParameteriv( GLenum target, GLenum pname,
+ const GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexParameterfv( GLenum target,
+ GLenum pname, GLfloat *params);
+GLAPI void GLAPIENTRY glGetTexParameteriv( GLenum target,
+ GLenum pname, GLint *params );
+
+GLAPI void GLAPIENTRY glGetTexLevelParameterfv( GLenum target, GLint level,
+ GLenum pname, GLfloat *params );
+GLAPI void GLAPIENTRY glGetTexLevelParameteriv( GLenum target, GLint level,
+ GLenum pname, GLint *params );
+
+
+GLAPI void GLAPIENTRY glTexImage1D( GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glTexImage2D( GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLsizei height,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glGetTexImage( GLenum target, GLint level,
+ GLenum format, GLenum type,
+ GLvoid *pixels );
+
+
+/* 1.1 functions */
+
+GLAPI void GLAPIENTRY glGenTextures( GLsizei n, GLuint *textures );
+
+GLAPI void GLAPIENTRY glDeleteTextures( GLsizei n, const GLuint *textures);
+
+GLAPI void GLAPIENTRY glBindTexture( GLenum target, GLuint texture );
+
+GLAPI void GLAPIENTRY glPrioritizeTextures( GLsizei n,
+ const GLuint *textures,
+ const GLclampf *priorities );
+
+GLAPI GLboolean GLAPIENTRY glAreTexturesResident( GLsizei n,
+ const GLuint *textures,
+ GLboolean *residences );
+
+GLAPI GLboolean GLAPIENTRY glIsTexture( GLuint texture );
+
+
+GLAPI void GLAPIENTRY glTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset,
+ GLsizei width, GLenum format,
+ GLenum type, const GLvoid *pixels );
+
+
+GLAPI void GLAPIENTRY glTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLsizei width, GLsizei height,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+
+GLAPI void GLAPIENTRY glCopyTexImage1D( GLenum target, GLint level,
+ GLenum internalformat,
+ GLint x, GLint y,
+ GLsizei width, GLint border );
+
+
+GLAPI void GLAPIENTRY glCopyTexImage2D( GLenum target, GLint level,
+ GLenum internalformat,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height,
+ GLint border );
+
+
+GLAPI void GLAPIENTRY glCopyTexSubImage1D( GLenum target, GLint level,
+ GLint xoffset, GLint x, GLint y,
+ GLsizei width );
+
+
+GLAPI void GLAPIENTRY glCopyTexSubImage2D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint x, GLint y,
+ GLsizei width, GLsizei height );
+
+
+/*
+ * Evaluators
+ */
+
+GLAPI void GLAPIENTRY glMap1d( GLenum target, GLdouble u1, GLdouble u2,
+ GLint stride,
+ GLint order, const GLdouble *points );
+GLAPI void GLAPIENTRY glMap1f( GLenum target, GLfloat u1, GLfloat u2,
+ GLint stride,
+ GLint order, const GLfloat *points );
+
+GLAPI void GLAPIENTRY glMap2d( GLenum target,
+ GLdouble u1, GLdouble u2, GLint ustride, GLint uorder,
+ GLdouble v1, GLdouble v2, GLint vstride, GLint vorder,
+ const GLdouble *points );
+GLAPI void GLAPIENTRY glMap2f( GLenum target,
+ GLfloat u1, GLfloat u2, GLint ustride, GLint uorder,
+ GLfloat v1, GLfloat v2, GLint vstride, GLint vorder,
+ const GLfloat *points );
+
+GLAPI void GLAPIENTRY glGetMapdv( GLenum target, GLenum query, GLdouble *v );
+GLAPI void GLAPIENTRY glGetMapfv( GLenum target, GLenum query, GLfloat *v );
+GLAPI void GLAPIENTRY glGetMapiv( GLenum target, GLenum query, GLint *v );
+
+GLAPI void GLAPIENTRY glEvalCoord1d( GLdouble u );
+GLAPI void GLAPIENTRY glEvalCoord1f( GLfloat u );
+
+GLAPI void GLAPIENTRY glEvalCoord1dv( const GLdouble *u );
+GLAPI void GLAPIENTRY glEvalCoord1fv( const GLfloat *u );
+
+GLAPI void GLAPIENTRY glEvalCoord2d( GLdouble u, GLdouble v );
+GLAPI void GLAPIENTRY glEvalCoord2f( GLfloat u, GLfloat v );
+
+GLAPI void GLAPIENTRY glEvalCoord2dv( const GLdouble *u );
+GLAPI void GLAPIENTRY glEvalCoord2fv( const GLfloat *u );
+
+GLAPI void GLAPIENTRY glMapGrid1d( GLint un, GLdouble u1, GLdouble u2 );
+GLAPI void GLAPIENTRY glMapGrid1f( GLint un, GLfloat u1, GLfloat u2 );
+
+GLAPI void GLAPIENTRY glMapGrid2d( GLint un, GLdouble u1, GLdouble u2,
+ GLint vn, GLdouble v1, GLdouble v2 );
+GLAPI void GLAPIENTRY glMapGrid2f( GLint un, GLfloat u1, GLfloat u2,
+ GLint vn, GLfloat v1, GLfloat v2 );
+
+GLAPI void GLAPIENTRY glEvalPoint1( GLint i );
+
+GLAPI void GLAPIENTRY glEvalPoint2( GLint i, GLint j );
+
+GLAPI void GLAPIENTRY glEvalMesh1( GLenum mode, GLint i1, GLint i2 );
+
+GLAPI void GLAPIENTRY glEvalMesh2( GLenum mode, GLint i1, GLint i2, GLint j1, GLint j2 );
+
+
+/*
+ * Fog
+ */
+
+GLAPI void GLAPIENTRY glFogf( GLenum pname, GLfloat param );
+
+GLAPI void GLAPIENTRY glFogi( GLenum pname, GLint param );
+
+GLAPI void GLAPIENTRY glFogfv( GLenum pname, const GLfloat *params );
+
+GLAPI void GLAPIENTRY glFogiv( GLenum pname, const GLint *params );
+
+
+/*
+ * Selection and Feedback
+ */
+
+GLAPI void GLAPIENTRY glFeedbackBuffer( GLsizei size, GLenum type, GLfloat *buffer );
+
+GLAPI void GLAPIENTRY glPassThrough( GLfloat token );
+
+GLAPI void GLAPIENTRY glSelectBuffer( GLsizei size, GLuint *buffer );
+
+GLAPI void GLAPIENTRY glInitNames( void );
+
+GLAPI void GLAPIENTRY glLoadName( GLuint name );
+
+GLAPI void GLAPIENTRY glPushName( GLuint name );
+
+GLAPI void GLAPIENTRY glPopName( void );
+
+
+
+/*
+ * OpenGL 1.2
+ */
+
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
+#define GL_SINGLE_COLOR 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_TEXTURE_BINDING_3D 0x806A
+
+GLAPI void GLAPIENTRY glDrawRangeElements( GLenum mode, GLuint start,
+ GLuint end, GLsizei count, GLenum type, const GLvoid *indices );
+
+GLAPI void GLAPIENTRY glTexImage3D( GLenum target, GLint level,
+ GLint internalFormat,
+ GLsizei width, GLsizei height,
+ GLsizei depth, GLint border,
+ GLenum format, GLenum type,
+ const GLvoid *pixels );
+
+GLAPI void GLAPIENTRY glTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLsizei width,
+ GLsizei height, GLsizei depth,
+ GLenum format,
+ GLenum type, const GLvoid *pixels);
+
+GLAPI void GLAPIENTRY glCopyTexSubImage3D( GLenum target, GLint level,
+ GLint xoffset, GLint yoffset,
+ GLint zoffset, GLint x,
+ GLint y, GLsizei width,
+ GLsizei height );
+
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+
+
+/*
+ * GL_ARB_imaging
+ */
+
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_COLOR_TABLE 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
+#define GL_PROXY_COLOR_TABLE 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE 0x80D6
+#define GL_COLOR_TABLE_BIAS 0x80D7
+#define GL_COLOR_TABLE_FORMAT 0x80D8
+#define GL_COLOR_TABLE_WIDTH 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
+#define GL_CONVOLUTION_1D 0x8010
+#define GL_CONVOLUTION_2D 0x8011
+#define GL_SEPARABLE_2D 0x8012
+#define GL_CONVOLUTION_BORDER_MODE 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS 0x8015
+#define GL_REDUCE 0x8016
+#define GL_CONVOLUTION_FORMAT 0x8017
+#define GL_CONVOLUTION_WIDTH 0x8018
+#define GL_CONVOLUTION_HEIGHT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
+#define GL_CONSTANT_BORDER 0x8151
+#define GL_REPLICATE_BORDER 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR 0x8154
+#define GL_COLOR_MATRIX 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
+#define GL_HISTOGRAM 0x8024
+#define GL_PROXY_HISTOGRAM 0x8025
+#define GL_HISTOGRAM_WIDTH 0x8026
+#define GL_HISTOGRAM_FORMAT 0x8027
+#define GL_HISTOGRAM_RED_SIZE 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
+#define GL_HISTOGRAM_SINK 0x802D
+#define GL_MINMAX 0x802E
+#define GL_MINMAX_FORMAT 0x802F
+#define GL_MINMAX_SINK 0x8030
+#define GL_TABLE_TOO_LARGE 0x8031
+#define GL_BLEND_EQUATION 0x8009
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_FUNC_ADD 0x8006
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_BLEND_COLOR 0x8005
+
+
+GLAPI void GLAPIENTRY glColorTable( GLenum target, GLenum internalformat,
+ GLsizei width, GLenum format,
+ GLenum type, const GLvoid *table );
+
+GLAPI void GLAPIENTRY glColorSubTable( GLenum target,
+ GLsizei start, GLsizei count,
+ GLenum format, GLenum type,
+ const GLvoid *data );
+
+GLAPI void GLAPIENTRY glColorTableParameteriv(GLenum target, GLenum pname,
+ const GLint *params);
+
+GLAPI void GLAPIENTRY glColorTableParameterfv(GLenum target, GLenum pname,
+ const GLfloat *params);
+
+GLAPI void GLAPIENTRY glCopyColorSubTable( GLenum target, GLsizei start,
+ GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glCopyColorTable( GLenum target, GLenum internalformat,
+ GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glGetColorTable( GLenum target, GLenum format,
+ GLenum type, GLvoid *table );
+
+GLAPI void GLAPIENTRY glGetColorTableParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetColorTableParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glBlendEquation( GLenum mode );
+
+GLAPI void GLAPIENTRY glBlendColor( GLclampf red, GLclampf green,
+ GLclampf blue, GLclampf alpha );
+
+GLAPI void GLAPIENTRY glHistogram( GLenum target, GLsizei width,
+ GLenum internalformat, GLboolean sink );
+
+GLAPI void GLAPIENTRY glResetHistogram( GLenum target );
+
+GLAPI void GLAPIENTRY glGetHistogram( GLenum target, GLboolean reset,
+ GLenum format, GLenum type,
+ GLvoid *values );
+
+GLAPI void GLAPIENTRY glGetHistogramParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetHistogramParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glMinmax( GLenum target, GLenum internalformat,
+ GLboolean sink );
+
+GLAPI void GLAPIENTRY glResetMinmax( GLenum target );
+
+GLAPI void GLAPIENTRY glGetMinmax( GLenum target, GLboolean reset,
+ GLenum format, GLenum types,
+ GLvoid *values );
+
+GLAPI void GLAPIENTRY glGetMinmaxParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetMinmaxParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glConvolutionFilter1D( GLenum target,
+ GLenum internalformat, GLsizei width, GLenum format, GLenum type,
+ const GLvoid *image );
+
+GLAPI void GLAPIENTRY glConvolutionFilter2D( GLenum target,
+ GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *image );
+
+GLAPI void GLAPIENTRY glConvolutionParameterf( GLenum target, GLenum pname,
+ GLfloat params );
+
+GLAPI void GLAPIENTRY glConvolutionParameterfv( GLenum target, GLenum pname,
+ const GLfloat *params );
+
+GLAPI void GLAPIENTRY glConvolutionParameteri( GLenum target, GLenum pname,
+ GLint params );
+
+GLAPI void GLAPIENTRY glConvolutionParameteriv( GLenum target, GLenum pname,
+ const GLint *params );
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter1D( GLenum target,
+ GLenum internalformat, GLint x, GLint y, GLsizei width );
+
+GLAPI void GLAPIENTRY glCopyConvolutionFilter2D( GLenum target,
+ GLenum internalformat, GLint x, GLint y, GLsizei width,
+ GLsizei height);
+
+GLAPI void GLAPIENTRY glGetConvolutionFilter( GLenum target, GLenum format,
+ GLenum type, GLvoid *image );
+
+GLAPI void GLAPIENTRY glGetConvolutionParameterfv( GLenum target, GLenum pname,
+ GLfloat *params );
+
+GLAPI void GLAPIENTRY glGetConvolutionParameteriv( GLenum target, GLenum pname,
+ GLint *params );
+
+GLAPI void GLAPIENTRY glSeparableFilter2D( GLenum target,
+ GLenum internalformat, GLsizei width, GLsizei height, GLenum format,
+ GLenum type, const GLvoid *row, const GLvoid *column );
+
+GLAPI void GLAPIENTRY glGetSeparableFilter( GLenum target, GLenum format,
+ GLenum type, GLvoid *row, GLvoid *column, GLvoid *span );
+
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
+
+
+
+/*
+ * OpenGL 1.3
+ */
+
+/* multitexture */
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
+#define GL_MAX_TEXTURE_UNITS 0x84E2
+/* texture_cube_map */
+#define GL_NORMAL_MAP 0x8511
+#define GL_REFLECTION_MAP 0x8512
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+/* texture_compression */
+#define GL_COMPRESSED_ALPHA 0x84E9
+#define GL_COMPRESSED_LUMINANCE 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
+#define GL_COMPRESSED_INTENSITY 0x84EC
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+/* multisample */
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_MULTISAMPLE_BIT 0x20000000
+/* transpose_matrix */
+#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
+/* texture_env_combine */
+#define GL_COMBINE 0x8570
+#define GL_COMBINE_RGB 0x8571
+#define GL_COMBINE_ALPHA 0x8572
+#define GL_SOURCE0_RGB 0x8580
+#define GL_SOURCE1_RGB 0x8581
+#define GL_SOURCE2_RGB 0x8582
+#define GL_SOURCE0_ALPHA 0x8588
+#define GL_SOURCE1_ALPHA 0x8589
+#define GL_SOURCE2_ALPHA 0x858A
+#define GL_OPERAND0_RGB 0x8590
+#define GL_OPERAND1_RGB 0x8591
+#define GL_OPERAND2_RGB 0x8592
+#define GL_OPERAND0_ALPHA 0x8598
+#define GL_OPERAND1_ALPHA 0x8599
+#define GL_OPERAND2_ALPHA 0x859A
+#define GL_RGB_SCALE 0x8573
+#define GL_ADD_SIGNED 0x8574
+#define GL_INTERPOLATE 0x8575
+#define GL_SUBTRACT 0x84E7
+#define GL_CONSTANT 0x8576
+#define GL_PRIMARY_COLOR 0x8577
+#define GL_PREVIOUS 0x8578
+/* texture_env_dot3 */
+#define GL_DOT3_RGB 0x86AE
+#define GL_DOT3_RGBA 0x86AF
+/* texture_border_clamp */
+#define GL_CLAMP_TO_BORDER 0x812D
+
+GLAPI void GLAPIENTRY glActiveTexture( GLenum texture );
+
+GLAPI void GLAPIENTRY glClientActiveTexture( GLenum texture );
+
+GLAPI void GLAPIENTRY glCompressedTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage1D( GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage2D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glCompressedTexSubImage3D( GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data );
+
+GLAPI void GLAPIENTRY glGetCompressedTexImage( GLenum target, GLint lod, GLvoid *img );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1d( GLenum target, GLdouble s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1f( GLenum target, GLfloat s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1i( GLenum target, GLint s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1s( GLenum target, GLshort s );
+
+GLAPI void GLAPIENTRY glMultiTexCoord1sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2d( GLenum target, GLdouble s, GLdouble t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2f( GLenum target, GLfloat s, GLfloat t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2i( GLenum target, GLint s, GLint t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2s( GLenum target, GLshort s, GLshort t );
+
+GLAPI void GLAPIENTRY glMultiTexCoord2sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3d( GLenum target, GLdouble s, GLdouble t, GLdouble r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3f( GLenum target, GLfloat s, GLfloat t, GLfloat r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3i( GLenum target, GLint s, GLint t, GLint r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3s( GLenum target, GLshort s, GLshort t, GLshort r );
+
+GLAPI void GLAPIENTRY glMultiTexCoord3sv( GLenum target, const GLshort *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4d( GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4dv( GLenum target, const GLdouble *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4f( GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4fv( GLenum target, const GLfloat *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4i( GLenum target, GLint s, GLint t, GLint r, GLint q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4iv( GLenum target, const GLint *v );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4s( GLenum target, GLshort s, GLshort t, GLshort r, GLshort q );
+
+GLAPI void GLAPIENTRY glMultiTexCoord4sv( GLenum target, const GLshort *v );
+
+
+GLAPI void GLAPIENTRY glLoadTransposeMatrixd( const GLdouble m[16] );
+
+GLAPI void GLAPIENTRY glLoadTransposeMatrixf( const GLfloat m[16] );
+
+GLAPI void GLAPIENTRY glMultTransposeMatrixd( const GLdouble m[16] );
+
+GLAPI void GLAPIENTRY glMultTransposeMatrixf( const GLfloat m[16] );
+
+GLAPI void GLAPIENTRY glSampleCoverage( GLclampf value, GLboolean invert );
+
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, void *img);
+
+
+/*
+ * GL_ARB_multitexture (ARB extension 1 and OpenGL 1.2.1)
+ */
+#ifndef GL_ARB_multitexture
+#define GL_ARB_multitexture 1
+
+#define GL_TEXTURE0_ARB 0x84C0
+#define GL_TEXTURE1_ARB 0x84C1
+#define GL_TEXTURE2_ARB 0x84C2
+#define GL_TEXTURE3_ARB 0x84C3
+#define GL_TEXTURE4_ARB 0x84C4
+#define GL_TEXTURE5_ARB 0x84C5
+#define GL_TEXTURE6_ARB 0x84C6
+#define GL_TEXTURE7_ARB 0x84C7
+#define GL_TEXTURE8_ARB 0x84C8
+#define GL_TEXTURE9_ARB 0x84C9
+#define GL_TEXTURE10_ARB 0x84CA
+#define GL_TEXTURE11_ARB 0x84CB
+#define GL_TEXTURE12_ARB 0x84CC
+#define GL_TEXTURE13_ARB 0x84CD
+#define GL_TEXTURE14_ARB 0x84CE
+#define GL_TEXTURE15_ARB 0x84CF
+#define GL_TEXTURE16_ARB 0x84D0
+#define GL_TEXTURE17_ARB 0x84D1
+#define GL_TEXTURE18_ARB 0x84D2
+#define GL_TEXTURE19_ARB 0x84D3
+#define GL_TEXTURE20_ARB 0x84D4
+#define GL_TEXTURE21_ARB 0x84D5
+#define GL_TEXTURE22_ARB 0x84D6
+#define GL_TEXTURE23_ARB 0x84D7
+#define GL_TEXTURE24_ARB 0x84D8
+#define GL_TEXTURE25_ARB 0x84D9
+#define GL_TEXTURE26_ARB 0x84DA
+#define GL_TEXTURE27_ARB 0x84DB
+#define GL_TEXTURE28_ARB 0x84DC
+#define GL_TEXTURE29_ARB 0x84DD
+#define GL_TEXTURE30_ARB 0x84DE
+#define GL_TEXTURE31_ARB 0x84DF
+#define GL_ACTIVE_TEXTURE_ARB 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
+#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
+
+GLAPI void GLAPIENTRY glActiveTextureARB(GLenum texture);
+GLAPI void GLAPIENTRY glClientActiveTextureARB(GLenum texture);
+GLAPI void GLAPIENTRY glMultiTexCoord1dARB(GLenum target, GLdouble s);
+GLAPI void GLAPIENTRY glMultiTexCoord1dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord1fARB(GLenum target, GLfloat s);
+GLAPI void GLAPIENTRY glMultiTexCoord1fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord1iARB(GLenum target, GLint s);
+GLAPI void GLAPIENTRY glMultiTexCoord1ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord1sARB(GLenum target, GLshort s);
+GLAPI void GLAPIENTRY glMultiTexCoord1svARB(GLenum target, const GLshort *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2dARB(GLenum target, GLdouble s, GLdouble t);
+GLAPI void GLAPIENTRY glMultiTexCoord2dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2fARB(GLenum target, GLfloat s, GLfloat t);
+GLAPI void GLAPIENTRY glMultiTexCoord2fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2iARB(GLenum target, GLint s, GLint t);
+GLAPI void GLAPIENTRY glMultiTexCoord2ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord2sARB(GLenum target, GLshort s, GLshort t);
+GLAPI void GLAPIENTRY glMultiTexCoord2svARB(GLenum target, const GLshort *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r);
+GLAPI void GLAPIENTRY glMultiTexCoord3dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r);
+GLAPI void GLAPIENTRY glMultiTexCoord3fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3iARB(GLenum target, GLint s, GLint t, GLint r);
+GLAPI void GLAPIENTRY glMultiTexCoord3ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord3sARB(GLenum target, GLshort s, GLshort t, GLshort r);
+GLAPI void GLAPIENTRY glMultiTexCoord3svARB(GLenum target, const GLshort *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4dARB(GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+GLAPI void GLAPIENTRY glMultiTexCoord4dvARB(GLenum target, const GLdouble *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4fARB(GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+GLAPI void GLAPIENTRY glMultiTexCoord4fvARB(GLenum target, const GLfloat *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4iARB(GLenum target, GLint s, GLint t, GLint r, GLint q);
+GLAPI void GLAPIENTRY glMultiTexCoord4ivARB(GLenum target, const GLint *v);
+GLAPI void GLAPIENTRY glMultiTexCoord4sARB(GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+GLAPI void GLAPIENTRY glMultiTexCoord4svARB(GLenum target, const GLshort *v);
+
+typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+
+#endif /* GL_ARB_multitexture */
+
+
+
+/*
+ * Define this token if you want "old-style" header file behaviour (extensions
+ * defined in gl.h). Otherwise, extensions will be included from glext.h.
+ */
+#if defined(GL_GLEXT_LEGACY)
+
+/* All extensions that used to be here are now found in glext.h */
+
+#else /* GL_GLEXT_LEGACY */
+
+#include "glext.h"
+
+#endif /* GL_GLEXT_LEGACY */
+
+
+
+/*
+ * ???. GL_MESA_trace
+ * XXX obsolete
+ */
+#ifndef GL_MESA_trace
+#define GL_MESA_trace 1
+
+#define GL_TRACE_ALL_BITS_MESA 0xFFFF
+#define GL_TRACE_OPERATIONS_BIT_MESA 0x0001
+#define GL_TRACE_PRIMITIVES_BIT_MESA 0x0002
+#define GL_TRACE_ARRAYS_BIT_MESA 0x0004
+#define GL_TRACE_TEXTURES_BIT_MESA 0x0008
+#define GL_TRACE_PIXELS_BIT_MESA 0x0010
+#define GL_TRACE_ERRORS_BIT_MESA 0x0020
+#define GL_TRACE_MASK_MESA 0x8755
+#define GL_TRACE_NAME_MESA 0x8756
+
+GLAPI void GLAPIENTRY glEnableTraceMESA( GLbitfield mask );
+GLAPI void GLAPIENTRY glDisableTraceMESA( GLbitfield mask );
+GLAPI void GLAPIENTRY glNewTraceMESA( GLbitfield mask, const GLubyte * traceName );
+GLAPI void GLAPIENTRY glEndTraceMESA( void );
+GLAPI void GLAPIENTRY glTraceAssertAttribMESA( GLbitfield attribMask );
+GLAPI void GLAPIENTRY glTraceCommentMESA( const GLubyte * comment );
+GLAPI void GLAPIENTRY glTraceTextureMESA( GLuint name, const GLubyte* comment );
+GLAPI void GLAPIENTRY glTraceListMESA( GLuint name, const GLubyte* comment );
+GLAPI void GLAPIENTRY glTracePointerMESA( GLvoid* pointer, const GLubyte* comment );
+GLAPI void GLAPIENTRY glTracePointerRangeMESA( const GLvoid* first, const GLvoid* last, const GLubyte* comment );
+
+#endif /* GL_MESA_trace */
+
+
+/*
+ * ???. GL_MESA_packed_depth_stencil
+ * XXX obsolete
+ */
+#ifndef GL_MESA_packed_depth_stencil
+#define GL_MESA_packed_depth_stencil 1
+
+#define GL_DEPTH_STENCIL_MESA 0x8750
+#define GL_UNSIGNED_INT_24_8_MESA 0x8751
+#define GL_UNSIGNED_INT_8_24_REV_MESA 0x8752
+#define GL_UNSIGNED_SHORT_15_1_MESA 0x8753
+#define GL_UNSIGNED_SHORT_1_15_REV_MESA 0x8754
+
+#endif /* GL_MESA_packed_depth_stencil */
+
+
+#ifndef GL_MESA_program_debug
+#define GL_MESA_program_debug 1
+
+#define GL_FRAGMENT_PROGRAM_POSITION_MESA 0x8bb0
+#define GL_FRAGMENT_PROGRAM_CALLBACK_MESA 0x8bb1
+#define GL_FRAGMENT_PROGRAM_CALLBACK_FUNC_MESA 0x8bb2
+#define GL_FRAGMENT_PROGRAM_CALLBACK_DATA_MESA 0x8bb3
+#define GL_VERTEX_PROGRAM_POSITION_MESA 0x8bb4
+#define GL_VERTEX_PROGRAM_CALLBACK_MESA 0x8bb5
+#define GL_VERTEX_PROGRAM_CALLBACK_FUNC_MESA 0x8bb6
+#define GL_VERTEX_PROGRAM_CALLBACK_DATA_MESA 0x8bb7
+
+typedef void (*GLprogramcallbackMESA)(GLenum target, GLvoid *data);
+
+GLAPI void GLAPIENTRY glProgramCallbackMESA(GLenum target, GLprogramcallbackMESA callback, GLvoid *data);
+
+GLAPI void GLAPIENTRY glGetProgramRegisterfvMESA(GLenum target, GLsizei len, const GLubyte *name, GLfloat *v);
+
+#endif /* GL_MESA_program_debug */
+
+
+#ifndef GL_ATI_blend_equation_separate
+#define GL_ATI_blend_equation_separate 1
+
+#define GL_ALPHA_BLEND_EQUATION_ATI 0x883D
+
+GLAPI void GLAPIENTRY glBlendEquationSeparateATI( GLenum modeRGB, GLenum modeA );
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEATIPROC) (GLenum modeRGB, GLenum modeA);
+
+#endif /* GL_ATI_blend_equation_separate */
+
+
+/**
+ ** NOTE!!!!! If you add new functions to this file, or update
+ ** glext.h be sure to regenerate the gl_mangle.h file. See comments
+ ** in that file for details.
+ **/
+
+
+
+/**********************************************************************
+ * Begin system-specific stuff
+ */
+#if defined(PRAGMA_EXPORT_SUPPORTED)
+#pragma export off
+#endif
+
+#if defined(macintosh) && PRAGMA_IMPORT_SUPPORTED
+#pragma import off
+#endif
+/*
+ * End system-specific stuff
+ **********************************************************************/
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __gl_h_ */
diff --git a/src/graphics/GL/glext.h b/src/graphics/GL/glext.h
new file mode 100644
index 0000000..b241429
--- /dev/null
+++ b/src/graphics/GL/glext.h
@@ -0,0 +1,8565 @@
+#ifndef __glext_h_
+#define __glext_h_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+** Copyright (c) 2007 The Khronos Group Inc.
+**
+** Permission is hereby granted, free of charge, to any person obtaining a
+** copy of this software and/or associated documentation files (the
+** "Materials"), to deal in the Materials without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Materials, and to
+** permit persons to whom the Materials are 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 Materials.
+**
+** THE MATERIALS ARE 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
+** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
+*/
+
+#if defined(_WIN32) && !defined(APIENTRY) && !defined(__CYGWIN__) && !defined(__SCITECH_SNAP__)
+#define WIN32_LEAN_AND_MEAN 1
+#include <windows.h>
+#endif
+
+#ifndef APIENTRY
+#define APIENTRY
+#endif
+#ifndef APIENTRYP
+#define APIENTRYP APIENTRY *
+#endif
+#ifndef GLAPI
+#define GLAPI extern
+#endif
+
+/*************************************************************/
+
+/* Header file version number, required by OpenGL ABI for Linux */
+/* glext.h last updated 2009/03/19 */
+/* Current version at http://www.opengl.org/registry/ */
+#define GL_GLEXT_VERSION 48
+
+#ifndef GL_VERSION_1_2
+#define GL_UNSIGNED_BYTE_3_3_2 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2 0x8036
+#define GL_RESCALE_NORMAL 0x803A
+#define GL_TEXTURE_BINDING_3D 0x806A
+#define GL_PACK_SKIP_IMAGES 0x806B
+#define GL_PACK_IMAGE_HEIGHT 0x806C
+#define GL_UNPACK_SKIP_IMAGES 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT 0x806E
+#define GL_TEXTURE_3D 0x806F
+#define GL_PROXY_TEXTURE_3D 0x8070
+#define GL_TEXTURE_DEPTH 0x8071
+#define GL_TEXTURE_WRAP_R 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE 0x8073
+#define GL_UNSIGNED_BYTE_2_3_3_REV 0x8362
+#define GL_UNSIGNED_SHORT_5_6_5 0x8363
+#define GL_UNSIGNED_SHORT_5_6_5_REV 0x8364
+#define GL_UNSIGNED_SHORT_4_4_4_4_REV 0x8365
+#define GL_UNSIGNED_SHORT_1_5_5_5_REV 0x8366
+#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
+#define GL_UNSIGNED_INT_2_10_10_10_REV 0x8368
+#define GL_BGR 0x80E0
+#define GL_BGRA 0x80E1
+#define GL_MAX_ELEMENTS_VERTICES 0x80E8
+#define GL_MAX_ELEMENTS_INDICES 0x80E9
+#define GL_CLAMP_TO_EDGE 0x812F
+#define GL_TEXTURE_MIN_LOD 0x813A
+#define GL_TEXTURE_MAX_LOD 0x813B
+#define GL_TEXTURE_BASE_LEVEL 0x813C
+#define GL_TEXTURE_MAX_LEVEL 0x813D
+#define GL_LIGHT_MODEL_COLOR_CONTROL 0x81F8
+#define GL_SINGLE_COLOR 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR 0x81FA
+#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12
+#define GL_SMOOTH_POINT_SIZE_GRANULARITY 0x0B13
+#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22
+#define GL_SMOOTH_LINE_WIDTH_GRANULARITY 0x0B23
+#define GL_ALIASED_POINT_SIZE_RANGE 0x846D
+#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E
+#endif
+
+#ifndef GL_ARB_imaging
+#define GL_CONSTANT_COLOR 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR 0x8002
+#define GL_CONSTANT_ALPHA 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA 0x8004
+#define GL_BLEND_COLOR 0x8005
+#define GL_FUNC_ADD 0x8006
+#define GL_MIN 0x8007
+#define GL_MAX 0x8008
+#define GL_BLEND_EQUATION 0x8009
+#define GL_FUNC_SUBTRACT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT 0x800B
+#define GL_CONVOLUTION_1D 0x8010
+#define GL_CONVOLUTION_2D 0x8011
+#define GL_SEPARABLE_2D 0x8012
+#define GL_CONVOLUTION_BORDER_MODE 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS 0x8015
+#define GL_REDUCE 0x8016
+#define GL_CONVOLUTION_FORMAT 0x8017
+#define GL_CONVOLUTION_WIDTH 0x8018
+#define GL_CONVOLUTION_HEIGHT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS 0x8023
+#define GL_HISTOGRAM 0x8024
+#define GL_PROXY_HISTOGRAM 0x8025
+#define GL_HISTOGRAM_WIDTH 0x8026
+#define GL_HISTOGRAM_FORMAT 0x8027
+#define GL_HISTOGRAM_RED_SIZE 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE 0x802C
+#define GL_HISTOGRAM_SINK 0x802D
+#define GL_MINMAX 0x802E
+#define GL_MINMAX_FORMAT 0x802F
+#define GL_MINMAX_SINK 0x8030
+#define GL_TABLE_TOO_LARGE 0x8031
+#define GL_COLOR_MATRIX 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS 0x80BB
+#define GL_COLOR_TABLE 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE 0x80D2
+#define GL_PROXY_COLOR_TABLE 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE 0x80D5
+#define GL_COLOR_TABLE_SCALE 0x80D6
+#define GL_COLOR_TABLE_BIAS 0x80D7
+#define GL_COLOR_TABLE_FORMAT 0x80D8
+#define GL_COLOR_TABLE_WIDTH 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE 0x80DF
+#define GL_CONSTANT_BORDER 0x8151
+#define GL_REPLICATE_BORDER 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR 0x8154
+#endif
+
+#ifndef GL_VERSION_1_3
+#define GL_TEXTURE0 0x84C0
+#define GL_TEXTURE1 0x84C1
+#define GL_TEXTURE2 0x84C2
+#define GL_TEXTURE3 0x84C3
+#define GL_TEXTURE4 0x84C4
+#define GL_TEXTURE5 0x84C5
+#define GL_TEXTURE6 0x84C6
+#define GL_TEXTURE7 0x84C7
+#define GL_TEXTURE8 0x84C8
+#define GL_TEXTURE9 0x84C9
+#define GL_TEXTURE10 0x84CA
+#define GL_TEXTURE11 0x84CB
+#define GL_TEXTURE12 0x84CC
+#define GL_TEXTURE13 0x84CD
+#define GL_TEXTURE14 0x84CE
+#define GL_TEXTURE15 0x84CF
+#define GL_TEXTURE16 0x84D0
+#define GL_TEXTURE17 0x84D1
+#define GL_TEXTURE18 0x84D2
+#define GL_TEXTURE19 0x84D3
+#define GL_TEXTURE20 0x84D4
+#define GL_TEXTURE21 0x84D5
+#define GL_TEXTURE22 0x84D6
+#define GL_TEXTURE23 0x84D7
+#define GL_TEXTURE24 0x84D8
+#define GL_TEXTURE25 0x84D9
+#define GL_TEXTURE26 0x84DA
+#define GL_TEXTURE27 0x84DB
+#define GL_TEXTURE28 0x84DC
+#define GL_TEXTURE29 0x84DD
+#define GL_TEXTURE30 0x84DE
+#define GL_TEXTURE31 0x84DF
+#define GL_ACTIVE_TEXTURE 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1
+#define GL_MAX_TEXTURE_UNITS 0x84E2
+#define GL_TRANSPOSE_MODELVIEW_MATRIX 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX 0x84E6
+#define GL_MULTISAMPLE 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE 0x809F
+#define GL_SAMPLE_COVERAGE 0x80A0
+#define GL_SAMPLE_BUFFERS 0x80A8
+#define GL_SAMPLES 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT 0x80AB
+#define GL_MULTISAMPLE_BIT 0x20000000
+#define GL_NORMAL_MAP 0x8511
+#define GL_REFLECTION_MAP 0x8512
+#define GL_TEXTURE_CUBE_MAP 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE 0x851C
+#define GL_COMPRESSED_ALPHA 0x84E9
+#define GL_COMPRESSED_LUMINANCE 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA 0x84EB
+#define GL_COMPRESSED_INTENSITY 0x84EC
+#define GL_COMPRESSED_RGB 0x84ED
+#define GL_COMPRESSED_RGBA 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE 0x86A0
+#define GL_TEXTURE_COMPRESSED 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3
+#define GL_CLAMP_TO_BORDER 0x812D
+#define GL_COMBINE 0x8570
+#define GL_COMBINE_RGB 0x8571
+#define GL_COMBINE_ALPHA 0x8572
+#define GL_SOURCE0_RGB 0x8580
+#define GL_SOURCE1_RGB 0x8581
+#define GL_SOURCE2_RGB 0x8582
+#define GL_SOURCE0_ALPHA 0x8588
+#define GL_SOURCE1_ALPHA 0x8589
+#define GL_SOURCE2_ALPHA 0x858A
+#define GL_OPERAND0_RGB 0x8590
+#define GL_OPERAND1_RGB 0x8591
+#define GL_OPERAND2_RGB 0x8592
+#define GL_OPERAND0_ALPHA 0x8598
+#define GL_OPERAND1_ALPHA 0x8599
+#define GL_OPERAND2_ALPHA 0x859A
+#define GL_RGB_SCALE 0x8573
+#define GL_ADD_SIGNED 0x8574
+#define GL_INTERPOLATE 0x8575
+#define GL_SUBTRACT 0x84E7
+#define GL_CONSTANT 0x8576
+#define GL_PRIMARY_COLOR 0x8577
+#define GL_PREVIOUS 0x8578
+#define GL_DOT3_RGB 0x86AE
+#define GL_DOT3_RGBA 0x86AF
+#endif
+
+#ifndef GL_VERSION_1_4
+#define GL_BLEND_DST_RGB 0x80C8
+#define GL_BLEND_SRC_RGB 0x80C9
+#define GL_BLEND_DST_ALPHA 0x80CA
+#define GL_BLEND_SRC_ALPHA 0x80CB
+#define GL_POINT_SIZE_MIN 0x8126
+#define GL_POINT_SIZE_MAX 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128
+#define GL_POINT_DISTANCE_ATTENUATION 0x8129
+#define GL_GENERATE_MIPMAP 0x8191
+#define GL_GENERATE_MIPMAP_HINT 0x8192
+#define GL_DEPTH_COMPONENT16 0x81A5
+#define GL_DEPTH_COMPONENT24 0x81A6
+#define GL_DEPTH_COMPONENT32 0x81A7
+#define GL_MIRRORED_REPEAT 0x8370
+#define GL_FOG_COORDINATE_SOURCE 0x8450
+#define GL_FOG_COORDINATE 0x8451
+#define GL_FRAGMENT_DEPTH 0x8452
+#define GL_CURRENT_FOG_COORDINATE 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER 0x8456
+#define GL_FOG_COORDINATE_ARRAY 0x8457
+#define GL_COLOR_SUM 0x8458
+#define GL_CURRENT_SECONDARY_COLOR 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER 0x845D
+#define GL_SECONDARY_COLOR_ARRAY 0x845E
+#define GL_MAX_TEXTURE_LOD_BIAS 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL 0x8500
+#define GL_TEXTURE_LOD_BIAS 0x8501
+#define GL_INCR_WRAP 0x8507
+#define GL_DECR_WRAP 0x8508
+#define GL_TEXTURE_DEPTH_SIZE 0x884A
+#define GL_DEPTH_TEXTURE_MODE 0x884B
+#define GL_TEXTURE_COMPARE_MODE 0x884C
+#define GL_TEXTURE_COMPARE_FUNC 0x884D
+#define GL_COMPARE_R_TO_TEXTURE 0x884E
+#endif
+
+#ifndef GL_VERSION_1_5
+#define GL_BUFFER_SIZE 0x8764
+#define GL_BUFFER_USAGE 0x8765
+#define GL_QUERY_COUNTER_BITS 0x8864
+#define GL_CURRENT_QUERY 0x8865
+#define GL_QUERY_RESULT 0x8866
+#define GL_QUERY_RESULT_AVAILABLE 0x8867
+#define GL_ARRAY_BUFFER 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER 0x8893
+#define GL_ARRAY_BUFFER_BINDING 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING 0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING 0x889F
+#define GL_READ_ONLY 0x88B8
+#define GL_WRITE_ONLY 0x88B9
+#define GL_READ_WRITE 0x88BA
+#define GL_BUFFER_ACCESS 0x88BB
+#define GL_BUFFER_MAPPED 0x88BC
+#define GL_BUFFER_MAP_POINTER 0x88BD
+#define GL_STREAM_DRAW 0x88E0
+#define GL_STREAM_READ 0x88E1
+#define GL_STREAM_COPY 0x88E2
+#define GL_STATIC_DRAW 0x88E4
+#define GL_STATIC_READ 0x88E5
+#define GL_STATIC_COPY 0x88E6
+#define GL_DYNAMIC_DRAW 0x88E8
+#define GL_DYNAMIC_READ 0x88E9
+#define GL_DYNAMIC_COPY 0x88EA
+#define GL_SAMPLES_PASSED 0x8914
+#define GL_FOG_COORD_SRC GL_FOG_COORDINATE_SOURCE
+#define GL_FOG_COORD GL_FOG_COORDINATE
+#define GL_CURRENT_FOG_COORD GL_CURRENT_FOG_COORDINATE
+#define GL_FOG_COORD_ARRAY_TYPE GL_FOG_COORDINATE_ARRAY_TYPE
+#define GL_FOG_COORD_ARRAY_STRIDE GL_FOG_COORDINATE_ARRAY_STRIDE
+#define GL_FOG_COORD_ARRAY_POINTER GL_FOG_COORDINATE_ARRAY_POINTER
+#define GL_FOG_COORD_ARRAY GL_FOG_COORDINATE_ARRAY
+#define GL_FOG_COORD_ARRAY_BUFFER_BINDING GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING
+#define GL_SRC0_RGB GL_SOURCE0_RGB
+#define GL_SRC1_RGB GL_SOURCE1_RGB
+#define GL_SRC2_RGB GL_SOURCE2_RGB
+#define GL_SRC0_ALPHA GL_SOURCE0_ALPHA
+#define GL_SRC1_ALPHA GL_SOURCE1_ALPHA
+#define GL_SRC2_ALPHA GL_SOURCE2_ALPHA
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_BLEND_EQUATION_RGB GL_BLEND_EQUATION
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB 0x8626
+#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER 0x8645
+#define GL_STENCIL_BACK_FUNC 0x8800
+#define GL_STENCIL_BACK_FAIL 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS 0x8803
+#define GL_MAX_DRAW_BUFFERS 0x8824
+#define GL_DRAW_BUFFER0 0x8825
+#define GL_DRAW_BUFFER1 0x8826
+#define GL_DRAW_BUFFER2 0x8827
+#define GL_DRAW_BUFFER3 0x8828
+#define GL_DRAW_BUFFER4 0x8829
+#define GL_DRAW_BUFFER5 0x882A
+#define GL_DRAW_BUFFER6 0x882B
+#define GL_DRAW_BUFFER7 0x882C
+#define GL_DRAW_BUFFER8 0x882D
+#define GL_DRAW_BUFFER9 0x882E
+#define GL_DRAW_BUFFER10 0x882F
+#define GL_DRAW_BUFFER11 0x8830
+#define GL_DRAW_BUFFER12 0x8831
+#define GL_DRAW_BUFFER13 0x8832
+#define GL_DRAW_BUFFER14 0x8833
+#define GL_DRAW_BUFFER15 0x8834
+#define GL_BLEND_EQUATION_ALPHA 0x883D
+#define GL_POINT_SPRITE 0x8861
+#define GL_COORD_REPLACE 0x8862
+#define GL_MAX_VERTEX_ATTRIBS 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
+#define GL_MAX_TEXTURE_COORDS 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS 0x8872
+#define GL_FRAGMENT_SHADER 0x8B30
+#define GL_VERTEX_SHADER 0x8B31
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A
+#define GL_MAX_VARYING_FLOATS 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS 0x8B4D
+#define GL_SHADER_TYPE 0x8B4F
+#define GL_FLOAT_VEC2 0x8B50
+#define GL_FLOAT_VEC3 0x8B51
+#define GL_FLOAT_VEC4 0x8B52
+#define GL_INT_VEC2 0x8B53
+#define GL_INT_VEC3 0x8B54
+#define GL_INT_VEC4 0x8B55
+#define GL_BOOL 0x8B56
+#define GL_BOOL_VEC2 0x8B57
+#define GL_BOOL_VEC3 0x8B58
+#define GL_BOOL_VEC4 0x8B59
+#define GL_FLOAT_MAT2 0x8B5A
+#define GL_FLOAT_MAT3 0x8B5B
+#define GL_FLOAT_MAT4 0x8B5C
+#define GL_SAMPLER_1D 0x8B5D
+#define GL_SAMPLER_2D 0x8B5E
+#define GL_SAMPLER_3D 0x8B5F
+#define GL_SAMPLER_CUBE 0x8B60
+#define GL_SAMPLER_1D_SHADOW 0x8B61
+#define GL_SAMPLER_2D_SHADOW 0x8B62
+#define GL_DELETE_STATUS 0x8B80
+#define GL_COMPILE_STATUS 0x8B81
+#define GL_LINK_STATUS 0x8B82
+#define GL_VALIDATE_STATUS 0x8B83
+#define GL_INFO_LOG_LENGTH 0x8B84
+#define GL_ATTACHED_SHADERS 0x8B85
+#define GL_ACTIVE_UNIFORMS 0x8B86
+#define GL_ACTIVE_UNIFORM_MAX_LENGTH 0x8B87
+#define GL_SHADER_SOURCE_LENGTH 0x8B88
+#define GL_ACTIVE_ATTRIBUTES 0x8B89
+#define GL_ACTIVE_ATTRIBUTE_MAX_LENGTH 0x8B8A
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT 0x8B8B
+#define GL_SHADING_LANGUAGE_VERSION 0x8B8C
+#define GL_CURRENT_PROGRAM 0x8B8D
+#define GL_POINT_SPRITE_COORD_ORIGIN 0x8CA0
+#define GL_LOWER_LEFT 0x8CA1
+#define GL_UPPER_LEFT 0x8CA2
+#define GL_STENCIL_BACK_REF 0x8CA3
+#define GL_STENCIL_BACK_VALUE_MASK 0x8CA4
+#define GL_STENCIL_BACK_WRITEMASK 0x8CA5
+#endif
+
+#ifndef GL_VERSION_2_1
+#define GL_CURRENT_RASTER_SECONDARY_COLOR 0x845F
+#define GL_PIXEL_PACK_BUFFER 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING 0x88EF
+#define GL_FLOAT_MAT2x3 0x8B65
+#define GL_FLOAT_MAT2x4 0x8B66
+#define GL_FLOAT_MAT3x2 0x8B67
+#define GL_FLOAT_MAT3x4 0x8B68
+#define GL_FLOAT_MAT4x2 0x8B69
+#define GL_FLOAT_MAT4x3 0x8B6A
+#define GL_SRGB 0x8C40
+#define GL_SRGB8 0x8C41
+#define GL_SRGB_ALPHA 0x8C42
+#define GL_SRGB8_ALPHA8 0x8C43
+#define GL_SLUMINANCE_ALPHA 0x8C44
+#define GL_SLUMINANCE8_ALPHA8 0x8C45
+#define GL_SLUMINANCE 0x8C46
+#define GL_SLUMINANCE8 0x8C47
+#define GL_COMPRESSED_SRGB 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA 0x8C49
+#define GL_COMPRESSED_SLUMINANCE 0x8C4A
+#define GL_COMPRESSED_SLUMINANCE_ALPHA 0x8C4B
+#endif
+
+#ifndef GL_VERSION_3_0
+#define GL_COMPARE_REF_TO_TEXTURE GL_COMPARE_R_TO_TEXTURE_ARB
+#define GL_CLIP_DISTANCE0 GL_CLIP_PLANE0
+#define GL_CLIP_DISTANCE1 GL_CLIP_PLANE1
+#define GL_CLIP_DISTANCE2 GL_CLIP_PLANE2
+#define GL_CLIP_DISTANCE3 GL_CLIP_PLANE3
+#define GL_CLIP_DISTANCE4 GL_CLIP_PLANE4
+#define GL_CLIP_DISTANCE5 GL_CLIP_PLANE5
+#define GL_MAX_CLIP_DISTANCES GL_MAX_CLIP_PLANES
+#define GL_MAJOR_VERSION 0x821B
+#define GL_MINOR_VERSION 0x821C
+#define GL_NUM_EXTENSIONS 0x821D
+#define GL_CONTEXT_FLAGS 0x821E
+#define GL_DEPTH_BUFFER 0x8223
+#define GL_STENCIL_BUFFER 0x8224
+#define GL_COMPRESSED_RED 0x8225
+#define GL_COMPRESSED_RG 0x8226
+#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001
+#define GL_RGBA32F 0x8814
+#define GL_RGB32F 0x8815
+#define GL_RGBA16F 0x881A
+#define GL_RGB16F 0x881B
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER 0x88FD
+#define GL_MAX_ARRAY_TEXTURE_LAYERS 0x88FF
+#define GL_MIN_PROGRAM_TEXEL_OFFSET 0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET 0x8905
+#define GL_CLAMP_VERTEX_COLOR 0x891A
+#define GL_CLAMP_FRAGMENT_COLOR 0x891B
+#define GL_CLAMP_READ_COLOR 0x891C
+#define GL_FIXED_ONLY 0x891D
+#define GL_MAX_VARYING_COMPONENTS GL_MAX_VARYING_FLOATS
+#define GL_TEXTURE_RED_TYPE 0x8C10
+#define GL_TEXTURE_GREEN_TYPE 0x8C11
+#define GL_TEXTURE_BLUE_TYPE 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE 0x8C13
+#define GL_TEXTURE_LUMINANCE_TYPE 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE 0x8C15
+#define GL_TEXTURE_DEPTH_TYPE 0x8C16
+#define GL_UNSIGNED_NORMALIZED 0x8C17
+#define GL_TEXTURE_1D_ARRAY 0x8C18
+#define GL_PROXY_TEXTURE_1D_ARRAY 0x8C19
+#define GL_TEXTURE_2D_ARRAY 0x8C1A
+#define GL_PROXY_TEXTURE_2D_ARRAY 0x8C1B
+#define GL_TEXTURE_BINDING_1D_ARRAY 0x8C1C
+#define GL_TEXTURE_BINDING_2D_ARRAY 0x8C1D
+#define GL_R11F_G11F_B10F 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV 0x8C3B
+#define GL_RGB9_E5 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV 0x8C3E
+#define GL_TEXTURE_SHARED_SIZE 0x8C3F
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH 0x8C76
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE 0x8C85
+#define GL_PRIMITIVES_GENERATED 0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN 0x8C88
+#define GL_RASTERIZER_DISCARD 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS 0x8C8C
+#define GL_SEPARATE_ATTRIBS 0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING 0x8C8F
+#define GL_RGBA32UI 0x8D70
+#define GL_RGB32UI 0x8D71
+#define GL_RGBA16UI 0x8D76
+#define GL_RGB16UI 0x8D77
+#define GL_RGBA8UI 0x8D7C
+#define GL_RGB8UI 0x8D7D
+#define GL_RGBA32I 0x8D82
+#define GL_RGB32I 0x8D83
+#define GL_RGBA16I 0x8D88
+#define GL_RGB16I 0x8D89
+#define GL_RGBA8I 0x8D8E
+#define GL_RGB8I 0x8D8F
+#define GL_RED_INTEGER 0x8D94
+#define GL_GREEN_INTEGER 0x8D95
+#define GL_BLUE_INTEGER 0x8D96
+#define GL_ALPHA_INTEGER 0x8D97
+#define GL_RGB_INTEGER 0x8D98
+#define GL_RGBA_INTEGER 0x8D99
+#define GL_BGR_INTEGER 0x8D9A
+#define GL_BGRA_INTEGER 0x8D9B
+#define GL_SAMPLER_1D_ARRAY 0x8DC0
+#define GL_SAMPLER_2D_ARRAY 0x8DC1
+#define GL_SAMPLER_1D_ARRAY_SHADOW 0x8DC3
+#define GL_SAMPLER_2D_ARRAY_SHADOW 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW 0x8DC5
+#define GL_UNSIGNED_INT_VEC2 0x8DC6
+#define GL_UNSIGNED_INT_VEC3 0x8DC7
+#define GL_UNSIGNED_INT_VEC4 0x8DC8
+#define GL_INT_SAMPLER_1D 0x8DC9
+#define GL_INT_SAMPLER_2D 0x8DCA
+#define GL_INT_SAMPLER_3D 0x8DCB
+#define GL_INT_SAMPLER_CUBE 0x8DCC
+#define GL_INT_SAMPLER_1D_ARRAY 0x8DCE
+#define GL_INT_SAMPLER_2D_ARRAY 0x8DCF
+#define GL_UNSIGNED_INT_SAMPLER_1D 0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_2D 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY 0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY 0x8DD7
+#define GL_QUERY_WAIT 0x8E13
+#define GL_QUERY_NO_WAIT 0x8E14
+#define GL_QUERY_BY_REGION_WAIT 0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT 0x8E16
+/* Reuse tokens from ARB_depth_buffer_float */
+/* reuse GL_DEPTH_COMPONENT32F */
+/* reuse GL_DEPTH32F_STENCIL8 */
+/* reuse GL_FLOAT_32_UNSIGNED_INT_24_8_REV */
+/* Reuse tokens from ARB_framebuffer_object */
+/* reuse GL_INVALID_FRAMEBUFFER_OPERATION */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE */
+/* reuse GL_FRAMEBUFFER_DEFAULT */
+/* reuse GL_FRAMEBUFFER_UNDEFINED */
+/* reuse GL_DEPTH_STENCIL_ATTACHMENT */
+/* reuse GL_INDEX */
+/* reuse GL_MAX_RENDERBUFFER_SIZE */
+/* reuse GL_DEPTH_STENCIL */
+/* reuse GL_UNSIGNED_INT_24_8 */
+/* reuse GL_DEPTH24_STENCIL8 */
+/* reuse GL_TEXTURE_STENCIL_SIZE */
+/* reuse GL_TEXTURE_RED_TYPE */
+/* reuse GL_TEXTURE_GREEN_TYPE */
+/* reuse GL_TEXTURE_BLUE_TYPE */
+/* reuse GL_TEXTURE_ALPHA_TYPE */
+/* reuse GL_TEXTURE_LUMINANCE_TYPE */
+/* reuse GL_TEXTURE_INTENSITY_TYPE */
+/* reuse GL_TEXTURE_DEPTH_TYPE */
+/* reuse GL_UNSIGNED_NORMALIZED */
+/* reuse GL_FRAMEBUFFER_BINDING */
+/* reuse GL_DRAW_FRAMEBUFFER_BINDING */
+/* reuse GL_RENDERBUFFER_BINDING */
+/* reuse GL_READ_FRAMEBUFFER */
+/* reuse GL_DRAW_FRAMEBUFFER */
+/* reuse GL_READ_FRAMEBUFFER_BINDING */
+/* reuse GL_RENDERBUFFER_SAMPLES */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+/* reuse GL_FRAMEBUFFER_COMPLETE */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER */
+/* reuse GL_FRAMEBUFFER_UNSUPPORTED */
+/* reuse GL_MAX_COLOR_ATTACHMENTS */
+/* reuse GL_COLOR_ATTACHMENT0 */
+/* reuse GL_COLOR_ATTACHMENT1 */
+/* reuse GL_COLOR_ATTACHMENT2 */
+/* reuse GL_COLOR_ATTACHMENT3 */
+/* reuse GL_COLOR_ATTACHMENT4 */
+/* reuse GL_COLOR_ATTACHMENT5 */
+/* reuse GL_COLOR_ATTACHMENT6 */
+/* reuse GL_COLOR_ATTACHMENT7 */
+/* reuse GL_COLOR_ATTACHMENT8 */
+/* reuse GL_COLOR_ATTACHMENT9 */
+/* reuse GL_COLOR_ATTACHMENT10 */
+/* reuse GL_COLOR_ATTACHMENT11 */
+/* reuse GL_COLOR_ATTACHMENT12 */
+/* reuse GL_COLOR_ATTACHMENT13 */
+/* reuse GL_COLOR_ATTACHMENT14 */
+/* reuse GL_COLOR_ATTACHMENT15 */
+/* reuse GL_DEPTH_ATTACHMENT */
+/* reuse GL_STENCIL_ATTACHMENT */
+/* reuse GL_FRAMEBUFFER */
+/* reuse GL_RENDERBUFFER */
+/* reuse GL_RENDERBUFFER_WIDTH */
+/* reuse GL_RENDERBUFFER_HEIGHT */
+/* reuse GL_RENDERBUFFER_INTERNAL_FORMAT */
+/* reuse GL_STENCIL_INDEX1 */
+/* reuse GL_STENCIL_INDEX4 */
+/* reuse GL_STENCIL_INDEX8 */
+/* reuse GL_STENCIL_INDEX16 */
+/* reuse GL_RENDERBUFFER_RED_SIZE */
+/* reuse GL_RENDERBUFFER_GREEN_SIZE */
+/* reuse GL_RENDERBUFFER_BLUE_SIZE */
+/* reuse GL_RENDERBUFFER_ALPHA_SIZE */
+/* reuse GL_RENDERBUFFER_DEPTH_SIZE */
+/* reuse GL_RENDERBUFFER_STENCIL_SIZE */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE */
+/* reuse GL_MAX_SAMPLES */
+/* Reuse tokens from ARB_framebuffer_sRGB */
+/* reuse GL_FRAMEBUFFER_SRGB */
+/* Reuse tokens from ARB_half_float_vertex */
+/* reuse GL_HALF_FLOAT */
+/* Reuse tokens from ARB_map_buffer_range */
+/* reuse GL_MAP_READ_BIT */
+/* reuse GL_MAP_WRITE_BIT */
+/* reuse GL_MAP_INVALIDATE_RANGE_BIT */
+/* reuse GL_MAP_INVALIDATE_BUFFER_BIT */
+/* reuse GL_MAP_FLUSH_EXPLICIT_BIT */
+/* reuse GL_MAP_UNSYNCHRONIZED_BIT */
+/* Reuse tokens from ARB_texture_compression_rgtc */
+/* reuse GL_COMPRESSED_RED_RGTC1 */
+/* reuse GL_COMPRESSED_SIGNED_RED_RGTC1 */
+/* reuse GL_COMPRESSED_RG_RGTC2 */
+/* reuse GL_COMPRESSED_SIGNED_RG_RGTC2 */
+/* Reuse tokens from ARB_texture_rg */
+/* reuse GL_RG */
+/* reuse GL_RG_INTEGER */
+/* reuse GL_R8 */
+/* reuse GL_R16 */
+/* reuse GL_RG8 */
+/* reuse GL_RG16 */
+/* reuse GL_R16F */
+/* reuse GL_R32F */
+/* reuse GL_RG16F */
+/* reuse GL_RG32F */
+/* reuse GL_R8I */
+/* reuse GL_R8UI */
+/* reuse GL_R16I */
+/* reuse GL_R16UI */
+/* reuse GL_R32I */
+/* reuse GL_R32UI */
+/* reuse GL_RG8I */
+/* reuse GL_RG8UI */
+/* reuse GL_RG16I */
+/* reuse GL_RG16UI */
+/* reuse GL_RG32I */
+/* reuse GL_RG32UI */
+/* Reuse tokens from ARB_vertex_array_object */
+/* reuse GL_VERTEX_ARRAY_BINDING */
+#endif
+
+#ifndef GL_ARB_multitexture
+#define GL_TEXTURE0_ARB 0x84C0
+#define GL_TEXTURE1_ARB 0x84C1
+#define GL_TEXTURE2_ARB 0x84C2
+#define GL_TEXTURE3_ARB 0x84C3
+#define GL_TEXTURE4_ARB 0x84C4
+#define GL_TEXTURE5_ARB 0x84C5
+#define GL_TEXTURE6_ARB 0x84C6
+#define GL_TEXTURE7_ARB 0x84C7
+#define GL_TEXTURE8_ARB 0x84C8
+#define GL_TEXTURE9_ARB 0x84C9
+#define GL_TEXTURE10_ARB 0x84CA
+#define GL_TEXTURE11_ARB 0x84CB
+#define GL_TEXTURE12_ARB 0x84CC
+#define GL_TEXTURE13_ARB 0x84CD
+#define GL_TEXTURE14_ARB 0x84CE
+#define GL_TEXTURE15_ARB 0x84CF
+#define GL_TEXTURE16_ARB 0x84D0
+#define GL_TEXTURE17_ARB 0x84D1
+#define GL_TEXTURE18_ARB 0x84D2
+#define GL_TEXTURE19_ARB 0x84D3
+#define GL_TEXTURE20_ARB 0x84D4
+#define GL_TEXTURE21_ARB 0x84D5
+#define GL_TEXTURE22_ARB 0x84D6
+#define GL_TEXTURE23_ARB 0x84D7
+#define GL_TEXTURE24_ARB 0x84D8
+#define GL_TEXTURE25_ARB 0x84D9
+#define GL_TEXTURE26_ARB 0x84DA
+#define GL_TEXTURE27_ARB 0x84DB
+#define GL_TEXTURE28_ARB 0x84DC
+#define GL_TEXTURE29_ARB 0x84DD
+#define GL_TEXTURE30_ARB 0x84DE
+#define GL_TEXTURE31_ARB 0x84DF
+#define GL_ACTIVE_TEXTURE_ARB 0x84E0
+#define GL_CLIENT_ACTIVE_TEXTURE_ARB 0x84E1
+#define GL_MAX_TEXTURE_UNITS_ARB 0x84E2
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#define GL_TRANSPOSE_MODELVIEW_MATRIX_ARB 0x84E3
+#define GL_TRANSPOSE_PROJECTION_MATRIX_ARB 0x84E4
+#define GL_TRANSPOSE_TEXTURE_MATRIX_ARB 0x84E5
+#define GL_TRANSPOSE_COLOR_MATRIX_ARB 0x84E6
+#endif
+
+#ifndef GL_ARB_multisample
+#define GL_MULTISAMPLE_ARB 0x809D
+#define GL_SAMPLE_ALPHA_TO_COVERAGE_ARB 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_ARB 0x809F
+#define GL_SAMPLE_COVERAGE_ARB 0x80A0
+#define GL_SAMPLE_BUFFERS_ARB 0x80A8
+#define GL_SAMPLES_ARB 0x80A9
+#define GL_SAMPLE_COVERAGE_VALUE_ARB 0x80AA
+#define GL_SAMPLE_COVERAGE_INVERT_ARB 0x80AB
+#define GL_MULTISAMPLE_BIT_ARB 0x20000000
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#define GL_NORMAL_MAP_ARB 0x8511
+#define GL_REFLECTION_MAP_ARB 0x8512
+#define GL_TEXTURE_CUBE_MAP_ARB 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_ARB 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_ARB 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_ARB 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_ARB 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_ARB 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_ARB 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_ARB 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB 0x851C
+#endif
+
+#ifndef GL_ARB_texture_compression
+#define GL_COMPRESSED_ALPHA_ARB 0x84E9
+#define GL_COMPRESSED_LUMINANCE_ARB 0x84EA
+#define GL_COMPRESSED_LUMINANCE_ALPHA_ARB 0x84EB
+#define GL_COMPRESSED_INTENSITY_ARB 0x84EC
+#define GL_COMPRESSED_RGB_ARB 0x84ED
+#define GL_COMPRESSED_RGBA_ARB 0x84EE
+#define GL_TEXTURE_COMPRESSION_HINT_ARB 0x84EF
+#define GL_TEXTURE_COMPRESSED_IMAGE_SIZE_ARB 0x86A0
+#define GL_TEXTURE_COMPRESSED_ARB 0x86A1
+#define GL_NUM_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A2
+#define GL_COMPRESSED_TEXTURE_FORMATS_ARB 0x86A3
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_ARB 0x812D
+#endif
+
+#ifndef GL_ARB_point_parameters
+#define GL_POINT_SIZE_MIN_ARB 0x8126
+#define GL_POINT_SIZE_MAX_ARB 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_ARB 0x8128
+#define GL_POINT_DISTANCE_ATTENUATION_ARB 0x8129
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#define GL_MAX_VERTEX_UNITS_ARB 0x86A4
+#define GL_ACTIVE_VERTEX_UNITS_ARB 0x86A5
+#define GL_WEIGHT_SUM_UNITY_ARB 0x86A6
+#define GL_VERTEX_BLEND_ARB 0x86A7
+#define GL_CURRENT_WEIGHT_ARB 0x86A8
+#define GL_WEIGHT_ARRAY_TYPE_ARB 0x86A9
+#define GL_WEIGHT_ARRAY_STRIDE_ARB 0x86AA
+#define GL_WEIGHT_ARRAY_SIZE_ARB 0x86AB
+#define GL_WEIGHT_ARRAY_POINTER_ARB 0x86AC
+#define GL_WEIGHT_ARRAY_ARB 0x86AD
+#define GL_MODELVIEW0_ARB 0x1700
+#define GL_MODELVIEW1_ARB 0x850A
+#define GL_MODELVIEW2_ARB 0x8722
+#define GL_MODELVIEW3_ARB 0x8723
+#define GL_MODELVIEW4_ARB 0x8724
+#define GL_MODELVIEW5_ARB 0x8725
+#define GL_MODELVIEW6_ARB 0x8726
+#define GL_MODELVIEW7_ARB 0x8727
+#define GL_MODELVIEW8_ARB 0x8728
+#define GL_MODELVIEW9_ARB 0x8729
+#define GL_MODELVIEW10_ARB 0x872A
+#define GL_MODELVIEW11_ARB 0x872B
+#define GL_MODELVIEW12_ARB 0x872C
+#define GL_MODELVIEW13_ARB 0x872D
+#define GL_MODELVIEW14_ARB 0x872E
+#define GL_MODELVIEW15_ARB 0x872F
+#define GL_MODELVIEW16_ARB 0x8730
+#define GL_MODELVIEW17_ARB 0x8731
+#define GL_MODELVIEW18_ARB 0x8732
+#define GL_MODELVIEW19_ARB 0x8733
+#define GL_MODELVIEW20_ARB 0x8734
+#define GL_MODELVIEW21_ARB 0x8735
+#define GL_MODELVIEW22_ARB 0x8736
+#define GL_MODELVIEW23_ARB 0x8737
+#define GL_MODELVIEW24_ARB 0x8738
+#define GL_MODELVIEW25_ARB 0x8739
+#define GL_MODELVIEW26_ARB 0x873A
+#define GL_MODELVIEW27_ARB 0x873B
+#define GL_MODELVIEW28_ARB 0x873C
+#define GL_MODELVIEW29_ARB 0x873D
+#define GL_MODELVIEW30_ARB 0x873E
+#define GL_MODELVIEW31_ARB 0x873F
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#define GL_MATRIX_PALETTE_ARB 0x8840
+#define GL_MAX_MATRIX_PALETTE_STACK_DEPTH_ARB 0x8841
+#define GL_MAX_PALETTE_MATRICES_ARB 0x8842
+#define GL_CURRENT_PALETTE_MATRIX_ARB 0x8843
+#define GL_MATRIX_INDEX_ARRAY_ARB 0x8844
+#define GL_CURRENT_MATRIX_INDEX_ARB 0x8845
+#define GL_MATRIX_INDEX_ARRAY_SIZE_ARB 0x8846
+#define GL_MATRIX_INDEX_ARRAY_TYPE_ARB 0x8847
+#define GL_MATRIX_INDEX_ARRAY_STRIDE_ARB 0x8848
+#define GL_MATRIX_INDEX_ARRAY_POINTER_ARB 0x8849
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_COMBINE_ARB 0x8570
+#define GL_COMBINE_RGB_ARB 0x8571
+#define GL_COMBINE_ALPHA_ARB 0x8572
+#define GL_SOURCE0_RGB_ARB 0x8580
+#define GL_SOURCE1_RGB_ARB 0x8581
+#define GL_SOURCE2_RGB_ARB 0x8582
+#define GL_SOURCE0_ALPHA_ARB 0x8588
+#define GL_SOURCE1_ALPHA_ARB 0x8589
+#define GL_SOURCE2_ALPHA_ARB 0x858A
+#define GL_OPERAND0_RGB_ARB 0x8590
+#define GL_OPERAND1_RGB_ARB 0x8591
+#define GL_OPERAND2_RGB_ARB 0x8592
+#define GL_OPERAND0_ALPHA_ARB 0x8598
+#define GL_OPERAND1_ALPHA_ARB 0x8599
+#define GL_OPERAND2_ALPHA_ARB 0x859A
+#define GL_RGB_SCALE_ARB 0x8573
+#define GL_ADD_SIGNED_ARB 0x8574
+#define GL_INTERPOLATE_ARB 0x8575
+#define GL_SUBTRACT_ARB 0x84E7
+#define GL_CONSTANT_ARB 0x8576
+#define GL_PRIMARY_COLOR_ARB 0x8577
+#define GL_PREVIOUS_ARB 0x8578
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_DOT3_RGB_ARB 0x86AE
+#define GL_DOT3_RGBA_ARB 0x86AF
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_ARB 0x8370
+#endif
+
+#ifndef GL_ARB_depth_texture
+#define GL_DEPTH_COMPONENT16_ARB 0x81A5
+#define GL_DEPTH_COMPONENT24_ARB 0x81A6
+#define GL_DEPTH_COMPONENT32_ARB 0x81A7
+#define GL_TEXTURE_DEPTH_SIZE_ARB 0x884A
+#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_TEXTURE_COMPARE_MODE_ARB 0x884C
+#define GL_TEXTURE_COMPARE_FUNC_ARB 0x884D
+#define GL_COMPARE_R_TO_TEXTURE_ARB 0x884E
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_TEXTURE_COMPARE_FAIL_VALUE_ARB 0x80BF
+#endif
+
+#ifndef GL_ARB_window_pos
+#endif
+
+#ifndef GL_ARB_vertex_program
+#define GL_COLOR_SUM_ARB 0x8458
+#define GL_VERTEX_PROGRAM_ARB 0x8620
+#define GL_VERTEX_ATTRIB_ARRAY_ENABLED_ARB 0x8622
+#define GL_VERTEX_ATTRIB_ARRAY_SIZE_ARB 0x8623
+#define GL_VERTEX_ATTRIB_ARRAY_STRIDE_ARB 0x8624
+#define GL_VERTEX_ATTRIB_ARRAY_TYPE_ARB 0x8625
+#define GL_CURRENT_VERTEX_ATTRIB_ARB 0x8626
+#define GL_PROGRAM_LENGTH_ARB 0x8627
+#define GL_PROGRAM_STRING_ARB 0x8628
+#define GL_MAX_PROGRAM_MATRIX_STACK_DEPTH_ARB 0x862E
+#define GL_MAX_PROGRAM_MATRICES_ARB 0x862F
+#define GL_CURRENT_MATRIX_STACK_DEPTH_ARB 0x8640
+#define GL_CURRENT_MATRIX_ARB 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_ARB 0x8643
+#define GL_VERTEX_ATTRIB_ARRAY_POINTER_ARB 0x8645
+#define GL_PROGRAM_ERROR_POSITION_ARB 0x864B
+#define GL_PROGRAM_BINDING_ARB 0x8677
+#define GL_MAX_VERTEX_ATTRIBS_ARB 0x8869
+#define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED_ARB 0x886A
+#define GL_PROGRAM_ERROR_STRING_ARB 0x8874
+#define GL_PROGRAM_FORMAT_ASCII_ARB 0x8875
+#define GL_PROGRAM_FORMAT_ARB 0x8876
+#define GL_PROGRAM_INSTRUCTIONS_ARB 0x88A0
+#define GL_MAX_PROGRAM_INSTRUCTIONS_ARB 0x88A1
+#define GL_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A2
+#define GL_MAX_PROGRAM_NATIVE_INSTRUCTIONS_ARB 0x88A3
+#define GL_PROGRAM_TEMPORARIES_ARB 0x88A4
+#define GL_MAX_PROGRAM_TEMPORARIES_ARB 0x88A5
+#define GL_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A6
+#define GL_MAX_PROGRAM_NATIVE_TEMPORARIES_ARB 0x88A7
+#define GL_PROGRAM_PARAMETERS_ARB 0x88A8
+#define GL_MAX_PROGRAM_PARAMETERS_ARB 0x88A9
+#define GL_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AA
+#define GL_MAX_PROGRAM_NATIVE_PARAMETERS_ARB 0x88AB
+#define GL_PROGRAM_ATTRIBS_ARB 0x88AC
+#define GL_MAX_PROGRAM_ATTRIBS_ARB 0x88AD
+#define GL_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AE
+#define GL_MAX_PROGRAM_NATIVE_ATTRIBS_ARB 0x88AF
+#define GL_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B0
+#define GL_MAX_PROGRAM_ADDRESS_REGISTERS_ARB 0x88B1
+#define GL_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B2
+#define GL_MAX_PROGRAM_NATIVE_ADDRESS_REGISTERS_ARB 0x88B3
+#define GL_MAX_PROGRAM_LOCAL_PARAMETERS_ARB 0x88B4
+#define GL_MAX_PROGRAM_ENV_PARAMETERS_ARB 0x88B5
+#define GL_PROGRAM_UNDER_NATIVE_LIMITS_ARB 0x88B6
+#define GL_TRANSPOSE_CURRENT_MATRIX_ARB 0x88B7
+#define GL_MATRIX0_ARB 0x88C0
+#define GL_MATRIX1_ARB 0x88C1
+#define GL_MATRIX2_ARB 0x88C2
+#define GL_MATRIX3_ARB 0x88C3
+#define GL_MATRIX4_ARB 0x88C4
+#define GL_MATRIX5_ARB 0x88C5
+#define GL_MATRIX6_ARB 0x88C6
+#define GL_MATRIX7_ARB 0x88C7
+#define GL_MATRIX8_ARB 0x88C8
+#define GL_MATRIX9_ARB 0x88C9
+#define GL_MATRIX10_ARB 0x88CA
+#define GL_MATRIX11_ARB 0x88CB
+#define GL_MATRIX12_ARB 0x88CC
+#define GL_MATRIX13_ARB 0x88CD
+#define GL_MATRIX14_ARB 0x88CE
+#define GL_MATRIX15_ARB 0x88CF
+#define GL_MATRIX16_ARB 0x88D0
+#define GL_MATRIX17_ARB 0x88D1
+#define GL_MATRIX18_ARB 0x88D2
+#define GL_MATRIX19_ARB 0x88D3
+#define GL_MATRIX20_ARB 0x88D4
+#define GL_MATRIX21_ARB 0x88D5
+#define GL_MATRIX22_ARB 0x88D6
+#define GL_MATRIX23_ARB 0x88D7
+#define GL_MATRIX24_ARB 0x88D8
+#define GL_MATRIX25_ARB 0x88D9
+#define GL_MATRIX26_ARB 0x88DA
+#define GL_MATRIX27_ARB 0x88DB
+#define GL_MATRIX28_ARB 0x88DC
+#define GL_MATRIX29_ARB 0x88DD
+#define GL_MATRIX30_ARB 0x88DE
+#define GL_MATRIX31_ARB 0x88DF
+#endif
+
+#ifndef GL_ARB_fragment_program
+#define GL_FRAGMENT_PROGRAM_ARB 0x8804
+#define GL_PROGRAM_ALU_INSTRUCTIONS_ARB 0x8805
+#define GL_PROGRAM_TEX_INSTRUCTIONS_ARB 0x8806
+#define GL_PROGRAM_TEX_INDIRECTIONS_ARB 0x8807
+#define GL_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x8808
+#define GL_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x8809
+#define GL_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x880A
+#define GL_MAX_PROGRAM_ALU_INSTRUCTIONS_ARB 0x880B
+#define GL_MAX_PROGRAM_TEX_INSTRUCTIONS_ARB 0x880C
+#define GL_MAX_PROGRAM_TEX_INDIRECTIONS_ARB 0x880D
+#define GL_MAX_PROGRAM_NATIVE_ALU_INSTRUCTIONS_ARB 0x880E
+#define GL_MAX_PROGRAM_NATIVE_TEX_INSTRUCTIONS_ARB 0x880F
+#define GL_MAX_PROGRAM_NATIVE_TEX_INDIRECTIONS_ARB 0x8810
+#define GL_MAX_TEXTURE_COORDS_ARB 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_ARB 0x8872
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_BUFFER_SIZE_ARB 0x8764
+#define GL_BUFFER_USAGE_ARB 0x8765
+#define GL_ARRAY_BUFFER_ARB 0x8892
+#define GL_ELEMENT_ARRAY_BUFFER_ARB 0x8893
+#define GL_ARRAY_BUFFER_BINDING_ARB 0x8894
+#define GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB 0x8895
+#define GL_VERTEX_ARRAY_BUFFER_BINDING_ARB 0x8896
+#define GL_NORMAL_ARRAY_BUFFER_BINDING_ARB 0x8897
+#define GL_COLOR_ARRAY_BUFFER_BINDING_ARB 0x8898
+#define GL_INDEX_ARRAY_BUFFER_BINDING_ARB 0x8899
+#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB 0x889A
+#define GL_EDGE_FLAG_ARRAY_BUFFER_BINDING_ARB 0x889B
+#define GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING_ARB 0x889C
+#define GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING_ARB 0x889D
+#define GL_WEIGHT_ARRAY_BUFFER_BINDING_ARB 0x889E
+#define GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING_ARB 0x889F
+#define GL_READ_ONLY_ARB 0x88B8
+#define GL_WRITE_ONLY_ARB 0x88B9
+#define GL_READ_WRITE_ARB 0x88BA
+#define GL_BUFFER_ACCESS_ARB 0x88BB
+#define GL_BUFFER_MAPPED_ARB 0x88BC
+#define GL_BUFFER_MAP_POINTER_ARB 0x88BD
+#define GL_STREAM_DRAW_ARB 0x88E0
+#define GL_STREAM_READ_ARB 0x88E1
+#define GL_STREAM_COPY_ARB 0x88E2
+#define GL_STATIC_DRAW_ARB 0x88E4
+#define GL_STATIC_READ_ARB 0x88E5
+#define GL_STATIC_COPY_ARB 0x88E6
+#define GL_DYNAMIC_DRAW_ARB 0x88E8
+#define GL_DYNAMIC_READ_ARB 0x88E9
+#define GL_DYNAMIC_COPY_ARB 0x88EA
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#define GL_QUERY_COUNTER_BITS_ARB 0x8864
+#define GL_CURRENT_QUERY_ARB 0x8865
+#define GL_QUERY_RESULT_ARB 0x8866
+#define GL_QUERY_RESULT_AVAILABLE_ARB 0x8867
+#define GL_SAMPLES_PASSED_ARB 0x8914
+#endif
+
+#ifndef GL_ARB_shader_objects
+#define GL_PROGRAM_OBJECT_ARB 0x8B40
+#define GL_SHADER_OBJECT_ARB 0x8B48
+#define GL_OBJECT_TYPE_ARB 0x8B4E
+#define GL_OBJECT_SUBTYPE_ARB 0x8B4F
+#define GL_FLOAT_VEC2_ARB 0x8B50
+#define GL_FLOAT_VEC3_ARB 0x8B51
+#define GL_FLOAT_VEC4_ARB 0x8B52
+#define GL_INT_VEC2_ARB 0x8B53
+#define GL_INT_VEC3_ARB 0x8B54
+#define GL_INT_VEC4_ARB 0x8B55
+#define GL_BOOL_ARB 0x8B56
+#define GL_BOOL_VEC2_ARB 0x8B57
+#define GL_BOOL_VEC3_ARB 0x8B58
+#define GL_BOOL_VEC4_ARB 0x8B59
+#define GL_FLOAT_MAT2_ARB 0x8B5A
+#define GL_FLOAT_MAT3_ARB 0x8B5B
+#define GL_FLOAT_MAT4_ARB 0x8B5C
+#define GL_SAMPLER_1D_ARB 0x8B5D
+#define GL_SAMPLER_2D_ARB 0x8B5E
+#define GL_SAMPLER_3D_ARB 0x8B5F
+#define GL_SAMPLER_CUBE_ARB 0x8B60
+#define GL_SAMPLER_1D_SHADOW_ARB 0x8B61
+#define GL_SAMPLER_2D_SHADOW_ARB 0x8B62
+#define GL_SAMPLER_2D_RECT_ARB 0x8B63
+#define GL_SAMPLER_2D_RECT_SHADOW_ARB 0x8B64
+#define GL_OBJECT_DELETE_STATUS_ARB 0x8B80
+#define GL_OBJECT_COMPILE_STATUS_ARB 0x8B81
+#define GL_OBJECT_LINK_STATUS_ARB 0x8B82
+#define GL_OBJECT_VALIDATE_STATUS_ARB 0x8B83
+#define GL_OBJECT_INFO_LOG_LENGTH_ARB 0x8B84
+#define GL_OBJECT_ATTACHED_OBJECTS_ARB 0x8B85
+#define GL_OBJECT_ACTIVE_UNIFORMS_ARB 0x8B86
+#define GL_OBJECT_ACTIVE_UNIFORM_MAX_LENGTH_ARB 0x8B87
+#define GL_OBJECT_SHADER_SOURCE_LENGTH_ARB 0x8B88
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#define GL_VERTEX_SHADER_ARB 0x8B31
+#define GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB 0x8B4A
+#define GL_MAX_VARYING_FLOATS_ARB 0x8B4B
+#define GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB 0x8B4C
+#define GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS_ARB 0x8B4D
+#define GL_OBJECT_ACTIVE_ATTRIBUTES_ARB 0x8B89
+#define GL_OBJECT_ACTIVE_ATTRIBUTE_MAX_LENGTH_ARB 0x8B8A
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_FRAGMENT_SHADER_ARB 0x8B30
+#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS_ARB 0x8B49
+#define GL_FRAGMENT_SHADER_DERIVATIVE_HINT_ARB 0x8B8B
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_SHADING_LANGUAGE_VERSION_ARB 0x8B8C
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_POINT_SPRITE_ARB 0x8861
+#define GL_COORD_REPLACE_ARB 0x8862
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_ARB 0x8824
+#define GL_DRAW_BUFFER0_ARB 0x8825
+#define GL_DRAW_BUFFER1_ARB 0x8826
+#define GL_DRAW_BUFFER2_ARB 0x8827
+#define GL_DRAW_BUFFER3_ARB 0x8828
+#define GL_DRAW_BUFFER4_ARB 0x8829
+#define GL_DRAW_BUFFER5_ARB 0x882A
+#define GL_DRAW_BUFFER6_ARB 0x882B
+#define GL_DRAW_BUFFER7_ARB 0x882C
+#define GL_DRAW_BUFFER8_ARB 0x882D
+#define GL_DRAW_BUFFER9_ARB 0x882E
+#define GL_DRAW_BUFFER10_ARB 0x882F
+#define GL_DRAW_BUFFER11_ARB 0x8830
+#define GL_DRAW_BUFFER12_ARB 0x8831
+#define GL_DRAW_BUFFER13_ARB 0x8832
+#define GL_DRAW_BUFFER14_ARB 0x8833
+#define GL_DRAW_BUFFER15_ARB 0x8834
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_ARB 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_ARB 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_ARB 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_ARB 0x84F8
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_RGBA_FLOAT_MODE_ARB 0x8820
+#define GL_CLAMP_VERTEX_COLOR_ARB 0x891A
+#define GL_CLAMP_FRAGMENT_COLOR_ARB 0x891B
+#define GL_CLAMP_READ_COLOR_ARB 0x891C
+#define GL_FIXED_ONLY_ARB 0x891D
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_HALF_FLOAT_ARB 0x140B
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_TEXTURE_RED_TYPE_ARB 0x8C10
+#define GL_TEXTURE_GREEN_TYPE_ARB 0x8C11
+#define GL_TEXTURE_BLUE_TYPE_ARB 0x8C12
+#define GL_TEXTURE_ALPHA_TYPE_ARB 0x8C13
+#define GL_TEXTURE_LUMINANCE_TYPE_ARB 0x8C14
+#define GL_TEXTURE_INTENSITY_TYPE_ARB 0x8C15
+#define GL_TEXTURE_DEPTH_TYPE_ARB 0x8C16
+#define GL_UNSIGNED_NORMALIZED_ARB 0x8C17
+#define GL_RGBA32F_ARB 0x8814
+#define GL_RGB32F_ARB 0x8815
+#define GL_ALPHA32F_ARB 0x8816
+#define GL_INTENSITY32F_ARB 0x8817
+#define GL_LUMINANCE32F_ARB 0x8818
+#define GL_LUMINANCE_ALPHA32F_ARB 0x8819
+#define GL_RGBA16F_ARB 0x881A
+#define GL_RGB16F_ARB 0x881B
+#define GL_ALPHA16F_ARB 0x881C
+#define GL_INTENSITY16F_ARB 0x881D
+#define GL_LUMINANCE16F_ARB 0x881E
+#define GL_LUMINANCE_ALPHA16F_ARB 0x881F
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_ARB 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_ARB 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_ARB 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_ARB 0x88EF
+#endif
+
+#ifndef GL_ARB_depth_buffer_float
+#define GL_DEPTH_COMPONENT32F 0x8CAC
+#define GL_DEPTH32F_STENCIL8 0x8CAD
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV 0x8DAD
+#endif
+
+#ifndef GL_ARB_draw_instanced
+#endif
+
+#ifndef GL_ARB_framebuffer_object
+#define GL_INVALID_FRAMEBUFFER_OPERATION 0x0506
+#define GL_FRAMEBUFFER_ATTACHMENT_COLOR_ENCODING 0x8210
+#define GL_FRAMEBUFFER_ATTACHMENT_COMPONENT_TYPE 0x8211
+#define GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE 0x8212
+#define GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE 0x8213
+#define GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE 0x8214
+#define GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE 0x8215
+#define GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE 0x8216
+#define GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE 0x8217
+#define GL_FRAMEBUFFER_DEFAULT 0x8218
+#define GL_FRAMEBUFFER_UNDEFINED 0x8219
+#define GL_DEPTH_STENCIL_ATTACHMENT 0x821A
+#define GL_INDEX 0x8222
+#define GL_MAX_RENDERBUFFER_SIZE 0x84E8
+#define GL_DEPTH_STENCIL 0x84F9
+#define GL_UNSIGNED_INT_24_8 0x84FA
+#define GL_DEPTH24_STENCIL8 0x88F0
+#define GL_TEXTURE_STENCIL_SIZE 0x88F1
+#define GL_FRAMEBUFFER_BINDING 0x8CA6
+#define GL_DRAW_FRAMEBUFFER_BINDING GL_FRAMEBUFFER_BINDING
+#define GL_RENDERBUFFER_BINDING 0x8CA7
+#define GL_READ_FRAMEBUFFER 0x8CA8
+#define GL_DRAW_FRAMEBUFFER 0x8CA9
+#define GL_READ_FRAMEBUFFER_BINDING 0x8CAA
+#define GL_RENDERBUFFER_SAMPLES 0x8CAB
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS 0x8CDF
+#define GL_COLOR_ATTACHMENT0 0x8CE0
+#define GL_COLOR_ATTACHMENT1 0x8CE1
+#define GL_COLOR_ATTACHMENT2 0x8CE2
+#define GL_COLOR_ATTACHMENT3 0x8CE3
+#define GL_COLOR_ATTACHMENT4 0x8CE4
+#define GL_COLOR_ATTACHMENT5 0x8CE5
+#define GL_COLOR_ATTACHMENT6 0x8CE6
+#define GL_COLOR_ATTACHMENT7 0x8CE7
+#define GL_COLOR_ATTACHMENT8 0x8CE8
+#define GL_COLOR_ATTACHMENT9 0x8CE9
+#define GL_COLOR_ATTACHMENT10 0x8CEA
+#define GL_COLOR_ATTACHMENT11 0x8CEB
+#define GL_COLOR_ATTACHMENT12 0x8CEC
+#define GL_COLOR_ATTACHMENT13 0x8CED
+#define GL_COLOR_ATTACHMENT14 0x8CEE
+#define GL_COLOR_ATTACHMENT15 0x8CEF
+#define GL_DEPTH_ATTACHMENT 0x8D00
+#define GL_STENCIL_ATTACHMENT 0x8D20
+#define GL_FRAMEBUFFER 0x8D40
+#define GL_RENDERBUFFER 0x8D41
+#define GL_RENDERBUFFER_WIDTH 0x8D42
+#define GL_RENDERBUFFER_HEIGHT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT 0x8D44
+#define GL_STENCIL_INDEX1 0x8D46
+#define GL_STENCIL_INDEX4 0x8D47
+#define GL_STENCIL_INDEX8 0x8D48
+#define GL_STENCIL_INDEX16 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE 0x8D55
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56
+#define GL_MAX_SAMPLES 0x8D57
+#endif
+
+#ifndef GL_ARB_framebuffer_sRGB
+#define GL_FRAMEBUFFER_SRGB 0x8DB9
+#endif
+
+#ifndef GL_ARB_geometry_shader4
+#define GL_LINES_ADJACENCY_ARB 0x000A
+#define GL_LINE_STRIP_ADJACENCY_ARB 0x000B
+#define GL_TRIANGLES_ADJACENCY_ARB 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_ARB 0x000D
+#define GL_PROGRAM_POINT_SIZE_ARB 0x8642
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_ARB 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_ARB 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_ARB 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_ARB 0x8DA9
+#define GL_GEOMETRY_SHADER_ARB 0x8DD9
+#define GL_GEOMETRY_VERTICES_OUT_ARB 0x8DDA
+#define GL_GEOMETRY_INPUT_TYPE_ARB 0x8DDB
+#define GL_GEOMETRY_OUTPUT_TYPE_ARB 0x8DDC
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_ARB 0x8DDD
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_ARB 0x8DDE
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_ARB 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_ARB 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_ARB 0x8DE1
+/* reuse GL_MAX_VARYING_COMPONENTS */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER */
+#endif
+
+#ifndef GL_ARB_half_float_vertex
+#define GL_HALF_FLOAT 0x140B
+#endif
+
+#ifndef GL_ARB_instanced_arrays
+#endif
+
+#ifndef GL_ARB_map_buffer_range
+#define GL_MAP_READ_BIT 0x0001
+#define GL_MAP_WRITE_BIT 0x0002
+#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004
+#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008
+#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010
+#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020
+#endif
+
+#ifndef GL_ARB_texture_buffer_object
+#define GL_TEXTURE_BUFFER_ARB 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_ARB 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_ARB 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_ARB 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT_ARB 0x8C2E
+#endif
+
+#ifndef GL_ARB_texture_compression_rgtc
+#define GL_COMPRESSED_RED_RGTC1 0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1 0x8DBC
+#define GL_COMPRESSED_RG_RGTC2 0x8DBD
+#define GL_COMPRESSED_SIGNED_RG_RGTC2 0x8DBE
+#endif
+
+#ifndef GL_ARB_texture_rg
+#define GL_RG 0x8227
+#define GL_RG_INTEGER 0x8228
+#define GL_R8 0x8229
+#define GL_R16 0x822A
+#define GL_RG8 0x822B
+#define GL_RG16 0x822C
+#define GL_R16F 0x822D
+#define GL_R32F 0x822E
+#define GL_RG16F 0x822F
+#define GL_RG32F 0x8230
+#define GL_R8I 0x8231
+#define GL_R8UI 0x8232
+#define GL_R16I 0x8233
+#define GL_R16UI 0x8234
+#define GL_R32I 0x8235
+#define GL_R32UI 0x8236
+#define GL_RG8I 0x8237
+#define GL_RG8UI 0x8238
+#define GL_RG16I 0x8239
+#define GL_RG16UI 0x823A
+#define GL_RG32I 0x823B
+#define GL_RG32UI 0x823C
+#endif
+
+#ifndef GL_ARB_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING 0x85B5
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_ABGR_EXT 0x8000
+#endif
+
+#ifndef GL_EXT_blend_color
+#define GL_CONSTANT_COLOR_EXT 0x8001
+#define GL_ONE_MINUS_CONSTANT_COLOR_EXT 0x8002
+#define GL_CONSTANT_ALPHA_EXT 0x8003
+#define GL_ONE_MINUS_CONSTANT_ALPHA_EXT 0x8004
+#define GL_BLEND_COLOR_EXT 0x8005
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_POLYGON_OFFSET_EXT 0x8037
+#define GL_POLYGON_OFFSET_FACTOR_EXT 0x8038
+#define GL_POLYGON_OFFSET_BIAS_EXT 0x8039
+#endif
+
+#ifndef GL_EXT_texture
+#define GL_ALPHA4_EXT 0x803B
+#define GL_ALPHA8_EXT 0x803C
+#define GL_ALPHA12_EXT 0x803D
+#define GL_ALPHA16_EXT 0x803E
+#define GL_LUMINANCE4_EXT 0x803F
+#define GL_LUMINANCE8_EXT 0x8040
+#define GL_LUMINANCE12_EXT 0x8041
+#define GL_LUMINANCE16_EXT 0x8042
+#define GL_LUMINANCE4_ALPHA4_EXT 0x8043
+#define GL_LUMINANCE6_ALPHA2_EXT 0x8044
+#define GL_LUMINANCE8_ALPHA8_EXT 0x8045
+#define GL_LUMINANCE12_ALPHA4_EXT 0x8046
+#define GL_LUMINANCE12_ALPHA12_EXT 0x8047
+#define GL_LUMINANCE16_ALPHA16_EXT 0x8048
+#define GL_INTENSITY_EXT 0x8049
+#define GL_INTENSITY4_EXT 0x804A
+#define GL_INTENSITY8_EXT 0x804B
+#define GL_INTENSITY12_EXT 0x804C
+#define GL_INTENSITY16_EXT 0x804D
+#define GL_RGB2_EXT 0x804E
+#define GL_RGB4_EXT 0x804F
+#define GL_RGB5_EXT 0x8050
+#define GL_RGB8_EXT 0x8051
+#define GL_RGB10_EXT 0x8052
+#define GL_RGB12_EXT 0x8053
+#define GL_RGB16_EXT 0x8054
+#define GL_RGBA2_EXT 0x8055
+#define GL_RGBA4_EXT 0x8056
+#define GL_RGB5_A1_EXT 0x8057
+#define GL_RGBA8_EXT 0x8058
+#define GL_RGB10_A2_EXT 0x8059
+#define GL_RGBA12_EXT 0x805A
+#define GL_RGBA16_EXT 0x805B
+#define GL_TEXTURE_RED_SIZE_EXT 0x805C
+#define GL_TEXTURE_GREEN_SIZE_EXT 0x805D
+#define GL_TEXTURE_BLUE_SIZE_EXT 0x805E
+#define GL_TEXTURE_ALPHA_SIZE_EXT 0x805F
+#define GL_TEXTURE_LUMINANCE_SIZE_EXT 0x8060
+#define GL_TEXTURE_INTENSITY_SIZE_EXT 0x8061
+#define GL_REPLACE_EXT 0x8062
+#define GL_PROXY_TEXTURE_1D_EXT 0x8063
+#define GL_PROXY_TEXTURE_2D_EXT 0x8064
+#define GL_TEXTURE_TOO_LARGE_EXT 0x8065
+#endif
+
+#ifndef GL_EXT_texture3D
+#define GL_PACK_SKIP_IMAGES_EXT 0x806B
+#define GL_PACK_IMAGE_HEIGHT_EXT 0x806C
+#define GL_UNPACK_SKIP_IMAGES_EXT 0x806D
+#define GL_UNPACK_IMAGE_HEIGHT_EXT 0x806E
+#define GL_TEXTURE_3D_EXT 0x806F
+#define GL_PROXY_TEXTURE_3D_EXT 0x8070
+#define GL_TEXTURE_DEPTH_EXT 0x8071
+#define GL_TEXTURE_WRAP_R_EXT 0x8072
+#define GL_MAX_3D_TEXTURE_SIZE_EXT 0x8073
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_FILTER4_SGIS 0x8146
+#define GL_TEXTURE_FILTER4_SIZE_SGIS 0x8147
+#endif
+
+#ifndef GL_EXT_subtexture
+#endif
+
+#ifndef GL_EXT_copy_texture
+#endif
+
+#ifndef GL_EXT_histogram
+#define GL_HISTOGRAM_EXT 0x8024
+#define GL_PROXY_HISTOGRAM_EXT 0x8025
+#define GL_HISTOGRAM_WIDTH_EXT 0x8026
+#define GL_HISTOGRAM_FORMAT_EXT 0x8027
+#define GL_HISTOGRAM_RED_SIZE_EXT 0x8028
+#define GL_HISTOGRAM_GREEN_SIZE_EXT 0x8029
+#define GL_HISTOGRAM_BLUE_SIZE_EXT 0x802A
+#define GL_HISTOGRAM_ALPHA_SIZE_EXT 0x802B
+#define GL_HISTOGRAM_LUMINANCE_SIZE_EXT 0x802C
+#define GL_HISTOGRAM_SINK_EXT 0x802D
+#define GL_MINMAX_EXT 0x802E
+#define GL_MINMAX_FORMAT_EXT 0x802F
+#define GL_MINMAX_SINK_EXT 0x8030
+#define GL_TABLE_TOO_LARGE_EXT 0x8031
+#endif
+
+#ifndef GL_EXT_convolution
+#define GL_CONVOLUTION_1D_EXT 0x8010
+#define GL_CONVOLUTION_2D_EXT 0x8011
+#define GL_SEPARABLE_2D_EXT 0x8012
+#define GL_CONVOLUTION_BORDER_MODE_EXT 0x8013
+#define GL_CONVOLUTION_FILTER_SCALE_EXT 0x8014
+#define GL_CONVOLUTION_FILTER_BIAS_EXT 0x8015
+#define GL_REDUCE_EXT 0x8016
+#define GL_CONVOLUTION_FORMAT_EXT 0x8017
+#define GL_CONVOLUTION_WIDTH_EXT 0x8018
+#define GL_CONVOLUTION_HEIGHT_EXT 0x8019
+#define GL_MAX_CONVOLUTION_WIDTH_EXT 0x801A
+#define GL_MAX_CONVOLUTION_HEIGHT_EXT 0x801B
+#define GL_POST_CONVOLUTION_RED_SCALE_EXT 0x801C
+#define GL_POST_CONVOLUTION_GREEN_SCALE_EXT 0x801D
+#define GL_POST_CONVOLUTION_BLUE_SCALE_EXT 0x801E
+#define GL_POST_CONVOLUTION_ALPHA_SCALE_EXT 0x801F
+#define GL_POST_CONVOLUTION_RED_BIAS_EXT 0x8020
+#define GL_POST_CONVOLUTION_GREEN_BIAS_EXT 0x8021
+#define GL_POST_CONVOLUTION_BLUE_BIAS_EXT 0x8022
+#define GL_POST_CONVOLUTION_ALPHA_BIAS_EXT 0x8023
+#endif
+
+#ifndef GL_SGI_color_matrix
+#define GL_COLOR_MATRIX_SGI 0x80B1
+#define GL_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B2
+#define GL_MAX_COLOR_MATRIX_STACK_DEPTH_SGI 0x80B3
+#define GL_POST_COLOR_MATRIX_RED_SCALE_SGI 0x80B4
+#define GL_POST_COLOR_MATRIX_GREEN_SCALE_SGI 0x80B5
+#define GL_POST_COLOR_MATRIX_BLUE_SCALE_SGI 0x80B6
+#define GL_POST_COLOR_MATRIX_ALPHA_SCALE_SGI 0x80B7
+#define GL_POST_COLOR_MATRIX_RED_BIAS_SGI 0x80B8
+#define GL_POST_COLOR_MATRIX_GREEN_BIAS_SGI 0x80B9
+#define GL_POST_COLOR_MATRIX_BLUE_BIAS_SGI 0x80BA
+#define GL_POST_COLOR_MATRIX_ALPHA_BIAS_SGI 0x80BB
+#endif
+
+#ifndef GL_SGI_color_table
+#define GL_COLOR_TABLE_SGI 0x80D0
+#define GL_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D1
+#define GL_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D2
+#define GL_PROXY_COLOR_TABLE_SGI 0x80D3
+#define GL_PROXY_POST_CONVOLUTION_COLOR_TABLE_SGI 0x80D4
+#define GL_PROXY_POST_COLOR_MATRIX_COLOR_TABLE_SGI 0x80D5
+#define GL_COLOR_TABLE_SCALE_SGI 0x80D6
+#define GL_COLOR_TABLE_BIAS_SGI 0x80D7
+#define GL_COLOR_TABLE_FORMAT_SGI 0x80D8
+#define GL_COLOR_TABLE_WIDTH_SGI 0x80D9
+#define GL_COLOR_TABLE_RED_SIZE_SGI 0x80DA
+#define GL_COLOR_TABLE_GREEN_SIZE_SGI 0x80DB
+#define GL_COLOR_TABLE_BLUE_SIZE_SGI 0x80DC
+#define GL_COLOR_TABLE_ALPHA_SIZE_SGI 0x80DD
+#define GL_COLOR_TABLE_LUMINANCE_SIZE_SGI 0x80DE
+#define GL_COLOR_TABLE_INTENSITY_SIZE_SGI 0x80DF
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#define GL_PIXEL_TEXTURE_SGIS 0x8353
+#define GL_PIXEL_FRAGMENT_RGB_SOURCE_SGIS 0x8354
+#define GL_PIXEL_FRAGMENT_ALPHA_SOURCE_SGIS 0x8355
+#define GL_PIXEL_GROUP_COLOR_SGIS 0x8356
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_PIXEL_TEX_GEN_SGIX 0x8139
+#define GL_PIXEL_TEX_GEN_MODE_SGIX 0x832B
+#endif
+
+#ifndef GL_SGIS_texture4D
+#define GL_PACK_SKIP_VOLUMES_SGIS 0x8130
+#define GL_PACK_IMAGE_DEPTH_SGIS 0x8131
+#define GL_UNPACK_SKIP_VOLUMES_SGIS 0x8132
+#define GL_UNPACK_IMAGE_DEPTH_SGIS 0x8133
+#define GL_TEXTURE_4D_SGIS 0x8134
+#define GL_PROXY_TEXTURE_4D_SGIS 0x8135
+#define GL_TEXTURE_4DSIZE_SGIS 0x8136
+#define GL_TEXTURE_WRAP_Q_SGIS 0x8137
+#define GL_MAX_4D_TEXTURE_SIZE_SGIS 0x8138
+#define GL_TEXTURE_4D_BINDING_SGIS 0x814F
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_TEXTURE_COLOR_TABLE_SGI 0x80BC
+#define GL_PROXY_TEXTURE_COLOR_TABLE_SGI 0x80BD
+#endif
+
+#ifndef GL_EXT_cmyka
+#define GL_CMYK_EXT 0x800C
+#define GL_CMYKA_EXT 0x800D
+#define GL_PACK_CMYK_HINT_EXT 0x800E
+#define GL_UNPACK_CMYK_HINT_EXT 0x800F
+#endif
+
+#ifndef GL_EXT_texture_object
+#define GL_TEXTURE_PRIORITY_EXT 0x8066
+#define GL_TEXTURE_RESIDENT_EXT 0x8067
+#define GL_TEXTURE_1D_BINDING_EXT 0x8068
+#define GL_TEXTURE_2D_BINDING_EXT 0x8069
+#define GL_TEXTURE_3D_BINDING_EXT 0x806A
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_DETAIL_TEXTURE_2D_SGIS 0x8095
+#define GL_DETAIL_TEXTURE_2D_BINDING_SGIS 0x8096
+#define GL_LINEAR_DETAIL_SGIS 0x8097
+#define GL_LINEAR_DETAIL_ALPHA_SGIS 0x8098
+#define GL_LINEAR_DETAIL_COLOR_SGIS 0x8099
+#define GL_DETAIL_TEXTURE_LEVEL_SGIS 0x809A
+#define GL_DETAIL_TEXTURE_MODE_SGIS 0x809B
+#define GL_DETAIL_TEXTURE_FUNC_POINTS_SGIS 0x809C
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_LINEAR_SHARPEN_SGIS 0x80AD
+#define GL_LINEAR_SHARPEN_ALPHA_SGIS 0x80AE
+#define GL_LINEAR_SHARPEN_COLOR_SGIS 0x80AF
+#define GL_SHARPEN_TEXTURE_FUNC_POINTS_SGIS 0x80B0
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#define GL_UNSIGNED_BYTE_3_3_2_EXT 0x8032
+#define GL_UNSIGNED_SHORT_4_4_4_4_EXT 0x8033
+#define GL_UNSIGNED_SHORT_5_5_5_1_EXT 0x8034
+#define GL_UNSIGNED_INT_8_8_8_8_EXT 0x8035
+#define GL_UNSIGNED_INT_10_10_10_2_EXT 0x8036
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#define GL_TEXTURE_MIN_LOD_SGIS 0x813A
+#define GL_TEXTURE_MAX_LOD_SGIS 0x813B
+#define GL_TEXTURE_BASE_LEVEL_SGIS 0x813C
+#define GL_TEXTURE_MAX_LEVEL_SGIS 0x813D
+#endif
+
+#ifndef GL_SGIS_multisample
+#define GL_MULTISAMPLE_SGIS 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_SGIS 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_SGIS 0x809F
+#define GL_SAMPLE_MASK_SGIS 0x80A0
+#define GL_1PASS_SGIS 0x80A1
+#define GL_2PASS_0_SGIS 0x80A2
+#define GL_2PASS_1_SGIS 0x80A3
+#define GL_4PASS_0_SGIS 0x80A4
+#define GL_4PASS_1_SGIS 0x80A5
+#define GL_4PASS_2_SGIS 0x80A6
+#define GL_4PASS_3_SGIS 0x80A7
+#define GL_SAMPLE_BUFFERS_SGIS 0x80A8
+#define GL_SAMPLES_SGIS 0x80A9
+#define GL_SAMPLE_MASK_VALUE_SGIS 0x80AA
+#define GL_SAMPLE_MASK_INVERT_SGIS 0x80AB
+#define GL_SAMPLE_PATTERN_SGIS 0x80AC
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_RESCALE_NORMAL_EXT 0x803A
+#endif
+
+#ifndef GL_EXT_vertex_array
+#define GL_VERTEX_ARRAY_EXT 0x8074
+#define GL_NORMAL_ARRAY_EXT 0x8075
+#define GL_COLOR_ARRAY_EXT 0x8076
+#define GL_INDEX_ARRAY_EXT 0x8077
+#define GL_TEXTURE_COORD_ARRAY_EXT 0x8078
+#define GL_EDGE_FLAG_ARRAY_EXT 0x8079
+#define GL_VERTEX_ARRAY_SIZE_EXT 0x807A
+#define GL_VERTEX_ARRAY_TYPE_EXT 0x807B
+#define GL_VERTEX_ARRAY_STRIDE_EXT 0x807C
+#define GL_VERTEX_ARRAY_COUNT_EXT 0x807D
+#define GL_NORMAL_ARRAY_TYPE_EXT 0x807E
+#define GL_NORMAL_ARRAY_STRIDE_EXT 0x807F
+#define GL_NORMAL_ARRAY_COUNT_EXT 0x8080
+#define GL_COLOR_ARRAY_SIZE_EXT 0x8081
+#define GL_COLOR_ARRAY_TYPE_EXT 0x8082
+#define GL_COLOR_ARRAY_STRIDE_EXT 0x8083
+#define GL_COLOR_ARRAY_COUNT_EXT 0x8084
+#define GL_INDEX_ARRAY_TYPE_EXT 0x8085
+#define GL_INDEX_ARRAY_STRIDE_EXT 0x8086
+#define GL_INDEX_ARRAY_COUNT_EXT 0x8087
+#define GL_TEXTURE_COORD_ARRAY_SIZE_EXT 0x8088
+#define GL_TEXTURE_COORD_ARRAY_TYPE_EXT 0x8089
+#define GL_TEXTURE_COORD_ARRAY_STRIDE_EXT 0x808A
+#define GL_TEXTURE_COORD_ARRAY_COUNT_EXT 0x808B
+#define GL_EDGE_FLAG_ARRAY_STRIDE_EXT 0x808C
+#define GL_EDGE_FLAG_ARRAY_COUNT_EXT 0x808D
+#define GL_VERTEX_ARRAY_POINTER_EXT 0x808E
+#define GL_NORMAL_ARRAY_POINTER_EXT 0x808F
+#define GL_COLOR_ARRAY_POINTER_EXT 0x8090
+#define GL_INDEX_ARRAY_POINTER_EXT 0x8091
+#define GL_TEXTURE_COORD_ARRAY_POINTER_EXT 0x8092
+#define GL_EDGE_FLAG_ARRAY_POINTER_EXT 0x8093
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_GENERATE_MIPMAP_SGIS 0x8191
+#define GL_GENERATE_MIPMAP_HINT_SGIS 0x8192
+#endif
+
+#ifndef GL_SGIX_clipmap
+#define GL_LINEAR_CLIPMAP_LINEAR_SGIX 0x8170
+#define GL_TEXTURE_CLIPMAP_CENTER_SGIX 0x8171
+#define GL_TEXTURE_CLIPMAP_FRAME_SGIX 0x8172
+#define GL_TEXTURE_CLIPMAP_OFFSET_SGIX 0x8173
+#define GL_TEXTURE_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8174
+#define GL_TEXTURE_CLIPMAP_LOD_OFFSET_SGIX 0x8175
+#define GL_TEXTURE_CLIPMAP_DEPTH_SGIX 0x8176
+#define GL_MAX_CLIPMAP_DEPTH_SGIX 0x8177
+#define GL_MAX_CLIPMAP_VIRTUAL_DEPTH_SGIX 0x8178
+#define GL_NEAREST_CLIPMAP_NEAREST_SGIX 0x844D
+#define GL_NEAREST_CLIPMAP_LINEAR_SGIX 0x844E
+#define GL_LINEAR_CLIPMAP_NEAREST_SGIX 0x844F
+#endif
+
+#ifndef GL_SGIX_shadow
+#define GL_TEXTURE_COMPARE_SGIX 0x819A
+#define GL_TEXTURE_COMPARE_OPERATOR_SGIX 0x819B
+#define GL_TEXTURE_LEQUAL_R_SGIX 0x819C
+#define GL_TEXTURE_GEQUAL_R_SGIX 0x819D
+#endif
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_CLAMP_TO_EDGE_SGIS 0x812F
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_CLAMP_TO_BORDER_SGIS 0x812D
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_FUNC_ADD_EXT 0x8006
+#define GL_MIN_EXT 0x8007
+#define GL_MAX_EXT 0x8008
+#define GL_BLEND_EQUATION_EXT 0x8009
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_FUNC_SUBTRACT_EXT 0x800A
+#define GL_FUNC_REVERSE_SUBTRACT_EXT 0x800B
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_INTERLACE_SGIX 0x8094
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_PIXEL_TILE_BEST_ALIGNMENT_SGIX 0x813E
+#define GL_PIXEL_TILE_CACHE_INCREMENT_SGIX 0x813F
+#define GL_PIXEL_TILE_WIDTH_SGIX 0x8140
+#define GL_PIXEL_TILE_HEIGHT_SGIX 0x8141
+#define GL_PIXEL_TILE_GRID_WIDTH_SGIX 0x8142
+#define GL_PIXEL_TILE_GRID_HEIGHT_SGIX 0x8143
+#define GL_PIXEL_TILE_GRID_DEPTH_SGIX 0x8144
+#define GL_PIXEL_TILE_CACHE_SIZE_SGIX 0x8145
+#endif
+
+#ifndef GL_SGIS_texture_select
+#define GL_DUAL_ALPHA4_SGIS 0x8110
+#define GL_DUAL_ALPHA8_SGIS 0x8111
+#define GL_DUAL_ALPHA12_SGIS 0x8112
+#define GL_DUAL_ALPHA16_SGIS 0x8113
+#define GL_DUAL_LUMINANCE4_SGIS 0x8114
+#define GL_DUAL_LUMINANCE8_SGIS 0x8115
+#define GL_DUAL_LUMINANCE12_SGIS 0x8116
+#define GL_DUAL_LUMINANCE16_SGIS 0x8117
+#define GL_DUAL_INTENSITY4_SGIS 0x8118
+#define GL_DUAL_INTENSITY8_SGIS 0x8119
+#define GL_DUAL_INTENSITY12_SGIS 0x811A
+#define GL_DUAL_INTENSITY16_SGIS 0x811B
+#define GL_DUAL_LUMINANCE_ALPHA4_SGIS 0x811C
+#define GL_DUAL_LUMINANCE_ALPHA8_SGIS 0x811D
+#define GL_QUAD_ALPHA4_SGIS 0x811E
+#define GL_QUAD_ALPHA8_SGIS 0x811F
+#define GL_QUAD_LUMINANCE4_SGIS 0x8120
+#define GL_QUAD_LUMINANCE8_SGIS 0x8121
+#define GL_QUAD_INTENSITY4_SGIS 0x8122
+#define GL_QUAD_INTENSITY8_SGIS 0x8123
+#define GL_DUAL_TEXTURE_SELECT_SGIS 0x8124
+#define GL_QUAD_TEXTURE_SELECT_SGIS 0x8125
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SPRITE_SGIX 0x8148
+#define GL_SPRITE_MODE_SGIX 0x8149
+#define GL_SPRITE_AXIS_SGIX 0x814A
+#define GL_SPRITE_TRANSLATION_SGIX 0x814B
+#define GL_SPRITE_AXIAL_SGIX 0x814C
+#define GL_SPRITE_OBJECT_ALIGNED_SGIX 0x814D
+#define GL_SPRITE_EYE_ALIGNED_SGIX 0x814E
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_TEXTURE_MULTI_BUFFER_HINT_SGIX 0x812E
+#endif
+
+#ifndef GL_EXT_point_parameters
+#define GL_POINT_SIZE_MIN_EXT 0x8126
+#define GL_POINT_SIZE_MAX_EXT 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_EXT 0x8128
+#define GL_DISTANCE_ATTENUATION_EXT 0x8129
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_POINT_SIZE_MIN_SGIS 0x8126
+#define GL_POINT_SIZE_MAX_SGIS 0x8127
+#define GL_POINT_FADE_THRESHOLD_SIZE_SGIS 0x8128
+#define GL_DISTANCE_ATTENUATION_SGIS 0x8129
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_INSTRUMENT_BUFFER_POINTER_SGIX 0x8180
+#define GL_INSTRUMENT_MEASUREMENTS_SGIX 0x8181
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#define GL_POST_TEXTURE_FILTER_BIAS_SGIX 0x8179
+#define GL_POST_TEXTURE_FILTER_SCALE_SGIX 0x817A
+#define GL_POST_TEXTURE_FILTER_BIAS_RANGE_SGIX 0x817B
+#define GL_POST_TEXTURE_FILTER_SCALE_RANGE_SGIX 0x817C
+#endif
+
+#ifndef GL_SGIX_framezoom
+#define GL_FRAMEZOOM_SGIX 0x818B
+#define GL_FRAMEZOOM_FACTOR_SGIX 0x818C
+#define GL_MAX_FRAMEZOOM_FACTOR_SGIX 0x818D
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#endif
+
+#ifndef GL_FfdMaskSGIX
+#define GL_TEXTURE_DEFORMATION_BIT_SGIX 0x00000001
+#define GL_GEOMETRY_DEFORMATION_BIT_SGIX 0x00000002
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_GEOMETRY_DEFORMATION_SGIX 0x8194
+#define GL_TEXTURE_DEFORMATION_SGIX 0x8195
+#define GL_DEFORMATIONS_MASK_SGIX 0x8196
+#define GL_MAX_DEFORMATION_ORDER_SGIX 0x8197
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_REFERENCE_PLANE_SGIX 0x817D
+#define GL_REFERENCE_PLANE_EQUATION_SGIX 0x817E
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_DEPTH_COMPONENT16_SGIX 0x81A5
+#define GL_DEPTH_COMPONENT24_SGIX 0x81A6
+#define GL_DEPTH_COMPONENT32_SGIX 0x81A7
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_FOG_FUNC_SGIS 0x812A
+#define GL_FOG_FUNC_POINTS_SGIS 0x812B
+#define GL_MAX_FOG_FUNC_POINTS_SGIS 0x812C
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_FOG_OFFSET_SGIX 0x8198
+#define GL_FOG_OFFSET_VALUE_SGIX 0x8199
+#endif
+
+#ifndef GL_HP_image_transform
+#define GL_IMAGE_SCALE_X_HP 0x8155
+#define GL_IMAGE_SCALE_Y_HP 0x8156
+#define GL_IMAGE_TRANSLATE_X_HP 0x8157
+#define GL_IMAGE_TRANSLATE_Y_HP 0x8158
+#define GL_IMAGE_ROTATE_ANGLE_HP 0x8159
+#define GL_IMAGE_ROTATE_ORIGIN_X_HP 0x815A
+#define GL_IMAGE_ROTATE_ORIGIN_Y_HP 0x815B
+#define GL_IMAGE_MAG_FILTER_HP 0x815C
+#define GL_IMAGE_MIN_FILTER_HP 0x815D
+#define GL_IMAGE_CUBIC_WEIGHT_HP 0x815E
+#define GL_CUBIC_HP 0x815F
+#define GL_AVERAGE_HP 0x8160
+#define GL_IMAGE_TRANSFORM_2D_HP 0x8161
+#define GL_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8162
+#define GL_PROXY_POST_IMAGE_TRANSFORM_COLOR_TABLE_HP 0x8163
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#define GL_IGNORE_BORDER_HP 0x8150
+#define GL_CONSTANT_BORDER_HP 0x8151
+#define GL_REPLICATE_BORDER_HP 0x8153
+#define GL_CONVOLUTION_BORDER_COLOR_HP 0x8154
+#endif
+
+#ifndef GL_INGR_palette_buffer
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_TEXTURE_ENV_BIAS_SGIX 0x80BE
+#endif
+
+#ifndef GL_EXT_color_subtable
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_VERTEX_DATA_HINT_PGI 0x1A22A
+#define GL_VERTEX_CONSISTENT_HINT_PGI 0x1A22B
+#define GL_MATERIAL_SIDE_HINT_PGI 0x1A22C
+#define GL_MAX_VERTEX_HINT_PGI 0x1A22D
+#define GL_COLOR3_BIT_PGI 0x00010000
+#define GL_COLOR4_BIT_PGI 0x00020000
+#define GL_EDGEFLAG_BIT_PGI 0x00040000
+#define GL_INDEX_BIT_PGI 0x00080000
+#define GL_MAT_AMBIENT_BIT_PGI 0x00100000
+#define GL_MAT_AMBIENT_AND_DIFFUSE_BIT_PGI 0x00200000
+#define GL_MAT_DIFFUSE_BIT_PGI 0x00400000
+#define GL_MAT_EMISSION_BIT_PGI 0x00800000
+#define GL_MAT_COLOR_INDEXES_BIT_PGI 0x01000000
+#define GL_MAT_SHININESS_BIT_PGI 0x02000000
+#define GL_MAT_SPECULAR_BIT_PGI 0x04000000
+#define GL_NORMAL_BIT_PGI 0x08000000
+#define GL_TEXCOORD1_BIT_PGI 0x10000000
+#define GL_TEXCOORD2_BIT_PGI 0x20000000
+#define GL_TEXCOORD3_BIT_PGI 0x40000000
+#define GL_TEXCOORD4_BIT_PGI 0x80000000
+#define GL_VERTEX23_BIT_PGI 0x00000004
+#define GL_VERTEX4_BIT_PGI 0x00000008
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PREFER_DOUBLEBUFFER_HINT_PGI 0x1A1F8
+#define GL_CONSERVE_MEMORY_HINT_PGI 0x1A1FD
+#define GL_RECLAIM_MEMORY_HINT_PGI 0x1A1FE
+#define GL_NATIVE_GRAPHICS_HANDLE_PGI 0x1A202
+#define GL_NATIVE_GRAPHICS_BEGIN_HINT_PGI 0x1A203
+#define GL_NATIVE_GRAPHICS_END_HINT_PGI 0x1A204
+#define GL_ALWAYS_FAST_HINT_PGI 0x1A20C
+#define GL_ALWAYS_SOFT_HINT_PGI 0x1A20D
+#define GL_ALLOW_DRAW_OBJ_HINT_PGI 0x1A20E
+#define GL_ALLOW_DRAW_WIN_HINT_PGI 0x1A20F
+#define GL_ALLOW_DRAW_FRG_HINT_PGI 0x1A210
+#define GL_ALLOW_DRAW_MEM_HINT_PGI 0x1A211
+#define GL_STRICT_DEPTHFUNC_HINT_PGI 0x1A216
+#define GL_STRICT_LIGHTING_HINT_PGI 0x1A217
+#define GL_STRICT_SCISSOR_HINT_PGI 0x1A218
+#define GL_FULL_STIPPLE_HINT_PGI 0x1A219
+#define GL_CLIP_NEAR_HINT_PGI 0x1A220
+#define GL_CLIP_FAR_HINT_PGI 0x1A221
+#define GL_WIDE_LINE_HINT_PGI 0x1A222
+#define GL_BACK_NORMALS_HINT_PGI 0x1A223
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#define GL_COLOR_INDEX1_EXT 0x80E2
+#define GL_COLOR_INDEX2_EXT 0x80E3
+#define GL_COLOR_INDEX4_EXT 0x80E4
+#define GL_COLOR_INDEX8_EXT 0x80E5
+#define GL_COLOR_INDEX12_EXT 0x80E6
+#define GL_COLOR_INDEX16_EXT 0x80E7
+#define GL_TEXTURE_INDEX_SIZE_EXT 0x80ED
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_CLIP_VOLUME_CLIPPING_HINT_EXT 0x80F0
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_LIST_PRIORITY_SGIX 0x8182
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_IR_INSTRUMENT1_SGIX 0x817F
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_CALLIGRAPHIC_FRAGMENT_SGIX 0x8183
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#define GL_TEXTURE_LOD_BIAS_S_SGIX 0x818E
+#define GL_TEXTURE_LOD_BIAS_T_SGIX 0x818F
+#define GL_TEXTURE_LOD_BIAS_R_SGIX 0x8190
+#endif
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SHADOW_AMBIENT_SGIX 0x80BF
+#endif
+
+#ifndef GL_EXT_index_texture
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_INDEX_MATERIAL_EXT 0x81B8
+#define GL_INDEX_MATERIAL_PARAMETER_EXT 0x81B9
+#define GL_INDEX_MATERIAL_FACE_EXT 0x81BA
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_INDEX_TEST_EXT 0x81B5
+#define GL_INDEX_TEST_FUNC_EXT 0x81B6
+#define GL_INDEX_TEST_REF_EXT 0x81B7
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#define GL_IUI_V2F_EXT 0x81AD
+#define GL_IUI_V3F_EXT 0x81AE
+#define GL_IUI_N3F_V2F_EXT 0x81AF
+#define GL_IUI_N3F_V3F_EXT 0x81B0
+#define GL_T2F_IUI_V2F_EXT 0x81B1
+#define GL_T2F_IUI_V3F_EXT 0x81B2
+#define GL_T2F_IUI_N3F_V2F_EXT 0x81B3
+#define GL_T2F_IUI_N3F_V3F_EXT 0x81B4
+#endif
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_ARRAY_ELEMENT_LOCK_FIRST_EXT 0x81A8
+#define GL_ARRAY_ELEMENT_LOCK_COUNT_EXT 0x81A9
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_CULL_VERTEX_EXT 0x81AA
+#define GL_CULL_VERTEX_EYE_POSITION_EXT 0x81AB
+#define GL_CULL_VERTEX_OBJECT_POSITION_EXT 0x81AC
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_YCRCB_422_SGIX 0x81BB
+#define GL_YCRCB_444_SGIX 0x81BC
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_FRAGMENT_LIGHTING_SGIX 0x8400
+#define GL_FRAGMENT_COLOR_MATERIAL_SGIX 0x8401
+#define GL_FRAGMENT_COLOR_MATERIAL_FACE_SGIX 0x8402
+#define GL_FRAGMENT_COLOR_MATERIAL_PARAMETER_SGIX 0x8403
+#define GL_MAX_FRAGMENT_LIGHTS_SGIX 0x8404
+#define GL_MAX_ACTIVE_LIGHTS_SGIX 0x8405
+#define GL_CURRENT_RASTER_NORMAL_SGIX 0x8406
+#define GL_LIGHT_ENV_MODE_SGIX 0x8407
+#define GL_FRAGMENT_LIGHT_MODEL_LOCAL_VIEWER_SGIX 0x8408
+#define GL_FRAGMENT_LIGHT_MODEL_TWO_SIDE_SGIX 0x8409
+#define GL_FRAGMENT_LIGHT_MODEL_AMBIENT_SGIX 0x840A
+#define GL_FRAGMENT_LIGHT_MODEL_NORMAL_INTERPOLATION_SGIX 0x840B
+#define GL_FRAGMENT_LIGHT0_SGIX 0x840C
+#define GL_FRAGMENT_LIGHT1_SGIX 0x840D
+#define GL_FRAGMENT_LIGHT2_SGIX 0x840E
+#define GL_FRAGMENT_LIGHT3_SGIX 0x840F
+#define GL_FRAGMENT_LIGHT4_SGIX 0x8410
+#define GL_FRAGMENT_LIGHT5_SGIX 0x8411
+#define GL_FRAGMENT_LIGHT6_SGIX 0x8412
+#define GL_FRAGMENT_LIGHT7_SGIX 0x8413
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_RASTER_POSITION_UNCLIPPED_IBM 0x19262
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_TEXTURE_LIGHTING_MODE_HP 0x8167
+#define GL_TEXTURE_POST_SPECULAR_HP 0x8168
+#define GL_TEXTURE_PRE_SPECULAR_HP 0x8169
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_MAX_ELEMENTS_VERTICES_EXT 0x80E8
+#define GL_MAX_ELEMENTS_INDICES_EXT 0x80E9
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_PHONG_WIN 0x80EA
+#define GL_PHONG_HINT_WIN 0x80EB
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_FOG_SPECULAR_TEXTURE_WIN 0x80EC
+#endif
+
+#ifndef GL_EXT_light_texture
+#define GL_FRAGMENT_MATERIAL_EXT 0x8349
+#define GL_FRAGMENT_NORMAL_EXT 0x834A
+#define GL_FRAGMENT_COLOR_EXT 0x834C
+#define GL_ATTENUATION_EXT 0x834D
+#define GL_SHADOW_ATTENUATION_EXT 0x834E
+#define GL_TEXTURE_APPLICATION_MODE_EXT 0x834F
+#define GL_TEXTURE_LIGHT_EXT 0x8350
+#define GL_TEXTURE_MATERIAL_FACE_EXT 0x8351
+#define GL_TEXTURE_MATERIAL_PARAMETER_EXT 0x8352
+/* reuse GL_FRAGMENT_DEPTH_EXT */
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_ALPHA_MIN_SGIX 0x8320
+#define GL_ALPHA_MAX_SGIX 0x8321
+#endif
+
+#ifndef GL_SGIX_impact_pixel_texture
+#define GL_PIXEL_TEX_GEN_Q_CEILING_SGIX 0x8184
+#define GL_PIXEL_TEX_GEN_Q_ROUND_SGIX 0x8185
+#define GL_PIXEL_TEX_GEN_Q_FLOOR_SGIX 0x8186
+#define GL_PIXEL_TEX_GEN_ALPHA_REPLACE_SGIX 0x8187
+#define GL_PIXEL_TEX_GEN_ALPHA_NO_REPLACE_SGIX 0x8188
+#define GL_PIXEL_TEX_GEN_ALPHA_LS_SGIX 0x8189
+#define GL_PIXEL_TEX_GEN_ALPHA_MS_SGIX 0x818A
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_BGR_EXT 0x80E0
+#define GL_BGRA_EXT 0x80E1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_ASYNC_MARKER_SGIX 0x8329
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#define GL_ASYNC_TEX_IMAGE_SGIX 0x835C
+#define GL_ASYNC_DRAW_PIXELS_SGIX 0x835D
+#define GL_ASYNC_READ_PIXELS_SGIX 0x835E
+#define GL_MAX_ASYNC_TEX_IMAGE_SGIX 0x835F
+#define GL_MAX_ASYNC_DRAW_PIXELS_SGIX 0x8360
+#define GL_MAX_ASYNC_READ_PIXELS_SGIX 0x8361
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_ASYNC_HISTOGRAM_SGIX 0x832C
+#define GL_MAX_ASYNC_HISTOGRAM_SGIX 0x832D
+#endif
+
+#ifndef GL_INTEL_texture_scissor
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#define GL_PARALLEL_ARRAYS_INTEL 0x83F4
+#define GL_VERTEX_ARRAY_PARALLEL_POINTERS_INTEL 0x83F5
+#define GL_NORMAL_ARRAY_PARALLEL_POINTERS_INTEL 0x83F6
+#define GL_COLOR_ARRAY_PARALLEL_POINTERS_INTEL 0x83F7
+#define GL_TEXTURE_COORD_ARRAY_PARALLEL_POINTERS_INTEL 0x83F8
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_OCCLUSION_TEST_HP 0x8165
+#define GL_OCCLUSION_TEST_RESULT_HP 0x8166
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#define GL_PIXEL_TRANSFORM_2D_EXT 0x8330
+#define GL_PIXEL_MAG_FILTER_EXT 0x8331
+#define GL_PIXEL_MIN_FILTER_EXT 0x8332
+#define GL_PIXEL_CUBIC_WEIGHT_EXT 0x8333
+#define GL_CUBIC_EXT 0x8334
+#define GL_AVERAGE_EXT 0x8335
+#define GL_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8336
+#define GL_MAX_PIXEL_TRANSFORM_2D_STACK_DEPTH_EXT 0x8337
+#define GL_PIXEL_TRANSFORM_2D_MATRIX_EXT 0x8338
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_LIGHT_MODEL_COLOR_CONTROL_EXT 0x81F8
+#define GL_SINGLE_COLOR_EXT 0x81F9
+#define GL_SEPARATE_SPECULAR_COLOR_EXT 0x81FA
+#endif
+
+#ifndef GL_EXT_secondary_color
+#define GL_COLOR_SUM_EXT 0x8458
+#define GL_CURRENT_SECONDARY_COLOR_EXT 0x8459
+#define GL_SECONDARY_COLOR_ARRAY_SIZE_EXT 0x845A
+#define GL_SECONDARY_COLOR_ARRAY_TYPE_EXT 0x845B
+#define GL_SECONDARY_COLOR_ARRAY_STRIDE_EXT 0x845C
+#define GL_SECONDARY_COLOR_ARRAY_POINTER_EXT 0x845D
+#define GL_SECONDARY_COLOR_ARRAY_EXT 0x845E
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_PERTURB_EXT 0x85AE
+#define GL_TEXTURE_NORMAL_EXT 0x85AF
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#endif
+
+#ifndef GL_EXT_fog_coord
+#define GL_FOG_COORDINATE_SOURCE_EXT 0x8450
+#define GL_FOG_COORDINATE_EXT 0x8451
+#define GL_FRAGMENT_DEPTH_EXT 0x8452
+#define GL_CURRENT_FOG_COORDINATE_EXT 0x8453
+#define GL_FOG_COORDINATE_ARRAY_TYPE_EXT 0x8454
+#define GL_FOG_COORDINATE_ARRAY_STRIDE_EXT 0x8455
+#define GL_FOG_COORDINATE_ARRAY_POINTER_EXT 0x8456
+#define GL_FOG_COORDINATE_ARRAY_EXT 0x8457
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_SCREEN_COORDINATES_REND 0x8490
+#define GL_INVERTED_SCREEN_W_REND 0x8491
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#define GL_TANGENT_ARRAY_EXT 0x8439
+#define GL_BINORMAL_ARRAY_EXT 0x843A
+#define GL_CURRENT_TANGENT_EXT 0x843B
+#define GL_CURRENT_BINORMAL_EXT 0x843C
+#define GL_TANGENT_ARRAY_TYPE_EXT 0x843E
+#define GL_TANGENT_ARRAY_STRIDE_EXT 0x843F
+#define GL_BINORMAL_ARRAY_TYPE_EXT 0x8440
+#define GL_BINORMAL_ARRAY_STRIDE_EXT 0x8441
+#define GL_TANGENT_ARRAY_POINTER_EXT 0x8442
+#define GL_BINORMAL_ARRAY_POINTER_EXT 0x8443
+#define GL_MAP1_TANGENT_EXT 0x8444
+#define GL_MAP2_TANGENT_EXT 0x8445
+#define GL_MAP1_BINORMAL_EXT 0x8446
+#define GL_MAP2_BINORMAL_EXT 0x8447
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#define GL_COMBINE_EXT 0x8570
+#define GL_COMBINE_RGB_EXT 0x8571
+#define GL_COMBINE_ALPHA_EXT 0x8572
+#define GL_RGB_SCALE_EXT 0x8573
+#define GL_ADD_SIGNED_EXT 0x8574
+#define GL_INTERPOLATE_EXT 0x8575
+#define GL_CONSTANT_EXT 0x8576
+#define GL_PRIMARY_COLOR_EXT 0x8577
+#define GL_PREVIOUS_EXT 0x8578
+#define GL_SOURCE0_RGB_EXT 0x8580
+#define GL_SOURCE1_RGB_EXT 0x8581
+#define GL_SOURCE2_RGB_EXT 0x8582
+#define GL_SOURCE0_ALPHA_EXT 0x8588
+#define GL_SOURCE1_ALPHA_EXT 0x8589
+#define GL_SOURCE2_ALPHA_EXT 0x858A
+#define GL_OPERAND0_RGB_EXT 0x8590
+#define GL_OPERAND1_RGB_EXT 0x8591
+#define GL_OPERAND2_RGB_EXT 0x8592
+#define GL_OPERAND0_ALPHA_EXT 0x8598
+#define GL_OPERAND1_ALPHA_EXT 0x8599
+#define GL_OPERAND2_ALPHA_EXT 0x859A
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_LIGHT_MODEL_SPECULAR_VECTOR_APPLE 0x85B0
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_TRANSFORM_HINT_APPLE 0x85B1
+#endif
+
+#ifndef GL_SGIX_fog_scale
+#define GL_FOG_SCALE_SGIX 0x81FC
+#define GL_FOG_SCALE_VALUE_SGIX 0x81FD
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_UNPACK_CONSTANT_DATA_SUNX 0x81D5
+#define GL_TEXTURE_CONSTANT_DATA_SUNX 0x81D6
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_GLOBAL_ALPHA_SUN 0x81D9
+#define GL_GLOBAL_ALPHA_FACTOR_SUN 0x81DA
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_RESTART_SUN 0x0001
+#define GL_REPLACE_MIDDLE_SUN 0x0002
+#define GL_REPLACE_OLDEST_SUN 0x0003
+#define GL_TRIANGLE_LIST_SUN 0x81D7
+#define GL_REPLACEMENT_CODE_SUN 0x81D8
+#define GL_REPLACEMENT_CODE_ARRAY_SUN 0x85C0
+#define GL_REPLACEMENT_CODE_ARRAY_TYPE_SUN 0x85C1
+#define GL_REPLACEMENT_CODE_ARRAY_STRIDE_SUN 0x85C2
+#define GL_REPLACEMENT_CODE_ARRAY_POINTER_SUN 0x85C3
+#define GL_R1UI_V3F_SUN 0x85C4
+#define GL_R1UI_C4UB_V3F_SUN 0x85C5
+#define GL_R1UI_C3F_V3F_SUN 0x85C6
+#define GL_R1UI_N3F_V3F_SUN 0x85C7
+#define GL_R1UI_C4F_N3F_V3F_SUN 0x85C8
+#define GL_R1UI_T2F_V3F_SUN 0x85C9
+#define GL_R1UI_T2F_N3F_V3F_SUN 0x85CA
+#define GL_R1UI_T2F_C4F_N3F_V3F_SUN 0x85CB
+#endif
+
+#ifndef GL_SUN_vertex
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#define GL_BLEND_DST_RGB_EXT 0x80C8
+#define GL_BLEND_SRC_RGB_EXT 0x80C9
+#define GL_BLEND_DST_ALPHA_EXT 0x80CA
+#define GL_BLEND_SRC_ALPHA_EXT 0x80CB
+#endif
+
+#ifndef GL_INGR_color_clamp
+#define GL_RED_MIN_CLAMP_INGR 0x8560
+#define GL_GREEN_MIN_CLAMP_INGR 0x8561
+#define GL_BLUE_MIN_CLAMP_INGR 0x8562
+#define GL_ALPHA_MIN_CLAMP_INGR 0x8563
+#define GL_RED_MAX_CLAMP_INGR 0x8564
+#define GL_GREEN_MAX_CLAMP_INGR 0x8565
+#define GL_BLUE_MAX_CLAMP_INGR 0x8566
+#define GL_ALPHA_MAX_CLAMP_INGR 0x8567
+#endif
+
+#ifndef GL_INGR_interlace_read
+#define GL_INTERLACE_READ_INGR 0x8568
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_INCR_WRAP_EXT 0x8507
+#define GL_DECR_WRAP_EXT 0x8508
+#endif
+
+#ifndef GL_EXT_422_pixels
+#define GL_422_EXT 0x80CC
+#define GL_422_REV_EXT 0x80CD
+#define GL_422_AVERAGE_EXT 0x80CE
+#define GL_422_REV_AVERAGE_EXT 0x80CF
+#endif
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NORMAL_MAP_NV 0x8511
+#define GL_REFLECTION_MAP_NV 0x8512
+#endif
+
+#ifndef GL_EXT_texture_cube_map
+#define GL_NORMAL_MAP_EXT 0x8511
+#define GL_REFLECTION_MAP_EXT 0x8512
+#define GL_TEXTURE_CUBE_MAP_EXT 0x8513
+#define GL_TEXTURE_BINDING_CUBE_MAP_EXT 0x8514
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT 0x8515
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT 0x8516
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT 0x8517
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT 0x8518
+#define GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT 0x8519
+#define GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT 0x851A
+#define GL_PROXY_TEXTURE_CUBE_MAP_EXT 0x851B
+#define GL_MAX_CUBE_MAP_TEXTURE_SIZE_EXT 0x851C
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_WRAP_BORDER_SUN 0x81D4
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_MAX_TEXTURE_LOD_BIAS_EXT 0x84FD
+#define GL_TEXTURE_FILTER_CONTROL_EXT 0x8500
+#define GL_TEXTURE_LOD_BIAS_EXT 0x8501
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_TEXTURE_MAX_ANISOTROPY_EXT 0x84FE
+#define GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT 0x84FF
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_MODELVIEW0_STACK_DEPTH_EXT GL_MODELVIEW_STACK_DEPTH
+#define GL_MODELVIEW1_STACK_DEPTH_EXT 0x8502
+#define GL_MODELVIEW0_MATRIX_EXT GL_MODELVIEW_MATRIX
+#define GL_MODELVIEW1_MATRIX_EXT 0x8506
+#define GL_VERTEX_WEIGHTING_EXT 0x8509
+#define GL_MODELVIEW0_EXT GL_MODELVIEW
+#define GL_MODELVIEW1_EXT 0x850A
+#define GL_CURRENT_VERTEX_WEIGHT_EXT 0x850B
+#define GL_VERTEX_WEIGHT_ARRAY_EXT 0x850C
+#define GL_VERTEX_WEIGHT_ARRAY_SIZE_EXT 0x850D
+#define GL_VERTEX_WEIGHT_ARRAY_TYPE_EXT 0x850E
+#define GL_VERTEX_WEIGHT_ARRAY_STRIDE_EXT 0x850F
+#define GL_VERTEX_WEIGHT_ARRAY_POINTER_EXT 0x8510
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_MAX_SHININESS_NV 0x8504
+#define GL_MAX_SPOT_EXPONENT_NV 0x8505
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#define GL_VERTEX_ARRAY_RANGE_NV 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_NV 0x851E
+#define GL_VERTEX_ARRAY_RANGE_VALID_NV 0x851F
+#define GL_MAX_VERTEX_ARRAY_RANGE_ELEMENT_NV 0x8520
+#define GL_VERTEX_ARRAY_RANGE_POINTER_NV 0x8521
+#endif
+
+#ifndef GL_NV_register_combiners
+#define GL_REGISTER_COMBINERS_NV 0x8522
+#define GL_VARIABLE_A_NV 0x8523
+#define GL_VARIABLE_B_NV 0x8524
+#define GL_VARIABLE_C_NV 0x8525
+#define GL_VARIABLE_D_NV 0x8526
+#define GL_VARIABLE_E_NV 0x8527
+#define GL_VARIABLE_F_NV 0x8528
+#define GL_VARIABLE_G_NV 0x8529
+#define GL_CONSTANT_COLOR0_NV 0x852A
+#define GL_CONSTANT_COLOR1_NV 0x852B
+#define GL_PRIMARY_COLOR_NV 0x852C
+#define GL_SECONDARY_COLOR_NV 0x852D
+#define GL_SPARE0_NV 0x852E
+#define GL_SPARE1_NV 0x852F
+#define GL_DISCARD_NV 0x8530
+#define GL_E_TIMES_F_NV 0x8531
+#define GL_SPARE0_PLUS_SECONDARY_COLOR_NV 0x8532
+#define GL_UNSIGNED_IDENTITY_NV 0x8536
+#define GL_UNSIGNED_INVERT_NV 0x8537
+#define GL_EXPAND_NORMAL_NV 0x8538
+#define GL_EXPAND_NEGATE_NV 0x8539
+#define GL_HALF_BIAS_NORMAL_NV 0x853A
+#define GL_HALF_BIAS_NEGATE_NV 0x853B
+#define GL_SIGNED_IDENTITY_NV 0x853C
+#define GL_SIGNED_NEGATE_NV 0x853D
+#define GL_SCALE_BY_TWO_NV 0x853E
+#define GL_SCALE_BY_FOUR_NV 0x853F
+#define GL_SCALE_BY_ONE_HALF_NV 0x8540
+#define GL_BIAS_BY_NEGATIVE_ONE_HALF_NV 0x8541
+#define GL_COMBINER_INPUT_NV 0x8542
+#define GL_COMBINER_MAPPING_NV 0x8543
+#define GL_COMBINER_COMPONENT_USAGE_NV 0x8544
+#define GL_COMBINER_AB_DOT_PRODUCT_NV 0x8545
+#define GL_COMBINER_CD_DOT_PRODUCT_NV 0x8546
+#define GL_COMBINER_MUX_SUM_NV 0x8547
+#define GL_COMBINER_SCALE_NV 0x8548
+#define GL_COMBINER_BIAS_NV 0x8549
+#define GL_COMBINER_AB_OUTPUT_NV 0x854A
+#define GL_COMBINER_CD_OUTPUT_NV 0x854B
+#define GL_COMBINER_SUM_OUTPUT_NV 0x854C
+#define GL_MAX_GENERAL_COMBINERS_NV 0x854D
+#define GL_NUM_GENERAL_COMBINERS_NV 0x854E
+#define GL_COLOR_SUM_CLAMP_NV 0x854F
+#define GL_COMBINER0_NV 0x8550
+#define GL_COMBINER1_NV 0x8551
+#define GL_COMBINER2_NV 0x8552
+#define GL_COMBINER3_NV 0x8553
+#define GL_COMBINER4_NV 0x8554
+#define GL_COMBINER5_NV 0x8555
+#define GL_COMBINER6_NV 0x8556
+#define GL_COMBINER7_NV 0x8557
+/* reuse GL_TEXTURE0_ARB */
+/* reuse GL_TEXTURE1_ARB */
+/* reuse GL_ZERO */
+/* reuse GL_NONE */
+/* reuse GL_FOG */
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_FOG_DISTANCE_MODE_NV 0x855A
+#define GL_EYE_RADIAL_NV 0x855B
+#define GL_EYE_PLANE_ABSOLUTE_NV 0x855C
+/* reuse GL_EYE_PLANE */
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_EMBOSS_LIGHT_NV 0x855D
+#define GL_EMBOSS_CONSTANT_NV 0x855E
+#define GL_EMBOSS_MAP_NV 0x855F
+#endif
+
+#ifndef GL_NV_blend_square
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#define GL_COMBINE4_NV 0x8503
+#define GL_SOURCE3_RGB_NV 0x8583
+#define GL_SOURCE3_ALPHA_NV 0x858B
+#define GL_OPERAND3_RGB_NV 0x8593
+#define GL_OPERAND3_ALPHA_NV 0x859B
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#endif
+
+#ifndef GL_MESA_window_pos
+#endif
+
+#ifndef GL_EXT_texture_compression_s3tc
+#define GL_COMPRESSED_RGB_S3TC_DXT1_EXT 0x83F0
+#define GL_COMPRESSED_RGBA_S3TC_DXT1_EXT 0x83F1
+#define GL_COMPRESSED_RGBA_S3TC_DXT3_EXT 0x83F2
+#define GL_COMPRESSED_RGBA_S3TC_DXT5_EXT 0x83F3
+#endif
+
+#ifndef GL_IBM_cull_vertex
+#define GL_CULL_VERTEX_IBM 103050
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#define GL_VERTEX_ARRAY_LIST_IBM 103070
+#define GL_NORMAL_ARRAY_LIST_IBM 103071
+#define GL_COLOR_ARRAY_LIST_IBM 103072
+#define GL_INDEX_ARRAY_LIST_IBM 103073
+#define GL_TEXTURE_COORD_ARRAY_LIST_IBM 103074
+#define GL_EDGE_FLAG_ARRAY_LIST_IBM 103075
+#define GL_FOG_COORDINATE_ARRAY_LIST_IBM 103076
+#define GL_SECONDARY_COLOR_ARRAY_LIST_IBM 103077
+#define GL_VERTEX_ARRAY_LIST_STRIDE_IBM 103080
+#define GL_NORMAL_ARRAY_LIST_STRIDE_IBM 103081
+#define GL_COLOR_ARRAY_LIST_STRIDE_IBM 103082
+#define GL_INDEX_ARRAY_LIST_STRIDE_IBM 103083
+#define GL_TEXTURE_COORD_ARRAY_LIST_STRIDE_IBM 103084
+#define GL_EDGE_FLAG_ARRAY_LIST_STRIDE_IBM 103085
+#define GL_FOG_COORDINATE_ARRAY_LIST_STRIDE_IBM 103086
+#define GL_SECONDARY_COLOR_ARRAY_LIST_STRIDE_IBM 103087
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_PACK_SUBSAMPLE_RATE_SGIX 0x85A0
+#define GL_UNPACK_SUBSAMPLE_RATE_SGIX 0x85A1
+#define GL_PIXEL_SUBSAMPLE_4444_SGIX 0x85A2
+#define GL_PIXEL_SUBSAMPLE_2424_SGIX 0x85A3
+#define GL_PIXEL_SUBSAMPLE_4242_SGIX 0x85A4
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_YCRCB_SGIX 0x8318
+#define GL_YCRCBA_SGIX 0x8319
+#endif
+
+#ifndef GL_SGI_depth_pass_instrument
+#define GL_DEPTH_PASS_INSTRUMENT_SGIX 0x8310
+#define GL_DEPTH_PASS_INSTRUMENT_COUNTERS_SGIX 0x8311
+#define GL_DEPTH_PASS_INSTRUMENT_MAX_SGIX 0x8312
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_COMPRESSED_RGB_FXT1_3DFX 0x86B0
+#define GL_COMPRESSED_RGBA_FXT1_3DFX 0x86B1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_MULTISAMPLE_3DFX 0x86B2
+#define GL_SAMPLE_BUFFERS_3DFX 0x86B3
+#define GL_SAMPLES_3DFX 0x86B4
+#define GL_MULTISAMPLE_BIT_3DFX 0x20000000
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#endif
+
+#ifndef GL_EXT_multisample
+#define GL_MULTISAMPLE_EXT 0x809D
+#define GL_SAMPLE_ALPHA_TO_MASK_EXT 0x809E
+#define GL_SAMPLE_ALPHA_TO_ONE_EXT 0x809F
+#define GL_SAMPLE_MASK_EXT 0x80A0
+#define GL_1PASS_EXT 0x80A1
+#define GL_2PASS_0_EXT 0x80A2
+#define GL_2PASS_1_EXT 0x80A3
+#define GL_4PASS_0_EXT 0x80A4
+#define GL_4PASS_1_EXT 0x80A5
+#define GL_4PASS_2_EXT 0x80A6
+#define GL_4PASS_3_EXT 0x80A7
+#define GL_SAMPLE_BUFFERS_EXT 0x80A8
+#define GL_SAMPLES_EXT 0x80A9
+#define GL_SAMPLE_MASK_VALUE_EXT 0x80AA
+#define GL_SAMPLE_MASK_INVERT_EXT 0x80AB
+#define GL_SAMPLE_PATTERN_EXT 0x80AC
+#define GL_MULTISAMPLE_BIT_EXT 0x20000000
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_VERTEX_PRECLIP_SGIX 0x83EE
+#define GL_VERTEX_PRECLIP_HINT_SGIX 0x83EF
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_CONVOLUTION_HINT_SGIX 0x8316
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_PACK_RESAMPLE_SGIX 0x842C
+#define GL_UNPACK_RESAMPLE_SGIX 0x842D
+#define GL_RESAMPLE_REPLICATE_SGIX 0x842E
+#define GL_RESAMPLE_ZERO_FILL_SGIX 0x842F
+#define GL_RESAMPLE_DECIMATE_SGIX 0x8430
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_EYE_DISTANCE_TO_POINT_SGIS 0x81F0
+#define GL_OBJECT_DISTANCE_TO_POINT_SGIS 0x81F1
+#define GL_EYE_DISTANCE_TO_LINE_SGIS 0x81F2
+#define GL_OBJECT_DISTANCE_TO_LINE_SGIS 0x81F3
+#define GL_EYE_POINT_SGIS 0x81F4
+#define GL_OBJECT_POINT_SGIS 0x81F5
+#define GL_EYE_LINE_SGIS 0x81F6
+#define GL_OBJECT_LINE_SGIS 0x81F7
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_TEXTURE_COLOR_WRITEMASK_SGIS 0x81EF
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_DOT3_RGB_EXT 0x8740
+#define GL_DOT3_RGBA_EXT 0x8741
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_MIRROR_CLAMP_ATI 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_ATI 0x8743
+#endif
+
+#ifndef GL_NV_fence
+#define GL_ALL_COMPLETED_NV 0x84F2
+#define GL_FENCE_STATUS_NV 0x84F3
+#define GL_FENCE_CONDITION_NV 0x84F4
+#endif
+
+#ifndef GL_IBM_texture_mirrored_repeat
+#define GL_MIRRORED_REPEAT_IBM 0x8370
+#endif
+
+#ifndef GL_NV_evaluators
+#define GL_EVAL_2D_NV 0x86C0
+#define GL_EVAL_TRIANGULAR_2D_NV 0x86C1
+#define GL_MAP_TESSELLATION_NV 0x86C2
+#define GL_MAP_ATTRIB_U_ORDER_NV 0x86C3
+#define GL_MAP_ATTRIB_V_ORDER_NV 0x86C4
+#define GL_EVAL_FRACTIONAL_TESSELLATION_NV 0x86C5
+#define GL_EVAL_VERTEX_ATTRIB0_NV 0x86C6
+#define GL_EVAL_VERTEX_ATTRIB1_NV 0x86C7
+#define GL_EVAL_VERTEX_ATTRIB2_NV 0x86C8
+#define GL_EVAL_VERTEX_ATTRIB3_NV 0x86C9
+#define GL_EVAL_VERTEX_ATTRIB4_NV 0x86CA
+#define GL_EVAL_VERTEX_ATTRIB5_NV 0x86CB
+#define GL_EVAL_VERTEX_ATTRIB6_NV 0x86CC
+#define GL_EVAL_VERTEX_ATTRIB7_NV 0x86CD
+#define GL_EVAL_VERTEX_ATTRIB8_NV 0x86CE
+#define GL_EVAL_VERTEX_ATTRIB9_NV 0x86CF
+#define GL_EVAL_VERTEX_ATTRIB10_NV 0x86D0
+#define GL_EVAL_VERTEX_ATTRIB11_NV 0x86D1
+#define GL_EVAL_VERTEX_ATTRIB12_NV 0x86D2
+#define GL_EVAL_VERTEX_ATTRIB13_NV 0x86D3
+#define GL_EVAL_VERTEX_ATTRIB14_NV 0x86D4
+#define GL_EVAL_VERTEX_ATTRIB15_NV 0x86D5
+#define GL_MAX_MAP_TESSELLATION_NV 0x86D6
+#define GL_MAX_RATIONAL_EVAL_ORDER_NV 0x86D7
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_DEPTH_STENCIL_NV 0x84F9
+#define GL_UNSIGNED_INT_24_8_NV 0x84FA
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_PER_STAGE_CONSTANTS_NV 0x8535
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#define GL_TEXTURE_RECTANGLE_NV 0x84F5
+#define GL_TEXTURE_BINDING_RECTANGLE_NV 0x84F6
+#define GL_PROXY_TEXTURE_RECTANGLE_NV 0x84F7
+#define GL_MAX_RECTANGLE_TEXTURE_SIZE_NV 0x84F8
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_OFFSET_TEXTURE_RECTANGLE_NV 0x864C
+#define GL_OFFSET_TEXTURE_RECTANGLE_SCALE_NV 0x864D
+#define GL_DOT_PRODUCT_TEXTURE_RECTANGLE_NV 0x864E
+#define GL_RGBA_UNSIGNED_DOT_PRODUCT_MAPPING_NV 0x86D9
+#define GL_UNSIGNED_INT_S8_S8_8_8_NV 0x86DA
+#define GL_UNSIGNED_INT_8_8_S8_S8_REV_NV 0x86DB
+#define GL_DSDT_MAG_INTENSITY_NV 0x86DC
+#define GL_SHADER_CONSISTENT_NV 0x86DD
+#define GL_TEXTURE_SHADER_NV 0x86DE
+#define GL_SHADER_OPERATION_NV 0x86DF
+#define GL_CULL_MODES_NV 0x86E0
+#define GL_OFFSET_TEXTURE_MATRIX_NV 0x86E1
+#define GL_OFFSET_TEXTURE_SCALE_NV 0x86E2
+#define GL_OFFSET_TEXTURE_BIAS_NV 0x86E3
+#define GL_OFFSET_TEXTURE_2D_MATRIX_NV GL_OFFSET_TEXTURE_MATRIX_NV
+#define GL_OFFSET_TEXTURE_2D_SCALE_NV GL_OFFSET_TEXTURE_SCALE_NV
+#define GL_OFFSET_TEXTURE_2D_BIAS_NV GL_OFFSET_TEXTURE_BIAS_NV
+#define GL_PREVIOUS_TEXTURE_INPUT_NV 0x86E4
+#define GL_CONST_EYE_NV 0x86E5
+#define GL_PASS_THROUGH_NV 0x86E6
+#define GL_CULL_FRAGMENT_NV 0x86E7
+#define GL_OFFSET_TEXTURE_2D_NV 0x86E8
+#define GL_DEPENDENT_AR_TEXTURE_2D_NV 0x86E9
+#define GL_DEPENDENT_GB_TEXTURE_2D_NV 0x86EA
+#define GL_DOT_PRODUCT_NV 0x86EC
+#define GL_DOT_PRODUCT_DEPTH_REPLACE_NV 0x86ED
+#define GL_DOT_PRODUCT_TEXTURE_2D_NV 0x86EE
+#define GL_DOT_PRODUCT_TEXTURE_CUBE_MAP_NV 0x86F0
+#define GL_DOT_PRODUCT_DIFFUSE_CUBE_MAP_NV 0x86F1
+#define GL_DOT_PRODUCT_REFLECT_CUBE_MAP_NV 0x86F2
+#define GL_DOT_PRODUCT_CONST_EYE_REFLECT_CUBE_MAP_NV 0x86F3
+#define GL_HILO_NV 0x86F4
+#define GL_DSDT_NV 0x86F5
+#define GL_DSDT_MAG_NV 0x86F6
+#define GL_DSDT_MAG_VIB_NV 0x86F7
+#define GL_HILO16_NV 0x86F8
+#define GL_SIGNED_HILO_NV 0x86F9
+#define GL_SIGNED_HILO16_NV 0x86FA
+#define GL_SIGNED_RGBA_NV 0x86FB
+#define GL_SIGNED_RGBA8_NV 0x86FC
+#define GL_SIGNED_RGB_NV 0x86FE
+#define GL_SIGNED_RGB8_NV 0x86FF
+#define GL_SIGNED_LUMINANCE_NV 0x8701
+#define GL_SIGNED_LUMINANCE8_NV 0x8702
+#define GL_SIGNED_LUMINANCE_ALPHA_NV 0x8703
+#define GL_SIGNED_LUMINANCE8_ALPHA8_NV 0x8704
+#define GL_SIGNED_ALPHA_NV 0x8705
+#define GL_SIGNED_ALPHA8_NV 0x8706
+#define GL_SIGNED_INTENSITY_NV 0x8707
+#define GL_SIGNED_INTENSITY8_NV 0x8708
+#define GL_DSDT8_NV 0x8709
+#define GL_DSDT8_MAG8_NV 0x870A
+#define GL_DSDT8_MAG8_INTENSITY8_NV 0x870B
+#define GL_SIGNED_RGB_UNSIGNED_ALPHA_NV 0x870C
+#define GL_SIGNED_RGB8_UNSIGNED_ALPHA8_NV 0x870D
+#define GL_HI_SCALE_NV 0x870E
+#define GL_LO_SCALE_NV 0x870F
+#define GL_DS_SCALE_NV 0x8710
+#define GL_DT_SCALE_NV 0x8711
+#define GL_MAGNITUDE_SCALE_NV 0x8712
+#define GL_VIBRANCE_SCALE_NV 0x8713
+#define GL_HI_BIAS_NV 0x8714
+#define GL_LO_BIAS_NV 0x8715
+#define GL_DS_BIAS_NV 0x8716
+#define GL_DT_BIAS_NV 0x8717
+#define GL_MAGNITUDE_BIAS_NV 0x8718
+#define GL_VIBRANCE_BIAS_NV 0x8719
+#define GL_TEXTURE_BORDER_VALUES_NV 0x871A
+#define GL_TEXTURE_HI_SIZE_NV 0x871B
+#define GL_TEXTURE_LO_SIZE_NV 0x871C
+#define GL_TEXTURE_DS_SIZE_NV 0x871D
+#define GL_TEXTURE_DT_SIZE_NV 0x871E
+#define GL_TEXTURE_MAG_SIZE_NV 0x871F
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_DOT_PRODUCT_TEXTURE_3D_NV 0x86EF
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_VERTEX_ARRAY_RANGE_WITHOUT_FLUSH_NV 0x8533
+#endif
+
+#ifndef GL_NV_vertex_program
+#define GL_VERTEX_PROGRAM_NV 0x8620
+#define GL_VERTEX_STATE_PROGRAM_NV 0x8621
+#define GL_ATTRIB_ARRAY_SIZE_NV 0x8623
+#define GL_ATTRIB_ARRAY_STRIDE_NV 0x8624
+#define GL_ATTRIB_ARRAY_TYPE_NV 0x8625
+#define GL_CURRENT_ATTRIB_NV 0x8626
+#define GL_PROGRAM_LENGTH_NV 0x8627
+#define GL_PROGRAM_STRING_NV 0x8628
+#define GL_MODELVIEW_PROJECTION_NV 0x8629
+#define GL_IDENTITY_NV 0x862A
+#define GL_INVERSE_NV 0x862B
+#define GL_TRANSPOSE_NV 0x862C
+#define GL_INVERSE_TRANSPOSE_NV 0x862D
+#define GL_MAX_TRACK_MATRIX_STACK_DEPTH_NV 0x862E
+#define GL_MAX_TRACK_MATRICES_NV 0x862F
+#define GL_MATRIX0_NV 0x8630
+#define GL_MATRIX1_NV 0x8631
+#define GL_MATRIX2_NV 0x8632
+#define GL_MATRIX3_NV 0x8633
+#define GL_MATRIX4_NV 0x8634
+#define GL_MATRIX5_NV 0x8635
+#define GL_MATRIX6_NV 0x8636
+#define GL_MATRIX7_NV 0x8637
+#define GL_CURRENT_MATRIX_STACK_DEPTH_NV 0x8640
+#define GL_CURRENT_MATRIX_NV 0x8641
+#define GL_VERTEX_PROGRAM_POINT_SIZE_NV 0x8642
+#define GL_VERTEX_PROGRAM_TWO_SIDE_NV 0x8643
+#define GL_PROGRAM_PARAMETER_NV 0x8644
+#define GL_ATTRIB_ARRAY_POINTER_NV 0x8645
+#define GL_PROGRAM_TARGET_NV 0x8646
+#define GL_PROGRAM_RESIDENT_NV 0x8647
+#define GL_TRACK_MATRIX_NV 0x8648
+#define GL_TRACK_MATRIX_TRANSFORM_NV 0x8649
+#define GL_VERTEX_PROGRAM_BINDING_NV 0x864A
+#define GL_PROGRAM_ERROR_POSITION_NV 0x864B
+#define GL_VERTEX_ATTRIB_ARRAY0_NV 0x8650
+#define GL_VERTEX_ATTRIB_ARRAY1_NV 0x8651
+#define GL_VERTEX_ATTRIB_ARRAY2_NV 0x8652
+#define GL_VERTEX_ATTRIB_ARRAY3_NV 0x8653
+#define GL_VERTEX_ATTRIB_ARRAY4_NV 0x8654
+#define GL_VERTEX_ATTRIB_ARRAY5_NV 0x8655
+#define GL_VERTEX_ATTRIB_ARRAY6_NV 0x8656
+#define GL_VERTEX_ATTRIB_ARRAY7_NV 0x8657
+#define GL_VERTEX_ATTRIB_ARRAY8_NV 0x8658
+#define GL_VERTEX_ATTRIB_ARRAY9_NV 0x8659
+#define GL_VERTEX_ATTRIB_ARRAY10_NV 0x865A
+#define GL_VERTEX_ATTRIB_ARRAY11_NV 0x865B
+#define GL_VERTEX_ATTRIB_ARRAY12_NV 0x865C
+#define GL_VERTEX_ATTRIB_ARRAY13_NV 0x865D
+#define GL_VERTEX_ATTRIB_ARRAY14_NV 0x865E
+#define GL_VERTEX_ATTRIB_ARRAY15_NV 0x865F
+#define GL_MAP1_VERTEX_ATTRIB0_4_NV 0x8660
+#define GL_MAP1_VERTEX_ATTRIB1_4_NV 0x8661
+#define GL_MAP1_VERTEX_ATTRIB2_4_NV 0x8662
+#define GL_MAP1_VERTEX_ATTRIB3_4_NV 0x8663
+#define GL_MAP1_VERTEX_ATTRIB4_4_NV 0x8664
+#define GL_MAP1_VERTEX_ATTRIB5_4_NV 0x8665
+#define GL_MAP1_VERTEX_ATTRIB6_4_NV 0x8666
+#define GL_MAP1_VERTEX_ATTRIB7_4_NV 0x8667
+#define GL_MAP1_VERTEX_ATTRIB8_4_NV 0x8668
+#define GL_MAP1_VERTEX_ATTRIB9_4_NV 0x8669
+#define GL_MAP1_VERTEX_ATTRIB10_4_NV 0x866A
+#define GL_MAP1_VERTEX_ATTRIB11_4_NV 0x866B
+#define GL_MAP1_VERTEX_ATTRIB12_4_NV 0x866C
+#define GL_MAP1_VERTEX_ATTRIB13_4_NV 0x866D
+#define GL_MAP1_VERTEX_ATTRIB14_4_NV 0x866E
+#define GL_MAP1_VERTEX_ATTRIB15_4_NV 0x866F
+#define GL_MAP2_VERTEX_ATTRIB0_4_NV 0x8670
+#define GL_MAP2_VERTEX_ATTRIB1_4_NV 0x8671
+#define GL_MAP2_VERTEX_ATTRIB2_4_NV 0x8672
+#define GL_MAP2_VERTEX_ATTRIB3_4_NV 0x8673
+#define GL_MAP2_VERTEX_ATTRIB4_4_NV 0x8674
+#define GL_MAP2_VERTEX_ATTRIB5_4_NV 0x8675
+#define GL_MAP2_VERTEX_ATTRIB6_4_NV 0x8676
+#define GL_MAP2_VERTEX_ATTRIB7_4_NV 0x8677
+#define GL_MAP2_VERTEX_ATTRIB8_4_NV 0x8678
+#define GL_MAP2_VERTEX_ATTRIB9_4_NV 0x8679
+#define GL_MAP2_VERTEX_ATTRIB10_4_NV 0x867A
+#define GL_MAP2_VERTEX_ATTRIB11_4_NV 0x867B
+#define GL_MAP2_VERTEX_ATTRIB12_4_NV 0x867C
+#define GL_MAP2_VERTEX_ATTRIB13_4_NV 0x867D
+#define GL_MAP2_VERTEX_ATTRIB14_4_NV 0x867E
+#define GL_MAP2_VERTEX_ATTRIB15_4_NV 0x867F
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_TEXTURE_MAX_CLAMP_S_SGIX 0x8369
+#define GL_TEXTURE_MAX_CLAMP_T_SGIX 0x836A
+#define GL_TEXTURE_MAX_CLAMP_R_SGIX 0x836B
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SCALEBIAS_HINT_SGIX 0x8322
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_INTERLACE_OML 0x8980
+#define GL_INTERLACE_READ_OML 0x8981
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_FORMAT_SUBSAMPLE_24_24_OML 0x8982
+#define GL_FORMAT_SUBSAMPLE_244_244_OML 0x8983
+#endif
+
+#ifndef GL_OML_resample
+#define GL_PACK_RESAMPLE_OML 0x8984
+#define GL_UNPACK_RESAMPLE_OML 0x8985
+#define GL_RESAMPLE_REPLICATE_OML 0x8986
+#define GL_RESAMPLE_ZERO_FILL_OML 0x8987
+#define GL_RESAMPLE_AVERAGE_OML 0x8988
+#define GL_RESAMPLE_DECIMATE_OML 0x8989
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_DEPTH_STENCIL_TO_RGBA_NV 0x886E
+#define GL_DEPTH_STENCIL_TO_BGRA_NV 0x886F
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#define GL_BUMP_ROT_MATRIX_ATI 0x8775
+#define GL_BUMP_ROT_MATRIX_SIZE_ATI 0x8776
+#define GL_BUMP_NUM_TEX_UNITS_ATI 0x8777
+#define GL_BUMP_TEX_UNITS_ATI 0x8778
+#define GL_DUDV_ATI 0x8779
+#define GL_DU8DV8_ATI 0x877A
+#define GL_BUMP_ENVMAP_ATI 0x877B
+#define GL_BUMP_TARGET_ATI 0x877C
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#define GL_FRAGMENT_SHADER_ATI 0x8920
+#define GL_REG_0_ATI 0x8921
+#define GL_REG_1_ATI 0x8922
+#define GL_REG_2_ATI 0x8923
+#define GL_REG_3_ATI 0x8924
+#define GL_REG_4_ATI 0x8925
+#define GL_REG_5_ATI 0x8926
+#define GL_REG_6_ATI 0x8927
+#define GL_REG_7_ATI 0x8928
+#define GL_REG_8_ATI 0x8929
+#define GL_REG_9_ATI 0x892A
+#define GL_REG_10_ATI 0x892B
+#define GL_REG_11_ATI 0x892C
+#define GL_REG_12_ATI 0x892D
+#define GL_REG_13_ATI 0x892E
+#define GL_REG_14_ATI 0x892F
+#define GL_REG_15_ATI 0x8930
+#define GL_REG_16_ATI 0x8931
+#define GL_REG_17_ATI 0x8932
+#define GL_REG_18_ATI 0x8933
+#define GL_REG_19_ATI 0x8934
+#define GL_REG_20_ATI 0x8935
+#define GL_REG_21_ATI 0x8936
+#define GL_REG_22_ATI 0x8937
+#define GL_REG_23_ATI 0x8938
+#define GL_REG_24_ATI 0x8939
+#define GL_REG_25_ATI 0x893A
+#define GL_REG_26_ATI 0x893B
+#define GL_REG_27_ATI 0x893C
+#define GL_REG_28_ATI 0x893D
+#define GL_REG_29_ATI 0x893E
+#define GL_REG_30_ATI 0x893F
+#define GL_REG_31_ATI 0x8940
+#define GL_CON_0_ATI 0x8941
+#define GL_CON_1_ATI 0x8942
+#define GL_CON_2_ATI 0x8943
+#define GL_CON_3_ATI 0x8944
+#define GL_CON_4_ATI 0x8945
+#define GL_CON_5_ATI 0x8946
+#define GL_CON_6_ATI 0x8947
+#define GL_CON_7_ATI 0x8948
+#define GL_CON_8_ATI 0x8949
+#define GL_CON_9_ATI 0x894A
+#define GL_CON_10_ATI 0x894B
+#define GL_CON_11_ATI 0x894C
+#define GL_CON_12_ATI 0x894D
+#define GL_CON_13_ATI 0x894E
+#define GL_CON_14_ATI 0x894F
+#define GL_CON_15_ATI 0x8950
+#define GL_CON_16_ATI 0x8951
+#define GL_CON_17_ATI 0x8952
+#define GL_CON_18_ATI 0x8953
+#define GL_CON_19_ATI 0x8954
+#define GL_CON_20_ATI 0x8955
+#define GL_CON_21_ATI 0x8956
+#define GL_CON_22_ATI 0x8957
+#define GL_CON_23_ATI 0x8958
+#define GL_CON_24_ATI 0x8959
+#define GL_CON_25_ATI 0x895A
+#define GL_CON_26_ATI 0x895B
+#define GL_CON_27_ATI 0x895C
+#define GL_CON_28_ATI 0x895D
+#define GL_CON_29_ATI 0x895E
+#define GL_CON_30_ATI 0x895F
+#define GL_CON_31_ATI 0x8960
+#define GL_MOV_ATI 0x8961
+#define GL_ADD_ATI 0x8963
+#define GL_MUL_ATI 0x8964
+#define GL_SUB_ATI 0x8965
+#define GL_DOT3_ATI 0x8966
+#define GL_DOT4_ATI 0x8967
+#define GL_MAD_ATI 0x8968
+#define GL_LERP_ATI 0x8969
+#define GL_CND_ATI 0x896A
+#define GL_CND0_ATI 0x896B
+#define GL_DOT2_ADD_ATI 0x896C
+#define GL_SECONDARY_INTERPOLATOR_ATI 0x896D
+#define GL_NUM_FRAGMENT_REGISTERS_ATI 0x896E
+#define GL_NUM_FRAGMENT_CONSTANTS_ATI 0x896F
+#define GL_NUM_PASSES_ATI 0x8970
+#define GL_NUM_INSTRUCTIONS_PER_PASS_ATI 0x8971
+#define GL_NUM_INSTRUCTIONS_TOTAL_ATI 0x8972
+#define GL_NUM_INPUT_INTERPOLATOR_COMPONENTS_ATI 0x8973
+#define GL_NUM_LOOPBACK_COMPONENTS_ATI 0x8974
+#define GL_COLOR_ALPHA_PAIRING_ATI 0x8975
+#define GL_SWIZZLE_STR_ATI 0x8976
+#define GL_SWIZZLE_STQ_ATI 0x8977
+#define GL_SWIZZLE_STR_DR_ATI 0x8978
+#define GL_SWIZZLE_STQ_DQ_ATI 0x8979
+#define GL_SWIZZLE_STRQ_ATI 0x897A
+#define GL_SWIZZLE_STRQ_DQ_ATI 0x897B
+#define GL_RED_BIT_ATI 0x00000001
+#define GL_GREEN_BIT_ATI 0x00000002
+#define GL_BLUE_BIT_ATI 0x00000004
+#define GL_2X_BIT_ATI 0x00000001
+#define GL_4X_BIT_ATI 0x00000002
+#define GL_8X_BIT_ATI 0x00000004
+#define GL_HALF_BIT_ATI 0x00000008
+#define GL_QUARTER_BIT_ATI 0x00000010
+#define GL_EIGHTH_BIT_ATI 0x00000020
+#define GL_SATURATE_BIT_ATI 0x00000040
+#define GL_COMP_BIT_ATI 0x00000002
+#define GL_NEGATE_BIT_ATI 0x00000004
+#define GL_BIAS_BIT_ATI 0x00000008
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#define GL_PN_TRIANGLES_ATI 0x87F0
+#define GL_MAX_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F1
+#define GL_PN_TRIANGLES_POINT_MODE_ATI 0x87F2
+#define GL_PN_TRIANGLES_NORMAL_MODE_ATI 0x87F3
+#define GL_PN_TRIANGLES_TESSELATION_LEVEL_ATI 0x87F4
+#define GL_PN_TRIANGLES_POINT_MODE_LINEAR_ATI 0x87F5
+#define GL_PN_TRIANGLES_POINT_MODE_CUBIC_ATI 0x87F6
+#define GL_PN_TRIANGLES_NORMAL_MODE_LINEAR_ATI 0x87F7
+#define GL_PN_TRIANGLES_NORMAL_MODE_QUADRATIC_ATI 0x87F8
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#define GL_STATIC_ATI 0x8760
+#define GL_DYNAMIC_ATI 0x8761
+#define GL_PRESERVE_ATI 0x8762
+#define GL_DISCARD_ATI 0x8763
+#define GL_OBJECT_BUFFER_SIZE_ATI 0x8764
+#define GL_OBJECT_BUFFER_USAGE_ATI 0x8765
+#define GL_ARRAY_OBJECT_BUFFER_ATI 0x8766
+#define GL_ARRAY_OBJECT_OFFSET_ATI 0x8767
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#define GL_VERTEX_SHADER_EXT 0x8780
+#define GL_VERTEX_SHADER_BINDING_EXT 0x8781
+#define GL_OP_INDEX_EXT 0x8782
+#define GL_OP_NEGATE_EXT 0x8783
+#define GL_OP_DOT3_EXT 0x8784
+#define GL_OP_DOT4_EXT 0x8785
+#define GL_OP_MUL_EXT 0x8786
+#define GL_OP_ADD_EXT 0x8787
+#define GL_OP_MADD_EXT 0x8788
+#define GL_OP_FRAC_EXT 0x8789
+#define GL_OP_MAX_EXT 0x878A
+#define GL_OP_MIN_EXT 0x878B
+#define GL_OP_SET_GE_EXT 0x878C
+#define GL_OP_SET_LT_EXT 0x878D
+#define GL_OP_CLAMP_EXT 0x878E
+#define GL_OP_FLOOR_EXT 0x878F
+#define GL_OP_ROUND_EXT 0x8790
+#define GL_OP_EXP_BASE_2_EXT 0x8791
+#define GL_OP_LOG_BASE_2_EXT 0x8792
+#define GL_OP_POWER_EXT 0x8793
+#define GL_OP_RECIP_EXT 0x8794
+#define GL_OP_RECIP_SQRT_EXT 0x8795
+#define GL_OP_SUB_EXT 0x8796
+#define GL_OP_CROSS_PRODUCT_EXT 0x8797
+#define GL_OP_MULTIPLY_MATRIX_EXT 0x8798
+#define GL_OP_MOV_EXT 0x8799
+#define GL_OUTPUT_VERTEX_EXT 0x879A
+#define GL_OUTPUT_COLOR0_EXT 0x879B
+#define GL_OUTPUT_COLOR1_EXT 0x879C
+#define GL_OUTPUT_TEXTURE_COORD0_EXT 0x879D
+#define GL_OUTPUT_TEXTURE_COORD1_EXT 0x879E
+#define GL_OUTPUT_TEXTURE_COORD2_EXT 0x879F
+#define GL_OUTPUT_TEXTURE_COORD3_EXT 0x87A0
+#define GL_OUTPUT_TEXTURE_COORD4_EXT 0x87A1
+#define GL_OUTPUT_TEXTURE_COORD5_EXT 0x87A2
+#define GL_OUTPUT_TEXTURE_COORD6_EXT 0x87A3
+#define GL_OUTPUT_TEXTURE_COORD7_EXT 0x87A4
+#define GL_OUTPUT_TEXTURE_COORD8_EXT 0x87A5
+#define GL_OUTPUT_TEXTURE_COORD9_EXT 0x87A6
+#define GL_OUTPUT_TEXTURE_COORD10_EXT 0x87A7
+#define GL_OUTPUT_TEXTURE_COORD11_EXT 0x87A8
+#define GL_OUTPUT_TEXTURE_COORD12_EXT 0x87A9
+#define GL_OUTPUT_TEXTURE_COORD13_EXT 0x87AA
+#define GL_OUTPUT_TEXTURE_COORD14_EXT 0x87AB
+#define GL_OUTPUT_TEXTURE_COORD15_EXT 0x87AC
+#define GL_OUTPUT_TEXTURE_COORD16_EXT 0x87AD
+#define GL_OUTPUT_TEXTURE_COORD17_EXT 0x87AE
+#define GL_OUTPUT_TEXTURE_COORD18_EXT 0x87AF
+#define GL_OUTPUT_TEXTURE_COORD19_EXT 0x87B0
+#define GL_OUTPUT_TEXTURE_COORD20_EXT 0x87B1
+#define GL_OUTPUT_TEXTURE_COORD21_EXT 0x87B2
+#define GL_OUTPUT_TEXTURE_COORD22_EXT 0x87B3
+#define GL_OUTPUT_TEXTURE_COORD23_EXT 0x87B4
+#define GL_OUTPUT_TEXTURE_COORD24_EXT 0x87B5
+#define GL_OUTPUT_TEXTURE_COORD25_EXT 0x87B6
+#define GL_OUTPUT_TEXTURE_COORD26_EXT 0x87B7
+#define GL_OUTPUT_TEXTURE_COORD27_EXT 0x87B8
+#define GL_OUTPUT_TEXTURE_COORD28_EXT 0x87B9
+#define GL_OUTPUT_TEXTURE_COORD29_EXT 0x87BA
+#define GL_OUTPUT_TEXTURE_COORD30_EXT 0x87BB
+#define GL_OUTPUT_TEXTURE_COORD31_EXT 0x87BC
+#define GL_OUTPUT_FOG_EXT 0x87BD
+#define GL_SCALAR_EXT 0x87BE
+#define GL_VECTOR_EXT 0x87BF
+#define GL_MATRIX_EXT 0x87C0
+#define GL_VARIANT_EXT 0x87C1
+#define GL_INVARIANT_EXT 0x87C2
+#define GL_LOCAL_CONSTANT_EXT 0x87C3
+#define GL_LOCAL_EXT 0x87C4
+#define GL_MAX_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87C5
+#define GL_MAX_VERTEX_SHADER_VARIANTS_EXT 0x87C6
+#define GL_MAX_VERTEX_SHADER_INVARIANTS_EXT 0x87C7
+#define GL_MAX_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87C8
+#define GL_MAX_VERTEX_SHADER_LOCALS_EXT 0x87C9
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CA
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_VARIANTS_EXT 0x87CB
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87CC
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_INVARIANTS_EXT 0x87CD
+#define GL_MAX_OPTIMIZED_VERTEX_SHADER_LOCALS_EXT 0x87CE
+#define GL_VERTEX_SHADER_INSTRUCTIONS_EXT 0x87CF
+#define GL_VERTEX_SHADER_VARIANTS_EXT 0x87D0
+#define GL_VERTEX_SHADER_INVARIANTS_EXT 0x87D1
+#define GL_VERTEX_SHADER_LOCAL_CONSTANTS_EXT 0x87D2
+#define GL_VERTEX_SHADER_LOCALS_EXT 0x87D3
+#define GL_VERTEX_SHADER_OPTIMIZED_EXT 0x87D4
+#define GL_X_EXT 0x87D5
+#define GL_Y_EXT 0x87D6
+#define GL_Z_EXT 0x87D7
+#define GL_W_EXT 0x87D8
+#define GL_NEGATIVE_X_EXT 0x87D9
+#define GL_NEGATIVE_Y_EXT 0x87DA
+#define GL_NEGATIVE_Z_EXT 0x87DB
+#define GL_NEGATIVE_W_EXT 0x87DC
+#define GL_ZERO_EXT 0x87DD
+#define GL_ONE_EXT 0x87DE
+#define GL_NEGATIVE_ONE_EXT 0x87DF
+#define GL_NORMALIZED_RANGE_EXT 0x87E0
+#define GL_FULL_RANGE_EXT 0x87E1
+#define GL_CURRENT_VERTEX_EXT 0x87E2
+#define GL_MVP_MATRIX_EXT 0x87E3
+#define GL_VARIANT_VALUE_EXT 0x87E4
+#define GL_VARIANT_DATATYPE_EXT 0x87E5
+#define GL_VARIANT_ARRAY_STRIDE_EXT 0x87E6
+#define GL_VARIANT_ARRAY_TYPE_EXT 0x87E7
+#define GL_VARIANT_ARRAY_EXT 0x87E8
+#define GL_VARIANT_ARRAY_POINTER_EXT 0x87E9
+#define GL_INVARIANT_VALUE_EXT 0x87EA
+#define GL_INVARIANT_DATATYPE_EXT 0x87EB
+#define GL_LOCAL_CONSTANT_VALUE_EXT 0x87EC
+#define GL_LOCAL_CONSTANT_DATATYPE_EXT 0x87ED
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_MAX_VERTEX_STREAMS_ATI 0x876B
+#define GL_VERTEX_STREAM0_ATI 0x876C
+#define GL_VERTEX_STREAM1_ATI 0x876D
+#define GL_VERTEX_STREAM2_ATI 0x876E
+#define GL_VERTEX_STREAM3_ATI 0x876F
+#define GL_VERTEX_STREAM4_ATI 0x8770
+#define GL_VERTEX_STREAM5_ATI 0x8771
+#define GL_VERTEX_STREAM6_ATI 0x8772
+#define GL_VERTEX_STREAM7_ATI 0x8773
+#define GL_VERTEX_SOURCE_ATI 0x8774
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ELEMENT_ARRAY_ATI 0x8768
+#define GL_ELEMENT_ARRAY_TYPE_ATI 0x8769
+#define GL_ELEMENT_ARRAY_POINTER_ATI 0x876A
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_QUAD_MESH_SUN 0x8614
+#define GL_TRIANGLE_MESH_SUN 0x8615
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SLICE_ACCUM_SUN 0x85CC
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_MULTISAMPLE_FILTER_HINT_NV 0x8534
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_DEPTH_CLAMP_NV 0x864F
+#endif
+
+#ifndef GL_NV_occlusion_query
+#define GL_PIXEL_COUNTER_BITS_NV 0x8864
+#define GL_CURRENT_OCCLUSION_QUERY_ID_NV 0x8865
+#define GL_PIXEL_COUNT_NV 0x8866
+#define GL_PIXEL_COUNT_AVAILABLE_NV 0x8867
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_POINT_SPRITE_NV 0x8861
+#define GL_COORD_REPLACE_NV 0x8862
+#define GL_POINT_SPRITE_R_MODE_NV 0x8863
+#endif
+
+#ifndef GL_NV_texture_shader3
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_NV 0x8850
+#define GL_OFFSET_PROJECTIVE_TEXTURE_2D_SCALE_NV 0x8851
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8852
+#define GL_OFFSET_PROJECTIVE_TEXTURE_RECTANGLE_SCALE_NV 0x8853
+#define GL_OFFSET_HILO_TEXTURE_2D_NV 0x8854
+#define GL_OFFSET_HILO_TEXTURE_RECTANGLE_NV 0x8855
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_2D_NV 0x8856
+#define GL_OFFSET_HILO_PROJECTIVE_TEXTURE_RECTANGLE_NV 0x8857
+#define GL_DEPENDENT_HILO_TEXTURE_2D_NV 0x8858
+#define GL_DEPENDENT_RGB_TEXTURE_3D_NV 0x8859
+#define GL_DEPENDENT_RGB_TEXTURE_CUBE_MAP_NV 0x885A
+#define GL_DOT_PRODUCT_PASS_THROUGH_NV 0x885B
+#define GL_DOT_PRODUCT_TEXTURE_1D_NV 0x885C
+#define GL_DOT_PRODUCT_AFFINE_DEPTH_REPLACE_NV 0x885D
+#define GL_HILO8_NV 0x885E
+#define GL_SIGNED_HILO8_NV 0x885F
+#define GL_FORCE_BLUE_TO_ONE_NV 0x8860
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_STENCIL_TEST_TWO_SIDE_EXT 0x8910
+#define GL_ACTIVE_STENCIL_FACE_EXT 0x8911
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_TEXT_FRAGMENT_SHADER_ATI 0x8200
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_UNPACK_CLIENT_STORAGE_APPLE 0x85B2
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_ELEMENT_ARRAY_APPLE 0x8768
+#define GL_ELEMENT_ARRAY_TYPE_APPLE 0x8769
+#define GL_ELEMENT_ARRAY_POINTER_APPLE 0x876A
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_DRAW_PIXELS_APPLE 0x8A0A
+#define GL_FENCE_APPLE 0x8A0B
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_VERTEX_ARRAY_BINDING_APPLE 0x85B5
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#define GL_VERTEX_ARRAY_RANGE_APPLE 0x851D
+#define GL_VERTEX_ARRAY_RANGE_LENGTH_APPLE 0x851E
+#define GL_VERTEX_ARRAY_STORAGE_HINT_APPLE 0x851F
+#define GL_VERTEX_ARRAY_RANGE_POINTER_APPLE 0x8521
+#define GL_STORAGE_CACHED_APPLE 0x85BE
+#define GL_STORAGE_SHARED_APPLE 0x85BF
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_YCBCR_422_APPLE 0x85B9
+#define GL_UNSIGNED_SHORT_8_8_APPLE 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_APPLE 0x85BB
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_RGB_S3TC 0x83A0
+#define GL_RGB4_S3TC 0x83A1
+#define GL_RGBA_S3TC 0x83A2
+#define GL_RGBA4_S3TC 0x83A3
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#define GL_MAX_DRAW_BUFFERS_ATI 0x8824
+#define GL_DRAW_BUFFER0_ATI 0x8825
+#define GL_DRAW_BUFFER1_ATI 0x8826
+#define GL_DRAW_BUFFER2_ATI 0x8827
+#define GL_DRAW_BUFFER3_ATI 0x8828
+#define GL_DRAW_BUFFER4_ATI 0x8829
+#define GL_DRAW_BUFFER5_ATI 0x882A
+#define GL_DRAW_BUFFER6_ATI 0x882B
+#define GL_DRAW_BUFFER7_ATI 0x882C
+#define GL_DRAW_BUFFER8_ATI 0x882D
+#define GL_DRAW_BUFFER9_ATI 0x882E
+#define GL_DRAW_BUFFER10_ATI 0x882F
+#define GL_DRAW_BUFFER11_ATI 0x8830
+#define GL_DRAW_BUFFER12_ATI 0x8831
+#define GL_DRAW_BUFFER13_ATI 0x8832
+#define GL_DRAW_BUFFER14_ATI 0x8833
+#define GL_DRAW_BUFFER15_ATI 0x8834
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_TYPE_RGBA_FLOAT_ATI 0x8820
+#define GL_COLOR_CLEAR_UNCLAMPED_VALUE_ATI 0x8835
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_MODULATE_ADD_ATI 0x8744
+#define GL_MODULATE_SIGNED_ADD_ATI 0x8745
+#define GL_MODULATE_SUBTRACT_ATI 0x8746
+#endif
+
+#ifndef GL_ATI_texture_float
+#define GL_RGBA_FLOAT32_ATI 0x8814
+#define GL_RGB_FLOAT32_ATI 0x8815
+#define GL_ALPHA_FLOAT32_ATI 0x8816
+#define GL_INTENSITY_FLOAT32_ATI 0x8817
+#define GL_LUMINANCE_FLOAT32_ATI 0x8818
+#define GL_LUMINANCE_ALPHA_FLOAT32_ATI 0x8819
+#define GL_RGBA_FLOAT16_ATI 0x881A
+#define GL_RGB_FLOAT16_ATI 0x881B
+#define GL_ALPHA_FLOAT16_ATI 0x881C
+#define GL_INTENSITY_FLOAT16_ATI 0x881D
+#define GL_LUMINANCE_FLOAT16_ATI 0x881E
+#define GL_LUMINANCE_ALPHA_FLOAT16_ATI 0x881F
+#endif
+
+#ifndef GL_NV_float_buffer
+#define GL_FLOAT_R_NV 0x8880
+#define GL_FLOAT_RG_NV 0x8881
+#define GL_FLOAT_RGB_NV 0x8882
+#define GL_FLOAT_RGBA_NV 0x8883
+#define GL_FLOAT_R16_NV 0x8884
+#define GL_FLOAT_R32_NV 0x8885
+#define GL_FLOAT_RG16_NV 0x8886
+#define GL_FLOAT_RG32_NV 0x8887
+#define GL_FLOAT_RGB16_NV 0x8888
+#define GL_FLOAT_RGB32_NV 0x8889
+#define GL_FLOAT_RGBA16_NV 0x888A
+#define GL_FLOAT_RGBA32_NV 0x888B
+#define GL_TEXTURE_FLOAT_COMPONENTS_NV 0x888C
+#define GL_FLOAT_CLEAR_COLOR_VALUE_NV 0x888D
+#define GL_FLOAT_RGBA_MODE_NV 0x888E
+#endif
+
+#ifndef GL_NV_fragment_program
+#define GL_MAX_FRAGMENT_PROGRAM_LOCAL_PARAMETERS_NV 0x8868
+#define GL_FRAGMENT_PROGRAM_NV 0x8870
+#define GL_MAX_TEXTURE_COORDS_NV 0x8871
+#define GL_MAX_TEXTURE_IMAGE_UNITS_NV 0x8872
+#define GL_FRAGMENT_PROGRAM_BINDING_NV 0x8873
+#define GL_PROGRAM_ERROR_STRING_NV 0x8874
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_HALF_FLOAT_NV 0x140B
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#define GL_WRITE_PIXEL_DATA_RANGE_NV 0x8878
+#define GL_READ_PIXEL_DATA_RANGE_NV 0x8879
+#define GL_WRITE_PIXEL_DATA_RANGE_LENGTH_NV 0x887A
+#define GL_READ_PIXEL_DATA_RANGE_LENGTH_NV 0x887B
+#define GL_WRITE_PIXEL_DATA_RANGE_POINTER_NV 0x887C
+#define GL_READ_PIXEL_DATA_RANGE_POINTER_NV 0x887D
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_PRIMITIVE_RESTART_NV 0x8558
+#define GL_PRIMITIVE_RESTART_INDEX_NV 0x8559
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_TEXTURE_UNSIGNED_REMAP_MODE_NV 0x888F
+#endif
+
+#ifndef GL_NV_vertex_program2
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#define GL_STENCIL_BACK_FUNC_ATI 0x8800
+#define GL_STENCIL_BACK_FAIL_ATI 0x8801
+#define GL_STENCIL_BACK_PASS_DEPTH_FAIL_ATI 0x8802
+#define GL_STENCIL_BACK_PASS_DEPTH_PASS_ATI 0x8803
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A
+#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_DEPTH_BOUNDS_TEST_EXT 0x8890
+#define GL_DEPTH_BOUNDS_EXT 0x8891
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_MIRROR_CLAMP_EXT 0x8742
+#define GL_MIRROR_CLAMP_TO_EDGE_EXT 0x8743
+#define GL_MIRROR_CLAMP_TO_BORDER_EXT 0x8912
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_BLEND_EQUATION_RGB_EXT GL_BLEND_EQUATION
+#define GL_BLEND_EQUATION_ALPHA_EXT 0x883D
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_PACK_INVERT_MESA 0x8758
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_UNSIGNED_SHORT_8_8_MESA 0x85BA
+#define GL_UNSIGNED_SHORT_8_8_REV_MESA 0x85BB
+#define GL_YCBCR_MESA 0x8757
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_PIXEL_PACK_BUFFER_EXT 0x88EB
+#define GL_PIXEL_UNPACK_BUFFER_EXT 0x88EC
+#define GL_PIXEL_PACK_BUFFER_BINDING_EXT 0x88ED
+#define GL_PIXEL_UNPACK_BUFFER_BINDING_EXT 0x88EF
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV 0x88F4
+#define GL_MAX_PROGRAM_CALL_DEPTH_NV 0x88F5
+#define GL_MAX_PROGRAM_IF_DEPTH_NV 0x88F6
+#define GL_MAX_PROGRAM_LOOP_DEPTH_NV 0x88F7
+#define GL_MAX_PROGRAM_LOOP_COUNT_NV 0x88F8
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+/* reuse GL_MAX_PROGRAM_EXEC_INSTRUCTIONS_NV */
+/* reuse GL_MAX_PROGRAM_CALL_DEPTH_NV */
+#endif
+
+#ifndef GL_NV_vertex_program3
+/* reuse GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS_ARB */
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506
+#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8
+#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6
+#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0
+#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4
+#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5
+#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6
+#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7
+#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9
+#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA
+#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB
+#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC
+#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD
+#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF
+#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0
+#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1
+#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2
+#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3
+#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4
+#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5
+#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6
+#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7
+#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8
+#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9
+#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA
+#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB
+#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC
+#define GL_COLOR_ATTACHMENT13_EXT 0x8CED
+#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE
+#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF
+#define GL_DEPTH_ATTACHMENT_EXT 0x8D00
+#define GL_STENCIL_ATTACHMENT_EXT 0x8D20
+#define GL_FRAMEBUFFER_EXT 0x8D40
+#define GL_RENDERBUFFER_EXT 0x8D41
+#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42
+#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43
+#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44
+#define GL_STENCIL_INDEX1_EXT 0x8D46
+#define GL_STENCIL_INDEX4_EXT 0x8D47
+#define GL_STENCIL_INDEX8_EXT 0x8D48
+#define GL_STENCIL_INDEX16_EXT 0x8D49
+#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50
+#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51
+#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52
+#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53
+#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54
+#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#endif
+
+#ifndef GL_EXT_packed_depth_stencil
+#define GL_DEPTH_STENCIL_EXT 0x84F9
+#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
+#define GL_DEPTH24_STENCIL8_EXT 0x88F0
+#define GL_TEXTURE_STENCIL_SIZE_EXT 0x88F1
+#endif
+
+#ifndef GL_EXT_stencil_clear_tag
+#define GL_STENCIL_TAG_BITS_EXT 0x88F2
+#define GL_STENCIL_CLEAR_TAG_VALUE_EXT 0x88F3
+#endif
+
+#ifndef GL_EXT_texture_sRGB
+#define GL_SRGB_EXT 0x8C40
+#define GL_SRGB8_EXT 0x8C41
+#define GL_SRGB_ALPHA_EXT 0x8C42
+#define GL_SRGB8_ALPHA8_EXT 0x8C43
+#define GL_SLUMINANCE_ALPHA_EXT 0x8C44
+#define GL_SLUMINANCE8_ALPHA8_EXT 0x8C45
+#define GL_SLUMINANCE_EXT 0x8C46
+#define GL_SLUMINANCE8_EXT 0x8C47
+#define GL_COMPRESSED_SRGB_EXT 0x8C48
+#define GL_COMPRESSED_SRGB_ALPHA_EXT 0x8C49
+#define GL_COMPRESSED_SLUMINANCE_EXT 0x8C4A
+#define GL_COMPRESSED_SLUMINANCE_ALPHA_EXT 0x8C4B
+#define GL_COMPRESSED_SRGB_S3TC_DXT1_EXT 0x8C4C
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT 0x8C4D
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT 0x8C4E
+#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
+#endif
+
+#ifndef GL_EXT_framebuffer_blit
+#define GL_READ_FRAMEBUFFER_EXT 0x8CA8
+#define GL_DRAW_FRAMEBUFFER_EXT 0x8CA9
+#define GL_DRAW_FRAMEBUFFER_BINDING_EXT GL_FRAMEBUFFER_BINDING_EXT
+#define GL_READ_FRAMEBUFFER_BINDING_EXT 0x8CAA
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_RENDERBUFFER_SAMPLES_EXT 0x8CAB
+#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56
+#define GL_MAX_SAMPLES_EXT 0x8D57
+#endif
+
+#ifndef GL_MESAX_texture_stack
+#define GL_TEXTURE_1D_STACK_MESAX 0x8759
+#define GL_TEXTURE_2D_STACK_MESAX 0x875A
+#define GL_PROXY_TEXTURE_1D_STACK_MESAX 0x875B
+#define GL_PROXY_TEXTURE_2D_STACK_MESAX 0x875C
+#define GL_TEXTURE_1D_STACK_BINDING_MESAX 0x875D
+#define GL_TEXTURE_2D_STACK_BINDING_MESAX 0x875E
+#endif
+
+#ifndef GL_EXT_timer_query
+#define GL_TIME_ELAPSED_EXT 0x88BF
+#endif
+
+#ifndef GL_EXT_gpu_program_parameters
+#endif
+
+#ifndef GL_APPLE_flush_buffer_range
+#define GL_BUFFER_SERIALIZED_MODIFY_APPLE 0x8A12
+#define GL_BUFFER_FLUSHING_UNMAP_APPLE 0x8A13
+#endif
+
+#ifndef GL_NV_gpu_program4
+#define GL_MIN_PROGRAM_TEXEL_OFFSET_NV 0x8904
+#define GL_MAX_PROGRAM_TEXEL_OFFSET_NV 0x8905
+#define GL_PROGRAM_ATTRIB_COMPONENTS_NV 0x8906
+#define GL_PROGRAM_RESULT_COMPONENTS_NV 0x8907
+#define GL_MAX_PROGRAM_ATTRIB_COMPONENTS_NV 0x8908
+#define GL_MAX_PROGRAM_RESULT_COMPONENTS_NV 0x8909
+#define GL_MAX_PROGRAM_GENERIC_ATTRIBS_NV 0x8DA5
+#define GL_MAX_PROGRAM_GENERIC_RESULTS_NV 0x8DA6
+#endif
+
+#ifndef GL_NV_geometry_program4
+#define GL_LINES_ADJACENCY_EXT 0x000A
+#define GL_LINE_STRIP_ADJACENCY_EXT 0x000B
+#define GL_TRIANGLES_ADJACENCY_EXT 0x000C
+#define GL_TRIANGLE_STRIP_ADJACENCY_EXT 0x000D
+#define GL_GEOMETRY_PROGRAM_NV 0x8C26
+#define GL_MAX_PROGRAM_OUTPUT_VERTICES_NV 0x8C27
+#define GL_MAX_PROGRAM_TOTAL_OUTPUT_COMPONENTS_NV 0x8C28
+#define GL_GEOMETRY_VERTICES_OUT_EXT 0x8DDA
+#define GL_GEOMETRY_INPUT_TYPE_EXT 0x8DDB
+#define GL_GEOMETRY_OUTPUT_TYPE_EXT 0x8DDC
+#define GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT 0x8C29
+#define GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT 0x8DA7
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT 0x8DA8
+#define GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT 0x8DA9
+#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT 0x8CD4
+#define GL_PROGRAM_POINT_SIZE_EXT 0x8642
+#endif
+
+#ifndef GL_EXT_geometry_shader4
+#define GL_GEOMETRY_SHADER_EXT 0x8DD9
+/* reuse GL_GEOMETRY_VERTICES_OUT_EXT */
+/* reuse GL_GEOMETRY_INPUT_TYPE_EXT */
+/* reuse GL_GEOMETRY_OUTPUT_TYPE_EXT */
+/* reuse GL_MAX_GEOMETRY_TEXTURE_IMAGE_UNITS_EXT */
+#define GL_MAX_GEOMETRY_VARYING_COMPONENTS_EXT 0x8DDD
+#define GL_MAX_VERTEX_VARYING_COMPONENTS_EXT 0x8DDE
+#define GL_MAX_VARYING_COMPONENTS_EXT 0x8B4B
+#define GL_MAX_GEOMETRY_UNIFORM_COMPONENTS_EXT 0x8DDF
+#define GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT 0x8DE0
+#define GL_MAX_GEOMETRY_TOTAL_OUTPUT_COMPONENTS_EXT 0x8DE1
+/* reuse GL_LINES_ADJACENCY_EXT */
+/* reuse GL_LINE_STRIP_ADJACENCY_EXT */
+/* reuse GL_TRIANGLES_ADJACENCY_EXT */
+/* reuse GL_TRIANGLE_STRIP_ADJACENCY_EXT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_TARGETS_EXT */
+/* reuse GL_FRAMEBUFFER_INCOMPLETE_LAYER_COUNT_EXT */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_LAYERED_EXT */
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+/* reuse GL_PROGRAM_POINT_SIZE_EXT */
+#endif
+
+#ifndef GL_NV_vertex_program4
+#define GL_VERTEX_ATTRIB_ARRAY_INTEGER_NV 0x88FD
+#endif
+
+#ifndef GL_EXT_gpu_shader4
+#define GL_SAMPLER_1D_ARRAY_EXT 0x8DC0
+#define GL_SAMPLER_2D_ARRAY_EXT 0x8DC1
+#define GL_SAMPLER_BUFFER_EXT 0x8DC2
+#define GL_SAMPLER_1D_ARRAY_SHADOW_EXT 0x8DC3
+#define GL_SAMPLER_2D_ARRAY_SHADOW_EXT 0x8DC4
+#define GL_SAMPLER_CUBE_SHADOW_EXT 0x8DC5
+#define GL_UNSIGNED_INT_VEC2_EXT 0x8DC6
+#define GL_UNSIGNED_INT_VEC3_EXT 0x8DC7
+#define GL_UNSIGNED_INT_VEC4_EXT 0x8DC8
+#define GL_INT_SAMPLER_1D_EXT 0x8DC9
+#define GL_INT_SAMPLER_2D_EXT 0x8DCA
+#define GL_INT_SAMPLER_3D_EXT 0x8DCB
+#define GL_INT_SAMPLER_CUBE_EXT 0x8DCC
+#define GL_INT_SAMPLER_2D_RECT_EXT 0x8DCD
+#define GL_INT_SAMPLER_1D_ARRAY_EXT 0x8DCE
+#define GL_INT_SAMPLER_2D_ARRAY_EXT 0x8DCF
+#define GL_INT_SAMPLER_BUFFER_EXT 0x8DD0
+#define GL_UNSIGNED_INT_SAMPLER_1D_EXT 0x8DD1
+#define GL_UNSIGNED_INT_SAMPLER_2D_EXT 0x8DD2
+#define GL_UNSIGNED_INT_SAMPLER_3D_EXT 0x8DD3
+#define GL_UNSIGNED_INT_SAMPLER_CUBE_EXT 0x8DD4
+#define GL_UNSIGNED_INT_SAMPLER_2D_RECT_EXT 0x8DD5
+#define GL_UNSIGNED_INT_SAMPLER_1D_ARRAY_EXT 0x8DD6
+#define GL_UNSIGNED_INT_SAMPLER_2D_ARRAY_EXT 0x8DD7
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_EXT 0x8DD8
+#endif
+
+#ifndef GL_EXT_draw_instanced
+#endif
+
+#ifndef GL_EXT_packed_float
+#define GL_R11F_G11F_B10F_EXT 0x8C3A
+#define GL_UNSIGNED_INT_10F_11F_11F_REV_EXT 0x8C3B
+#define GL_RGBA_SIGNED_COMPONENTS_EXT 0x8C3C
+#endif
+
+#ifndef GL_EXT_texture_array
+#define GL_TEXTURE_1D_ARRAY_EXT 0x8C18
+#define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19
+#define GL_TEXTURE_2D_ARRAY_EXT 0x8C1A
+#define GL_PROXY_TEXTURE_2D_ARRAY_EXT 0x8C1B
+#define GL_TEXTURE_BINDING_1D_ARRAY_EXT 0x8C1C
+#define GL_TEXTURE_BINDING_2D_ARRAY_EXT 0x8C1D
+#define GL_MAX_ARRAY_TEXTURE_LAYERS_EXT 0x88FF
+#define GL_COMPARE_REF_DEPTH_TO_TEXTURE_EXT 0x884E
+/* reuse GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LAYER_EXT */
+#endif
+
+#ifndef GL_EXT_texture_buffer_object
+#define GL_TEXTURE_BUFFER_EXT 0x8C2A
+#define GL_MAX_TEXTURE_BUFFER_SIZE_EXT 0x8C2B
+#define GL_TEXTURE_BINDING_BUFFER_EXT 0x8C2C
+#define GL_TEXTURE_BUFFER_DATA_STORE_BINDING_EXT 0x8C2D
+#define GL_TEXTURE_BUFFER_FORMAT_EXT 0x8C2E
+#endif
+
+#ifndef GL_EXT_texture_compression_latc
+#define GL_COMPRESSED_LUMINANCE_LATC1_EXT 0x8C70
+#define GL_COMPRESSED_SIGNED_LUMINANCE_LATC1_EXT 0x8C71
+#define GL_COMPRESSED_LUMINANCE_ALPHA_LATC2_EXT 0x8C72
+#define GL_COMPRESSED_SIGNED_LUMINANCE_ALPHA_LATC2_EXT 0x8C73
+#endif
+
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_COMPRESSED_RED_RGTC1_EXT 0x8DBB
+#define GL_COMPRESSED_SIGNED_RED_RGTC1_EXT 0x8DBC
+#define GL_COMPRESSED_RED_GREEN_RGTC2_EXT 0x8DBD
+#define GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE
+#endif
+
+#ifndef GL_EXT_texture_shared_exponent
+#define GL_RGB9_E5_EXT 0x8C3D
+#define GL_UNSIGNED_INT_5_9_9_9_REV_EXT 0x8C3E
+#define GL_TEXTURE_SHARED_SIZE_EXT 0x8C3F
+#endif
+
+#ifndef GL_NV_depth_buffer_float
+#define GL_DEPTH_COMPONENT32F_NV 0x8DAB
+#define GL_DEPTH32F_STENCIL8_NV 0x8DAC
+#define GL_FLOAT_32_UNSIGNED_INT_24_8_REV_NV 0x8DAD
+#define GL_DEPTH_BUFFER_FLOAT_MODE_NV 0x8DAF
+#endif
+
+#ifndef GL_NV_fragment_program4
+#endif
+
+#ifndef GL_NV_framebuffer_multisample_coverage
+#define GL_RENDERBUFFER_COVERAGE_SAMPLES_NV 0x8CAB
+#define GL_RENDERBUFFER_COLOR_SAMPLES_NV 0x8E10
+#define GL_MAX_MULTISAMPLE_COVERAGE_MODES_NV 0x8E11
+#define GL_MULTISAMPLE_COVERAGE_MODES_NV 0x8E12
+#endif
+
+#ifndef GL_EXT_framebuffer_sRGB
+#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
+#define GL_FRAMEBUFFER_SRGB_CAPABLE_EXT 0x8DBA
+#endif
+
+#ifndef GL_NV_geometry_shader4
+#endif
+
+#ifndef GL_NV_parameter_buffer_object
+#define GL_MAX_PROGRAM_PARAMETER_BUFFER_BINDINGS_NV 0x8DA0
+#define GL_MAX_PROGRAM_PARAMETER_BUFFER_SIZE_NV 0x8DA1
+#define GL_VERTEX_PROGRAM_PARAMETER_BUFFER_NV 0x8DA2
+#define GL_GEOMETRY_PROGRAM_PARAMETER_BUFFER_NV 0x8DA3
+#define GL_FRAGMENT_PROGRAM_PARAMETER_BUFFER_NV 0x8DA4
+#endif
+
+#ifndef GL_EXT_draw_buffers2
+#endif
+
+#ifndef GL_NV_transform_feedback
+#define GL_BACK_PRIMARY_COLOR_NV 0x8C77
+#define GL_BACK_SECONDARY_COLOR_NV 0x8C78
+#define GL_TEXTURE_COORD_NV 0x8C79
+#define GL_CLIP_DISTANCE_NV 0x8C7A
+#define GL_VERTEX_ID_NV 0x8C7B
+#define GL_PRIMITIVE_ID_NV 0x8C7C
+#define GL_GENERIC_ATTRIB_NV 0x8C7D
+#define GL_TRANSFORM_FEEDBACK_ATTRIBS_NV 0x8C7E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_NV 0x8C7F
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_NV 0x8C80
+#define GL_ACTIVE_VARYINGS_NV 0x8C81
+#define GL_ACTIVE_VARYING_MAX_LENGTH_NV 0x8C82
+#define GL_TRANSFORM_FEEDBACK_VARYINGS_NV 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START_NV 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_NV 0x8C85
+#define GL_TRANSFORM_FEEDBACK_RECORD_NV 0x8C86
+#define GL_PRIMITIVES_GENERATED_NV 0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_NV 0x8C88
+#define GL_RASTERIZER_DISCARD_NV 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_ATTRIBS_NV 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_NV 0x8C8B
+#define GL_INTERLEAVED_ATTRIBS_NV 0x8C8C
+#define GL_SEPARATE_ATTRIBS_NV 0x8C8D
+#define GL_TRANSFORM_FEEDBACK_BUFFER_NV 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_NV 0x8C8F
+#endif
+
+#ifndef GL_EXT_bindable_uniform
+#define GL_MAX_VERTEX_BINDABLE_UNIFORMS_EXT 0x8DE2
+#define GL_MAX_FRAGMENT_BINDABLE_UNIFORMS_EXT 0x8DE3
+#define GL_MAX_GEOMETRY_BINDABLE_UNIFORMS_EXT 0x8DE4
+#define GL_MAX_BINDABLE_UNIFORM_SIZE_EXT 0x8DED
+#define GL_UNIFORM_BUFFER_EXT 0x8DEE
+#define GL_UNIFORM_BUFFER_BINDING_EXT 0x8DEF
+#endif
+
+#ifndef GL_EXT_texture_integer
+#define GL_RGBA32UI_EXT 0x8D70
+#define GL_RGB32UI_EXT 0x8D71
+#define GL_ALPHA32UI_EXT 0x8D72
+#define GL_INTENSITY32UI_EXT 0x8D73
+#define GL_LUMINANCE32UI_EXT 0x8D74
+#define GL_LUMINANCE_ALPHA32UI_EXT 0x8D75
+#define GL_RGBA16UI_EXT 0x8D76
+#define GL_RGB16UI_EXT 0x8D77
+#define GL_ALPHA16UI_EXT 0x8D78
+#define GL_INTENSITY16UI_EXT 0x8D79
+#define GL_LUMINANCE16UI_EXT 0x8D7A
+#define GL_LUMINANCE_ALPHA16UI_EXT 0x8D7B
+#define GL_RGBA8UI_EXT 0x8D7C
+#define GL_RGB8UI_EXT 0x8D7D
+#define GL_ALPHA8UI_EXT 0x8D7E
+#define GL_INTENSITY8UI_EXT 0x8D7F
+#define GL_LUMINANCE8UI_EXT 0x8D80
+#define GL_LUMINANCE_ALPHA8UI_EXT 0x8D81
+#define GL_RGBA32I_EXT 0x8D82
+#define GL_RGB32I_EXT 0x8D83
+#define GL_ALPHA32I_EXT 0x8D84
+#define GL_INTENSITY32I_EXT 0x8D85
+#define GL_LUMINANCE32I_EXT 0x8D86
+#define GL_LUMINANCE_ALPHA32I_EXT 0x8D87
+#define GL_RGBA16I_EXT 0x8D88
+#define GL_RGB16I_EXT 0x8D89
+#define GL_ALPHA16I_EXT 0x8D8A
+#define GL_INTENSITY16I_EXT 0x8D8B
+#define GL_LUMINANCE16I_EXT 0x8D8C
+#define GL_LUMINANCE_ALPHA16I_EXT 0x8D8D
+#define GL_RGBA8I_EXT 0x8D8E
+#define GL_RGB8I_EXT 0x8D8F
+#define GL_ALPHA8I_EXT 0x8D90
+#define GL_INTENSITY8I_EXT 0x8D91
+#define GL_LUMINANCE8I_EXT 0x8D92
+#define GL_LUMINANCE_ALPHA8I_EXT 0x8D93
+#define GL_RED_INTEGER_EXT 0x8D94
+#define GL_GREEN_INTEGER_EXT 0x8D95
+#define GL_BLUE_INTEGER_EXT 0x8D96
+#define GL_ALPHA_INTEGER_EXT 0x8D97
+#define GL_RGB_INTEGER_EXT 0x8D98
+#define GL_RGBA_INTEGER_EXT 0x8D99
+#define GL_BGR_INTEGER_EXT 0x8D9A
+#define GL_BGRA_INTEGER_EXT 0x8D9B
+#define GL_LUMINANCE_INTEGER_EXT 0x8D9C
+#define GL_LUMINANCE_ALPHA_INTEGER_EXT 0x8D9D
+#define GL_RGBA_INTEGER_MODE_EXT 0x8D9E
+#endif
+
+#ifndef GL_GREMEDY_frame_terminator
+#endif
+
+#ifndef GL_NV_conditional_render
+#define GL_QUERY_WAIT_NV 0x8E13
+#define GL_QUERY_NO_WAIT_NV 0x8E14
+#define GL_QUERY_BY_REGION_WAIT_NV 0x8E15
+#define GL_QUERY_BY_REGION_NO_WAIT_NV 0x8E16
+#endif
+
+#ifndef GL_NV_present_video
+#define GL_FRAME_NV 0x8E26
+#define GL_FIELDS_NV 0x8E27
+#define GL_CURRENT_TIME_NV 0x8E28
+#define GL_NUM_FILL_STREAMS_NV 0x8E29
+#define GL_PRESENT_TIME_NV 0x8E2A
+#define GL_PRESENT_DURATION_NV 0x8E2B
+#endif
+
+#ifndef GL_EXT_transform_feedback
+#define GL_TRANSFORM_FEEDBACK_BUFFER_EXT 0x8C8E
+#define GL_TRANSFORM_FEEDBACK_BUFFER_START_EXT 0x8C84
+#define GL_TRANSFORM_FEEDBACK_BUFFER_SIZE_EXT 0x8C85
+#define GL_TRANSFORM_FEEDBACK_BUFFER_BINDING_EXT 0x8C8F
+#define GL_INTERLEAVED_ATTRIBS_EXT 0x8C8C
+#define GL_SEPARATE_ATTRIBS_EXT 0x8C8D
+#define GL_PRIMITIVES_GENERATED_EXT 0x8C87
+#define GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN_EXT 0x8C88
+#define GL_RASTERIZER_DISCARD_EXT 0x8C89
+#define GL_MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS_EXT 0x8C8A
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS_EXT 0x8C8B
+#define GL_MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS_EXT 0x8C80
+#define GL_TRANSFORM_FEEDBACK_VARYINGS_EXT 0x8C83
+#define GL_TRANSFORM_FEEDBACK_BUFFER_MODE_EXT 0x8C7F
+#define GL_TRANSFORM_FEEDBACK_VARYING_MAX_LENGTH_EXT 0x8C76
+#endif
+
+#ifndef GL_EXT_direct_state_access
+#define GL_PROGRAM_MATRIX_EXT 0x8E2D
+#define GL_TRANSPOSE_PROGRAM_MATRIX_EXT 0x8E2E
+#define GL_PROGRAM_MATRIX_STACK_DEPTH_EXT 0x8E2F
+#endif
+
+#ifndef GL_EXT_vertex_array_bgra
+/* reuse GL_BGRA */
+#endif
+
+#ifndef GL_EXT_texture_swizzle
+#define GL_TEXTURE_SWIZZLE_R_EXT 0x8E42
+#define GL_TEXTURE_SWIZZLE_G_EXT 0x8E43
+#define GL_TEXTURE_SWIZZLE_B_EXT 0x8E44
+#define GL_TEXTURE_SWIZZLE_A_EXT 0x8E45
+#define GL_TEXTURE_SWIZZLE_RGBA_EXT 0x8E46
+#endif
+
+#ifndef GL_NV_explicit_multisample
+#define GL_SAMPLE_POSITION_NV 0x8E50
+#define GL_SAMPLE_MASK_NV 0x8E51
+#define GL_SAMPLE_MASK_VALUE_NV 0x8E52
+#define GL_TEXTURE_BINDING_RENDERBUFFER_NV 0x8E53
+#define GL_TEXTURE_RENDERBUFFER_DATA_STORE_BINDING_NV 0x8E54
+#define GL_MAX_SAMPLE_MASK_WORDS_NV 0x8E59
+#define GL_TEXTURE_RENDERBUFFER_NV 0x8E55
+#define GL_SAMPLER_RENDERBUFFER_NV 0x8E56
+#define GL_INT_SAMPLER_RENDERBUFFER_NV 0x8E57
+#define GL_UNSIGNED_INT_SAMPLER_RENDERBUFFER_NV 0x8E58
+#endif
+
+#ifndef GL_NV_transform_feedback2
+#define GL_TRANSFORM_FEEDBACK_NV 0x8E22
+#define GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED_NV 0x8E23
+#define GL_TRANSFORM_FEEDBACK_BUFFER_ACTIVE_NV 0x8E24
+#define GL_TRANSFORM_FEEDBACK_BINDING_NV 0x8E25
+#endif
+
+#ifndef GL_ATI_meminfo
+#define GL_VBO_FREE_MEMORY_ATI 0x87FB
+#define GL_TEXTURE_FREE_MEMORY_ATI 0x87FC
+#define GL_RENDERBUFFER_FREE_MEMORY_ATI 0x87FD
+#endif
+
+#ifndef GL_AMD_performance_monitor
+#define GL_COUNTER_TYPE_AMD 0x8BC0
+#define GL_COUNTER_RANGE_AMD 0x8BC1
+#define GL_UNSIGNED_INT64_AMD 0x8BC2
+#define GL_PERCENTAGE_AMD 0x8BC3
+#define GL_PERFMON_RESULT_AVAILABLE_AMD 0x8BC4
+#define GL_PERFMON_RESULT_SIZE_AMD 0x8BC5
+#define GL_PERFMON_RESULT_AMD 0x8BC6
+#endif
+
+#ifndef GL_AMD_texture_texture4
+#endif
+
+#ifndef GL_AMD_vertex_shader_tesselator
+#define GL_SAMPLER_BUFFER_AMD 0x9001
+#define GL_INT_SAMPLER_BUFFER_AMD 0x9002
+#define GL_UNSIGNED_INT_SAMPLER_BUFFER_AMD 0x9003
+#define GL_TESSELLATION_MODE_AMD 0x9004
+#define GL_TESSELLATION_FACTOR_AMD 0x9005
+#define GL_DISCRETE_AMD 0x9006
+#define GL_CONTINUOUS_AMD 0x9007
+#endif
+
+#ifndef GL_EXT_provoking_vertex
+#define GL_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION_EXT 0x8E4C
+#define GL_FIRST_VERTEX_CONVENTION_EXT 0x8E4D
+#define GL_LAST_VERTEX_CONVENTION_EXT 0x8E4E
+#define GL_PROVOKING_VERTEX_EXT 0x8E4F
+#endif
+
+
+/*************************************************************/
+
+#include <stddef.h>
+#ifndef GL_VERSION_2_0
+/* GL type for program/shader text */
+typedef char GLchar; /* native character */
+#endif
+
+#ifndef GL_VERSION_1_5
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptr;
+typedef ptrdiff_t GLsizeiptr;
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+/* GL types for handling large vertex buffer objects */
+typedef ptrdiff_t GLintptrARB;
+typedef ptrdiff_t GLsizeiptrARB;
+#endif
+
+#ifndef GL_ARB_shader_objects
+/* GL types for handling shader object handles and program/shader text */
+typedef char GLcharARB; /* native character */
+typedef unsigned int GLhandleARB; /* shader object handle */
+#endif
+
+/* GL types for "half" precision (s10e5) float data in host memory */
+#ifndef GL_ARB_half_float_pixel
+typedef unsigned short GLhalfARB;
+#endif
+
+#ifndef GL_NV_half_float
+typedef unsigned short GLhalfNV;
+#endif
+
+#ifndef GLEXT_64_TYPES_DEFINED
+/* This code block is duplicated in glxext.h, so must be protected */
+#define GLEXT_64_TYPES_DEFINED
+/* Define int32_t, int64_t, and uint64_t types for UST/MSC */
+/* (as used in the GL_EXT_timer_query extension). */
+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+#include <inttypes.h>
+#elif defined(__sun__) || defined(__digital__)
+#include <inttypes.h>
+#if defined(__STDC__)
+#if defined(__arch64__) || defined(_LP64)
+typedef long int int64_t;
+typedef unsigned long int uint64_t;
+#else
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#endif /* __arch64__ */
+#endif /* __STDC__ */
+#elif defined( __VMS ) || defined(__sgi)
+#include <inttypes.h>
+#elif defined(__SCO__) || defined(__USLC__)
+#include <stdint.h>
+#elif defined(__UNIXOS2__) || defined(__SOL64__)
+typedef long int int32_t;
+typedef long long int int64_t;
+typedef unsigned long long int uint64_t;
+#elif defined(_WIN32) && defined(__GNUC__)
+#include <stdint.h>
+#elif defined(_WIN32)
+typedef __int32 int32_t;
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+#else
+#include <inttypes.h> /* Fallback option */
+#endif
+#endif
+
+#ifndef GL_EXT_timer_query
+typedef int64_t GLint64EXT;
+typedef uint64_t GLuint64EXT;
+#endif
+
+#ifndef GL_VERSION_1_2
+#define GL_VERSION_1_2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColor (GLclampf, GLclampf, GLclampf, GLclampf);
+GLAPI void APIENTRY glBlendEquation (GLenum);
+GLAPI void APIENTRY glDrawRangeElements (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
+GLAPI void APIENTRY glColorTable (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glColorTableParameterfv (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glColorTableParameteriv (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyColorTable (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glGetColorTable (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetColorTableParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetColorTableParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glColorSubTable (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyColorSubTable (GLenum, GLsizei, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glConvolutionFilter1D (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionParameterf (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glConvolutionParameterfv (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glConvolutionParameteri (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glConvolutionParameteriv (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyConvolutionFilter1D (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyConvolutionFilter2D (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetConvolutionFilter (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetConvolutionParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetConvolutionParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetSeparableFilter (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
+GLAPI void APIENTRY glSeparableFilter2D (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
+GLAPI void APIENTRY glGetHistogram (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetHistogramParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetHistogramParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMinmax (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetMinmaxParameterfv (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMinmaxParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glHistogram (GLenum, GLsizei, GLenum, GLboolean);
+GLAPI void APIENTRY glMinmax (GLenum, GLenum, GLboolean);
+GLAPI void APIENTRY glResetHistogram (GLenum);
+GLAPI void APIENTRY glResetMinmax (GLenum);
+GLAPI void APIENTRY glTexImage3D (GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLORPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+typedef void (APIENTRYP PFNGLBLENDEQUATIONPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+typedef void (APIENTRYP PFNGLCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLEPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTERPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLTEXIMAGE3DPROC) (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_VERSION_1_3
+#define GL_VERSION_1_3 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTexture (GLenum);
+GLAPI void APIENTRY glClientActiveTexture (GLenum);
+GLAPI void APIENTRY glMultiTexCoord1d (GLenum, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord1dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord1f (GLenum, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord1fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord1i (GLenum, GLint);
+GLAPI void APIENTRY glMultiTexCoord1iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord1s (GLenum, GLshort);
+GLAPI void APIENTRY glMultiTexCoord1sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord2d (GLenum, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord2dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord2f (GLenum, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord2fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord2i (GLenum, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord2iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord2s (GLenum, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord2sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord3d (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord3dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord3f (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord3fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord3i (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord3iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord3s (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord3sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord4d (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord4dv (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord4f (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord4fv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord4i (GLenum, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord4iv (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord4s (GLenum, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord4sv (GLenum, const GLshort *);
+GLAPI void APIENTRY glLoadTransposeMatrixf (const GLfloat *);
+GLAPI void APIENTRY glLoadTransposeMatrixd (const GLdouble *);
+GLAPI void APIENTRY glMultTransposeMatrixf (const GLfloat *);
+GLAPI void APIENTRY glMultTransposeMatrixd (const GLdouble *);
+GLAPI void APIENTRY glSampleCoverage (GLclampf, GLboolean);
+GLAPI void APIENTRY glCompressedTexImage3D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage2D (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage1D (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage3D (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage2D (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage1D (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetCompressedTexImage (GLenum, GLint, GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_VERSION_1_4
+#define GL_VERSION_1_4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparate (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glFogCoordf (GLfloat);
+GLAPI void APIENTRY glFogCoordfv (const GLfloat *);
+GLAPI void APIENTRY glFogCoordd (GLdouble);
+GLAPI void APIENTRY glFogCoorddv (const GLdouble *);
+GLAPI void APIENTRY glFogCoordPointer (GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glMultiDrawArrays (GLenum, GLint *, GLsizei *, GLsizei);
+GLAPI void APIENTRY glMultiDrawElements (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
+GLAPI void APIENTRY glPointParameterf (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfv (GLenum, const GLfloat *);
+GLAPI void APIENTRY glPointParameteri (GLenum, GLint);
+GLAPI void APIENTRY glPointParameteriv (GLenum, const GLint *);
+GLAPI void APIENTRY glSecondaryColor3b (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glSecondaryColor3bv (const GLbyte *);
+GLAPI void APIENTRY glSecondaryColor3d (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glSecondaryColor3dv (const GLdouble *);
+GLAPI void APIENTRY glSecondaryColor3f (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glSecondaryColor3fv (const GLfloat *);
+GLAPI void APIENTRY glSecondaryColor3i (GLint, GLint, GLint);
+GLAPI void APIENTRY glSecondaryColor3iv (const GLint *);
+GLAPI void APIENTRY glSecondaryColor3s (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glSecondaryColor3sv (const GLshort *);
+GLAPI void APIENTRY glSecondaryColor3ub (GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glSecondaryColor3ubv (const GLubyte *);
+GLAPI void APIENTRY glSecondaryColor3ui (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSecondaryColor3uiv (const GLuint *);
+GLAPI void APIENTRY glSecondaryColor3us (GLushort, GLushort, GLushort);
+GLAPI void APIENTRY glSecondaryColor3usv (const GLushort *);
+GLAPI void APIENTRY glSecondaryColorPointer (GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glWindowPos2d (GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos2dv (const GLdouble *);
+GLAPI void APIENTRY glWindowPos2f (GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos2fv (const GLfloat *);
+GLAPI void APIENTRY glWindowPos2i (GLint, GLint);
+GLAPI void APIENTRY glWindowPos2iv (const GLint *);
+GLAPI void APIENTRY glWindowPos2s (GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos2sv (const GLshort *);
+GLAPI void APIENTRY glWindowPos3d (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos3dv (const GLdouble *);
+GLAPI void APIENTRY glWindowPos3f (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos3fv (const GLfloat *);
+GLAPI void APIENTRY glWindowPos3i (GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos3iv (const GLint *);
+GLAPI void APIENTRY glWindowPos3s (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos3sv (const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+typedef void (APIENTRYP PFNGLFOGCOORDFPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_VERSION_1_5
+#define GL_VERSION_1_5 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueries (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteQueries (GLsizei, const GLuint *);
+GLAPI GLboolean APIENTRY glIsQuery (GLuint);
+GLAPI void APIENTRY glBeginQuery (GLenum, GLuint);
+GLAPI void APIENTRY glEndQuery (GLenum);
+GLAPI void APIENTRY glGetQueryiv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectuiv (GLuint, GLenum, GLuint *);
+GLAPI void APIENTRY glBindBuffer (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteBuffers (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenBuffers (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsBuffer (GLuint);
+GLAPI void APIENTRY glBufferData (GLenum, GLsizeiptr, const GLvoid *, GLenum);
+GLAPI void APIENTRY glBufferSubData (GLenum, GLintptr, GLsizeiptr, const GLvoid *);
+GLAPI void APIENTRY glGetBufferSubData (GLenum, GLintptr, GLsizeiptr, GLvoid *);
+GLAPI GLvoid* APIENTRY glMapBuffer (GLenum, GLenum);
+GLAPI GLboolean APIENTRY glUnmapBuffer (GLenum);
+GLAPI void APIENTRY glGetBufferParameteriv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetBufferPointerv (GLenum, GLenum, GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVPROC) (GLuint id, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDBUFFERPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAPROC) (GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAPROC) (GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_VERSION_2_0
+#define GL_VERSION_2_0 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparate (GLenum, GLenum);
+GLAPI void APIENTRY glDrawBuffers (GLsizei, const GLenum *);
+GLAPI void APIENTRY glStencilOpSeparate (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glStencilFuncSeparate (GLenum, GLenum, GLint, GLuint);
+GLAPI void APIENTRY glStencilMaskSeparate (GLenum, GLuint);
+GLAPI void APIENTRY glAttachShader (GLuint, GLuint);
+GLAPI void APIENTRY glBindAttribLocation (GLuint, GLuint, const GLchar *);
+GLAPI void APIENTRY glCompileShader (GLuint);
+GLAPI GLuint APIENTRY glCreateProgram (void);
+GLAPI GLuint APIENTRY glCreateShader (GLenum);
+GLAPI void APIENTRY glDeleteProgram (GLuint);
+GLAPI void APIENTRY glDeleteShader (GLuint);
+GLAPI void APIENTRY glDetachShader (GLuint, GLuint);
+GLAPI void APIENTRY glDisableVertexAttribArray (GLuint);
+GLAPI void APIENTRY glEnableVertexAttribArray (GLuint);
+GLAPI void APIENTRY glGetActiveAttrib (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
+GLAPI void APIENTRY glGetActiveUniform (GLuint, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLchar *);
+GLAPI void APIENTRY glGetAttachedShaders (GLuint, GLsizei, GLsizei *, GLuint *);
+GLAPI GLint APIENTRY glGetAttribLocation (GLuint, const GLchar *);
+GLAPI void APIENTRY glGetProgramiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetProgramInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetShaderiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetShaderInfoLog (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetShaderSource (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI GLint APIENTRY glGetUniformLocation (GLuint, const GLchar *);
+GLAPI void APIENTRY glGetUniformfv (GLuint, GLint, GLfloat *);
+GLAPI void APIENTRY glGetUniformiv (GLuint, GLint, GLint *);
+GLAPI void APIENTRY glGetVertexAttribdv (GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetVertexAttribfv (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribPointerv (GLuint, GLenum, GLvoid* *);
+GLAPI GLboolean APIENTRY glIsProgram (GLuint);
+GLAPI GLboolean APIENTRY glIsShader (GLuint);
+GLAPI void APIENTRY glLinkProgram (GLuint);
+GLAPI void APIENTRY glShaderSource (GLuint, GLsizei, const GLchar* *, const GLint *);
+GLAPI void APIENTRY glUseProgram (GLuint);
+GLAPI void APIENTRY glUniform1f (GLint, GLfloat);
+GLAPI void APIENTRY glUniform2f (GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform3f (GLint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform4f (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform1i (GLint, GLint);
+GLAPI void APIENTRY glUniform2i (GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform3i (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform4i (GLint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform1fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform2fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform3fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform4fv (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform1iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform2iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform3iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform4iv (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniformMatrix2fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix3fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix4fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glValidateProgram (GLuint);
+GLAPI void APIENTRY glVertexAttrib1d (GLuint, GLdouble);
+GLAPI void APIENTRY glVertexAttrib1dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib1f (GLuint, GLfloat);
+GLAPI void APIENTRY glVertexAttrib1fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib1s (GLuint, GLshort);
+GLAPI void APIENTRY glVertexAttrib1sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib2d (GLuint, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib2dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib2f (GLuint, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib2fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib2s (GLuint, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib2sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib3d (GLuint, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib3dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib3f (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib3fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib3s (GLuint, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib3sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4Nbv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4Niv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4Nsv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4Nub (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glVertexAttrib4Nubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4Nuiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4Nusv (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttrib4bv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4d (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib4dv (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib4f (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib4fv (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib4iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4s (GLuint, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib4sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4ubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4usv (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttribPointer (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEPROC) (GLenum modeRGB, GLenum modeAlpha);
+typedef void (APIENTRYP PFNGLDRAWBUFFERSPROC) (GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+typedef void (APIENTRYP PFNGLSTENCILMASKSEPARATEPROC) (GLenum face, GLuint mask);
+typedef void (APIENTRYP PFNGLATTACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONPROC) (GLuint program, GLuint index, const GLchar *name);
+typedef void (APIENTRYP PFNGLCOMPILESHADERPROC) (GLuint shader);
+typedef GLuint (APIENTRYP PFNGLCREATEPROGRAMPROC) (void);
+typedef GLuint (APIENTRYP PFNGLCREATESHADERPROC) (GLenum type);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLDELETESHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLDETACHSHADERPROC) (GLuint program, GLuint shader);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLint *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETATTACHEDSHADERSPROC) (GLuint program, GLsizei maxCount, GLsizei *count, GLuint *obj);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVPROC) (GLuint program, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMINFOLOGPROC) (GLuint program, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERIVPROC) (GLuint shader, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERINFOLOGPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *infoLog);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEPROC) (GLuint shader, GLsizei bufSize, GLsizei *length, GLchar *source);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVPROC) (GLuint program, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVPROC) (GLuint program, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMPROC) (GLuint program);
+typedef GLboolean (APIENTRYP PFNGLISSHADERPROC) (GLuint shader);
+typedef void (APIENTRYP PFNGLLINKPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLSHADERSOURCEPROC) (GLuint shader, GLsizei count, const GLchar* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLUSEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLUNIFORM1FPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMPROC) (GLuint program);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_VERSION_2_1
+#define GL_VERSION_2_1 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniformMatrix2x3fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix3x2fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix2x4fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix4x2fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix3x4fv (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix4x3fv (GLint, GLsizei, GLboolean, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X2FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3X4FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4X3FVPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+#endif
+
+#ifndef GL_VERSION_3_0
+#define GL_VERSION_3_0 1
+/* OpenGL 3.0 also reuses entry points from these extensions: */
+/* ARB_framebuffer_object */
+/* ARB_map_buffer_range */
+/* ARB_vertex_array_object */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorMaski (GLuint, GLboolean, GLboolean, GLboolean, GLboolean);
+GLAPI void APIENTRY glGetBooleani_v (GLenum, GLuint, GLboolean *);
+GLAPI void APIENTRY glGetIntegeri_v (GLenum, GLuint, GLint *);
+GLAPI void APIENTRY glEnablei (GLenum, GLuint);
+GLAPI void APIENTRY glDisablei (GLenum, GLuint);
+GLAPI GLboolean APIENTRY glIsEnabledi (GLenum, GLuint);
+GLAPI void APIENTRY glBeginTransformFeedback (GLenum);
+GLAPI void APIENTRY glEndTransformFeedback (void);
+GLAPI void APIENTRY glBindBufferRange (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);
+GLAPI void APIENTRY glBindBufferBase (GLenum, GLuint, GLuint);
+GLAPI void APIENTRY glTransformFeedbackVaryings (GLuint, GLsizei, const GLchar* *, GLenum);
+GLAPI void APIENTRY glGetTransformFeedbackVarying (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);
+GLAPI void APIENTRY glClampColor (GLenum, GLenum);
+GLAPI void APIENTRY glBeginConditionalRender (GLuint, GLenum);
+GLAPI void APIENTRY glEndConditionalRender (void);
+GLAPI void APIENTRY glVertexAttribI1i (GLuint, GLint);
+GLAPI void APIENTRY glVertexAttribI2i (GLuint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI3i (GLuint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI4i (GLuint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI1ui (GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI2ui (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI3ui (GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI4ui (GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI1iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI2iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI3iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI4iv (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI1uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI2uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI3uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI4uiv (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI4bv (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttribI4sv (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttribI4ubv (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttribI4usv (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttribIPointer (GLuint, GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetVertexAttribIiv (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribIuiv (GLuint, GLenum, GLuint *);
+GLAPI void APIENTRY glGetUniformuiv (GLuint, GLint, GLuint *);
+GLAPI void APIENTRY glBindFragDataLocation (GLuint, GLuint, const GLchar *);
+GLAPI GLint APIENTRY glGetFragDataLocation (GLuint, const GLchar *);
+GLAPI void APIENTRY glUniform1ui (GLint, GLuint);
+GLAPI void APIENTRY glUniform2ui (GLint, GLuint, GLuint);
+GLAPI void APIENTRY glUniform3ui (GLint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glUniform4ui (GLint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glUniform1uiv (GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glUniform2uiv (GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glUniform3uiv (GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glUniform4uiv (GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glTexParameterIiv (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glTexParameterIuiv (GLenum, GLenum, const GLuint *);
+GLAPI void APIENTRY glGetTexParameterIiv (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetTexParameterIuiv (GLenum, GLenum, GLuint *);
+GLAPI void APIENTRY glClearBufferiv (GLenum, GLint, const GLint *);
+GLAPI void APIENTRY glClearBufferuiv (GLenum, GLint, const GLuint *);
+GLAPI void APIENTRY glClearBufferfv (GLenum, GLint, const GLfloat *);
+GLAPI void APIENTRY glClearBufferfi (GLenum, GLint, GLfloat, GLint);
+GLAPI const GLubyte * APIENTRY glGetStringi (GLenum, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORMASKIPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (APIENTRYP PFNGLGETBOOLEANI_VPROC) (GLenum target, GLuint index, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINTEGERI_VPROC) (GLenum target, GLuint index, GLint *data);
+typedef void (APIENTRYP PFNGLENABLEIPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEIPROC) (GLenum target, GLuint index);
+typedef GLboolean (APIENTRYP PFNGLISENABLEDIPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKPROC) (void);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGEPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLCLAMPCOLORPROC) (GLenum target, GLenum clamp);
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERPROC) (GLuint id, GLenum mode);
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERPROC) (void);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IPROC) (GLuint index, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IPROC) (GLuint index, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IPROC) (GLuint index, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIPROC) (GLuint index, GLuint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIPROC) (GLuint index, GLuint x, GLuint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTERPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVPROC) (GLuint index, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMUIVPROC) (GLuint program, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONPROC) (GLuint program, GLuint color, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORM1UIPROC) (GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2UIPROC) (GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4UIPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UIVPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLCLEARBUFFERIVPROC) (GLenum buffer, GLint drawbuffer, const GLint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERUIVPROC) (GLenum buffer, GLint drawbuffer, const GLuint *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFVPROC) (GLenum buffer, GLint drawbuffer, const GLfloat *value);
+typedef void (APIENTRYP PFNGLCLEARBUFFERFIPROC) (GLenum buffer, GLint drawbuffer, GLfloat depth, GLint stencil);
+typedef const GLubyte * (APIENTRYP PFNGLGETSTRINGIPROC) (GLenum name, GLuint index);
+#endif
+
+#ifndef GL_ARB_multitexture
+#define GL_ARB_multitexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveTextureARB (GLenum);
+GLAPI void APIENTRY glClientActiveTextureARB (GLenum);
+GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);
+GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);
+GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord2dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord2fARB (GLenum, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord2fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord2iARB (GLenum, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord2ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord2sARB (GLenum, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord2svARB (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord3dARB (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord3dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord3fARB (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord3fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord3iARB (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord3ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord3sARB (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord3svARB (GLenum, const GLshort *);
+GLAPI void APIENTRY glMultiTexCoord4dARB (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMultiTexCoord4dvARB (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexCoord4fARB (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMultiTexCoord4fvARB (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexCoord4iARB (GLenum, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glMultiTexCoord4ivARB (GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexCoord4sARB (GLenum, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glMultiTexCoord4svARB (GLenum, const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLCLIENTACTIVETEXTUREARBPROC) (GLenum texture);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DARBPROC) (GLenum target, GLdouble s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FARBPROC) (GLenum target, GLfloat s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IARBPROC) (GLenum target, GLint s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SARBPROC) (GLenum target, GLshort s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DARBPROC) (GLenum target, GLdouble s, GLdouble t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FARBPROC) (GLenum target, GLfloat s, GLfloat t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IARBPROC) (GLenum target, GLint s, GLint t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SARBPROC) (GLenum target, GLshort s, GLshort t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IARBPROC) (GLenum target, GLint s, GLint t, GLint r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3SVARBPROC) (GLenum target, const GLshort *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DARBPROC) (GLenum target, GLdouble s, GLdouble t, GLdouble r, GLdouble q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4DVARBPROC) (GLenum target, const GLdouble *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FARBPROC) (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4FVARBPROC) (GLenum target, const GLfloat *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IARBPROC) (GLenum target, GLint s, GLint t, GLint r, GLint q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4IVARBPROC) (GLenum target, const GLint *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SARBPROC) (GLenum target, GLshort s, GLshort t, GLshort r, GLshort q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4SVARBPROC) (GLenum target, const GLshort *v);
+#endif
+
+#ifndef GL_ARB_transpose_matrix
+#define GL_ARB_transpose_matrix 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLoadTransposeMatrixfARB (const GLfloat *);
+GLAPI void APIENTRY glLoadTransposeMatrixdARB (const GLdouble *);
+GLAPI void APIENTRY glMultTransposeMatrixfARB (const GLfloat *);
+GLAPI void APIENTRY glMultTransposeMatrixdARB (const GLdouble *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLLOADTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXFARBPROC) (const GLfloat *m);
+typedef void (APIENTRYP PFNGLMULTTRANSPOSEMATRIXDARBPROC) (const GLdouble *m);
+#endif
+
+#ifndef GL_ARB_multisample
+#define GL_ARB_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleCoverageARB (GLclampf, GLboolean);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLECOVERAGEARBPROC) (GLclampf value, GLboolean invert);
+#endif
+
+#ifndef GL_ARB_texture_env_add
+#define GL_ARB_texture_env_add 1
+#endif
+
+#ifndef GL_ARB_texture_cube_map
+#define GL_ARB_texture_cube_map 1
+#endif
+
+#ifndef GL_ARB_texture_compression
+#define GL_ARB_texture_compression 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCompressedTexImage3DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage2DARB (GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexImage1DARB (GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage3DARB (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage2DARB (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTexSubImage1DARB (GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetCompressedTexImageARB (GLenum, GLint, GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE3DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE2DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXIMAGE1DARBPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE3DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE2DARBPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXSUBIMAGE1DARBPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXIMAGEARBPROC) (GLenum target, GLint level, GLvoid *img);
+#endif
+
+#ifndef GL_ARB_texture_border_clamp
+#define GL_ARB_texture_border_clamp 1
+#endif
+
+#ifndef GL_ARB_point_parameters
+#define GL_ARB_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfARB (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfvARB (GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFARBPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVARBPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_ARB_vertex_blend
+#define GL_ARB_vertex_blend 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWeightbvARB (GLint, const GLbyte *);
+GLAPI void APIENTRY glWeightsvARB (GLint, const GLshort *);
+GLAPI void APIENTRY glWeightivARB (GLint, const GLint *);
+GLAPI void APIENTRY glWeightfvARB (GLint, const GLfloat *);
+GLAPI void APIENTRY glWeightdvARB (GLint, const GLdouble *);
+GLAPI void APIENTRY glWeightubvARB (GLint, const GLubyte *);
+GLAPI void APIENTRY glWeightusvARB (GLint, const GLushort *);
+GLAPI void APIENTRY glWeightuivARB (GLint, const GLuint *);
+GLAPI void APIENTRY glWeightPointerARB (GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glVertexBlendARB (GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWEIGHTBVARBPROC) (GLint size, const GLbyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTSVARBPROC) (GLint size, const GLshort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTIVARBPROC) (GLint size, const GLint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTFVARBPROC) (GLint size, const GLfloat *weights);
+typedef void (APIENTRYP PFNGLWEIGHTDVARBPROC) (GLint size, const GLdouble *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUBVARBPROC) (GLint size, const GLubyte *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUSVARBPROC) (GLint size, const GLushort *weights);
+typedef void (APIENTRYP PFNGLWEIGHTUIVARBPROC) (GLint size, const GLuint *weights);
+typedef void (APIENTRYP PFNGLWEIGHTPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXBLENDARBPROC) (GLint count);
+#endif
+
+#ifndef GL_ARB_matrix_palette
+#define GL_ARB_matrix_palette 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCurrentPaletteMatrixARB (GLint);
+GLAPI void APIENTRY glMatrixIndexubvARB (GLint, const GLubyte *);
+GLAPI void APIENTRY glMatrixIndexusvARB (GLint, const GLushort *);
+GLAPI void APIENTRY glMatrixIndexuivARB (GLint, const GLuint *);
+GLAPI void APIENTRY glMatrixIndexPointerARB (GLint, GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCURRENTPALETTEMATRIXARBPROC) (GLint index);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUBVARBPROC) (GLint size, const GLubyte *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUSVARBPROC) (GLint size, const GLushort *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXUIVARBPROC) (GLint size, const GLuint *indices);
+typedef void (APIENTRYP PFNGLMATRIXINDEXPOINTERARBPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_ARB_texture_env_combine
+#define GL_ARB_texture_env_combine 1
+#endif
+
+#ifndef GL_ARB_texture_env_crossbar
+#define GL_ARB_texture_env_crossbar 1
+#endif
+
+#ifndef GL_ARB_texture_env_dot3
+#define GL_ARB_texture_env_dot3 1
+#endif
+
+#ifndef GL_ARB_texture_mirrored_repeat
+#define GL_ARB_texture_mirrored_repeat 1
+#endif
+
+#ifndef GL_ARB_depth_texture
+#define GL_ARB_depth_texture 1
+#endif
+
+#ifndef GL_ARB_shadow
+#define GL_ARB_shadow 1
+#endif
+
+#ifndef GL_ARB_shadow_ambient
+#define GL_ARB_shadow_ambient 1
+#endif
+
+#ifndef GL_ARB_window_pos
+#define GL_ARB_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dARB (GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos2dvARB (const GLdouble *);
+GLAPI void APIENTRY glWindowPos2fARB (GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos2fvARB (const GLfloat *);
+GLAPI void APIENTRY glWindowPos2iARB (GLint, GLint);
+GLAPI void APIENTRY glWindowPos2ivARB (const GLint *);
+GLAPI void APIENTRY glWindowPos2sARB (GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos2svARB (const GLshort *);
+GLAPI void APIENTRY glWindowPos3dARB (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos3dvARB (const GLdouble *);
+GLAPI void APIENTRY glWindowPos3fARB (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos3fvARB (const GLfloat *);
+GLAPI void APIENTRY glWindowPos3iARB (GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos3ivARB (const GLint *);
+GLAPI void APIENTRY glWindowPos3sARB (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos3svARB (const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DARBPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FARBPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IARBPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SARBPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVARBPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DARBPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVARBPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FARBPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVARBPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IARBPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVARBPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SARBPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVARBPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_ARB_vertex_program
+#define GL_ARB_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttrib1dARB (GLuint, GLdouble);
+GLAPI void APIENTRY glVertexAttrib1dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib1fARB (GLuint, GLfloat);
+GLAPI void APIENTRY glVertexAttrib1fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib1sARB (GLuint, GLshort);
+GLAPI void APIENTRY glVertexAttrib1svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib2dARB (GLuint, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib2dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib2fARB (GLuint, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib2fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib2sARB (GLuint, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib2svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib3dARB (GLuint, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib3dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib3fARB (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib3fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib3sARB (GLuint, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib3svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4NbvARB (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4NivARB (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4NsvARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4NubARB (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glVertexAttrib4NubvARB (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4NuivARB (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4NusvARB (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttrib4bvARB (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttrib4dARB (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib4dvARB (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib4fARB (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib4fvARB (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib4ivARB (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttrib4sARB (GLuint, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib4svARB (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4ubvARB (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttrib4uivARB (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttrib4usvARB (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttribPointerARB (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glEnableVertexAttribArrayARB (GLuint);
+GLAPI void APIENTRY glDisableVertexAttribArrayARB (GLuint);
+GLAPI void APIENTRY glProgramStringARB (GLenum, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glBindProgramARB (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteProgramsARB (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenProgramsARB (GLsizei, GLuint *);
+GLAPI void APIENTRY glProgramEnvParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramEnvParameter4dvARB (GLenum, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramEnvParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramEnvParameter4fvARB (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glProgramLocalParameter4dARB (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramLocalParameter4dvARB (GLenum, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramLocalParameter4fARB (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramLocalParameter4fvARB (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glGetProgramEnvParameterdvARB (GLenum, GLuint, GLdouble *);
+GLAPI void APIENTRY glGetProgramEnvParameterfvARB (GLenum, GLuint, GLfloat *);
+GLAPI void APIENTRY glGetProgramLocalParameterdvARB (GLenum, GLuint, GLdouble *);
+GLAPI void APIENTRY glGetProgramLocalParameterfvARB (GLenum, GLuint, GLfloat *);
+GLAPI void APIENTRY glGetProgramivARB (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetProgramStringARB (GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetVertexAttribdvARB (GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetVertexAttribfvARB (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribivARB (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribPointervARB (GLuint, GLenum, GLvoid* *);
+GLAPI GLboolean APIENTRY glIsProgramARB (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DARBPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FARBPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SARBPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DARBPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FARBPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SARBPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NBVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NIVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NSVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBARBPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4NUSVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4BVARBPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DARBPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVARBPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FARBPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVARBPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4IVARBPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SARBPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVARBPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVARBPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UIVARBPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4USVARBPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERARBPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLENABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEVERTEXATTRIBARRAYARBPROC) (GLuint index);
+typedef void (APIENTRYP PFNGLPROGRAMSTRINGARBPROC) (GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (APIENTRYP PFNGLBINDPROGRAMARBPROC) (GLenum target, GLuint program);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSARBPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLGENPROGRAMSARBPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DARBPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4DVARBPROC) (GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FARBPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) (GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERDVARBPROC) (GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERFVARBPROC) (GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGARBPROC) (GLenum target, GLenum pname, GLvoid *string);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVARBPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVARBPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVARBPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVARBPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMARBPROC) (GLuint program);
+#endif
+
+#ifndef GL_ARB_fragment_program
+#define GL_ARB_fragment_program 1
+/* All ARB_fragment_program entry points are shared with ARB_vertex_program. */
+#endif
+
+#ifndef GL_ARB_vertex_buffer_object
+#define GL_ARB_vertex_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindBufferARB (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteBuffersARB (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenBuffersARB (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsBufferARB (GLuint);
+GLAPI void APIENTRY glBufferDataARB (GLenum, GLsizeiptrARB, const GLvoid *, GLenum);
+GLAPI void APIENTRY glBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, const GLvoid *);
+GLAPI void APIENTRY glGetBufferSubDataARB (GLenum, GLintptrARB, GLsizeiptrARB, GLvoid *);
+GLAPI GLvoid* APIENTRY glMapBufferARB (GLenum, GLenum);
+GLAPI GLboolean APIENTRY glUnmapBufferARB (GLenum);
+GLAPI void APIENTRY glGetBufferParameterivARB (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetBufferPointervARB (GLenum, GLenum, GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDBUFFERARBPROC) (GLenum target, GLuint buffer);
+typedef void (APIENTRYP PFNGLDELETEBUFFERSARBPROC) (GLsizei n, const GLuint *buffers);
+typedef void (APIENTRYP PFNGLGENBUFFERSARBPROC) (GLsizei n, GLuint *buffers);
+typedef GLboolean (APIENTRYP PFNGLISBUFFERARBPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLBUFFERDATAARBPROC) (GLenum target, GLsizeiptrARB size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, const GLvoid *data);
+typedef void (APIENTRYP PFNGLGETBUFFERSUBDATAARBPROC) (GLenum target, GLintptrARB offset, GLsizeiptrARB size, GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERARBPROC) (GLenum target, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPBUFFERARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETBUFFERPARAMETERIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETBUFFERPOINTERVARBPROC) (GLenum target, GLenum pname, GLvoid* *params);
+#endif
+
+#ifndef GL_ARB_occlusion_query
+#define GL_ARB_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenQueriesARB (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteQueriesARB (GLsizei, const GLuint *);
+GLAPI GLboolean APIENTRY glIsQueryARB (GLuint);
+GLAPI void APIENTRY glBeginQueryARB (GLenum, GLuint);
+GLAPI void APIENTRY glEndQueryARB (GLenum);
+GLAPI void APIENTRY glGetQueryivARB (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectivARB (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetQueryObjectuivARB (GLuint, GLenum, GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENQUERIESARBPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEQUERIESARBPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISQUERYARBPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINQUERYARBPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLENDQUERYARBPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLGETQUERYIVARBPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTIVARBPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUIVARBPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_ARB_shader_objects
+#define GL_ARB_shader_objects 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteObjectARB (GLhandleARB);
+GLAPI GLhandleARB APIENTRY glGetHandleARB (GLenum);
+GLAPI void APIENTRY glDetachObjectARB (GLhandleARB, GLhandleARB);
+GLAPI GLhandleARB APIENTRY glCreateShaderObjectARB (GLenum);
+GLAPI void APIENTRY glShaderSourceARB (GLhandleARB, GLsizei, const GLcharARB* *, const GLint *);
+GLAPI void APIENTRY glCompileShaderARB (GLhandleARB);
+GLAPI GLhandleARB APIENTRY glCreateProgramObjectARB (void);
+GLAPI void APIENTRY glAttachObjectARB (GLhandleARB, GLhandleARB);
+GLAPI void APIENTRY glLinkProgramARB (GLhandleARB);
+GLAPI void APIENTRY glUseProgramObjectARB (GLhandleARB);
+GLAPI void APIENTRY glValidateProgramARB (GLhandleARB);
+GLAPI void APIENTRY glUniform1fARB (GLint, GLfloat);
+GLAPI void APIENTRY glUniform2fARB (GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform3fARB (GLint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform4fARB (GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glUniform1iARB (GLint, GLint);
+GLAPI void APIENTRY glUniform2iARB (GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform3iARB (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform4iARB (GLint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glUniform1fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform2fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform3fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform4fvARB (GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glUniform1ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform2ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform3ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniform4ivARB (GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glUniformMatrix2fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix3fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glUniformMatrix4fvARB (GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glGetObjectParameterfvARB (GLhandleARB, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetObjectParameterivARB (GLhandleARB, GLenum, GLint *);
+GLAPI void APIENTRY glGetInfoLogARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+GLAPI void APIENTRY glGetAttachedObjectsARB (GLhandleARB, GLsizei, GLsizei *, GLhandleARB *);
+GLAPI GLint APIENTRY glGetUniformLocationARB (GLhandleARB, const GLcharARB *);
+GLAPI void APIENTRY glGetActiveUniformARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+GLAPI void APIENTRY glGetUniformfvARB (GLhandleARB, GLint, GLfloat *);
+GLAPI void APIENTRY glGetUniformivARB (GLhandleARB, GLint, GLint *);
+GLAPI void APIENTRY glGetShaderSourceARB (GLhandleARB, GLsizei, GLsizei *, GLcharARB *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEOBJECTARBPROC) (GLhandleARB obj);
+typedef GLhandleARB (APIENTRYP PFNGLGETHANDLEARBPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLDETACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB attachedObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATESHADEROBJECTARBPROC) (GLenum shaderType);
+typedef void (APIENTRYP PFNGLSHADERSOURCEARBPROC) (GLhandleARB shaderObj, GLsizei count, const GLcharARB* *string, const GLint *length);
+typedef void (APIENTRYP PFNGLCOMPILESHADERARBPROC) (GLhandleARB shaderObj);
+typedef GLhandleARB (APIENTRYP PFNGLCREATEPROGRAMOBJECTARBPROC) (void);
+typedef void (APIENTRYP PFNGLATTACHOBJECTARBPROC) (GLhandleARB containerObj, GLhandleARB obj);
+typedef void (APIENTRYP PFNGLLINKPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUSEPROGRAMOBJECTARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLVALIDATEPROGRAMARBPROC) (GLhandleARB programObj);
+typedef void (APIENTRYP PFNGLUNIFORM1FARBPROC) (GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLUNIFORM2FARBPROC) (GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLUNIFORM3FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLUNIFORM4FARBPROC) (GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLUNIFORM1IARBPROC) (GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2IARBPROC) (GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4IARBPROC) (GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM2FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM3FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM4FVARBPROC) (GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORM1IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4IVARBPROC) (GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX2FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX3FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLUNIFORMMATRIX4FVARBPROC) (GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERFVARBPROC) (GLhandleARB obj, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTPARAMETERIVARBPROC) (GLhandleARB obj, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETINFOLOGARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
+typedef void (APIENTRYP PFNGLGETATTACHEDOBJECTSARBPROC) (GLhandleARB containerObj, GLsizei maxCount, GLsizei *count, GLhandleARB *obj);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEUNIFORMARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETUNIFORMFVARBPROC) (GLhandleARB programObj, GLint location, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETUNIFORMIVARBPROC) (GLhandleARB programObj, GLint location, GLint *params);
+typedef void (APIENTRYP PFNGLGETSHADERSOURCEARBPROC) (GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *source);
+#endif
+
+#ifndef GL_ARB_vertex_shader
+#define GL_ARB_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindAttribLocationARB (GLhandleARB, GLuint, const GLcharARB *);
+GLAPI void APIENTRY glGetActiveAttribARB (GLhandleARB, GLuint, GLsizei, GLsizei *, GLint *, GLenum *, GLcharARB *);
+GLAPI GLint APIENTRY glGetAttribLocationARB (GLhandleARB, const GLcharARB *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDATTRIBLOCATIONARBPROC) (GLhandleARB programObj, GLuint index, const GLcharARB *name);
+typedef void (APIENTRYP PFNGLGETACTIVEATTRIBARBPROC) (GLhandleARB programObj, GLuint index, GLsizei maxLength, GLsizei *length, GLint *size, GLenum *type, GLcharARB *name);
+typedef GLint (APIENTRYP PFNGLGETATTRIBLOCATIONARBPROC) (GLhandleARB programObj, const GLcharARB *name);
+#endif
+
+#ifndef GL_ARB_fragment_shader
+#define GL_ARB_fragment_shader 1
+#endif
+
+#ifndef GL_ARB_shading_language_100
+#define GL_ARB_shading_language_100 1
+#endif
+
+#ifndef GL_ARB_texture_non_power_of_two
+#define GL_ARB_texture_non_power_of_two 1
+#endif
+
+#ifndef GL_ARB_point_sprite
+#define GL_ARB_point_sprite 1
+#endif
+
+#ifndef GL_ARB_fragment_program_shadow
+#define GL_ARB_fragment_program_shadow 1
+#endif
+
+#ifndef GL_ARB_draw_buffers
+#define GL_ARB_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersARB (GLsizei, const GLenum *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSARBPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ARB_texture_rectangle
+#define GL_ARB_texture_rectangle 1
+#endif
+
+#ifndef GL_ARB_color_buffer_float
+#define GL_ARB_color_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClampColorARB (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLAMPCOLORARBPROC) (GLenum target, GLenum clamp);
+#endif
+
+#ifndef GL_ARB_half_float_pixel
+#define GL_ARB_half_float_pixel 1
+#endif
+
+#ifndef GL_ARB_texture_float
+#define GL_ARB_texture_float 1
+#endif
+
+#ifndef GL_ARB_pixel_buffer_object
+#define GL_ARB_pixel_buffer_object 1
+#endif
+
+#ifndef GL_ARB_depth_buffer_float
+#define GL_ARB_depth_buffer_float 1
+#endif
+
+#ifndef GL_ARB_draw_instanced
+#define GL_ARB_draw_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedARB (GLenum, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glDrawElementsInstancedARB (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDARBPROC) (GLenum mode, GLint first, GLsizei count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDARBPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_ARB_framebuffer_object
+#define GL_ARB_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbuffer (GLuint);
+GLAPI void APIENTRY glBindRenderbuffer (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteRenderbuffers (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenRenderbuffers (GLsizei, GLuint *);
+GLAPI void APIENTRY glRenderbufferStorage (GLenum, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetRenderbufferParameteriv (GLenum, GLenum, GLint *);
+GLAPI GLboolean APIENTRY glIsFramebuffer (GLuint);
+GLAPI void APIENTRY glBindFramebuffer (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteFramebuffers (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenFramebuffers (GLsizei, GLuint *);
+GLAPI GLenum APIENTRY glCheckFramebufferStatus (GLenum);
+GLAPI void APIENTRY glFramebufferTexture1D (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture2D (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture3D (GLenum, GLenum, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glFramebufferRenderbuffer (GLenum, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameteriv (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGenerateMipmap (GLenum);
+GLAPI void APIENTRY glBlitFramebuffer (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
+GLAPI void APIENTRY glRenderbufferStorageMultisample (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glFramebufferTextureLayer (GLenum, GLenum, GLuint, GLint, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFERPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFERPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFERPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFERPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFERPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLBLITFRAMEBUFFERPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+#endif
+
+#ifndef GL_ARB_framebuffer_sRGB
+#define GL_ARB_framebuffer_sRGB 1
+#endif
+
+#ifndef GL_ARB_geometry_shader4
+#define GL_ARB_geometry_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramParameteriARB (GLuint, GLenum, GLint);
+GLAPI void APIENTRY glFramebufferTextureARB (GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTextureLayerARB (GLenum, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glFramebufferTextureFaceARB (GLenum, GLenum, GLuint, GLint, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIARBPROC) (GLuint program, GLenum pname, GLint value);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYERARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEARBPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif
+
+#ifndef GL_ARB_half_float_vertex
+#define GL_ARB_half_float_vertex 1
+#endif
+
+#ifndef GL_ARB_instanced_arrays
+#define GL_ARB_instanced_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribDivisor (GLuint, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBDIVISORPROC) (GLuint index, GLuint divisor);
+#endif
+
+#ifndef GL_ARB_map_buffer_range
+#define GL_ARB_map_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLvoid* APIENTRY glMapBufferRange (GLenum, GLintptr, GLsizeiptr, GLbitfield);
+GLAPI void APIENTRY glFlushMappedBufferRange (GLenum, GLintptr, GLsizeiptr);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLvoid* (APIENTRYP PFNGLMAPBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEPROC) (GLenum target, GLintptr offset, GLsizeiptr length);
+#endif
+
+#ifndef GL_ARB_texture_buffer_object
+#define GL_ARB_texture_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferARB (GLenum, GLenum, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFERARBPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+#endif
+
+#ifndef GL_ARB_texture_compression_rgtc
+#define GL_ARB_texture_compression_rgtc 1
+#endif
+
+#ifndef GL_ARB_texture_rg
+#define GL_ARB_texture_rg 1
+#endif
+
+#ifndef GL_ARB_vertex_array_object
+#define GL_ARB_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexArray (GLuint);
+GLAPI void APIENTRY glDeleteVertexArrays (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenVertexArrays (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsVertexArray (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYPROC) (GLuint array);
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYPROC) (GLuint array);
+#endif
+
+#ifndef GL_EXT_abgr
+#define GL_EXT_abgr 1
+#endif
+
+#ifndef GL_EXT_blend_color
+#define GL_EXT_blend_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendColorEXT (GLclampf, GLclampf, GLclampf, GLclampf);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDCOLOREXTPROC) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
+#endif
+
+#ifndef GL_EXT_polygon_offset
+#define GL_EXT_polygon_offset 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPolygonOffsetEXT (GLfloat, GLfloat);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOLYGONOFFSETEXTPROC) (GLfloat factor, GLfloat bias);
+#endif
+
+#ifndef GL_EXT_texture
+#define GL_EXT_texture 1
+#endif
+
+#ifndef GL_EXT_texture3D
+#define GL_EXT_texture3D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage3DEXT (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE3DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_SGIS_texture_filter4
+#define GL_SGIS_texture_filter4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetTexFilterFuncSGIS (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glTexFilterFuncSGIS (GLenum, GLenum, GLsizei, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLfloat *weights);
+typedef void (APIENTRYP PFNGLTEXFILTERFUNCSGISPROC) (GLenum target, GLenum filter, GLsizei n, const GLfloat *weights);
+#endif
+
+#ifndef GL_EXT_subtexture
+#define GL_EXT_subtexture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexSubImage1DEXT (GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_EXT_copy_texture
+#define GL_EXT_copy_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCopyTexImage1DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
+GLAPI void APIENTRY glCopyTexImage2DEXT (GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+GLAPI void APIENTRY glCopyTexSubImage1DEXT (GLenum, GLint, GLint, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyTexSubImage2DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glCopyTexSubImage3DEXT (GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE1DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXIMAGE2DEXTPROC) (GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE1DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE2DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLCOPYTEXSUBIMAGE3DEXTPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_EXT_histogram
+#define GL_EXT_histogram 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetHistogramEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetHistogramParameterfvEXT (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetHistogramParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMinmaxEXT (GLenum, GLboolean, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetMinmaxParameterfvEXT (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMinmaxParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glHistogramEXT (GLenum, GLsizei, GLenum, GLboolean);
+GLAPI void APIENTRY glMinmaxEXT (GLenum, GLenum, GLboolean);
+GLAPI void APIENTRY glResetHistogramEXT (GLenum);
+GLAPI void APIENTRY glResetMinmaxEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETHISTOGRAMEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETHISTOGRAMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMINMAXEXTPROC) (GLenum target, GLboolean reset, GLenum format, GLenum type, GLvoid *values);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMINMAXPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLHISTOGRAMEXTPROC) (GLenum target, GLsizei width, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLMINMAXEXTPROC) (GLenum target, GLenum internalformat, GLboolean sink);
+typedef void (APIENTRYP PFNGLRESETHISTOGRAMEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLRESETMINMAXEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_EXT_convolution
+#define GL_EXT_convolution 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glConvolutionFilter1DEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glConvolutionParameterfEXT (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glConvolutionParameterfvEXT (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glConvolutionParameteriEXT (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glConvolutionParameterivEXT (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyConvolutionFilter1DEXT (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyConvolutionFilter2DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetConvolutionFilterEXT (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetConvolutionParameterfvEXT (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetConvolutionParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetSeparableFilterEXT (GLenum, GLenum, GLenum, GLvoid *, GLvoid *, GLvoid *);
+GLAPI void APIENTRY glSeparableFilter2DEXT (GLenum, GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *image);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint params);
+typedef void (APIENTRYP PFNGLCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER1DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYCONVOLUTIONFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *image);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCONVOLUTIONPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETSEPARABLEFILTEREXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *row, GLvoid *column, GLvoid *span);
+typedef void (APIENTRYP PFNGLSEPARABLEFILTER2DEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *row, const GLvoid *column);
+#endif
+
+#ifndef GL_SGI_color_matrix
+#define GL_SGI_color_matrix 1
+#endif
+
+#ifndef GL_SGI_color_table
+#define GL_SGI_color_table 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableSGI (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glColorTableParameterfvSGI (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glColorTableParameterivSGI (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glCopyColorTableSGI (GLenum, GLenum, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glGetColorTableSGI (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetColorTableParameterfvSGI (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetColorTableParameterivSGI (GLenum, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOPYCOLORTABLESGIPROC) (GLenum target, GLenum internalformat, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLGETCOLORTABLESGIPROC) (GLenum target, GLenum format, GLenum type, GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVSGIPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVSGIPROC) (GLenum target, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_SGIX_pixel_texture
+#define GL_SGIX_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenSGIX (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENSGIXPROC) (GLenum mode);
+#endif
+
+#ifndef GL_SGIS_pixel_texture
+#define GL_SGIS_pixel_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTexGenParameteriSGIS (GLenum, GLint);
+GLAPI void APIENTRY glPixelTexGenParameterivSGIS (GLenum, const GLint *);
+GLAPI void APIENTRY glPixelTexGenParameterfSGIS (GLenum, GLfloat);
+GLAPI void APIENTRY glPixelTexGenParameterfvSGIS (GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetPixelTexGenParameterivSGIS (GLenum, GLint *);
+GLAPI void APIENTRY glGetPixelTexGenParameterfvSGIS (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERISGISPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERIVSGISPROC) (GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPIXELTEXGENPARAMETERFVSGISPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_texture4D
+#define GL_SGIS_texture4D 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexImage4DSGIS (GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTexSubImage4DSGIS (GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXIMAGE4DSGISPROC) (GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXSUBIMAGE4DSGISPROC) (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint woffset, GLsizei width, GLsizei height, GLsizei depth, GLsizei size4d, GLenum format, GLenum type, const GLvoid *pixels);
+#endif
+
+#ifndef GL_SGI_texture_color_table
+#define GL_SGI_texture_color_table 1
+#endif
+
+#ifndef GL_EXT_cmyka
+#define GL_EXT_cmyka 1
+#endif
+
+#ifndef GL_EXT_texture_object
+#define GL_EXT_texture_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreTexturesResidentEXT (GLsizei, const GLuint *, GLboolean *);
+GLAPI void APIENTRY glBindTextureEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteTexturesEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenTexturesEXT (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsTextureEXT (GLuint);
+GLAPI void APIENTRY glPrioritizeTexturesEXT (GLsizei, const GLuint *, const GLclampf *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLARETEXTURESRESIDENTEXTPROC) (GLsizei n, const GLuint *textures, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDTEXTUREEXTPROC) (GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLDELETETEXTURESEXTPROC) (GLsizei n, const GLuint *textures);
+typedef void (APIENTRYP PFNGLGENTEXTURESEXTPROC) (GLsizei n, GLuint *textures);
+typedef GLboolean (APIENTRYP PFNGLISTEXTUREEXTPROC) (GLuint texture);
+typedef void (APIENTRYP PFNGLPRIORITIZETEXTURESEXTPROC) (GLsizei n, const GLuint *textures, const GLclampf *priorities);
+#endif
+
+#ifndef GL_SGIS_detail_texture
+#define GL_SGIS_detail_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDetailTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glGetDetailTexFuncSGIS (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDETAILTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETDETAILTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_SGIS_sharpen_texture
+#define GL_SGIS_sharpen_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSharpenTexFuncSGIS (GLenum, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glGetSharpenTexFuncSGIS (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSHARPENTEXFUNCSGISPROC) (GLenum target, GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETSHARPENTEXFUNCSGISPROC) (GLenum target, GLfloat *points);
+#endif
+
+#ifndef GL_EXT_packed_pixels
+#define GL_EXT_packed_pixels 1
+#endif
+
+#ifndef GL_SGIS_texture_lod
+#define GL_SGIS_texture_lod 1
+#endif
+
+#ifndef GL_SGIS_multisample
+#define GL_SGIS_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskSGIS (GLclampf, GLboolean);
+GLAPI void APIENTRY glSamplePatternSGIS (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKSGISPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNSGISPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_EXT_rescale_normal
+#define GL_EXT_rescale_normal 1
+#endif
+
+#ifndef GL_EXT_vertex_array
+#define GL_EXT_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glArrayElementEXT (GLint);
+GLAPI void APIENTRY glColorPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glDrawArraysEXT (GLenum, GLint, GLsizei);
+GLAPI void APIENTRY glEdgeFlagPointerEXT (GLsizei, GLsizei, const GLboolean *);
+GLAPI void APIENTRY glGetPointervEXT (GLenum, GLvoid* *);
+GLAPI void APIENTRY glIndexPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glNormalPointerEXT (GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glTexCoordPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glVertexPointerEXT (GLint, GLenum, GLsizei, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLARRAYELEMENTEXTPROC) (GLint i);
+typedef void (APIENTRYP PFNGLCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWARRAYSEXTPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTEREXTPROC) (GLsizei stride, GLsizei count, const GLboolean *pointer);
+typedef void (APIENTRYP PFNGLGETPOINTERVEXTPROC) (GLenum pname, GLvoid* *params);
+typedef void (APIENTRYP PFNGLINDEXPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, GLsizei count, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_misc_attribute
+#define GL_EXT_misc_attribute 1
+#endif
+
+#ifndef GL_SGIS_generate_mipmap
+#define GL_SGIS_generate_mipmap 1
+#endif
+
+#ifndef GL_SGIX_clipmap
+#define GL_SGIX_clipmap 1
+#endif
+
+#ifndef GL_SGIX_shadow
+#define GL_SGIX_shadow 1
+#endif
+
+#ifndef GL_SGIS_texture_edge_clamp
+#define GL_SGIS_texture_edge_clamp 1
+#endif
+
+#ifndef GL_SGIS_texture_border_clamp
+#define GL_SGIS_texture_border_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_minmax
+#define GL_EXT_blend_minmax 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_blend_subtract
+#define GL_EXT_blend_subtract 1
+#endif
+
+#ifndef GL_EXT_blend_logic_op
+#define GL_EXT_blend_logic_op 1
+#endif
+
+#ifndef GL_SGIX_interlace
+#define GL_SGIX_interlace 1
+#endif
+
+#ifndef GL_SGIX_pixel_tiles
+#define GL_SGIX_pixel_tiles 1
+#endif
+
+#ifndef GL_SGIX_texture_select
+#define GL_SGIX_texture_select 1
+#endif
+
+#ifndef GL_SGIX_sprite
+#define GL_SGIX_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSpriteParameterfSGIX (GLenum, GLfloat);
+GLAPI void APIENTRY glSpriteParameterfvSGIX (GLenum, const GLfloat *);
+GLAPI void APIENTRY glSpriteParameteriSGIX (GLenum, GLint);
+GLAPI void APIENTRY glSpriteParameterivSGIX (GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLSPRITEPARAMETERIVSGIXPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_texture_multi_buffer
+#define GL_SGIX_texture_multi_buffer 1
+#endif
+
+#ifndef GL_EXT_point_parameters
+#define GL_EXT_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfEXT (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfvEXT (GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFEXTPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVEXTPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIS_point_parameters
+#define GL_SGIS_point_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameterfSGIS (GLenum, GLfloat);
+GLAPI void APIENTRY glPointParameterfvSGIS (GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFSGISPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERFVSGISPROC) (GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_instruments
+#define GL_SGIX_instruments 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLint APIENTRY glGetInstrumentsSGIX (void);
+GLAPI void APIENTRY glInstrumentsBufferSGIX (GLsizei, GLint *);
+GLAPI GLint APIENTRY glPollInstrumentsSGIX (GLint *);
+GLAPI void APIENTRY glReadInstrumentsSGIX (GLint);
+GLAPI void APIENTRY glStartInstrumentsSGIX (void);
+GLAPI void APIENTRY glStopInstrumentsSGIX (GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLint (APIENTRYP PFNGLGETINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLINSTRUMENTSBUFFERSGIXPROC) (GLsizei size, GLint *buffer);
+typedef GLint (APIENTRYP PFNGLPOLLINSTRUMENTSSGIXPROC) (GLint *marker_p);
+typedef void (APIENTRYP PFNGLREADINSTRUMENTSSGIXPROC) (GLint marker);
+typedef void (APIENTRYP PFNGLSTARTINSTRUMENTSSGIXPROC) (void);
+typedef void (APIENTRYP PFNGLSTOPINSTRUMENTSSGIXPROC) (GLint marker);
+#endif
+
+#ifndef GL_SGIX_texture_scale_bias
+#define GL_SGIX_texture_scale_bias 1
+#endif
+
+#ifndef GL_SGIX_framezoom
+#define GL_SGIX_framezoom 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFrameZoomSGIX (GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMEZOOMSGIXPROC) (GLint factor);
+#endif
+
+#ifndef GL_SGIX_tag_sample_buffer
+#define GL_SGIX_tag_sample_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTagSampleBufferSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTAGSAMPLEBUFFERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_polynomial_ffd
+#define GL_SGIX_polynomial_ffd 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeformationMap3dSGIX (GLenum, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, GLdouble, GLdouble, GLint, GLint, const GLdouble *);
+GLAPI void APIENTRY glDeformationMap3fSGIX (GLenum, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, GLfloat, GLfloat, GLint, GLint, const GLfloat *);
+GLAPI void APIENTRY glDeformSGIX (GLbitfield);
+GLAPI void APIENTRY glLoadIdentityDeformationMapSGIX (GLbitfield);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3DSGIXPROC) (GLenum target, GLdouble u1, GLdouble u2, GLint ustride, GLint uorder, GLdouble v1, GLdouble v2, GLint vstride, GLint vorder, GLdouble w1, GLdouble w2, GLint wstride, GLint worder, const GLdouble *points);
+typedef void (APIENTRYP PFNGLDEFORMATIONMAP3FSGIXPROC) (GLenum target, GLfloat u1, GLfloat u2, GLint ustride, GLint uorder, GLfloat v1, GLfloat v2, GLint vstride, GLint vorder, GLfloat w1, GLfloat w2, GLint wstride, GLint worder, const GLfloat *points);
+typedef void (APIENTRYP PFNGLDEFORMSGIXPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLLOADIDENTITYDEFORMATIONMAPSGIXPROC) (GLbitfield mask);
+#endif
+
+#ifndef GL_SGIX_reference_plane
+#define GL_SGIX_reference_plane 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReferencePlaneSGIX (const GLdouble *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREFERENCEPLANESGIXPROC) (const GLdouble *equation);
+#endif
+
+#ifndef GL_SGIX_flush_raster
+#define GL_SGIX_flush_raster 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushRasterSGIX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHRASTERSGIXPROC) (void);
+#endif
+
+#ifndef GL_SGIX_depth_texture
+#define GL_SGIX_depth_texture 1
+#endif
+
+#ifndef GL_SGIS_fog_function
+#define GL_SGIS_fog_function 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogFuncSGIS (GLsizei, const GLfloat *);
+GLAPI void APIENTRY glGetFogFuncSGIS (GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGFUNCSGISPROC) (GLsizei n, const GLfloat *points);
+typedef void (APIENTRYP PFNGLGETFOGFUNCSGISPROC) (GLfloat *points);
+#endif
+
+#ifndef GL_SGIX_fog_offset
+#define GL_SGIX_fog_offset 1
+#endif
+
+#ifndef GL_HP_image_transform
+#define GL_HP_image_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glImageTransformParameteriHP (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glImageTransformParameterfHP (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glImageTransformParameterivHP (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glImageTransformParameterfvHP (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetImageTransformParameterivHP (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetImageTransformParameterfvHP (GLenum, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIHPPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFHPPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERIVHPPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETIMAGETRANSFORMPARAMETERFVHPPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_HP_convolution_border_modes
+#define GL_HP_convolution_border_modes 1
+#endif
+
+#ifndef GL_SGIX_texture_add_env
+#define GL_SGIX_texture_add_env 1
+#endif
+
+#ifndef GL_EXT_color_subtable
+#define GL_EXT_color_subtable 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorSubTableEXT (GLenum, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyColorSubTableEXT (GLenum, GLsizei, GLint, GLint, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLsizei count, GLenum format, GLenum type, const GLvoid *data);
+typedef void (APIENTRYP PFNGLCOPYCOLORSUBTABLEEXTPROC) (GLenum target, GLsizei start, GLint x, GLint y, GLsizei width);
+#endif
+
+#ifndef GL_PGI_vertex_hints
+#define GL_PGI_vertex_hints 1
+#endif
+
+#ifndef GL_PGI_misc_hints
+#define GL_PGI_misc_hints 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glHintPGI (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLHINTPGIPROC) (GLenum target, GLint mode);
+#endif
+
+#ifndef GL_EXT_paletted_texture
+#define GL_EXT_paletted_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorTableEXT (GLenum, GLenum, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glGetColorTableEXT (GLenum, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetColorTableParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetColorTableParameterfvEXT (GLenum, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORTABLEEXTPROC) (GLenum target, GLenum internalFormat, GLsizei width, GLenum format, GLenum type, const GLvoid *table);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEEXTPROC) (GLenum target, GLenum format, GLenum type, GLvoid *data);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOLORTABLEPARAMETERFVEXTPROC) (GLenum target, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_EXT_clip_volume_hint
+#define GL_EXT_clip_volume_hint 1
+#endif
+
+#ifndef GL_SGIX_list_priority
+#define GL_SGIX_list_priority 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetListParameterfvSGIX (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetListParameterivSGIX (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glListParameterfSGIX (GLuint, GLenum, GLfloat);
+GLAPI void APIENTRY glListParameterfvSGIX (GLuint, GLenum, const GLfloat *);
+GLAPI void APIENTRY glListParameteriSGIX (GLuint, GLenum, GLint);
+GLAPI void APIENTRY glListParameterivSGIX (GLuint, GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFSGIXPROC) (GLuint list, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERFVSGIXPROC) (GLuint list, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLLISTPARAMETERISGIXPROC) (GLuint list, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLLISTPARAMETERIVSGIXPROC) (GLuint list, GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_SGIX_ir_instrument1
+#define GL_SGIX_ir_instrument1 1
+#endif
+
+#ifndef GL_SGIX_calligraphic_fragment
+#define GL_SGIX_calligraphic_fragment 1
+#endif
+
+#ifndef GL_SGIX_texture_lod_bias
+#define GL_SGIX_texture_lod_bias 1
+#endif
+
+#ifndef GL_SGIX_shadow_ambient
+#define GL_SGIX_shadow_ambient 1
+#endif
+
+#ifndef GL_EXT_index_texture
+#define GL_EXT_index_texture 1
+#endif
+
+#ifndef GL_EXT_index_material
+#define GL_EXT_index_material 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexMaterialEXT (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_EXT_index_func
+#define GL_EXT_index_func 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIndexFuncEXT (GLenum, GLclampf);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLINDEXFUNCEXTPROC) (GLenum func, GLclampf ref);
+#endif
+
+#ifndef GL_EXT_index_array_formats
+#define GL_EXT_index_array_formats 1
+#endif
+
+#ifndef GL_EXT_compiled_vertex_array
+#define GL_EXT_compiled_vertex_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glLockArraysEXT (GLint, GLsizei);
+GLAPI void APIENTRY glUnlockArraysEXT (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLLOCKARRAYSEXTPROC) (GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLUNLOCKARRAYSEXTPROC) (void);
+#endif
+
+#ifndef GL_EXT_cull_vertex
+#define GL_EXT_cull_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCullParameterdvEXT (GLenum, GLdouble *);
+GLAPI void APIENTRY glCullParameterfvEXT (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCULLPARAMETERDVEXTPROC) (GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLCULLPARAMETERFVEXTPROC) (GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_SGIX_ycrcb
+#define GL_SGIX_ycrcb 1
+#endif
+
+#ifndef GL_SGIX_fragment_lighting
+#define GL_SGIX_fragment_lighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFragmentColorMaterialSGIX (GLenum, GLenum);
+GLAPI void APIENTRY glFragmentLightfSGIX (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glFragmentLightfvSGIX (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glFragmentLightiSGIX (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glFragmentLightivSGIX (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glFragmentLightModelfSGIX (GLenum, GLfloat);
+GLAPI void APIENTRY glFragmentLightModelfvSGIX (GLenum, const GLfloat *);
+GLAPI void APIENTRY glFragmentLightModeliSGIX (GLenum, GLint);
+GLAPI void APIENTRY glFragmentLightModelivSGIX (GLenum, const GLint *);
+GLAPI void APIENTRY glFragmentMaterialfSGIX (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glFragmentMaterialfvSGIX (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glFragmentMaterialiSGIX (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glFragmentMaterialivSGIX (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glGetFragmentLightfvSGIX (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetFragmentLightivSGIX (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetFragmentMaterialfvSGIX (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetFragmentMaterialivSGIX (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glLightEnviSGIX (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAGMENTCOLORMATERIALSGIXPROC) (GLenum face, GLenum mode);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFSGIXPROC) (GLenum light, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTISGIXPROC) (GLenum light, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFSGIXPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELFVSGIXPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELISGIXPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTLIGHTMODELIVSGIXPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFSGIXPROC) (GLenum face, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALISGIXPROC) (GLenum face, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTFVSGIXPROC) (GLenum light, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTLIGHTIVSGIXPROC) (GLenum light, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALFVSGIXPROC) (GLenum face, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFRAGMENTMATERIALIVSGIXPROC) (GLenum face, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLLIGHTENVISGIXPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_IBM_rasterpos_clip
+#define GL_IBM_rasterpos_clip 1
+#endif
+
+#ifndef GL_HP_texture_lighting
+#define GL_HP_texture_lighting 1
+#endif
+
+#ifndef GL_EXT_draw_range_elements
+#define GL_EXT_draw_range_elements 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawRangeElementsEXT (GLenum, GLuint, GLuint, GLsizei, GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTSEXTPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices);
+#endif
+
+#ifndef GL_WIN_phong_shading
+#define GL_WIN_phong_shading 1
+#endif
+
+#ifndef GL_WIN_specular_fog
+#define GL_WIN_specular_fog 1
+#endif
+
+#ifndef GL_EXT_light_texture
+#define GL_EXT_light_texture 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glApplyTextureEXT (GLenum);
+GLAPI void APIENTRY glTextureLightEXT (GLenum);
+GLAPI void APIENTRY glTextureMaterialEXT (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLAPPLYTEXTUREEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLTEXTURELIGHTEXTPROC) (GLenum pname);
+typedef void (APIENTRYP PFNGLTEXTUREMATERIALEXTPROC) (GLenum face, GLenum mode);
+#endif
+
+#ifndef GL_SGIX_blend_alpha_minmax
+#define GL_SGIX_blend_alpha_minmax 1
+#endif
+
+#ifndef GL_EXT_bgra
+#define GL_EXT_bgra 1
+#endif
+
+#ifndef GL_SGIX_async
+#define GL_SGIX_async 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glAsyncMarkerSGIX (GLuint);
+GLAPI GLint APIENTRY glFinishAsyncSGIX (GLuint *);
+GLAPI GLint APIENTRY glPollAsyncSGIX (GLuint *);
+GLAPI GLuint APIENTRY glGenAsyncMarkersSGIX (GLsizei);
+GLAPI void APIENTRY glDeleteAsyncMarkersSGIX (GLuint, GLsizei);
+GLAPI GLboolean APIENTRY glIsAsyncMarkerSGIX (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLASYNCMARKERSGIXPROC) (GLuint marker);
+typedef GLint (APIENTRYP PFNGLFINISHASYNCSGIXPROC) (GLuint *markerp);
+typedef GLint (APIENTRYP PFNGLPOLLASYNCSGIXPROC) (GLuint *markerp);
+typedef GLuint (APIENTRYP PFNGLGENASYNCMARKERSSGIXPROC) (GLsizei range);
+typedef void (APIENTRYP PFNGLDELETEASYNCMARKERSSGIXPROC) (GLuint marker, GLsizei range);
+typedef GLboolean (APIENTRYP PFNGLISASYNCMARKERSGIXPROC) (GLuint marker);
+#endif
+
+#ifndef GL_SGIX_async_pixel
+#define GL_SGIX_async_pixel 1
+#endif
+
+#ifndef GL_SGIX_async_histogram
+#define GL_SGIX_async_histogram 1
+#endif
+
+#ifndef GL_INTEL_parallel_arrays
+#define GL_INTEL_parallel_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexPointervINTEL (GLint, GLenum, const GLvoid* *);
+GLAPI void APIENTRY glNormalPointervINTEL (GLenum, const GLvoid* *);
+GLAPI void APIENTRY glColorPointervINTEL (GLint, GLenum, const GLvoid* *);
+GLAPI void APIENTRY glTexCoordPointervINTEL (GLint, GLenum, const GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLNORMALPOINTERVINTELPROC) (GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLCOLORPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERVINTELPROC) (GLint size, GLenum type, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_HP_occlusion_test
+#define GL_HP_occlusion_test 1
+#endif
+
+#ifndef GL_EXT_pixel_transform
+#define GL_EXT_pixel_transform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelTransformParameteriEXT (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glPixelTransformParameterfEXT (GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glPixelTransformParameterivEXT (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glPixelTransformParameterfvEXT (GLenum, GLenum, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIEXTPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFEXTPROC) (GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLPIXELTRANSFORMPARAMETERFVEXTPROC) (GLenum target, GLenum pname, const GLfloat *params);
+#endif
+
+#ifndef GL_EXT_pixel_transform_color_table
+#define GL_EXT_pixel_transform_color_table 1
+#endif
+
+#ifndef GL_EXT_shared_texture_palette
+#define GL_EXT_shared_texture_palette 1
+#endif
+
+#ifndef GL_EXT_separate_specular_color
+#define GL_EXT_separate_specular_color 1
+#endif
+
+#ifndef GL_EXT_secondary_color
+#define GL_EXT_secondary_color 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSecondaryColor3bEXT (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glSecondaryColor3bvEXT (const GLbyte *);
+GLAPI void APIENTRY glSecondaryColor3dEXT (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glSecondaryColor3dvEXT (const GLdouble *);
+GLAPI void APIENTRY glSecondaryColor3fEXT (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glSecondaryColor3fvEXT (const GLfloat *);
+GLAPI void APIENTRY glSecondaryColor3iEXT (GLint, GLint, GLint);
+GLAPI void APIENTRY glSecondaryColor3ivEXT (const GLint *);
+GLAPI void APIENTRY glSecondaryColor3sEXT (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glSecondaryColor3svEXT (const GLshort *);
+GLAPI void APIENTRY glSecondaryColor3ubEXT (GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glSecondaryColor3ubvEXT (const GLubyte *);
+GLAPI void APIENTRY glSecondaryColor3uiEXT (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSecondaryColor3uivEXT (const GLuint *);
+GLAPI void APIENTRY glSecondaryColor3usEXT (GLushort, GLushort, GLushort);
+GLAPI void APIENTRY glSecondaryColor3usvEXT (const GLushort *);
+GLAPI void APIENTRY glSecondaryColorPointerEXT (GLint, GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BEXTPROC) (GLbyte red, GLbyte green, GLbyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DEXTPROC) (GLdouble red, GLdouble green, GLdouble blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FEXTPROC) (GLfloat red, GLfloat green, GLfloat blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IEXTPROC) (GLint red, GLint green, GLint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SEXTPROC) (GLshort red, GLshort green, GLshort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBEXTPROC) (GLubyte red, GLubyte green, GLubyte blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UBVEXTPROC) (const GLubyte *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIEXTPROC) (GLuint red, GLuint green, GLuint blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3UIVEXTPROC) (const GLuint *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USEXTPROC) (GLushort red, GLushort green, GLushort blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3USVEXTPROC) (const GLushort *v);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTEREXTPROC) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_perturb_normal
+#define GL_EXT_texture_perturb_normal 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureNormalEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURENORMALEXTPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_multi_draw_arrays
+#define GL_EXT_multi_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiDrawArraysEXT (GLenum, GLint *, GLsizei *, GLsizei);
+GLAPI void APIENTRY glMultiDrawElementsEXT (GLenum, const GLsizei *, GLenum, const GLvoid* *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIDRAWARRAYSEXTPROC) (GLenum mode, GLint *first, GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTSEXTPROC) (GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_EXT_fog_coord
+#define GL_EXT_fog_coord 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFogCoordfEXT (GLfloat);
+GLAPI void APIENTRY glFogCoordfvEXT (const GLfloat *);
+GLAPI void APIENTRY glFogCoorddEXT (GLdouble);
+GLAPI void APIENTRY glFogCoorddvEXT (const GLdouble *);
+GLAPI void APIENTRY glFogCoordPointerEXT (GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFOGCOORDFEXTPROC) (GLfloat coord);
+typedef void (APIENTRYP PFNGLFOGCOORDFVEXTPROC) (const GLfloat *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDEXTPROC) (GLdouble coord);
+typedef void (APIENTRYP PFNGLFOGCOORDDVEXTPROC) (const GLdouble *coord);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_REND_screen_coordinates
+#define GL_REND_screen_coordinates 1
+#endif
+
+#ifndef GL_EXT_coordinate_frame
+#define GL_EXT_coordinate_frame 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTangent3bEXT (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glTangent3bvEXT (const GLbyte *);
+GLAPI void APIENTRY glTangent3dEXT (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glTangent3dvEXT (const GLdouble *);
+GLAPI void APIENTRY glTangent3fEXT (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTangent3fvEXT (const GLfloat *);
+GLAPI void APIENTRY glTangent3iEXT (GLint, GLint, GLint);
+GLAPI void APIENTRY glTangent3ivEXT (const GLint *);
+GLAPI void APIENTRY glTangent3sEXT (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glTangent3svEXT (const GLshort *);
+GLAPI void APIENTRY glBinormal3bEXT (GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glBinormal3bvEXT (const GLbyte *);
+GLAPI void APIENTRY glBinormal3dEXT (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glBinormal3dvEXT (const GLdouble *);
+GLAPI void APIENTRY glBinormal3fEXT (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glBinormal3fvEXT (const GLfloat *);
+GLAPI void APIENTRY glBinormal3iEXT (GLint, GLint, GLint);
+GLAPI void APIENTRY glBinormal3ivEXT (const GLint *);
+GLAPI void APIENTRY glBinormal3sEXT (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glBinormal3svEXT (const GLshort *);
+GLAPI void APIENTRY glTangentPointerEXT (GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glBinormalPointerEXT (GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTANGENT3BEXTPROC) (GLbyte tx, GLbyte ty, GLbyte tz);
+typedef void (APIENTRYP PFNGLTANGENT3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLTANGENT3DEXTPROC) (GLdouble tx, GLdouble ty, GLdouble tz);
+typedef void (APIENTRYP PFNGLTANGENT3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLTANGENT3FEXTPROC) (GLfloat tx, GLfloat ty, GLfloat tz);
+typedef void (APIENTRYP PFNGLTANGENT3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLTANGENT3IEXTPROC) (GLint tx, GLint ty, GLint tz);
+typedef void (APIENTRYP PFNGLTANGENT3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLTANGENT3SEXTPROC) (GLshort tx, GLshort ty, GLshort tz);
+typedef void (APIENTRYP PFNGLTANGENT3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLBINORMAL3BEXTPROC) (GLbyte bx, GLbyte by, GLbyte bz);
+typedef void (APIENTRYP PFNGLBINORMAL3BVEXTPROC) (const GLbyte *v);
+typedef void (APIENTRYP PFNGLBINORMAL3DEXTPROC) (GLdouble bx, GLdouble by, GLdouble bz);
+typedef void (APIENTRYP PFNGLBINORMAL3DVEXTPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLBINORMAL3FEXTPROC) (GLfloat bx, GLfloat by, GLfloat bz);
+typedef void (APIENTRYP PFNGLBINORMAL3FVEXTPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLBINORMAL3IEXTPROC) (GLint bx, GLint by, GLint bz);
+typedef void (APIENTRYP PFNGLBINORMAL3IVEXTPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLBINORMAL3SEXTPROC) (GLshort bx, GLshort by, GLshort bz);
+typedef void (APIENTRYP PFNGLBINORMAL3SVEXTPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLTANGENTPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLBINORMALPOINTEREXTPROC) (GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_EXT_texture_env_combine
+#define GL_EXT_texture_env_combine 1
+#endif
+
+#ifndef GL_APPLE_specular_vector
+#define GL_APPLE_specular_vector 1
+#endif
+
+#ifndef GL_APPLE_transform_hint
+#define GL_APPLE_transform_hint 1
+#endif
+
+#ifndef GL_SGIX_fog_scale
+#define GL_SGIX_fog_scale 1
+#endif
+
+#ifndef GL_SUNX_constant_data
+#define GL_SUNX_constant_data 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFinishTextureSUNX (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFINISHTEXTURESUNXPROC) (void);
+#endif
+
+#ifndef GL_SUN_global_alpha
+#define GL_SUN_global_alpha 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGlobalAlphaFactorbSUN (GLbyte);
+GLAPI void APIENTRY glGlobalAlphaFactorsSUN (GLshort);
+GLAPI void APIENTRY glGlobalAlphaFactoriSUN (GLint);
+GLAPI void APIENTRY glGlobalAlphaFactorfSUN (GLfloat);
+GLAPI void APIENTRY glGlobalAlphaFactordSUN (GLdouble);
+GLAPI void APIENTRY glGlobalAlphaFactorubSUN (GLubyte);
+GLAPI void APIENTRY glGlobalAlphaFactorusSUN (GLushort);
+GLAPI void APIENTRY glGlobalAlphaFactoruiSUN (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORBSUNPROC) (GLbyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORSSUNPROC) (GLshort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORISUNPROC) (GLint factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORFSUNPROC) (GLfloat factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORDSUNPROC) (GLdouble factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUBSUNPROC) (GLubyte factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUSSUNPROC) (GLushort factor);
+typedef void (APIENTRYP PFNGLGLOBALALPHAFACTORUISUNPROC) (GLuint factor);
+#endif
+
+#ifndef GL_SUN_triangle_list
+#define GL_SUN_triangle_list 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glReplacementCodeuiSUN (GLuint);
+GLAPI void APIENTRY glReplacementCodeusSUN (GLushort);
+GLAPI void APIENTRY glReplacementCodeubSUN (GLubyte);
+GLAPI void APIENTRY glReplacementCodeuivSUN (const GLuint *);
+GLAPI void APIENTRY glReplacementCodeusvSUN (const GLushort *);
+GLAPI void APIENTRY glReplacementCodeubvSUN (const GLubyte *);
+GLAPI void APIENTRY glReplacementCodePointerSUN (GLenum, GLsizei, const GLvoid* *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUISUNPROC) (GLuint code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSSUNPROC) (GLushort code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBSUNPROC) (GLubyte code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVSUNPROC) (const GLuint *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUSVSUNPROC) (const GLushort *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUBVSUNPROC) (const GLubyte *code);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEPOINTERSUNPROC) (GLenum type, GLsizei stride, const GLvoid* *pointer);
+#endif
+
+#ifndef GL_SUN_vertex
+#define GL_SUN_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColor4ubVertex2fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor4ubVertex2fvSUN (const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glColor4ubVertex3fSUN (GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor4ubVertex3fvSUN (const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor3fVertex3fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fVertex3fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord4fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord4fVertex4fvSUN (const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fSUN (GLfloat, GLfloat, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fColor4ubVertex3fvSUN (const GLfloat *, const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fColor3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord2fColor4fNormal3fVertex3fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fSUN (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glTexCoord4fColor4fNormal3fVertex4fvSUN (const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiVertex3fvSUN (const GLuint *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fSUN (GLuint, GLubyte, GLubyte, GLubyte, GLubyte, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiColor4ubVertex3fvSUN (const GLuint *, const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiColor3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fSUN (GLuint, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glReplacementCodeuiTexCoord2fColor4fNormal3fVertex3fvSUN (const GLuint *, const GLfloat *, const GLfloat *, const GLfloat *, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX2FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FSUNPROC) (GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4UBVERTEX3FVSUNPROC) (const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FSUNPROC) (GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLTEXCOORD4FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4UBVERTEX3FVSUNPROC) (const GLfloat *tc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLTEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FSUNPROC) (GLfloat s, GLfloat t, GLfloat p, GLfloat q, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLTEXCOORD4FCOLOR4FNORMAL3FVERTEX4FVSUNPROC) (const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FSUNPROC) (GLuint rc, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUIVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FSUNPROC) (GLuint rc, GLubyte r, GLubyte g, GLubyte b, GLubyte a, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4UBVERTEX3FVSUNPROC) (const GLuint *rc, const GLubyte *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUINORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUICOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *n, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FSUNPROC) (GLuint rc, GLfloat s, GLfloat t, GLfloat r, GLfloat g, GLfloat b, GLfloat a, GLfloat nx, GLfloat ny, GLfloat nz, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLREPLACEMENTCODEUITEXCOORD2FCOLOR4FNORMAL3FVERTEX3FVSUNPROC) (const GLuint *rc, const GLfloat *tc, const GLfloat *c, const GLfloat *n, const GLfloat *v);
+#endif
+
+#ifndef GL_EXT_blend_func_separate
+#define GL_EXT_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateEXT (GLenum, GLenum, GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEEXTPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_blend_func_separate
+#define GL_INGR_blend_func_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendFuncSeparateINGR (GLenum, GLenum, GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDFUNCSEPARATEINGRPROC) (GLenum sfactorRGB, GLenum dfactorRGB, GLenum sfactorAlpha, GLenum dfactorAlpha);
+#endif
+
+#ifndef GL_INGR_color_clamp
+#define GL_INGR_color_clamp 1
+#endif
+
+#ifndef GL_INGR_interlace_read
+#define GL_INGR_interlace_read 1
+#endif
+
+#ifndef GL_EXT_stencil_wrap
+#define GL_EXT_stencil_wrap 1
+#endif
+
+#ifndef GL_EXT_422_pixels
+#define GL_EXT_422_pixels 1
+#endif
+
+#ifndef GL_NV_texgen_reflection
+#define GL_NV_texgen_reflection 1
+#endif
+
+#ifndef GL_SUN_convolution_border_modes
+#define GL_SUN_convolution_border_modes 1
+#endif
+
+#ifndef GL_EXT_texture_env_add
+#define GL_EXT_texture_env_add 1
+#endif
+
+#ifndef GL_EXT_texture_lod_bias
+#define GL_EXT_texture_lod_bias 1
+#endif
+
+#ifndef GL_EXT_texture_filter_anisotropic
+#define GL_EXT_texture_filter_anisotropic 1
+#endif
+
+#ifndef GL_EXT_vertex_weighting
+#define GL_EXT_vertex_weighting 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexWeightfEXT (GLfloat);
+GLAPI void APIENTRY glVertexWeightfvEXT (const GLfloat *);
+GLAPI void APIENTRY glVertexWeightPointerEXT (GLsizei, GLenum, GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFEXTPROC) (GLfloat weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTFVEXTPROC) (const GLfloat *weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTPOINTEREXTPROC) (GLsizei size, GLenum type, GLsizei stride, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_light_max_exponent
+#define GL_NV_light_max_exponent 1
+#endif
+
+#ifndef GL_NV_vertex_array_range
+#define GL_NV_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFlushVertexArrayRangeNV (void);
+GLAPI void APIENTRY glVertexArrayRangeNV (GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGENVPROC) (void);
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGENVPROC) (GLsizei length, const GLvoid *pointer);
+#endif
+
+#ifndef GL_NV_register_combiners
+#define GL_NV_register_combiners 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerParameterfvNV (GLenum, const GLfloat *);
+GLAPI void APIENTRY glCombinerParameterfNV (GLenum, GLfloat);
+GLAPI void APIENTRY glCombinerParameterivNV (GLenum, const GLint *);
+GLAPI void APIENTRY glCombinerParameteriNV (GLenum, GLint);
+GLAPI void APIENTRY glCombinerInputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glCombinerOutputNV (GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLenum, GLboolean, GLboolean, GLboolean);
+GLAPI void APIENTRY glFinalCombinerInputNV (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glGetCombinerInputParameterfvNV (GLenum, GLenum, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetCombinerInputParameterivNV (GLenum, GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetCombinerOutputParameterfvNV (GLenum, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetCombinerOutputParameterivNV (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterfvNV (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetFinalCombinerInputParameterivNV (GLenum, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFVNVPROC) (GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERFNVPROC) (GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLCOMBINERPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLCOMBINERINPUTNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLCOMBINEROUTPUTNVPROC) (GLenum stage, GLenum portion, GLenum abOutput, GLenum cdOutput, GLenum sumOutput, GLenum scale, GLenum bias, GLboolean abDotProduct, GLboolean cdDotProduct, GLboolean muxSum);
+typedef void (APIENTRYP PFNGLFINALCOMBINERINPUTNVPROC) (GLenum variable, GLenum input, GLenum mapping, GLenum componentUsage);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERINPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum variable, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERFVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINEROUTPUTPARAMETERIVNVPROC) (GLenum stage, GLenum portion, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERFVNVPROC) (GLenum variable, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETFINALCOMBINERINPUTPARAMETERIVNVPROC) (GLenum variable, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_NV_fog_distance
+#define GL_NV_fog_distance 1
+#endif
+
+#ifndef GL_NV_texgen_emboss
+#define GL_NV_texgen_emboss 1
+#endif
+
+#ifndef GL_NV_blend_square
+#define GL_NV_blend_square 1
+#endif
+
+#ifndef GL_NV_texture_env_combine4
+#define GL_NV_texture_env_combine4 1
+#endif
+
+#ifndef GL_MESA_resize_buffers
+#define GL_MESA_resize_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glResizeBuffersMESA (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRESIZEBUFFERSMESAPROC) (void);
+#endif
+
+#ifndef GL_MESA_window_pos
+#define GL_MESA_window_pos 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glWindowPos2dMESA (GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos2dvMESA (const GLdouble *);
+GLAPI void APIENTRY glWindowPos2fMESA (GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos2fvMESA (const GLfloat *);
+GLAPI void APIENTRY glWindowPos2iMESA (GLint, GLint);
+GLAPI void APIENTRY glWindowPos2ivMESA (const GLint *);
+GLAPI void APIENTRY glWindowPos2sMESA (GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos2svMESA (const GLshort *);
+GLAPI void APIENTRY glWindowPos3dMESA (GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos3dvMESA (const GLdouble *);
+GLAPI void APIENTRY glWindowPos3fMESA (GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos3fvMESA (const GLfloat *);
+GLAPI void APIENTRY glWindowPos3iMESA (GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos3ivMESA (const GLint *);
+GLAPI void APIENTRY glWindowPos3sMESA (GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos3svMESA (const GLshort *);
+GLAPI void APIENTRY glWindowPos4dMESA (GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glWindowPos4dvMESA (const GLdouble *);
+GLAPI void APIENTRY glWindowPos4fMESA (GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glWindowPos4fvMESA (const GLfloat *);
+GLAPI void APIENTRY glWindowPos4iMESA (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glWindowPos4ivMESA (const GLint *);
+GLAPI void APIENTRY glWindowPos4sMESA (GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glWindowPos4svMESA (const GLshort *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLWINDOWPOS2DMESAPROC) (GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FMESAPROC) (GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IMESAPROC) (GLint x, GLint y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SMESAPROC) (GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLWINDOWPOS2SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DMESAPROC) (GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FMESAPROC) (GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IMESAPROC) (GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SMESAPROC) (GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLWINDOWPOS3SVMESAPROC) (const GLshort *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DMESAPROC) (GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4DVMESAPROC) (const GLdouble *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FMESAPROC) (GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4FVMESAPROC) (const GLfloat *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IMESAPROC) (GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4IVMESAPROC) (const GLint *v);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SMESAPROC) (GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLWINDOWPOS4SVMESAPROC) (const GLshort *v);
+#endif
+
+#ifndef GL_IBM_cull_vertex
+#define GL_IBM_cull_vertex 1
+#endif
+
+#ifndef GL_IBM_multimode_draw_arrays
+#define GL_IBM_multimode_draw_arrays 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMultiModeDrawArraysIBM (const GLenum *, const GLint *, const GLsizei *, GLsizei, GLint);
+GLAPI void APIENTRY glMultiModeDrawElementsIBM (const GLenum *, const GLsizei *, GLenum, const GLvoid* const *, GLsizei, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWARRAYSIBMPROC) (const GLenum *mode, const GLint *first, const GLsizei *count, GLsizei primcount, GLint modestride);
+typedef void (APIENTRYP PFNGLMULTIMODEDRAWELEMENTSIBMPROC) (const GLenum *mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount, GLint modestride);
+#endif
+
+#ifndef GL_IBM_vertex_array_lists
+#define GL_IBM_vertex_array_lists 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glSecondaryColorPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glEdgeFlagPointerListIBM (GLint, const GLboolean* *, GLint);
+GLAPI void APIENTRY glFogCoordPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glIndexPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glNormalPointerListIBM (GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glTexCoordPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+GLAPI void APIENTRY glVertexPointerListIBM (GLint, GLenum, GLint, const GLvoid* *, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLSECONDARYCOLORPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLEDGEFLAGPOINTERLISTIBMPROC) (GLint stride, const GLboolean* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLFOGCOORDPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLINDEXPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLNORMALPOINTERLISTIBMPROC) (GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLTEXCOORDPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+typedef void (APIENTRYP PFNGLVERTEXPOINTERLISTIBMPROC) (GLint size, GLenum type, GLint stride, const GLvoid* *pointer, GLint ptrstride);
+#endif
+
+#ifndef GL_SGIX_subsample
+#define GL_SGIX_subsample 1
+#endif
+
+#ifndef GL_SGIX_ycrcba
+#define GL_SGIX_ycrcba 1
+#endif
+
+#ifndef GL_SGIX_ycrcb_subsample
+#define GL_SGIX_ycrcb_subsample 1
+#endif
+
+#ifndef GL_SGIX_depth_pass_instrument
+#define GL_SGIX_depth_pass_instrument 1
+#endif
+
+#ifndef GL_3DFX_texture_compression_FXT1
+#define GL_3DFX_texture_compression_FXT1 1
+#endif
+
+#ifndef GL_3DFX_multisample
+#define GL_3DFX_multisample 1
+#endif
+
+#ifndef GL_3DFX_tbuffer
+#define GL_3DFX_tbuffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTbufferMask3DFX (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTBUFFERMASK3DFXPROC) (GLuint mask);
+#endif
+
+#ifndef GL_EXT_multisample
+#define GL_EXT_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glSampleMaskEXT (GLclampf, GLboolean);
+GLAPI void APIENTRY glSamplePatternEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSAMPLEMASKEXTPROC) (GLclampf value, GLboolean invert);
+typedef void (APIENTRYP PFNGLSAMPLEPATTERNEXTPROC) (GLenum pattern);
+#endif
+
+#ifndef GL_SGIX_vertex_preclip
+#define GL_SGIX_vertex_preclip 1
+#endif
+
+#ifndef GL_SGIX_convolution_accuracy
+#define GL_SGIX_convolution_accuracy 1
+#endif
+
+#ifndef GL_SGIX_resample
+#define GL_SGIX_resample 1
+#endif
+
+#ifndef GL_SGIS_point_line_texgen
+#define GL_SGIS_point_line_texgen 1
+#endif
+
+#ifndef GL_SGIS_texture_color_mask
+#define GL_SGIS_texture_color_mask 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTextureColorMaskSGIS (GLboolean, GLboolean, GLboolean, GLboolean);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXTURECOLORMASKSGISPROC) (GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha);
+#endif
+
+#ifndef GL_SGIX_igloo_interface
+#define GL_SGIX_igloo_interface 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glIglooInterfaceSGIX (GLenum, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLIGLOOINTERFACESGIXPROC) (GLenum pname, const GLvoid *params);
+#endif
+
+#ifndef GL_EXT_texture_env_dot3
+#define GL_EXT_texture_env_dot3 1
+#endif
+
+#ifndef GL_ATI_texture_mirror_once
+#define GL_ATI_texture_mirror_once 1
+#endif
+
+#ifndef GL_NV_fence
+#define GL_NV_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDeleteFencesNV (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenFencesNV (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsFenceNV (GLuint);
+GLAPI GLboolean APIENTRY glTestFenceNV (GLuint);
+GLAPI void APIENTRY glGetFenceivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glFinishFenceNV (GLuint);
+GLAPI void APIENTRY glSetFenceNV (GLuint, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDELETEFENCESNVPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLGENFENCESNVPROC) (GLsizei n, GLuint *fences);
+typedef GLboolean (APIENTRYP PFNGLISFENCENVPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLGETFENCEIVNVPROC) (GLuint fence, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFINISHFENCENVPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLSETFENCENVPROC) (GLuint fence, GLenum condition);
+#endif
+
+#ifndef GL_NV_evaluators
+#define GL_NV_evaluators 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLint, GLint, GLboolean, const GLvoid *);
+GLAPI void APIENTRY glMapParameterivNV (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glMapParameterfvNV (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetMapControlPointsNV (GLenum, GLuint, GLenum, GLsizei, GLsizei, GLboolean, GLvoid *);
+GLAPI void APIENTRY glGetMapParameterivNV (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMapParameterfvNV (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMapAttribParameterivNV (GLenum, GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetMapAttribParameterfvNV (GLenum, GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glEvalMapsNV (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLint uorder, GLint vorder, GLboolean packed, const GLvoid *points);
+typedef void (APIENTRYP PFNGLMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPCONTROLPOINTSNVPROC) (GLenum target, GLuint index, GLenum type, GLsizei ustride, GLsizei vstride, GLboolean packed, GLvoid *points);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERIVNVPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPPARAMETERFVNVPROC) (GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERIVNVPROC) (GLenum target, GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMAPATTRIBPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLEVALMAPSNVPROC) (GLenum target, GLenum mode);
+#endif
+
+#ifndef GL_NV_packed_depth_stencil
+#define GL_NV_packed_depth_stencil 1
+#endif
+
+#ifndef GL_NV_register_combiners2
+#define GL_NV_register_combiners2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glCombinerStageParameterfvNV (GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetCombinerStageParameterfvNV (GLenum, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETCOMBINERSTAGEPARAMETERFVNVPROC) (GLenum stage, GLenum pname, GLfloat *params);
+#endif
+
+#ifndef GL_NV_texture_compression_vtc
+#define GL_NV_texture_compression_vtc 1
+#endif
+
+#ifndef GL_NV_texture_rectangle
+#define GL_NV_texture_rectangle 1
+#endif
+
+#ifndef GL_NV_texture_shader
+#define GL_NV_texture_shader 1
+#endif
+
+#ifndef GL_NV_texture_shader2
+#define GL_NV_texture_shader2 1
+#endif
+
+#ifndef GL_NV_vertex_array_range2
+#define GL_NV_vertex_array_range2 1
+#endif
+
+#ifndef GL_NV_vertex_program
+#define GL_NV_vertex_program 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glAreProgramsResidentNV (GLsizei, const GLuint *, GLboolean *);
+GLAPI void APIENTRY glBindProgramNV (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteProgramsNV (GLsizei, const GLuint *);
+GLAPI void APIENTRY glExecuteProgramNV (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glGenProgramsNV (GLsizei, GLuint *);
+GLAPI void APIENTRY glGetProgramParameterdvNV (GLenum, GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetProgramParameterfvNV (GLenum, GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetProgramivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetProgramStringNV (GLuint, GLenum, GLubyte *);
+GLAPI void APIENTRY glGetTrackMatrixivNV (GLenum, GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribdvNV (GLuint, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetVertexAttribfvNV (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribPointervNV (GLuint, GLenum, GLvoid* *);
+GLAPI GLboolean APIENTRY glIsProgramNV (GLuint);
+GLAPI void APIENTRY glLoadProgramNV (GLenum, GLuint, GLsizei, const GLubyte *);
+GLAPI void APIENTRY glProgramParameter4dNV (GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramParameter4dvNV (GLenum, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramParameter4fNV (GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramParameter4fvNV (GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glProgramParameters4dvNV (GLenum, GLuint, GLuint, const GLdouble *);
+GLAPI void APIENTRY glProgramParameters4fvNV (GLenum, GLuint, GLuint, const GLfloat *);
+GLAPI void APIENTRY glRequestResidentProgramsNV (GLsizei, const GLuint *);
+GLAPI void APIENTRY glTrackMatrixNV (GLenum, GLuint, GLenum, GLenum);
+GLAPI void APIENTRY glVertexAttribPointerNV (GLuint, GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glVertexAttrib1dNV (GLuint, GLdouble);
+GLAPI void APIENTRY glVertexAttrib1dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib1fNV (GLuint, GLfloat);
+GLAPI void APIENTRY glVertexAttrib1fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib1sNV (GLuint, GLshort);
+GLAPI void APIENTRY glVertexAttrib1svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib2dNV (GLuint, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib2dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib2fNV (GLuint, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib2fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib2sNV (GLuint, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib2svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib3dNV (GLuint, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib3dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib3fNV (GLuint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib3fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib3sNV (GLuint, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib3svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4dNV (GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexAttrib4dvNV (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVertexAttrib4fNV (GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexAttrib4fvNV (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVertexAttrib4sNV (GLuint, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexAttrib4svNV (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttrib4ubNV (GLuint, GLubyte, GLubyte, GLubyte, GLubyte);
+GLAPI void APIENTRY glVertexAttrib4ubvNV (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttribs1dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs1fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs1svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs2dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs2fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs2svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs3dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs3fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs3svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs4dvNV (GLuint, GLsizei, const GLdouble *);
+GLAPI void APIENTRY glVertexAttribs4fvNV (GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glVertexAttribs4svNV (GLuint, GLsizei, const GLshort *);
+GLAPI void APIENTRY glVertexAttribs4ubvNV (GLuint, GLsizei, const GLubyte *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLAREPROGRAMSRESIDENTNVPROC) (GLsizei n, const GLuint *programs, GLboolean *residences);
+typedef void (APIENTRYP PFNGLBINDPROGRAMNVPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETEPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLEXECUTEPROGRAMNVPROC) (GLenum target, GLuint id, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGENPROGRAMSNVPROC) (GLsizei n, GLuint *programs);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERDVNVPROC) (GLenum target, GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMPARAMETERFVNVPROC) (GLenum target, GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMSTRINGNVPROC) (GLuint id, GLenum pname, GLubyte *program);
+typedef void (APIENTRYP PFNGLGETTRACKMATRIXIVNVPROC) (GLenum target, GLuint address, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBDVNVPROC) (GLuint index, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBFVNVPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIVNVPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBPOINTERVNVPROC) (GLuint index, GLenum pname, GLvoid* *pointer);
+typedef GLboolean (APIENTRYP PFNGLISPROGRAMNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLLOADPROGRAMNVPROC) (GLenum target, GLuint id, GLsizei len, const GLubyte *program);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DNVPROC) (GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4DVNVPROC) (GLenum target, GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FNVPROC) (GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETER4FVNVPROC) (GLenum target, GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4DVNVPROC) (GLenum target, GLuint index, GLuint count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERS4FVNVPROC) (GLenum target, GLuint index, GLuint count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLREQUESTRESIDENTPROGRAMSNVPROC) (GLsizei n, const GLuint *programs);
+typedef void (APIENTRYP PFNGLTRACKMATRIXNVPROC) (GLenum target, GLuint address, GLenum matrix, GLenum transform);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBPOINTERNVPROC) (GLuint index, GLint fsize, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DNVPROC) (GLuint index, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FNVPROC) (GLuint index, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SNVPROC) (GLuint index, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DNVPROC) (GLuint index, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FNVPROC) (GLuint index, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SNVPROC) (GLuint index, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DNVPROC) (GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4DVNVPROC) (GLuint index, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FNVPROC) (GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4FVNVPROC) (GLuint index, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SNVPROC) (GLuint index, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4SVNVPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBNVPROC) (GLuint index, GLubyte x, GLubyte y, GLubyte z, GLubyte w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4UBVNVPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4DVNVPROC) (GLuint index, GLsizei count, const GLdouble *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4FVNVPROC) (GLuint index, GLsizei count, const GLfloat *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4SVNVPROC) (GLuint index, GLsizei count, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4UBVNVPROC) (GLuint index, GLsizei count, const GLubyte *v);
+#endif
+
+#ifndef GL_SGIX_texture_coordinate_clamp
+#define GL_SGIX_texture_coordinate_clamp 1
+#endif
+
+#ifndef GL_SGIX_scalebias_hint
+#define GL_SGIX_scalebias_hint 1
+#endif
+
+#ifndef GL_OML_interlace
+#define GL_OML_interlace 1
+#endif
+
+#ifndef GL_OML_subsample
+#define GL_OML_subsample 1
+#endif
+
+#ifndef GL_OML_resample
+#define GL_OML_resample 1
+#endif
+
+#ifndef GL_NV_copy_depth_to_color
+#define GL_NV_copy_depth_to_color 1
+#endif
+
+#ifndef GL_ATI_envmap_bumpmap
+#define GL_ATI_envmap_bumpmap 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBumpParameterivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glTexBumpParameterfvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glGetTexBumpParameterivATI (GLenum, GLint *);
+GLAPI void APIENTRY glGetTexBumpParameterfvATI (GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERIVATIPROC) (GLenum pname, const GLint *param);
+typedef void (APIENTRYP PFNGLTEXBUMPPARAMETERFVATIPROC) (GLenum pname, const GLfloat *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERIVATIPROC) (GLenum pname, GLint *param);
+typedef void (APIENTRYP PFNGLGETTEXBUMPPARAMETERFVATIPROC) (GLenum pname, GLfloat *param);
+#endif
+
+#ifndef GL_ATI_fragment_shader
+#define GL_ATI_fragment_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glGenFragmentShadersATI (GLuint);
+GLAPI void APIENTRY glBindFragmentShaderATI (GLuint);
+GLAPI void APIENTRY glDeleteFragmentShaderATI (GLuint);
+GLAPI void APIENTRY glBeginFragmentShaderATI (void);
+GLAPI void APIENTRY glEndFragmentShaderATI (void);
+GLAPI void APIENTRY glPassTexCoordATI (GLuint, GLuint, GLenum);
+GLAPI void APIENTRY glSampleMapATI (GLuint, GLuint, GLenum);
+GLAPI void APIENTRY glColorFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glColorFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glColorFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glAlphaFragmentOp1ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glAlphaFragmentOp2ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glAlphaFragmentOp3ATI (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSetFragmentShaderConstantATI (GLuint, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLGENFRAGMENTSHADERSATIPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLBINDFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDELETEFRAGMENTSHADERATIPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLENDFRAGMENTSHADERATIPROC) (void);
+typedef void (APIENTRYP PFNGLPASSTEXCOORDATIPROC) (GLuint dst, GLuint coord, GLenum swizzle);
+typedef void (APIENTRYP PFNGLSAMPLEMAPATIPROC) (GLuint dst, GLuint interp, GLenum swizzle);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLCOLORFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP1ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP2ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod);
+typedef void (APIENTRYP PFNGLALPHAFRAGMENTOP3ATIPROC) (GLenum op, GLuint dst, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod);
+typedef void (APIENTRYP PFNGLSETFRAGMENTSHADERCONSTANTATIPROC) (GLuint dst, const GLfloat *value);
+#endif
+
+#ifndef GL_ATI_pn_triangles
+#define GL_ATI_pn_triangles 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPNTrianglesiATI (GLenum, GLint);
+GLAPI void APIENTRY glPNTrianglesfATI (GLenum, GLfloat);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPNTRIANGLESIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPNTRIANGLESFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_vertex_array_object
+#define GL_ATI_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLuint APIENTRY glNewObjectBufferATI (GLsizei, const GLvoid *, GLenum);
+GLAPI GLboolean APIENTRY glIsObjectBufferATI (GLuint);
+GLAPI void APIENTRY glUpdateObjectBufferATI (GLuint, GLuint, GLsizei, const GLvoid *, GLenum);
+GLAPI void APIENTRY glGetObjectBufferfvATI (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetObjectBufferivATI (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glFreeObjectBufferATI (GLuint);
+GLAPI void APIENTRY glArrayObjectATI (GLenum, GLint, GLenum, GLsizei, GLuint, GLuint);
+GLAPI void APIENTRY glGetArrayObjectfvATI (GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetArrayObjectivATI (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glVariantArrayObjectATI (GLuint, GLenum, GLsizei, GLuint, GLuint);
+GLAPI void APIENTRY glGetVariantArrayObjectfvATI (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVariantArrayObjectivATI (GLuint, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLuint (APIENTRYP PFNGLNEWOBJECTBUFFERATIPROC) (GLsizei size, const GLvoid *pointer, GLenum usage);
+typedef GLboolean (APIENTRYP PFNGLISOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUPDATEOBJECTBUFFERATIPROC) (GLuint buffer, GLuint offset, GLsizei size, const GLvoid *pointer, GLenum preserve);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERFVATIPROC) (GLuint buffer, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETOBJECTBUFFERIVATIPROC) (GLuint buffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLFREEOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLARRAYOBJECTATIPROC) (GLenum array, GLint size, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTFVATIPROC) (GLenum array, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETARRAYOBJECTIVATIPROC) (GLenum array, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLVARIANTARRAYOBJECTATIPROC) (GLuint id, GLenum type, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTFVATIPROC) (GLuint id, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVARIANTARRAYOBJECTIVATIPROC) (GLuint id, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_EXT_vertex_shader
+#define GL_EXT_vertex_shader 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginVertexShaderEXT (void);
+GLAPI void APIENTRY glEndVertexShaderEXT (void);
+GLAPI void APIENTRY glBindVertexShaderEXT (GLuint);
+GLAPI GLuint APIENTRY glGenVertexShadersEXT (GLuint);
+GLAPI void APIENTRY glDeleteVertexShaderEXT (GLuint);
+GLAPI void APIENTRY glShaderOp1EXT (GLenum, GLuint, GLuint);
+GLAPI void APIENTRY glShaderOp2EXT (GLenum, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glShaderOp3EXT (GLenum, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glSwizzleEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glWriteMaskEXT (GLuint, GLuint, GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glInsertComponentEXT (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glExtractComponentEXT (GLuint, GLuint, GLuint);
+GLAPI GLuint APIENTRY glGenSymbolsEXT (GLenum, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glSetInvariantEXT (GLuint, GLenum, const GLvoid *);
+GLAPI void APIENTRY glSetLocalConstantEXT (GLuint, GLenum, const GLvoid *);
+GLAPI void APIENTRY glVariantbvEXT (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVariantsvEXT (GLuint, const GLshort *);
+GLAPI void APIENTRY glVariantivEXT (GLuint, const GLint *);
+GLAPI void APIENTRY glVariantfvEXT (GLuint, const GLfloat *);
+GLAPI void APIENTRY glVariantdvEXT (GLuint, const GLdouble *);
+GLAPI void APIENTRY glVariantubvEXT (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVariantusvEXT (GLuint, const GLushort *);
+GLAPI void APIENTRY glVariantuivEXT (GLuint, const GLuint *);
+GLAPI void APIENTRY glVariantPointerEXT (GLuint, GLenum, GLuint, const GLvoid *);
+GLAPI void APIENTRY glEnableVariantClientStateEXT (GLuint);
+GLAPI void APIENTRY glDisableVariantClientStateEXT (GLuint);
+GLAPI GLuint APIENTRY glBindLightParameterEXT (GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindMaterialParameterEXT (GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindTexGenParameterEXT (GLenum, GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindTextureUnitParameterEXT (GLenum, GLenum);
+GLAPI GLuint APIENTRY glBindParameterEXT (GLenum);
+GLAPI GLboolean APIENTRY glIsVariantEnabledEXT (GLuint, GLenum);
+GLAPI void APIENTRY glGetVariantBooleanvEXT (GLuint, GLenum, GLboolean *);
+GLAPI void APIENTRY glGetVariantIntegervEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVariantFloatvEXT (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVariantPointervEXT (GLuint, GLenum, GLvoid* *);
+GLAPI void APIENTRY glGetInvariantBooleanvEXT (GLuint, GLenum, GLboolean *);
+GLAPI void APIENTRY glGetInvariantIntegervEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetInvariantFloatvEXT (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetLocalConstantBooleanvEXT (GLuint, GLenum, GLboolean *);
+GLAPI void APIENTRY glGetLocalConstantIntegervEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetLocalConstantFloatvEXT (GLuint, GLenum, GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLENDVERTEXSHADEREXTPROC) (void);
+typedef void (APIENTRYP PFNGLBINDVERTEXSHADEREXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLGENVERTEXSHADERSEXTPROC) (GLuint range);
+typedef void (APIENTRYP PFNGLDELETEVERTEXSHADEREXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLSHADEROP1EXTPROC) (GLenum op, GLuint res, GLuint arg1);
+typedef void (APIENTRYP PFNGLSHADEROP2EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2);
+typedef void (APIENTRYP PFNGLSHADEROP3EXTPROC) (GLenum op, GLuint res, GLuint arg1, GLuint arg2, GLuint arg3);
+typedef void (APIENTRYP PFNGLSWIZZLEEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLWRITEMASKEXTPROC) (GLuint res, GLuint in, GLenum outX, GLenum outY, GLenum outZ, GLenum outW);
+typedef void (APIENTRYP PFNGLINSERTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef void (APIENTRYP PFNGLEXTRACTCOMPONENTEXTPROC) (GLuint res, GLuint src, GLuint num);
+typedef GLuint (APIENTRYP PFNGLGENSYMBOLSEXTPROC) (GLenum datatype, GLenum storagetype, GLenum range, GLuint components);
+typedef void (APIENTRYP PFNGLSETINVARIANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLSETLOCALCONSTANTEXTPROC) (GLuint id, GLenum type, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLVARIANTBVEXTPROC) (GLuint id, const GLbyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTSVEXTPROC) (GLuint id, const GLshort *addr);
+typedef void (APIENTRYP PFNGLVARIANTIVEXTPROC) (GLuint id, const GLint *addr);
+typedef void (APIENTRYP PFNGLVARIANTFVEXTPROC) (GLuint id, const GLfloat *addr);
+typedef void (APIENTRYP PFNGLVARIANTDVEXTPROC) (GLuint id, const GLdouble *addr);
+typedef void (APIENTRYP PFNGLVARIANTUBVEXTPROC) (GLuint id, const GLubyte *addr);
+typedef void (APIENTRYP PFNGLVARIANTUSVEXTPROC) (GLuint id, const GLushort *addr);
+typedef void (APIENTRYP PFNGLVARIANTUIVEXTPROC) (GLuint id, const GLuint *addr);
+typedef void (APIENTRYP PFNGLVARIANTPOINTEREXTPROC) (GLuint id, GLenum type, GLuint stride, const GLvoid *addr);
+typedef void (APIENTRYP PFNGLENABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLDISABLEVARIANTCLIENTSTATEEXTPROC) (GLuint id);
+typedef GLuint (APIENTRYP PFNGLBINDLIGHTPARAMETEREXTPROC) (GLenum light, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDMATERIALPARAMETEREXTPROC) (GLenum face, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXGENPARAMETEREXTPROC) (GLenum unit, GLenum coord, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDTEXTUREUNITPARAMETEREXTPROC) (GLenum unit, GLenum value);
+typedef GLuint (APIENTRYP PFNGLBINDPARAMETEREXTPROC) (GLenum value);
+typedef GLboolean (APIENTRYP PFNGLISVARIANTENABLEDEXTPROC) (GLuint id, GLenum cap);
+typedef void (APIENTRYP PFNGLGETVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETVARIANTPOINTERVEXTPROC) (GLuint id, GLenum value, GLvoid* *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETINVARIANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTBOOLEANVEXTPROC) (GLuint id, GLenum value, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTINTEGERVEXTPROC) (GLuint id, GLenum value, GLint *data);
+typedef void (APIENTRYP PFNGLGETLOCALCONSTANTFLOATVEXTPROC) (GLuint id, GLenum value, GLfloat *data);
+#endif
+
+#ifndef GL_ATI_vertex_streams
+#define GL_ATI_vertex_streams 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexStream1sATI (GLenum, GLshort);
+GLAPI void APIENTRY glVertexStream1svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream1iATI (GLenum, GLint);
+GLAPI void APIENTRY glVertexStream1ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream1fATI (GLenum, GLfloat);
+GLAPI void APIENTRY glVertexStream1fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream1dATI (GLenum, GLdouble);
+GLAPI void APIENTRY glVertexStream1dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glVertexStream2sATI (GLenum, GLshort, GLshort);
+GLAPI void APIENTRY glVertexStream2svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream2iATI (GLenum, GLint, GLint);
+GLAPI void APIENTRY glVertexStream2ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream2fATI (GLenum, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexStream2fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream2dATI (GLenum, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexStream2dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glVertexStream3sATI (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexStream3svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream3iATI (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexStream3ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream3fATI (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexStream3fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream3dATI (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexStream3dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glVertexStream4sATI (GLenum, GLshort, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glVertexStream4svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glVertexStream4iATI (GLenum, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexStream4ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glVertexStream4fATI (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glVertexStream4fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glVertexStream4dATI (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glVertexStream4dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glNormalStream3bATI (GLenum, GLbyte, GLbyte, GLbyte);
+GLAPI void APIENTRY glNormalStream3bvATI (GLenum, const GLbyte *);
+GLAPI void APIENTRY glNormalStream3sATI (GLenum, GLshort, GLshort, GLshort);
+GLAPI void APIENTRY glNormalStream3svATI (GLenum, const GLshort *);
+GLAPI void APIENTRY glNormalStream3iATI (GLenum, GLint, GLint, GLint);
+GLAPI void APIENTRY glNormalStream3ivATI (GLenum, const GLint *);
+GLAPI void APIENTRY glNormalStream3fATI (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glNormalStream3fvATI (GLenum, const GLfloat *);
+GLAPI void APIENTRY glNormalStream3dATI (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glNormalStream3dvATI (GLenum, const GLdouble *);
+GLAPI void APIENTRY glClientActiveVertexStreamATI (GLenum);
+GLAPI void APIENTRY glVertexBlendEnviATI (GLenum, GLint);
+GLAPI void APIENTRY glVertexBlendEnvfATI (GLenum, GLfloat);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SATIPROC) (GLenum stream, GLshort x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IATIPROC) (GLenum stream, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FATIPROC) (GLenum stream, GLfloat x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DATIPROC) (GLenum stream, GLdouble x);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM1DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SATIPROC) (GLenum stream, GLshort x, GLshort y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IATIPROC) (GLenum stream, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FATIPROC) (GLenum stream, GLfloat x, GLfloat y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DATIPROC) (GLenum stream, GLdouble x, GLdouble y);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM2DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IATIPROC) (GLenum stream, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SATIPROC) (GLenum stream, GLshort x, GLshort y, GLshort z, GLshort w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IATIPROC) (GLenum stream, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FATIPROC) (GLenum stream, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DATIPROC) (GLenum stream, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLVERTEXSTREAM4DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BATIPROC) (GLenum stream, GLbyte nx, GLbyte ny, GLbyte nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3BVATIPROC) (GLenum stream, const GLbyte *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SATIPROC) (GLenum stream, GLshort nx, GLshort ny, GLshort nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3SVATIPROC) (GLenum stream, const GLshort *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IATIPROC) (GLenum stream, GLint nx, GLint ny, GLint nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3IVATIPROC) (GLenum stream, const GLint *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FATIPROC) (GLenum stream, GLfloat nx, GLfloat ny, GLfloat nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3FVATIPROC) (GLenum stream, const GLfloat *coords);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DATIPROC) (GLenum stream, GLdouble nx, GLdouble ny, GLdouble nz);
+typedef void (APIENTRYP PFNGLNORMALSTREAM3DVATIPROC) (GLenum stream, const GLdouble *coords);
+typedef void (APIENTRYP PFNGLCLIENTACTIVEVERTEXSTREAMATIPROC) (GLenum stream);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVIATIPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLVERTEXBLENDENVFATIPROC) (GLenum pname, GLfloat param);
+#endif
+
+#ifndef GL_ATI_element_array
+#define GL_ATI_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerATI (GLenum, const GLvoid *);
+GLAPI void APIENTRY glDrawElementArrayATI (GLenum, GLsizei);
+GLAPI void APIENTRY glDrawRangeElementArrayATI (GLenum, GLuint, GLuint, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERATIPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYATIPROC) (GLenum mode, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYATIPROC) (GLenum mode, GLuint start, GLuint end, GLsizei count);
+#endif
+
+#ifndef GL_SUN_mesh_array
+#define GL_SUN_mesh_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawMeshArraysSUN (GLenum, GLint, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWMESHARRAYSSUNPROC) (GLenum mode, GLint first, GLsizei count, GLsizei width);
+#endif
+
+#ifndef GL_SUN_slice_accum
+#define GL_SUN_slice_accum 1
+#endif
+
+#ifndef GL_NV_multisample_filter_hint
+#define GL_NV_multisample_filter_hint 1
+#endif
+
+#ifndef GL_NV_depth_clamp
+#define GL_NV_depth_clamp 1
+#endif
+
+#ifndef GL_NV_occlusion_query
+#define GL_NV_occlusion_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenOcclusionQueriesNV (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteOcclusionQueriesNV (GLsizei, const GLuint *);
+GLAPI GLboolean APIENTRY glIsOcclusionQueryNV (GLuint);
+GLAPI void APIENTRY glBeginOcclusionQueryNV (GLuint);
+GLAPI void APIENTRY glEndOcclusionQueryNV (void);
+GLAPI void APIENTRY glGetOcclusionQueryivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetOcclusionQueryuivNV (GLuint, GLenum, GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENOCCLUSIONQUERIESNVPROC) (GLsizei n, GLuint *ids);
+typedef void (APIENTRYP PFNGLDELETEOCCLUSIONQUERIESNVPROC) (GLsizei n, const GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLBEGINOCCLUSIONQUERYNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLENDOCCLUSIONQUERYNVPROC) (void);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYIVNVPROC) (GLuint id, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETOCCLUSIONQUERYUIVNVPROC) (GLuint id, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_NV_point_sprite
+#define GL_NV_point_sprite 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPointParameteriNV (GLenum, GLint);
+GLAPI void APIENTRY glPointParameterivNV (GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPOINTPARAMETERINVPROC) (GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLPOINTPARAMETERIVNVPROC) (GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_NV_texture_shader3
+#define GL_NV_texture_shader3 1
+#endif
+
+#ifndef GL_NV_vertex_program1_1
+#define GL_NV_vertex_program1_1 1
+#endif
+
+#ifndef GL_EXT_shadow_funcs
+#define GL_EXT_shadow_funcs 1
+#endif
+
+#ifndef GL_EXT_stencil_two_side
+#define GL_EXT_stencil_two_side 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glActiveStencilFaceEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLACTIVESTENCILFACEEXTPROC) (GLenum face);
+#endif
+
+#ifndef GL_ATI_text_fragment_shader
+#define GL_ATI_text_fragment_shader 1
+#endif
+
+#ifndef GL_APPLE_client_storage
+#define GL_APPLE_client_storage 1
+#endif
+
+#ifndef GL_APPLE_element_array
+#define GL_APPLE_element_array 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glElementPointerAPPLE (GLenum, const GLvoid *);
+GLAPI void APIENTRY glDrawElementArrayAPPLE (GLenum, GLint, GLsizei);
+GLAPI void APIENTRY glDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, GLint, GLsizei);
+GLAPI void APIENTRY glMultiDrawElementArrayAPPLE (GLenum, const GLint *, const GLsizei *, GLsizei);
+GLAPI void APIENTRY glMultiDrawRangeElementArrayAPPLE (GLenum, GLuint, GLuint, const GLint *, const GLsizei *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLELEMENTPOINTERAPPLEPROC) (GLenum type, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, GLint first, GLsizei count);
+typedef void (APIENTRYP PFNGLMULTIDRAWELEMENTARRAYAPPLEPROC) (GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLMULTIDRAWRANGEELEMENTARRAYAPPLEPROC) (GLenum mode, GLuint start, GLuint end, const GLint *first, const GLsizei *count, GLsizei primcount);
+#endif
+
+#ifndef GL_APPLE_fence
+#define GL_APPLE_fence 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGenFencesAPPLE (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeleteFencesAPPLE (GLsizei, const GLuint *);
+GLAPI void APIENTRY glSetFenceAPPLE (GLuint);
+GLAPI GLboolean APIENTRY glIsFenceAPPLE (GLuint);
+GLAPI GLboolean APIENTRY glTestFenceAPPLE (GLuint);
+GLAPI void APIENTRY glFinishFenceAPPLE (GLuint);
+GLAPI GLboolean APIENTRY glTestObjectAPPLE (GLenum, GLuint);
+GLAPI void APIENTRY glFinishObjectAPPLE (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGENFENCESAPPLEPROC) (GLsizei n, GLuint *fences);
+typedef void (APIENTRYP PFNGLDELETEFENCESAPPLEPROC) (GLsizei n, const GLuint *fences);
+typedef void (APIENTRYP PFNGLSETFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLISFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTFENCEAPPLEPROC) (GLuint fence);
+typedef void (APIENTRYP PFNGLFINISHFENCEAPPLEPROC) (GLuint fence);
+typedef GLboolean (APIENTRYP PFNGLTESTOBJECTAPPLEPROC) (GLenum object, GLuint name);
+typedef void (APIENTRYP PFNGLFINISHOBJECTAPPLEPROC) (GLenum object, GLint name);
+#endif
+
+#ifndef GL_APPLE_vertex_array_object
+#define GL_APPLE_vertex_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindVertexArrayAPPLE (GLuint);
+GLAPI void APIENTRY glDeleteVertexArraysAPPLE (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenVertexArraysAPPLE (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsVertexArrayAPPLE (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDVERTEXARRAYAPPLEPROC) (GLuint array);
+typedef void (APIENTRYP PFNGLDELETEVERTEXARRAYSAPPLEPROC) (GLsizei n, const GLuint *arrays);
+typedef void (APIENTRYP PFNGLGENVERTEXARRAYSAPPLEPROC) (GLsizei n, GLuint *arrays);
+typedef GLboolean (APIENTRYP PFNGLISVERTEXARRAYAPPLEPROC) (GLuint array);
+#endif
+
+#ifndef GL_APPLE_vertex_array_range
+#define GL_APPLE_vertex_array_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexArrayRangeAPPLE (GLsizei, GLvoid *);
+GLAPI void APIENTRY glFlushVertexArrayRangeAPPLE (GLsizei, GLvoid *);
+GLAPI void APIENTRY glVertexArrayParameteriAPPLE (GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHVERTEXARRAYRANGEAPPLEPROC) (GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLVERTEXARRAYPARAMETERIAPPLEPROC) (GLenum pname, GLint param);
+#endif
+
+#ifndef GL_APPLE_ycbcr_422
+#define GL_APPLE_ycbcr_422 1
+#endif
+
+#ifndef GL_S3_s3tc
+#define GL_S3_s3tc 1
+#endif
+
+#ifndef GL_ATI_draw_buffers
+#define GL_ATI_draw_buffers 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawBuffersATI (GLsizei, const GLenum *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWBUFFERSATIPROC) (GLsizei n, const GLenum *bufs);
+#endif
+
+#ifndef GL_ATI_pixel_format_float
+#define GL_ATI_pixel_format_float 1
+/* This is really a WGL extension, but defines some associated GL enums.
+ * ATI does not export "GL_ATI_pixel_format_float" in the GL_EXTENSIONS string.
+ */
+#endif
+
+#ifndef GL_ATI_texture_env_combine3
+#define GL_ATI_texture_env_combine3 1
+#endif
+
+#ifndef GL_ATI_texture_float
+#define GL_ATI_texture_float 1
+#endif
+
+#ifndef GL_NV_float_buffer
+#define GL_NV_float_buffer 1
+#endif
+
+#ifndef GL_NV_fragment_program
+#define GL_NV_fragment_program 1
+/* Some NV_fragment_program entry points are shared with ARB_vertex_program. */
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramNamedParameter4fNV (GLuint, GLsizei, const GLubyte *, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramNamedParameter4dNV (GLuint, GLsizei, const GLubyte *, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glProgramNamedParameter4fvNV (GLuint, GLsizei, const GLubyte *, const GLfloat *);
+GLAPI void APIENTRY glProgramNamedParameter4dvNV (GLuint, GLsizei, const GLubyte *, const GLdouble *);
+GLAPI void APIENTRY glGetProgramNamedParameterfvNV (GLuint, GLsizei, const GLubyte *, GLfloat *);
+GLAPI void APIENTRY glGetProgramNamedParameterdvNV (GLuint, GLsizei, const GLubyte *, GLdouble *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4FVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLfloat *v);
+typedef void (APIENTRYP PFNGLPROGRAMNAMEDPARAMETER4DVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, const GLdouble *v);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERFVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMNAMEDPARAMETERDVNVPROC) (GLuint id, GLsizei len, const GLubyte *name, GLdouble *params);
+#endif
+
+#ifndef GL_NV_half_float
+#define GL_NV_half_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertex2hNV (GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertex2hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertex3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertex3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertex4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertex4hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glNormal3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glNormal3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glColor3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glColor4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glColor4hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord1hNV (GLhalfNV);
+GLAPI void APIENTRY glTexCoord1hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord2hNV (GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glTexCoord2hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glTexCoord3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glTexCoord4hNV (GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glTexCoord4hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord1hNV (GLenum, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord1hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord2hNV (GLenum, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord2hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord3hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord3hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glMultiTexCoord4hNV (GLenum, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glMultiTexCoord4hvNV (GLenum, const GLhalfNV *);
+GLAPI void APIENTRY glFogCoordhNV (GLhalfNV);
+GLAPI void APIENTRY glFogCoordhvNV (const GLhalfNV *);
+GLAPI void APIENTRY glSecondaryColor3hNV (GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glSecondaryColor3hvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertexWeighthNV (GLhalfNV);
+GLAPI void APIENTRY glVertexWeighthvNV (const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib1hNV (GLuint, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib1hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib2hNV (GLuint, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib2hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib3hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib3hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttrib4hNV (GLuint, GLhalfNV, GLhalfNV, GLhalfNV, GLhalfNV);
+GLAPI void APIENTRY glVertexAttrib4hvNV (GLuint, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs1hvNV (GLuint, GLsizei, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs2hvNV (GLuint, GLsizei, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs3hvNV (GLuint, GLsizei, const GLhalfNV *);
+GLAPI void APIENTRY glVertexAttribs4hvNV (GLuint, GLsizei, const GLhalfNV *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEX2HNVPROC) (GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEX2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX3HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEX3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEX4HNVPROC) (GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEX4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLNORMAL3HNVPROC) (GLhalfNV nx, GLhalfNV ny, GLhalfNV nz);
+typedef void (APIENTRYP PFNGLNORMAL3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLCOLOR4HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue, GLhalfNV alpha);
+typedef void (APIENTRYP PFNGLCOLOR4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD1HNVPROC) (GLhalfNV s);
+typedef void (APIENTRYP PFNGLTEXCOORD1HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD2HNVPROC) (GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLTEXCOORD2HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD3HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLTEXCOORD3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLTEXCOORD4HNVPROC) (GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLTEXCOORD4HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HNVPROC) (GLenum target, GLhalfNV s);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD1HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD2HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD3HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HNVPROC) (GLenum target, GLhalfNV s, GLhalfNV t, GLhalfNV r, GLhalfNV q);
+typedef void (APIENTRYP PFNGLMULTITEXCOORD4HVNVPROC) (GLenum target, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLFOGCOORDHNVPROC) (GLhalfNV fog);
+typedef void (APIENTRYP PFNGLFOGCOORDHVNVPROC) (const GLhalfNV *fog);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HNVPROC) (GLhalfNV red, GLhalfNV green, GLhalfNV blue);
+typedef void (APIENTRYP PFNGLSECONDARYCOLOR3HVNVPROC) (const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHNVPROC) (GLhalfNV weight);
+typedef void (APIENTRYP PFNGLVERTEXWEIGHTHVNVPROC) (const GLhalfNV *weight);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HNVPROC) (GLuint index, GLhalfNV x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB1HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB2HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB3HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HNVPROC) (GLuint index, GLhalfNV x, GLhalfNV y, GLhalfNV z, GLhalfNV w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIB4HVNVPROC) (GLuint index, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS1HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS2HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS3HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBS4HVNVPROC) (GLuint index, GLsizei n, const GLhalfNV *v);
+#endif
+
+#ifndef GL_NV_pixel_data_range
+#define GL_NV_pixel_data_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPixelDataRangeNV (GLenum, GLsizei, GLvoid *);
+GLAPI void APIENTRY glFlushPixelDataRangeNV (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPIXELDATARANGENVPROC) (GLenum target, GLsizei length, GLvoid *pointer);
+typedef void (APIENTRYP PFNGLFLUSHPIXELDATARANGENVPROC) (GLenum target);
+#endif
+
+#ifndef GL_NV_primitive_restart
+#define GL_NV_primitive_restart 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPrimitiveRestartNV (void);
+GLAPI void APIENTRY glPrimitiveRestartIndexNV (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTNVPROC) (void);
+typedef void (APIENTRYP PFNGLPRIMITIVERESTARTINDEXNVPROC) (GLuint index);
+#endif
+
+#ifndef GL_NV_texture_expand_normal
+#define GL_NV_texture_expand_normal 1
+#endif
+
+#ifndef GL_NV_vertex_program2
+#define GL_NV_vertex_program2 1
+#endif
+
+#ifndef GL_ATI_map_object_buffer
+#define GL_ATI_map_object_buffer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLvoid* APIENTRY glMapObjectBufferATI (GLuint);
+GLAPI void APIENTRY glUnmapObjectBufferATI (GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLvoid* (APIENTRYP PFNGLMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLUNMAPOBJECTBUFFERATIPROC) (GLuint buffer);
+#endif
+
+#ifndef GL_ATI_separate_stencil
+#define GL_ATI_separate_stencil 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilOpSeparateATI (GLenum, GLenum, GLenum, GLenum);
+GLAPI void APIENTRY glStencilFuncSeparateATI (GLenum, GLenum, GLint, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILOPSEPARATEATIPROC) (GLenum face, GLenum sfail, GLenum dpfail, GLenum dppass);
+typedef void (APIENTRYP PFNGLSTENCILFUNCSEPARATEATIPROC) (GLenum frontfunc, GLenum backfunc, GLint ref, GLuint mask);
+#endif
+
+#ifndef GL_ATI_vertex_attrib_array_object
+#define GL_ATI_vertex_attrib_array_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribArrayObjectATI (GLuint, GLint, GLenum, GLboolean, GLsizei, GLuint, GLuint);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectfvATI (GLuint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetVertexAttribArrayObjectivATI (GLuint, GLenum, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBARRAYOBJECTATIPROC) (GLuint index, GLint size, GLenum type, GLboolean normalized, GLsizei stride, GLuint buffer, GLuint offset);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTFVATIPROC) (GLuint index, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBARRAYOBJECTIVATIPROC) (GLuint index, GLenum pname, GLint *params);
+#endif
+
+#ifndef GL_OES_read_format
+#define GL_OES_read_format 1
+#endif
+
+#ifndef GL_EXT_depth_bounds_test
+#define GL_EXT_depth_bounds_test 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthBoundsEXT (GLclampd, GLclampd);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHBOUNDSEXTPROC) (GLclampd zmin, GLclampd zmax);
+#endif
+
+#ifndef GL_EXT_texture_mirror_clamp
+#define GL_EXT_texture_mirror_clamp 1
+#endif
+
+#ifndef GL_EXT_blend_equation_separate
+#define GL_EXT_blend_equation_separate 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlendEquationSeparateEXT (GLenum, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLENDEQUATIONSEPARATEEXTPROC) (GLenum modeRGB, GLenum modeAlpha);
+#endif
+
+#ifndef GL_MESA_pack_invert
+#define GL_MESA_pack_invert 1
+#endif
+
+#ifndef GL_MESA_ycbcr_texture
+#define GL_MESA_ycbcr_texture 1
+#endif
+
+#ifndef GL_EXT_pixel_buffer_object
+#define GL_EXT_pixel_buffer_object 1
+#endif
+
+#ifndef GL_NV_fragment_program_option
+#define GL_NV_fragment_program_option 1
+#endif
+
+#ifndef GL_NV_fragment_program2
+#define GL_NV_fragment_program2 1
+#endif
+
+#ifndef GL_NV_vertex_program2_option
+#define GL_NV_vertex_program2_option 1
+#endif
+
+#ifndef GL_NV_vertex_program3
+#define GL_NV_vertex_program3 1
+#endif
+
+#ifndef GL_EXT_framebuffer_object
+#define GL_EXT_framebuffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI GLboolean APIENTRY glIsRenderbufferEXT (GLuint);
+GLAPI void APIENTRY glBindRenderbufferEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteRenderbuffersEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenRenderbuffersEXT (GLsizei, GLuint *);
+GLAPI void APIENTRY glRenderbufferStorageEXT (GLenum, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetRenderbufferParameterivEXT (GLenum, GLenum, GLint *);
+GLAPI GLboolean APIENTRY glIsFramebufferEXT (GLuint);
+GLAPI void APIENTRY glBindFramebufferEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteFramebuffersEXT (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenFramebuffersEXT (GLsizei, GLuint *);
+GLAPI GLenum APIENTRY glCheckFramebufferStatusEXT (GLenum);
+GLAPI void APIENTRY glFramebufferTexture1DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture2DEXT (GLenum, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTexture3DEXT (GLenum, GLenum, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glFramebufferRenderbufferEXT (GLenum, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glGetFramebufferAttachmentParameterivEXT (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGenerateMipmapEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef GLboolean (APIENTRYP PFNGLISRENDERBUFFEREXTPROC) (GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLBINDRENDERBUFFEREXTPROC) (GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLDELETERENDERBUFFERSEXTPROC) (GLsizei n, const GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLGENRENDERBUFFERSEXTPROC) (GLsizei n, GLuint *renderbuffers);
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEEXTPROC) (GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETRENDERBUFFERPARAMETERIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef GLboolean (APIENTRYP PFNGLISFRAMEBUFFEREXTPROC) (GLuint framebuffer);
+typedef void (APIENTRYP PFNGLBINDFRAMEBUFFEREXTPROC) (GLenum target, GLuint framebuffer);
+typedef void (APIENTRYP PFNGLDELETEFRAMEBUFFERSEXTPROC) (GLsizei n, const GLuint *framebuffers);
+typedef void (APIENTRYP PFNGLGENFRAMEBUFFERSEXTPROC) (GLsizei n, GLuint *framebuffers);
+typedef GLenum (APIENTRYP PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC) (GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE1DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE2DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURE3DEXTPROC) (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC) (GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLenum target, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATEMIPMAPEXTPROC) (GLenum target);
+#endif
+
+#ifndef GL_GREMEDY_string_marker
+#define GL_GREMEDY_string_marker 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStringMarkerGREMEDY (GLsizei, const GLvoid *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTRINGMARKERGREMEDYPROC) (GLsizei len, const GLvoid *string);
+#endif
+
+#ifndef GL_EXT_packed_depth_stencil
+#define GL_EXT_packed_depth_stencil 1
+#endif
+
+#ifndef GL_EXT_stencil_clear_tag
+#define GL_EXT_stencil_clear_tag 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glStencilClearTagEXT (GLsizei, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLSTENCILCLEARTAGEXTPROC) (GLsizei stencilTagBits, GLuint stencilClearTag);
+#endif
+
+#ifndef GL_EXT_texture_sRGB
+#define GL_EXT_texture_sRGB 1
+#endif
+
+#ifndef GL_EXT_framebuffer_blit
+#define GL_EXT_framebuffer_blit 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBlitFramebufferEXT (GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLint, GLbitfield, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBLITFRAMEBUFFEREXTPROC) (GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
+#endif
+
+#ifndef GL_EXT_framebuffer_multisample
+#define GL_EXT_framebuffer_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glRenderbufferStorageMultisampleEXT (GLenum, GLsizei, GLenum, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_MESAX_texture_stack
+#define GL_MESAX_texture_stack 1
+#endif
+
+#ifndef GL_EXT_timer_query
+#define GL_EXT_timer_query 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetQueryObjecti64vEXT (GLuint, GLenum, GLint64EXT *);
+GLAPI void APIENTRY glGetQueryObjectui64vEXT (GLuint, GLenum, GLuint64EXT *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTI64VEXTPROC) (GLuint id, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETQUERYOBJECTUI64VEXTPROC) (GLuint id, GLenum pname, GLuint64EXT *params);
+#endif
+
+#ifndef GL_EXT_gpu_program_parameters
+#define GL_EXT_gpu_program_parameters 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramEnvParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glProgramLocalParameters4fvEXT (GLenum, GLuint, GLsizei, const GLfloat *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+#endif
+
+#ifndef GL_APPLE_flush_buffer_range
+#define GL_APPLE_flush_buffer_range 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBufferParameteriAPPLE (GLenum, GLenum, GLint);
+GLAPI void APIENTRY glFlushMappedBufferRangeAPPLE (GLenum, GLintptr, GLsizeiptr);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBUFFERPARAMETERIAPPLEPROC) (GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLFLUSHMAPPEDBUFFERRANGEAPPLEPROC) (GLenum target, GLintptr offset, GLsizeiptr size);
+#endif
+
+#ifndef GL_NV_gpu_program4
+#define GL_NV_gpu_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramLocalParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glProgramLocalParameterI4ivNV (GLenum, GLuint, const GLint *);
+GLAPI void APIENTRY glProgramLocalParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *);
+GLAPI void APIENTRY glProgramLocalParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glProgramLocalParameterI4uivNV (GLenum, GLuint, const GLuint *);
+GLAPI void APIENTRY glProgramLocalParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glProgramEnvParameterI4iNV (GLenum, GLuint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glProgramEnvParameterI4ivNV (GLenum, GLuint, const GLint *);
+GLAPI void APIENTRY glProgramEnvParametersI4ivNV (GLenum, GLuint, GLsizei, const GLint *);
+GLAPI void APIENTRY glProgramEnvParameterI4uiNV (GLenum, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glProgramEnvParameterI4uivNV (GLenum, GLuint, const GLuint *);
+GLAPI void APIENTRY glProgramEnvParametersI4uivNV (GLenum, GLuint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glGetProgramLocalParameterIivNV (GLenum, GLuint, GLint *);
+GLAPI void APIENTRY glGetProgramLocalParameterIuivNV (GLenum, GLuint, GLuint *);
+GLAPI void APIENTRY glGetProgramEnvParameterIivNV (GLenum, GLuint, GLint *);
+GLAPI void APIENTRY glGetProgramEnvParameterIuivNV (GLenum, GLuint, GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMLOCALPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4INVPROC) (GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4IVNVPROC) (GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4IVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UINVPROC) (GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERI4UIVNVPROC) (GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMENVPARAMETERSI4UIVNVPROC) (GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMLOCALPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIIVNVPROC) (GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETPROGRAMENVPARAMETERIUIVNVPROC) (GLenum target, GLuint index, GLuint *params);
+#endif
+
+#ifndef GL_NV_geometry_program4
+#define GL_NV_geometry_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramVertexLimitNV (GLenum, GLint);
+GLAPI void APIENTRY glFramebufferTextureEXT (GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glFramebufferTextureLayerEXT (GLenum, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glFramebufferTextureFaceEXT (GLenum, GLenum, GLuint, GLint, GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMVERTEXLIMITNVPROC) (GLenum target, GLint limit);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTUREFACEEXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLenum face);
+#endif
+
+#ifndef GL_EXT_geometry_shader4
+#define GL_EXT_geometry_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramParameteriEXT (GLuint, GLenum, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMPARAMETERIEXTPROC) (GLuint program, GLenum pname, GLint value);
+#endif
+
+#ifndef GL_NV_vertex_program4
+#define GL_NV_vertex_program4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glVertexAttribI1iEXT (GLuint, GLint);
+GLAPI void APIENTRY glVertexAttribI2iEXT (GLuint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI3iEXT (GLuint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI4iEXT (GLuint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glVertexAttribI1uiEXT (GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI2uiEXT (GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI3uiEXT (GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI4uiEXT (GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glVertexAttribI1ivEXT (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI2ivEXT (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI3ivEXT (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI4ivEXT (GLuint, const GLint *);
+GLAPI void APIENTRY glVertexAttribI1uivEXT (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI2uivEXT (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI3uivEXT (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI4uivEXT (GLuint, const GLuint *);
+GLAPI void APIENTRY glVertexAttribI4bvEXT (GLuint, const GLbyte *);
+GLAPI void APIENTRY glVertexAttribI4svEXT (GLuint, const GLshort *);
+GLAPI void APIENTRY glVertexAttribI4ubvEXT (GLuint, const GLubyte *);
+GLAPI void APIENTRY glVertexAttribI4usvEXT (GLuint, const GLushort *);
+GLAPI void APIENTRY glVertexAttribIPointerEXT (GLuint, GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetVertexAttribIivEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVertexAttribIuivEXT (GLuint, GLenum, GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IEXTPROC) (GLuint index, GLint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IEXTPROC) (GLuint index, GLint x, GLint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IEXTPROC) (GLuint index, GLint x, GLint y, GLint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IEXTPROC) (GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIEXTPROC) (GLuint index, GLuint x);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIEXTPROC) (GLuint index, GLuint x, GLuint y);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIEXTPROC) (GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4IVEXTPROC) (GLuint index, const GLint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI1UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI2UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI3UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UIVEXTPROC) (GLuint index, const GLuint *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4BVEXTPROC) (GLuint index, const GLbyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4SVEXTPROC) (GLuint index, const GLshort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4UBVEXTPROC) (GLuint index, const GLubyte *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBI4USVEXTPROC) (GLuint index, const GLushort *v);
+typedef void (APIENTRYP PFNGLVERTEXATTRIBIPOINTEREXTPROC) (GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIIVEXTPROC) (GLuint index, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVERTEXATTRIBIUIVEXTPROC) (GLuint index, GLenum pname, GLuint *params);
+#endif
+
+#ifndef GL_EXT_gpu_shader4
+#define GL_EXT_gpu_shader4 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetUniformuivEXT (GLuint, GLint, GLuint *);
+GLAPI void APIENTRY glBindFragDataLocationEXT (GLuint, GLuint, const GLchar *);
+GLAPI GLint APIENTRY glGetFragDataLocationEXT (GLuint, const GLchar *);
+GLAPI void APIENTRY glUniform1uiEXT (GLint, GLuint);
+GLAPI void APIENTRY glUniform2uiEXT (GLint, GLuint, GLuint);
+GLAPI void APIENTRY glUniform3uiEXT (GLint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glUniform4uiEXT (GLint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glUniform1uivEXT (GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glUniform2uivEXT (GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glUniform3uivEXT (GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glUniform4uivEXT (GLint, GLsizei, const GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETUNIFORMUIVEXTPROC) (GLuint program, GLint location, GLuint *params);
+typedef void (APIENTRYP PFNGLBINDFRAGDATALOCATIONEXTPROC) (GLuint program, GLuint color, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETFRAGDATALOCATIONEXTPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLUNIFORM1UIEXTPROC) (GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLUNIFORM2UIEXTPROC) (GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLUNIFORM3UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLUNIFORM4UIEXTPROC) (GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLUNIFORM1UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM2UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM3UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLUNIFORM4UIVEXTPROC) (GLint location, GLsizei count, const GLuint *value);
+#endif
+
+#ifndef GL_EXT_draw_instanced
+#define GL_EXT_draw_instanced 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDrawArraysInstancedEXT (GLenum, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glDrawElementsInstancedEXT (GLenum, GLsizei, GLenum, const GLvoid *, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDRAWARRAYSINSTANCEDEXTPROC) (GLenum mode, GLint start, GLsizei count, GLsizei primcount);
+typedef void (APIENTRYP PFNGLDRAWELEMENTSINSTANCEDEXTPROC) (GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei primcount);
+#endif
+
+#ifndef GL_EXT_packed_float
+#define GL_EXT_packed_float 1
+#endif
+
+#ifndef GL_EXT_texture_array
+#define GL_EXT_texture_array 1
+#endif
+
+#ifndef GL_EXT_texture_buffer_object
+#define GL_EXT_texture_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexBufferEXT (GLenum, GLenum, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXBUFFEREXTPROC) (GLenum target, GLenum internalformat, GLuint buffer);
+#endif
+
+#ifndef GL_EXT_texture_compression_latc
+#define GL_EXT_texture_compression_latc 1
+#endif
+
+#ifndef GL_EXT_texture_compression_rgtc
+#define GL_EXT_texture_compression_rgtc 1
+#endif
+
+#ifndef GL_EXT_texture_shared_exponent
+#define GL_EXT_texture_shared_exponent 1
+#endif
+
+#ifndef GL_NV_depth_buffer_float
+#define GL_NV_depth_buffer_float 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glDepthRangedNV (GLdouble, GLdouble);
+GLAPI void APIENTRY glClearDepthdNV (GLdouble);
+GLAPI void APIENTRY glDepthBoundsdNV (GLdouble, GLdouble);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLDEPTHRANGEDNVPROC) (GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLCLEARDEPTHDNVPROC) (GLdouble depth);
+typedef void (APIENTRYP PFNGLDEPTHBOUNDSDNVPROC) (GLdouble zmin, GLdouble zmax);
+#endif
+
+#ifndef GL_NV_fragment_program4
+#define GL_NV_fragment_program4 1
+#endif
+
+#ifndef GL_NV_framebuffer_multisample_coverage
+#define GL_NV_framebuffer_multisample_coverage 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glRenderbufferStorageMultisampleCoverageNV (GLenum, GLsizei, GLsizei, GLenum, GLsizei, GLsizei);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLRENDERBUFFERSTORAGEMULTISAMPLECOVERAGENVPROC) (GLenum target, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+#endif
+
+#ifndef GL_EXT_framebuffer_sRGB
+#define GL_EXT_framebuffer_sRGB 1
+#endif
+
+#ifndef GL_NV_geometry_shader4
+#define GL_NV_geometry_shader4 1
+#endif
+
+#ifndef GL_NV_parameter_buffer_object
+#define GL_NV_parameter_buffer_object 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProgramBufferParametersfvNV (GLenum, GLuint, GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glProgramBufferParametersIivNV (GLenum, GLuint, GLuint, GLsizei, const GLint *);
+GLAPI void APIENTRY glProgramBufferParametersIuivNV (GLenum, GLuint, GLuint, GLsizei, const GLuint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSFVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLPROGRAMBUFFERPARAMETERSIUIVNVPROC) (GLenum target, GLuint buffer, GLuint index, GLsizei count, const GLuint *params);
+#endif
+
+#ifndef GL_EXT_draw_buffers2
+#define GL_EXT_draw_buffers2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glColorMaskIndexedEXT (GLuint, GLboolean, GLboolean, GLboolean, GLboolean);
+GLAPI void APIENTRY glGetBooleanIndexedvEXT (GLenum, GLuint, GLboolean *);
+GLAPI void APIENTRY glGetIntegerIndexedvEXT (GLenum, GLuint, GLint *);
+GLAPI void APIENTRY glEnableIndexedEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDisableIndexedEXT (GLenum, GLuint);
+GLAPI GLboolean APIENTRY glIsEnabledIndexedEXT (GLenum, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCOLORMASKINDEXEDEXTPROC) (GLuint index, GLboolean r, GLboolean g, GLboolean b, GLboolean a);
+typedef void (APIENTRYP PFNGLGETBOOLEANINDEXEDVEXTPROC) (GLenum target, GLuint index, GLboolean *data);
+typedef void (APIENTRYP PFNGLGETINTEGERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLint *data);
+typedef void (APIENTRYP PFNGLENABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLEINDEXEDEXTPROC) (GLenum target, GLuint index);
+typedef GLboolean (APIENTRYP PFNGLISENABLEDINDEXEDEXTPROC) (GLenum target, GLuint index);
+#endif
+
+#ifndef GL_NV_transform_feedback
+#define GL_NV_transform_feedback 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginTransformFeedbackNV (GLenum);
+GLAPI void APIENTRY glEndTransformFeedbackNV (void);
+GLAPI void APIENTRY glTransformFeedbackAttribsNV (GLuint, const GLint *, GLenum);
+GLAPI void APIENTRY glBindBufferRangeNV (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);
+GLAPI void APIENTRY glBindBufferOffsetNV (GLenum, GLuint, GLuint, GLintptr);
+GLAPI void APIENTRY glBindBufferBaseNV (GLenum, GLuint, GLuint);
+GLAPI void APIENTRY glTransformFeedbackVaryingsNV (GLuint, GLsizei, const GLint *, GLenum);
+GLAPI void APIENTRY glActiveVaryingNV (GLuint, const GLchar *);
+GLAPI GLint APIENTRY glGetVaryingLocationNV (GLuint, const GLchar *);
+GLAPI void APIENTRY glGetActiveVaryingNV (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);
+GLAPI void APIENTRY glGetTransformFeedbackVaryingNV (GLuint, GLuint, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKNVPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKATTRIBSNVPROC) (GLuint count, const GLint *attribs, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGENVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETNVPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASENVPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSNVPROC) (GLuint program, GLsizei count, const GLint *locations, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLACTIVEVARYINGNVPROC) (GLuint program, const GLchar *name);
+typedef GLint (APIENTRYP PFNGLGETVARYINGLOCATIONNVPROC) (GLuint program, const GLchar *name);
+typedef void (APIENTRYP PFNGLGETACTIVEVARYINGNVPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGNVPROC) (GLuint program, GLuint index, GLint *location);
+#endif
+
+#ifndef GL_EXT_bindable_uniform
+#define GL_EXT_bindable_uniform 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glUniformBufferEXT (GLuint, GLint, GLuint);
+GLAPI GLint APIENTRY glGetUniformBufferSizeEXT (GLuint, GLint);
+GLAPI GLintptr APIENTRY glGetUniformOffsetEXT (GLuint, GLint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLUNIFORMBUFFEREXTPROC) (GLuint program, GLint location, GLuint buffer);
+typedef GLint (APIENTRYP PFNGLGETUNIFORMBUFFERSIZEEXTPROC) (GLuint program, GLint location);
+typedef GLintptr (APIENTRYP PFNGLGETUNIFORMOFFSETEXTPROC) (GLuint program, GLint location);
+#endif
+
+#ifndef GL_EXT_texture_integer
+#define GL_EXT_texture_integer 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTexParameterIivEXT (GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glTexParameterIuivEXT (GLenum, GLenum, const GLuint *);
+GLAPI void APIENTRY glGetTexParameterIivEXT (GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetTexParameterIuivEXT (GLenum, GLenum, GLuint *);
+GLAPI void APIENTRY glClearColorIiEXT (GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glClearColorIuiEXT (GLuint, GLuint, GLuint, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIIVEXTPROC) (GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXPARAMETERIUIVEXTPROC) (GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLCLEARCOLORIIEXTPROC) (GLint red, GLint green, GLint blue, GLint alpha);
+typedef void (APIENTRYP PFNGLCLEARCOLORIUIEXTPROC) (GLuint red, GLuint green, GLuint blue, GLuint alpha);
+#endif
+
+#ifndef GL_GREMEDY_frame_terminator
+#define GL_GREMEDY_frame_terminator 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glFrameTerminatorGREMEDY (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLFRAMETERMINATORGREMEDYPROC) (void);
+#endif
+
+#ifndef GL_NV_conditional_render
+#define GL_NV_conditional_render 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginConditionalRenderNV (GLuint, GLenum);
+GLAPI void APIENTRY glEndConditionalRenderNV (void);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINCONDITIONALRENDERNVPROC) (GLuint id, GLenum mode);
+typedef void (APIENTRYP PFNGLENDCONDITIONALRENDERNVPROC) (void);
+#endif
+
+#ifndef GL_NV_present_video
+#define GL_NV_present_video 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glPresentFrameKeyedNV (GLuint, GLuint64EXT, GLuint, GLuint, GLenum, GLenum, GLuint, GLuint, GLenum, GLuint, GLuint);
+GLAPI void APIENTRY glPresentFrameDualFillNV (GLuint, GLuint64EXT, GLuint, GLuint, GLenum, GLenum, GLuint, GLenum, GLuint, GLenum, GLuint, GLenum, GLuint);
+GLAPI void APIENTRY glGetVideoivNV (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetVideouivNV (GLuint, GLenum, GLuint *);
+GLAPI void APIENTRY glGetVideoi64vNV (GLuint, GLenum, GLint64EXT *);
+GLAPI void APIENTRY glGetVideoui64vNV (GLuint, GLenum, GLuint64EXT *);
+GLAPI void APIENTRY glVideoParameterivNV (GLuint, GLenum, const GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPRESENTFRAMEKEYEDNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLuint key0, GLenum target1, GLuint fill1, GLuint key1);
+typedef void (APIENTRYP PFNGLPRESENTFRAMEDUALFILLNVPROC) (GLuint video_slot, GLuint64EXT minPresentTime, GLuint beginPresentTimeId, GLuint presentDurationId, GLenum type, GLenum target0, GLuint fill0, GLenum target1, GLuint fill1, GLenum target2, GLuint fill2, GLenum target3, GLuint fill3);
+typedef void (APIENTRYP PFNGLGETVIDEOIVNVPROC) (GLuint video_slot, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOUIVNVPROC) (GLuint video_slot, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLGETVIDEOI64VNVPROC) (GLuint video_slot, GLenum pname, GLint64EXT *params);
+typedef void (APIENTRYP PFNGLGETVIDEOUI64VNVPROC) (GLuint video_slot, GLenum pname, GLuint64EXT *params);
+typedef void (APIENTRYP PFNGLVIDEOPARAMETERIVNVPROC) (GLuint video_slot, GLenum pname, const GLint *params);
+#endif
+
+#ifndef GL_EXT_transform_feedback
+#define GL_EXT_transform_feedback 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBeginTransformFeedbackEXT (GLenum);
+GLAPI void APIENTRY glEndTransformFeedbackEXT (void);
+GLAPI void APIENTRY glBindBufferRangeEXT (GLenum, GLuint, GLuint, GLintptr, GLsizeiptr);
+GLAPI void APIENTRY glBindBufferOffsetEXT (GLenum, GLuint, GLuint, GLintptr);
+GLAPI void APIENTRY glBindBufferBaseEXT (GLenum, GLuint, GLuint);
+GLAPI void APIENTRY glTransformFeedbackVaryingsEXT (GLuint, GLsizei, const GLchar* *, GLenum);
+GLAPI void APIENTRY glGetTransformFeedbackVaryingEXT (GLuint, GLuint, GLsizei, GLsizei *, GLsizei *, GLenum *, GLchar *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBEGINTRANSFORMFEEDBACKEXTPROC) (GLenum primitiveMode);
+typedef void (APIENTRYP PFNGLENDTRANSFORMFEEDBACKEXTPROC) (void);
+typedef void (APIENTRYP PFNGLBINDBUFFERRANGEEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset, GLsizeiptr size);
+typedef void (APIENTRYP PFNGLBINDBUFFEROFFSETEXTPROC) (GLenum target, GLuint index, GLuint buffer, GLintptr offset);
+typedef void (APIENTRYP PFNGLBINDBUFFERBASEEXTPROC) (GLenum target, GLuint index, GLuint buffer);
+typedef void (APIENTRYP PFNGLTRANSFORMFEEDBACKVARYINGSEXTPROC) (GLuint program, GLsizei count, const GLchar* *varyings, GLenum bufferMode);
+typedef void (APIENTRYP PFNGLGETTRANSFORMFEEDBACKVARYINGEXTPROC) (GLuint program, GLuint index, GLsizei bufSize, GLsizei *length, GLsizei *size, GLenum *type, GLchar *name);
+#endif
+
+#ifndef GL_EXT_direct_state_access
+#define GL_EXT_direct_state_access 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glClientAttribDefaultEXT (GLbitfield);
+GLAPI void APIENTRY glPushClientAttribDefaultEXT (GLbitfield);
+GLAPI void APIENTRY glMatrixLoadfEXT (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMatrixLoaddEXT (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMatrixMultfEXT (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMatrixMultdEXT (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMatrixLoadIdentityEXT (GLenum);
+GLAPI void APIENTRY glMatrixRotatefEXT (GLenum, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMatrixRotatedEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMatrixScalefEXT (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMatrixScaledEXT (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMatrixTranslatefEXT (GLenum, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glMatrixTranslatedEXT (GLenum, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMatrixFrustumEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMatrixOrthoEXT (GLenum, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glMatrixPopEXT (GLenum);
+GLAPI void APIENTRY glMatrixPushEXT (GLenum);
+GLAPI void APIENTRY glMatrixLoadTransposefEXT (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMatrixLoadTransposedEXT (GLenum, const GLdouble *);
+GLAPI void APIENTRY glMatrixMultTransposefEXT (GLenum, const GLfloat *);
+GLAPI void APIENTRY glMatrixMultTransposedEXT (GLenum, const GLdouble *);
+GLAPI void APIENTRY glTextureParameterfEXT (GLuint, GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glTextureParameterfvEXT (GLuint, GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glTextureParameteriEXT (GLuint, GLenum, GLenum, GLint);
+GLAPI void APIENTRY glTextureParameterivEXT (GLuint, GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
+GLAPI void APIENTRY glCopyTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+GLAPI void APIENTRY glCopyTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetTextureImageEXT (GLuint, GLenum, GLint, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetTextureParameterfvEXT (GLuint, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetTextureParameterivEXT (GLuint, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetTextureLevelParameterfvEXT (GLuint, GLenum, GLint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetTextureLevelParameterivEXT (GLuint, GLenum, GLint, GLenum, GLint *);
+GLAPI void APIENTRY glTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glMultiTexParameterfEXT (GLenum, GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glMultiTexParameterfvEXT (GLenum, GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexParameteriEXT (GLenum, GLenum, GLenum, GLint);
+GLAPI void APIENTRY glMultiTexParameterivEXT (GLenum, GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLint);
+GLAPI void APIENTRY glCopyMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint);
+GLAPI void APIENTRY glCopyMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei);
+GLAPI void APIENTRY glCopyMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetMultiTexImageEXT (GLenum, GLenum, GLint, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glGetMultiTexParameterfvEXT (GLenum, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMultiTexParameterivEXT (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMultiTexLevelParameterfvEXT (GLenum, GLenum, GLint, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMultiTexLevelParameterivEXT (GLenum, GLenum, GLint, GLenum, GLint *);
+GLAPI void APIENTRY glMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid *);
+GLAPI void APIENTRY glCopyMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei);
+GLAPI void APIENTRY glBindMultiTextureEXT (GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glEnableClientStateIndexedEXT (GLenum, GLuint);
+GLAPI void APIENTRY glDisableClientStateIndexedEXT (GLenum, GLuint);
+GLAPI void APIENTRY glMultiTexCoordPointerEXT (GLenum, GLint, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glMultiTexEnvfEXT (GLenum, GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glMultiTexEnvfvEXT (GLenum, GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexEnviEXT (GLenum, GLenum, GLenum, GLint);
+GLAPI void APIENTRY glMultiTexEnvivEXT (GLenum, GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexGendEXT (GLenum, GLenum, GLenum, GLdouble);
+GLAPI void APIENTRY glMultiTexGendvEXT (GLenum, GLenum, GLenum, const GLdouble *);
+GLAPI void APIENTRY glMultiTexGenfEXT (GLenum, GLenum, GLenum, GLfloat);
+GLAPI void APIENTRY glMultiTexGenfvEXT (GLenum, GLenum, GLenum, const GLfloat *);
+GLAPI void APIENTRY glMultiTexGeniEXT (GLenum, GLenum, GLenum, GLint);
+GLAPI void APIENTRY glMultiTexGenivEXT (GLenum, GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glGetMultiTexEnvfvEXT (GLenum, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMultiTexEnvivEXT (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMultiTexGendvEXT (GLenum, GLenum, GLenum, GLdouble *);
+GLAPI void APIENTRY glGetMultiTexGenfvEXT (GLenum, GLenum, GLenum, GLfloat *);
+GLAPI void APIENTRY glGetMultiTexGenivEXT (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetFloatIndexedvEXT (GLenum, GLuint, GLfloat *);
+GLAPI void APIENTRY glGetDoubleIndexedvEXT (GLenum, GLuint, GLdouble *);
+GLAPI void APIENTRY glGetPointerIndexedvEXT (GLenum, GLuint, GLvoid* *);
+GLAPI void APIENTRY glCompressedTextureImage3DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTextureImage2DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTextureImage1DEXT (GLuint, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTextureSubImage3DEXT (GLuint, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTextureSubImage2DEXT (GLuint, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedTextureSubImage1DEXT (GLuint, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetCompressedTextureImageEXT (GLuint, GLenum, GLint, GLvoid *);
+GLAPI void APIENTRY glCompressedMultiTexImage3DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedMultiTexImage2DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedMultiTexImage1DEXT (GLenum, GLenum, GLint, GLenum, GLsizei, GLint, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedMultiTexSubImage3DEXT (GLenum, GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedMultiTexSubImage2DEXT (GLenum, GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glCompressedMultiTexSubImage1DEXT (GLenum, GLenum, GLint, GLint, GLsizei, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glGetCompressedMultiTexImageEXT (GLenum, GLenum, GLint, GLvoid *);
+GLAPI void APIENTRY glNamedProgramStringEXT (GLuint, GLenum, GLenum, GLsizei, const GLvoid *);
+GLAPI void APIENTRY glNamedProgramLocalParameter4dEXT (GLuint, GLenum, GLuint, GLdouble, GLdouble, GLdouble, GLdouble);
+GLAPI void APIENTRY glNamedProgramLocalParameter4dvEXT (GLuint, GLenum, GLuint, const GLdouble *);
+GLAPI void APIENTRY glNamedProgramLocalParameter4fEXT (GLuint, GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glNamedProgramLocalParameter4fvEXT (GLuint, GLenum, GLuint, const GLfloat *);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterdvEXT (GLuint, GLenum, GLuint, GLdouble *);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterfvEXT (GLuint, GLenum, GLuint, GLfloat *);
+GLAPI void APIENTRY glGetNamedProgramivEXT (GLuint, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetNamedProgramStringEXT (GLuint, GLenum, GLenum, GLvoid *);
+GLAPI void APIENTRY glNamedProgramLocalParameters4fvEXT (GLuint, GLenum, GLuint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4iEXT (GLuint, GLenum, GLuint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4ivEXT (GLuint, GLenum, GLuint, const GLint *);
+GLAPI void APIENTRY glNamedProgramLocalParametersI4ivEXT (GLuint, GLenum, GLuint, GLsizei, const GLint *);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4uiEXT (GLuint, GLenum, GLuint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glNamedProgramLocalParameterI4uivEXT (GLuint, GLenum, GLuint, const GLuint *);
+GLAPI void APIENTRY glNamedProgramLocalParametersI4uivEXT (GLuint, GLenum, GLuint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterIivEXT (GLuint, GLenum, GLuint, GLint *);
+GLAPI void APIENTRY glGetNamedProgramLocalParameterIuivEXT (GLuint, GLenum, GLuint, GLuint *);
+GLAPI void APIENTRY glTextureParameterIivEXT (GLuint, GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glTextureParameterIuivEXT (GLuint, GLenum, GLenum, const GLuint *);
+GLAPI void APIENTRY glGetTextureParameterIivEXT (GLuint, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetTextureParameterIuivEXT (GLuint, GLenum, GLenum, GLuint *);
+GLAPI void APIENTRY glMultiTexParameterIivEXT (GLenum, GLenum, GLenum, const GLint *);
+GLAPI void APIENTRY glMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, const GLuint *);
+GLAPI void APIENTRY glGetMultiTexParameterIivEXT (GLenum, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGetMultiTexParameterIuivEXT (GLenum, GLenum, GLenum, GLuint *);
+GLAPI void APIENTRY glProgramUniform1fEXT (GLuint, GLint, GLfloat);
+GLAPI void APIENTRY glProgramUniform2fEXT (GLuint, GLint, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramUniform3fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramUniform4fEXT (GLuint, GLint, GLfloat, GLfloat, GLfloat, GLfloat);
+GLAPI void APIENTRY glProgramUniform1iEXT (GLuint, GLint, GLint);
+GLAPI void APIENTRY glProgramUniform2iEXT (GLuint, GLint, GLint, GLint);
+GLAPI void APIENTRY glProgramUniform3iEXT (GLuint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glProgramUniform4iEXT (GLuint, GLint, GLint, GLint, GLint, GLint);
+GLAPI void APIENTRY glProgramUniform1fvEXT (GLuint, GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glProgramUniform2fvEXT (GLuint, GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glProgramUniform3fvEXT (GLuint, GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glProgramUniform4fvEXT (GLuint, GLint, GLsizei, const GLfloat *);
+GLAPI void APIENTRY glProgramUniform1ivEXT (GLuint, GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glProgramUniform2ivEXT (GLuint, GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glProgramUniform3ivEXT (GLuint, GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glProgramUniform4ivEXT (GLuint, GLint, GLsizei, const GLint *);
+GLAPI void APIENTRY glProgramUniformMatrix2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix2x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix3x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix2x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix4x2fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix3x4fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniformMatrix4x3fvEXT (GLuint, GLint, GLsizei, GLboolean, const GLfloat *);
+GLAPI void APIENTRY glProgramUniform1uiEXT (GLuint, GLint, GLuint);
+GLAPI void APIENTRY glProgramUniform2uiEXT (GLuint, GLint, GLuint, GLuint);
+GLAPI void APIENTRY glProgramUniform3uiEXT (GLuint, GLint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glProgramUniform4uiEXT (GLuint, GLint, GLuint, GLuint, GLuint, GLuint);
+GLAPI void APIENTRY glProgramUniform1uivEXT (GLuint, GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glProgramUniform2uivEXT (GLuint, GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glProgramUniform3uivEXT (GLuint, GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glProgramUniform4uivEXT (GLuint, GLint, GLsizei, const GLuint *);
+GLAPI void APIENTRY glNamedBufferDataEXT (GLuint, GLsizeiptr, const GLvoid *, GLenum);
+GLAPI void APIENTRY glNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, const GLvoid *);
+GLAPI GLvoid* APIENTRY glMapNamedBufferEXT (GLuint, GLenum);
+GLAPI GLboolean APIENTRY glUnmapNamedBufferEXT (GLuint);
+GLAPI void APIENTRY glGetNamedBufferParameterivEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glGetNamedBufferPointervEXT (GLuint, GLenum, GLvoid* *);
+GLAPI void APIENTRY glGetNamedBufferSubDataEXT (GLuint, GLintptr, GLsizeiptr, GLvoid *);
+GLAPI void APIENTRY glTextureBufferEXT (GLuint, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glMultiTexBufferEXT (GLenum, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glNamedRenderbufferStorageEXT (GLuint, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glGetNamedRenderbufferParameterivEXT (GLuint, GLenum, GLint *);
+GLAPI GLenum APIENTRY glCheckNamedFramebufferStatusEXT (GLuint, GLenum);
+GLAPI void APIENTRY glNamedFramebufferTexture1DEXT (GLuint, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glNamedFramebufferTexture2DEXT (GLuint, GLenum, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glNamedFramebufferTexture3DEXT (GLuint, GLenum, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glNamedFramebufferRenderbufferEXT (GLuint, GLenum, GLenum, GLuint);
+GLAPI void APIENTRY glGetNamedFramebufferAttachmentParameterivEXT (GLuint, GLenum, GLenum, GLint *);
+GLAPI void APIENTRY glGenerateTextureMipmapEXT (GLuint, GLenum);
+GLAPI void APIENTRY glGenerateMultiTexMipmapEXT (GLenum, GLenum);
+GLAPI void APIENTRY glFramebufferDrawBufferEXT (GLuint, GLenum);
+GLAPI void APIENTRY glFramebufferDrawBuffersEXT (GLuint, GLsizei, const GLenum *);
+GLAPI void APIENTRY glFramebufferReadBufferEXT (GLuint, GLenum);
+GLAPI void APIENTRY glGetFramebufferParameterivEXT (GLuint, GLenum, GLint *);
+GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleEXT (GLuint, GLsizei, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glNamedRenderbufferStorageMultisampleCoverageEXT (GLuint, GLsizei, GLsizei, GLenum, GLsizei, GLsizei);
+GLAPI void APIENTRY glNamedFramebufferTextureEXT (GLuint, GLenum, GLuint, GLint);
+GLAPI void APIENTRY glNamedFramebufferTextureLayerEXT (GLuint, GLenum, GLuint, GLint, GLint);
+GLAPI void APIENTRY glNamedFramebufferTextureFaceEXT (GLuint, GLenum, GLuint, GLint, GLenum);
+GLAPI void APIENTRY glTextureRenderbufferEXT (GLuint, GLenum, GLuint);
+GLAPI void APIENTRY glMultiTexRenderbufferEXT (GLenum, GLenum, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLPUSHCLIENTATTRIBDEFAULTEXTPROC) (GLbitfield mask);
+typedef void (APIENTRYP PFNGLMATRIXLOADFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADIDENTITYEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXROTATEFEXTPROC) (GLenum mode, GLfloat angle, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXROTATEDEXTPROC) (GLenum mode, GLdouble angle, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXSCALEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXSCALEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXTRANSLATEFEXTPROC) (GLenum mode, GLfloat x, GLfloat y, GLfloat z);
+typedef void (APIENTRYP PFNGLMATRIXTRANSLATEDEXTPROC) (GLenum mode, GLdouble x, GLdouble y, GLdouble z);
+typedef void (APIENTRYP PFNGLMATRIXFRUSTUMEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLMATRIXORTHOEXTPROC) (GLenum mode, GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar);
+typedef void (APIENTRYP PFNGLMATRIXPOPEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXPUSHEXTPROC) (GLenum mode);
+typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXLOADTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEFEXTPROC) (GLenum mode, const GLfloat *m);
+typedef void (APIENTRYP PFNGLMATRIXMULTTRANSPOSEDEXTPROC) (GLenum mode, const GLdouble *m);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERFVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETTEXTURELEVELPARAMETERIVEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLint border);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLint x, GLint y, GLsizei width, GLsizei height, GLint border);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint x, GLint y, GLsizei width);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERFVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXLEVELPARAMETERIVEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const GLvoid *pixels);
+typedef void (APIENTRYP PFNGLCOPYMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLint x, GLint y, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLBINDMULTITEXTUREEXTPROC) (GLenum texunit, GLenum target, GLuint texture);
+typedef void (APIENTRYP PFNGLENABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (APIENTRYP PFNGLDISABLECLIENTSTATEINDEXEDEXTPROC) (GLenum array, GLuint index);
+typedef void (APIENTRYP PFNGLMULTITEXCOORDPOINTEREXTPROC) (GLenum texunit, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
+typedef void (APIENTRYP PFNGLMULTITEXENVFEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXENVIEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENDEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble param);
+typedef void (APIENTRYP PFNGLMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLdouble *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENFEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat param);
+typedef void (APIENTRYP PFNGLMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLfloat *params);
+typedef void (APIENTRYP PFNGLMULTITEXGENIEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint param);
+typedef void (APIENTRYP PFNGLMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXENVFVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXENVIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENDVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENFVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXGENIVEXTPROC) (GLenum texunit, GLenum coord, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETFLOATINDEXEDVEXTPROC) (GLenum target, GLuint index, GLfloat *data);
+typedef void (APIENTRYP PFNGLGETDOUBLEINDEXEDVEXTPROC) (GLenum target, GLuint index, GLdouble *data);
+typedef void (APIENTRYP PFNGLGETPOINTERINDEXEDVEXTPROC) (GLenum target, GLuint index, GLvoid* *data);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTUREIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE3DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE2DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDTEXTURESUBIMAGE1DEXTPROC) (GLuint texture, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDTEXTUREIMAGEEXTPROC) (GLuint texture, GLenum target, GLint lod, GLvoid *img);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE3DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE2DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLCOMPRESSEDMULTITEXSUBIMAGE1DEXTPROC) (GLenum texunit, GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLsizei imageSize, const GLvoid *bits);
+typedef void (APIENTRYP PFNGLGETCOMPRESSEDMULTITEXIMAGEEXTPROC) (GLenum texunit, GLenum target, GLint lod, GLvoid *img);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum format, GLsizei len, const GLvoid *string);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble x, GLdouble y, GLdouble z, GLdouble w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4DVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLdouble *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat x, GLfloat y, GLfloat z, GLfloat w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETER4FVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERDVEXTPROC) (GLuint program, GLenum target, GLuint index, GLdouble *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERFVEXTPROC) (GLuint program, GLenum target, GLuint index, GLfloat *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMIVEXTPROC) (GLuint program, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMSTRINGEXTPROC) (GLuint program, GLenum target, GLenum pname, GLvoid *string);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERS4FVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLfloat *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IEXTPROC) (GLuint program, GLenum target, GLuint index, GLint x, GLint y, GLint z, GLint w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4IVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint x, GLuint y, GLuint z, GLuint w);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, const GLuint *params);
+typedef void (APIENTRYP PFNGLNAMEDPROGRAMLOCALPARAMETERSI4UIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLsizei count, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDPROGRAMLOCALPARAMETERIUIVEXTPROC) (GLuint program, GLenum target, GLuint index, GLuint *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETTEXTUREPARAMETERIUIVEXTPROC) (GLuint texture, GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLint *params);
+typedef void (APIENTRYP PFNGLMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, const GLuint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETMULTITEXPARAMETERIUIVEXTPROC) (GLenum texunit, GLenum target, GLenum pname, GLuint *params);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FEXTPROC) (GLuint program, GLint location, GLfloat v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FEXTPROC) (GLuint program, GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IEXTPROC) (GLuint program, GLint location, GLint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IEXTPROC) (GLuint program, GLint location, GLint v0, GLint v1, GLint v2, GLint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4FVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4IVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX2X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X2FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX3X4FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORMMATRIX4X3FVEXTPROC) (GLuint program, GLint location, GLsizei count, GLboolean transpose, const GLfloat *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIEXTPROC) (GLuint program, GLint location, GLuint v0);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIEXTPROC) (GLuint program, GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM1UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM2UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM3UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLPROGRAMUNIFORM4UIVEXTPROC) (GLuint program, GLint location, GLsizei count, const GLuint *value);
+typedef void (APIENTRYP PFNGLNAMEDBUFFERDATAEXTPROC) (GLuint buffer, GLsizeiptr size, const GLvoid *data, GLenum usage);
+typedef void (APIENTRYP PFNGLNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, const GLvoid *data);
+typedef GLvoid* (APIENTRYP PFNGLMAPNAMEDBUFFEREXTPROC) (GLuint buffer, GLenum access);
+typedef GLboolean (APIENTRYP PFNGLUNMAPNAMEDBUFFEREXTPROC) (GLuint buffer);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPARAMETERIVEXTPROC) (GLuint buffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERPOINTERVEXTPROC) (GLuint buffer, GLenum pname, GLvoid* *params);
+typedef void (APIENTRYP PFNGLGETNAMEDBUFFERSUBDATAEXTPROC) (GLuint buffer, GLintptr offset, GLsizeiptr size, GLvoid *data);
+typedef void (APIENTRYP PFNGLTEXTUREBUFFEREXTPROC) (GLuint texture, GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLMULTITEXBUFFEREXTPROC) (GLenum texunit, GLenum target, GLenum internalformat, GLuint buffer);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEEXTPROC) (GLuint renderbuffer, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLGETNAMEDRENDERBUFFERPARAMETERIVEXTPROC) (GLuint renderbuffer, GLenum pname, GLint *params);
+typedef GLenum (APIENTRYP PFNGLCHECKNAMEDFRAMEBUFFERSTATUSEXTPROC) (GLuint framebuffer, GLenum target);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE1DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE2DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURE3DEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERRENDERBUFFEREXTPROC) (GLuint framebuffer, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLGETNAMEDFRAMEBUFFERATTACHMENTPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum attachment, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLGENERATETEXTUREMIPMAPEXTPROC) (GLuint texture, GLenum target);
+typedef void (APIENTRYP PFNGLGENERATEMULTITEXMIPMAPEXTPROC) (GLenum texunit, GLenum target);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERDRAWBUFFERSEXTPROC) (GLuint framebuffer, GLsizei n, const GLenum *bufs);
+typedef void (APIENTRYP PFNGLFRAMEBUFFERREADBUFFEREXTPROC) (GLuint framebuffer, GLenum mode);
+typedef void (APIENTRYP PFNGLGETFRAMEBUFFERPARAMETERIVEXTPROC) (GLuint framebuffer, GLenum pname, GLint *params);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC) (GLuint renderbuffer, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLNAMEDRENDERBUFFERSTORAGEMULTISAMPLECOVERAGEEXTPROC) (GLuint renderbuffer, GLsizei coverageSamples, GLsizei colorSamples, GLenum internalformat, GLsizei width, GLsizei height);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTURELAYEREXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLint layer);
+typedef void (APIENTRYP PFNGLNAMEDFRAMEBUFFERTEXTUREFACEEXTPROC) (GLuint framebuffer, GLenum attachment, GLuint texture, GLint level, GLenum face);
+typedef void (APIENTRYP PFNGLTEXTURERENDERBUFFEREXTPROC) (GLuint texture, GLenum target, GLuint renderbuffer);
+typedef void (APIENTRYP PFNGLMULTITEXRENDERBUFFEREXTPROC) (GLenum texunit, GLenum target, GLuint renderbuffer);
+#endif
+
+#ifndef GL_EXT_vertex_array_bgra
+#define GL_EXT_vertex_array_bgra 1
+#endif
+
+#ifndef GL_EXT_texture_swizzle
+#define GL_EXT_texture_swizzle 1
+#endif
+
+#ifndef GL_NV_explicit_multisample
+#define GL_NV_explicit_multisample 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetMultisamplefvNV (GLenum, GLuint, GLfloat *);
+GLAPI void APIENTRY glSampleMaskIndexedNV (GLuint, GLbitfield);
+GLAPI void APIENTRY glTexRenderbufferNV (GLenum, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETMULTISAMPLEFVNVPROC) (GLenum pname, GLuint index, GLfloat *val);
+typedef void (APIENTRYP PFNGLSAMPLEMASKINDEXEDNVPROC) (GLuint index, GLbitfield mask);
+typedef void (APIENTRYP PFNGLTEXRENDERBUFFERNVPROC) (GLenum target, GLuint renderbuffer);
+#endif
+
+#ifndef GL_NV_transform_feedback2
+#define GL_NV_transform_feedback2 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glBindTransformFeedbackNV (GLenum, GLuint);
+GLAPI void APIENTRY glDeleteTransformFeedbacksNV (GLsizei, const GLuint *);
+GLAPI void APIENTRY glGenTransformFeedbacksNV (GLsizei, GLuint *);
+GLAPI GLboolean APIENTRY glIsTransformFeedbackNV (GLuint);
+GLAPI void APIENTRY glPauseTransformFeedbackNV (void);
+GLAPI void APIENTRY glResumeTransformFeedbackNV (void);
+GLAPI void APIENTRY glDrawTransformFeedbackNV (GLenum, GLuint);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLBINDTRANSFORMFEEDBACKNVPROC) (GLenum target, GLuint id);
+typedef void (APIENTRYP PFNGLDELETETRANSFORMFEEDBACKSNVPROC) (GLsizei n, const GLuint *ids);
+typedef void (APIENTRYP PFNGLGENTRANSFORMFEEDBACKSNVPROC) (GLsizei n, GLuint *ids);
+typedef GLboolean (APIENTRYP PFNGLISTRANSFORMFEEDBACKNVPROC) (GLuint id);
+typedef void (APIENTRYP PFNGLPAUSETRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLRESUMETRANSFORMFEEDBACKNVPROC) (void);
+typedef void (APIENTRYP PFNGLDRAWTRANSFORMFEEDBACKNVPROC) (GLenum mode, GLuint id);
+#endif
+
+#ifndef GL_ATI_meminfo
+#define GL_ATI_meminfo 1
+#endif
+
+#ifndef GL_AMD_performance_monitor
+#define GL_AMD_performance_monitor 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glGetPerfMonitorGroupsAMD (GLint *, GLsizei, GLuint *);
+GLAPI void APIENTRY glGetPerfMonitorCountersAMD (GLuint, GLint *, GLint *, GLsizei, GLuint *);
+GLAPI void APIENTRY glGetPerfMonitorGroupStringAMD (GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetPerfMonitorCounterStringAMD (GLuint, GLuint, GLsizei, GLsizei *, GLchar *);
+GLAPI void APIENTRY glGetPerfMonitorCounterInfoAMD (GLuint, GLuint, GLenum, void *);
+GLAPI void APIENTRY glGenPerfMonitorsAMD (GLsizei, GLuint *);
+GLAPI void APIENTRY glDeletePerfMonitorsAMD (GLsizei, GLuint *);
+GLAPI void APIENTRY glSelectPerfMonitorCountersAMD (GLuint, GLboolean, GLuint, GLint, GLuint *);
+GLAPI void APIENTRY glBeginPerfMonitorAMD (GLuint);
+GLAPI void APIENTRY glEndPerfMonitorAMD (GLuint);
+GLAPI void APIENTRY glGetPerfMonitorCounterDataAMD (GLuint, GLenum, GLsizei, GLuint *, GLint *);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSAMDPROC) (GLint *numGroups, GLsizei groupsSize, GLuint *groups);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSAMDPROC) (GLuint group, GLint *numCounters, GLint *maxActiveCounters, GLsizei counterSize, GLuint *counters);
+typedef void (APIENTRYP PFNGLGETPERFMONITORGROUPSTRINGAMDPROC) (GLuint group, GLsizei bufSize, GLsizei *length, GLchar *groupString);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERSTRINGAMDPROC) (GLuint group, GLuint counter, GLsizei bufSize, GLsizei *length, GLchar *counterString);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERINFOAMDPROC) (GLuint group, GLuint counter, GLenum pname, void *data);
+typedef void (APIENTRYP PFNGLGENPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (APIENTRYP PFNGLDELETEPERFMONITORSAMDPROC) (GLsizei n, GLuint *monitors);
+typedef void (APIENTRYP PFNGLSELECTPERFMONITORCOUNTERSAMDPROC) (GLuint monitor, GLboolean enable, GLuint group, GLint numCounters, GLuint *counterList);
+typedef void (APIENTRYP PFNGLBEGINPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (APIENTRYP PFNGLENDPERFMONITORAMDPROC) (GLuint monitor);
+typedef void (APIENTRYP PFNGLGETPERFMONITORCOUNTERDATAAMDPROC) (GLuint monitor, GLenum pname, GLsizei dataSize, GLuint *data, GLint *bytesWritten);
+#endif
+
+#ifndef GL_AMD_texture_texture4
+#define GL_AMD_texture_texture4 1
+#endif
+
+#ifndef GL_AMD_vertex_shader_tesselator
+#define GL_AMD_vertex_shader_tesselator 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glTessellationFactorAMD (GLfloat);
+GLAPI void APIENTRY glTessellationModeAMD (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLTESSELLATIONFACTORAMDPROC) (GLfloat factor);
+typedef void (APIENTRYP PFNGLTESSELLATIONMODEAMDPROC) (GLenum mode);
+#endif
+
+#ifndef GL_EXT_provoking_vertex
+#define GL_EXT_provoking_vertex 1
+#ifdef GL_GLEXT_PROTOTYPES
+GLAPI void APIENTRY glProvokingVertexEXT (GLenum);
+#endif /* GL_GLEXT_PROTOTYPES */
+typedef void (APIENTRYP PFNGLPROVOKINGVERTEXEXTPROC) (GLenum mode);
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/graphics/GL/glu.h b/src/graphics/GL/glu.h
new file mode 100644
index 0000000..f386524
--- /dev/null
+++ b/src/graphics/GL/glu.h
@@ -0,0 +1,341 @@
+/*
+** License Applicability. Except to the extent portions of this file are
+** made subject to an alternative license as permitted in the SGI Free
+** Software License B, Version 1.1 (the "License"), the contents of this
+** file are subject only to the provisions of the License. You may not use
+** this file except in compliance with the License. You may obtain a copy
+** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
+** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
+**
+** http://oss.sgi.com/projects/FreeB
+**
+** Note that, as provided in the License, the Software is distributed on an
+** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
+** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
+** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
+** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
+**
+** Original Code. The Original Code is: OpenGL Sample Implementation,
+** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
+** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
+** Copyright in any portions created by third parties is as indicated
+** elsewhere herein. All Rights Reserved.
+**
+** Additional Notice Provisions: This software was created using the
+** OpenGL(R) version 1.2.1 Sample Implementation published by SGI, but has
+** not been independently verified as being compliant with the OpenGL(R)
+** version 1.2.1 Specification.
+*/
+
+#ifndef __glu_h__
+#define __glu_h__
+
+#if defined(USE_MGL_NAMESPACE)
+#include "../../api.h"
+#include "glu_mangle.h"
+#endif
+
+#include "gl.h"
+
+#ifndef GLAPIENTRY
+#define GLAPIENTRY
+#endif
+
+#ifndef GLAPIENTRYP
+#define GLAPIENTRYP GLAPIENTRY *
+#endif
+
+#ifndef GLAPI
+#define GLAPI
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*************************************************************/
+
+/* Extensions */
+#define GLU_EXT_object_space_tess 1
+#define GLU_EXT_nurbs_tessellator 1
+
+/* Boolean */
+#define GLU_FALSE 0
+#define GLU_TRUE 1
+
+/* Version */
+#define GLU_VERSION_1_1 1
+#define GLU_VERSION_1_2 1
+#define GLU_VERSION_1_3 1
+
+/* StringName */
+#define GLU_VERSION 100800
+#define GLU_EXTENSIONS 100801
+
+/* ErrorCode */
+#define GLU_INVALID_ENUM 100900
+#define GLU_INVALID_VALUE 100901
+#define GLU_OUT_OF_MEMORY 100902
+#define GLU_INCOMPATIBLE_GL_VERSION 100903
+#define GLU_INVALID_OPERATION 100904
+
+/* NurbsDisplay */
+/* GLU_FILL */
+#define GLU_OUTLINE_POLYGON 100240
+#define GLU_OUTLINE_PATCH 100241
+
+/* NurbsCallback */
+#define GLU_NURBS_ERROR 100103
+#define GLU_ERROR 100103
+#define GLU_NURBS_BEGIN 100164
+#define GLU_NURBS_BEGIN_EXT 100164
+#define GLU_NURBS_VERTEX 100165
+#define GLU_NURBS_VERTEX_EXT 100165
+#define GLU_NURBS_NORMAL 100166
+#define GLU_NURBS_NORMAL_EXT 100166
+#define GLU_NURBS_COLOR 100167
+#define GLU_NURBS_COLOR_EXT 100167
+#define GLU_NURBS_TEXTURE_COORD 100168
+#define GLU_NURBS_TEX_COORD_EXT 100168
+#define GLU_NURBS_END 100169
+#define GLU_NURBS_END_EXT 100169
+#define GLU_NURBS_BEGIN_DATA 100170
+#define GLU_NURBS_BEGIN_DATA_EXT 100170
+#define GLU_NURBS_VERTEX_DATA 100171
+#define GLU_NURBS_VERTEX_DATA_EXT 100171
+#define GLU_NURBS_NORMAL_DATA 100172
+#define GLU_NURBS_NORMAL_DATA_EXT 100172
+#define GLU_NURBS_COLOR_DATA 100173
+#define GLU_NURBS_COLOR_DATA_EXT 100173
+#define GLU_NURBS_TEXTURE_COORD_DATA 100174
+#define GLU_NURBS_TEX_COORD_DATA_EXT 100174
+#define GLU_NURBS_END_DATA 100175
+#define GLU_NURBS_END_DATA_EXT 100175
+
+/* NurbsError */
+#define GLU_NURBS_ERROR1 100251
+#define GLU_NURBS_ERROR2 100252
+#define GLU_NURBS_ERROR3 100253
+#define GLU_NURBS_ERROR4 100254
+#define GLU_NURBS_ERROR5 100255
+#define GLU_NURBS_ERROR6 100256
+#define GLU_NURBS_ERROR7 100257
+#define GLU_NURBS_ERROR8 100258
+#define GLU_NURBS_ERROR9 100259
+#define GLU_NURBS_ERROR10 100260
+#define GLU_NURBS_ERROR11 100261
+#define GLU_NURBS_ERROR12 100262
+#define GLU_NURBS_ERROR13 100263
+#define GLU_NURBS_ERROR14 100264
+#define GLU_NURBS_ERROR15 100265
+#define GLU_NURBS_ERROR16 100266
+#define GLU_NURBS_ERROR17 100267
+#define GLU_NURBS_ERROR18 100268
+#define GLU_NURBS_ERROR19 100269
+#define GLU_NURBS_ERROR20 100270
+#define GLU_NURBS_ERROR21 100271
+#define GLU_NURBS_ERROR22 100272
+#define GLU_NURBS_ERROR23 100273
+#define GLU_NURBS_ERROR24 100274
+#define GLU_NURBS_ERROR25 100275
+#define GLU_NURBS_ERROR26 100276
+#define GLU_NURBS_ERROR27 100277
+#define GLU_NURBS_ERROR28 100278
+#define GLU_NURBS_ERROR29 100279
+#define GLU_NURBS_ERROR30 100280
+#define GLU_NURBS_ERROR31 100281
+#define GLU_NURBS_ERROR32 100282
+#define GLU_NURBS_ERROR33 100283
+#define GLU_NURBS_ERROR34 100284
+#define GLU_NURBS_ERROR35 100285
+#define GLU_NURBS_ERROR36 100286
+#define GLU_NURBS_ERROR37 100287
+
+/* NurbsProperty */
+#define GLU_AUTO_LOAD_MATRIX 100200
+#define GLU_CULLING 100201
+#define GLU_SAMPLING_TOLERANCE 100203
+#define GLU_DISPLAY_MODE 100204
+#define GLU_PARAMETRIC_TOLERANCE 100202
+#define GLU_SAMPLING_METHOD 100205
+#define GLU_U_STEP 100206
+#define GLU_V_STEP 100207
+#define GLU_NURBS_MODE 100160
+#define GLU_NURBS_MODE_EXT 100160
+#define GLU_NURBS_TESSELLATOR 100161
+#define GLU_NURBS_TESSELLATOR_EXT 100161
+#define GLU_NURBS_RENDERER 100162
+#define GLU_NURBS_RENDERER_EXT 100162
+
+/* NurbsSampling */
+#define GLU_OBJECT_PARAMETRIC_ERROR 100208
+#define GLU_OBJECT_PARAMETRIC_ERROR_EXT 100208
+#define GLU_OBJECT_PATH_LENGTH 100209
+#define GLU_OBJECT_PATH_LENGTH_EXT 100209
+#define GLU_PATH_LENGTH 100215
+#define GLU_PARAMETRIC_ERROR 100216
+#define GLU_DOMAIN_DISTANCE 100217
+
+/* NurbsTrim */
+#define GLU_MAP1_TRIM_2 100210
+#define GLU_MAP1_TRIM_3 100211
+
+/* QuadricDrawStyle */
+#define GLU_POINT 100010
+#define GLU_LINE 100011
+#define GLU_FILL 100012
+#define GLU_SILHOUETTE 100013
+
+/* QuadricCallback */
+/* GLU_ERROR */
+
+/* QuadricNormal */
+#define GLU_SMOOTH 100000
+#define GLU_FLAT 100001
+#define GLU_NONE 100002
+
+/* QuadricOrientation */
+#define GLU_OUTSIDE 100020
+#define GLU_INSIDE 100021
+
+/* TessCallback */
+#define GLU_TESS_BEGIN 100100
+#define GLU_BEGIN 100100
+#define GLU_TESS_VERTEX 100101
+#define GLU_VERTEX 100101
+#define GLU_TESS_END 100102
+#define GLU_END 100102
+#define GLU_TESS_ERROR 100103
+#define GLU_TESS_EDGE_FLAG 100104
+#define GLU_EDGE_FLAG 100104
+#define GLU_TESS_COMBINE 100105
+#define GLU_TESS_BEGIN_DATA 100106
+#define GLU_TESS_VERTEX_DATA 100107
+#define GLU_TESS_END_DATA 100108
+#define GLU_TESS_ERROR_DATA 100109
+#define GLU_TESS_EDGE_FLAG_DATA 100110
+#define GLU_TESS_COMBINE_DATA 100111
+
+/* TessContour */
+#define GLU_CW 100120
+#define GLU_CCW 100121
+#define GLU_INTERIOR 100122
+#define GLU_EXTERIOR 100123
+#define GLU_UNKNOWN 100124
+
+/* TessProperty */
+#define GLU_TESS_WINDING_RULE 100140
+#define GLU_TESS_BOUNDARY_ONLY 100141
+#define GLU_TESS_TOLERANCE 100142
+
+/* TessError */
+#define GLU_TESS_ERROR1 100151
+#define GLU_TESS_ERROR2 100152
+#define GLU_TESS_ERROR3 100153
+#define GLU_TESS_ERROR4 100154
+#define GLU_TESS_ERROR5 100155
+#define GLU_TESS_ERROR6 100156
+#define GLU_TESS_ERROR7 100157
+#define GLU_TESS_ERROR8 100158
+#define GLU_TESS_MISSING_BEGIN_POLYGON 100151
+#define GLU_TESS_MISSING_BEGIN_CONTOUR 100152
+#define GLU_TESS_MISSING_END_POLYGON 100153
+#define GLU_TESS_MISSING_END_CONTOUR 100154
+#define GLU_TESS_COORD_TOO_LARGE 100155
+#define GLU_TESS_NEED_COMBINE_CALLBACK 100156
+
+/* TessWinding */
+#define GLU_TESS_WINDING_ODD 100130
+#define GLU_TESS_WINDING_NONZERO 100131
+#define GLU_TESS_WINDING_POSITIVE 100132
+#define GLU_TESS_WINDING_NEGATIVE 100133
+#define GLU_TESS_WINDING_ABS_GEQ_TWO 100134
+
+/*************************************************************/
+
+
+#ifdef __cplusplus
+class GLUnurbs;
+class GLUquadric;
+class GLUtesselator;
+#else
+typedef struct GLUnurbs GLUnurbs;
+typedef struct GLUquadric GLUquadric;
+typedef struct GLUtesselator GLUtesselator;
+#endif
+
+typedef GLUnurbs GLUnurbsObj;
+typedef GLUquadric GLUquadricObj;
+typedef GLUtesselator GLUtesselatorObj;
+typedef GLUtesselator GLUtriangulatorObj;
+
+#define GLU_TESS_MAX_COORD 1.0e150
+
+/* Internal convenience typedefs */
+typedef void (GLAPIENTRYP _GLUfuncptr)();
+
+GLAPI void GLAPIENTRY gluBeginCurve (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluBeginPolygon (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluBeginSurface (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluBeginTrim (GLUnurbs* nurb);
+GLAPI GLint GLAPIENTRY gluBuild1DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild1DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLenum format, GLenum type, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild2DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild2DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLenum format, GLenum type, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild3DMipmapLevels (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLint level, GLint base, GLint max, const void *data);
+GLAPI GLint GLAPIENTRY gluBuild3DMipmaps (GLenum target, GLint internalFormat, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, const void *data);
+GLAPI GLboolean GLAPIENTRY gluCheckExtension (const GLubyte *extName, const GLubyte *extString);
+GLAPI void GLAPIENTRY gluCylinder (GLUquadric* quad, GLdouble base, GLdouble top, GLdouble height, GLint slices, GLint stacks);
+GLAPI void GLAPIENTRY gluDeleteNurbsRenderer (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluDeleteQuadric (GLUquadric* quad);
+GLAPI void GLAPIENTRY gluDeleteTess (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops);
+GLAPI void GLAPIENTRY gluEndCurve (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluEndPolygon (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluEndSurface (GLUnurbs* nurb);
+GLAPI void GLAPIENTRY gluEndTrim (GLUnurbs* nurb);
+GLAPI const GLubyte * GLAPIENTRY gluErrorString (GLenum error);
+GLAPI void GLAPIENTRY gluGetNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat* data);
+GLAPI const GLubyte * GLAPIENTRY gluGetString (GLenum name);
+GLAPI void GLAPIENTRY gluGetTessProperty (GLUtesselator* tess, GLenum which, GLdouble* data);
+GLAPI void GLAPIENTRY gluLoadSamplingMatrices (GLUnurbs* nurb, const GLfloat *model, const GLfloat *perspective, const GLint *view);
+GLAPI void GLAPIENTRY gluLookAt (GLdouble eyeX, GLdouble eyeY, GLdouble eyeZ, GLdouble centerX, GLdouble centerY, GLdouble centerZ, GLdouble upX, GLdouble upY, GLdouble upZ);
+GLAPI GLUnurbs* GLAPIENTRY gluNewNurbsRenderer (void);
+GLAPI GLUquadric* GLAPIENTRY gluNewQuadric (void);
+GLAPI GLUtesselator* GLAPIENTRY gluNewTess (void);
+GLAPI void GLAPIENTRY gluNextContour (GLUtesselator* tess, GLenum type);
+GLAPI void GLAPIENTRY gluNurbsCallback (GLUnurbs* nurb, GLenum which, _GLUfuncptr CallBackFunc);
+GLAPI void GLAPIENTRY gluNurbsCallbackData (GLUnurbs* nurb, GLvoid* userData);
+GLAPI void GLAPIENTRY gluNurbsCallbackDataEXT (GLUnurbs* nurb, GLvoid* userData);
+GLAPI void GLAPIENTRY gluNurbsCurve (GLUnurbs* nurb, GLint knotCount, GLfloat *knots, GLint stride, GLfloat *control, GLint order, GLenum type);
+GLAPI void GLAPIENTRY gluNurbsProperty (GLUnurbs* nurb, GLenum property, GLfloat value);
+GLAPI void GLAPIENTRY gluNurbsSurface (GLUnurbs* nurb, GLint sKnotCount, GLfloat* sKnots, GLint tKnotCount, GLfloat* tKnots, GLint sStride, GLint tStride, GLfloat* control, GLint sOrder, GLint tOrder, GLenum type);
+GLAPI void GLAPIENTRY gluOrtho2D (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top);
+GLAPI void GLAPIENTRY gluPartialDisk (GLUquadric* quad, GLdouble inner, GLdouble outer, GLint slices, GLint loops, GLdouble start, GLdouble sweep);
+GLAPI void GLAPIENTRY gluPerspective (GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
+GLAPI void GLAPIENTRY gluPickMatrix (GLdouble x, GLdouble y, GLdouble delX, GLdouble delY, GLint *viewport);
+GLAPI GLint GLAPIENTRY gluProject (GLdouble objX, GLdouble objY, GLdouble objZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* winX, GLdouble* winY, GLdouble* winZ);
+GLAPI void GLAPIENTRY gluPwlCurve (GLUnurbs* nurb, GLint count, GLfloat* data, GLint stride, GLenum type);
+GLAPI void GLAPIENTRY gluQuadricCallback (GLUquadric* quad, GLenum which, _GLUfuncptr CallBackFunc);
+GLAPI void GLAPIENTRY gluQuadricDrawStyle (GLUquadric* quad, GLenum draw);
+GLAPI void GLAPIENTRY gluQuadricNormals (GLUquadric* quad, GLenum normal);
+GLAPI void GLAPIENTRY gluQuadricOrientation (GLUquadric* quad, GLenum orientation);
+GLAPI void GLAPIENTRY gluQuadricTexture (GLUquadric* quad, GLboolean texture);
+GLAPI GLint GLAPIENTRY gluScaleImage (GLenum format, GLsizei wIn, GLsizei hIn, GLenum typeIn, const void *dataIn, GLsizei wOut, GLsizei hOut, GLenum typeOut, GLvoid* dataOut);
+GLAPI void GLAPIENTRY gluSphere (GLUquadric* quad, GLdouble radius, GLint slices, GLint stacks);
+GLAPI void GLAPIENTRY gluTessBeginContour (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluTessBeginPolygon (GLUtesselator* tess, GLvoid* data);
+GLAPI void GLAPIENTRY gluTessCallback (GLUtesselator* tess, GLenum which, _GLUfuncptr CallBackFunc);
+GLAPI void GLAPIENTRY gluTessEndContour (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluTessEndPolygon (GLUtesselator* tess);
+GLAPI void GLAPIENTRY gluTessNormal (GLUtesselator* tess, GLdouble valueX, GLdouble valueY, GLdouble valueZ);
+GLAPI void GLAPIENTRY gluTessProperty (GLUtesselator* tess, GLenum which, GLdouble data);
+GLAPI void GLAPIENTRY gluTessVertex (GLUtesselator* tess, GLdouble *location, GLvoid* data);
+GLAPI GLint GLAPIENTRY gluUnProject (GLdouble winX, GLdouble winY, GLdouble winZ, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble* objX, GLdouble* objY, GLdouble* objZ);
+GLAPI GLint GLAPIENTRY gluUnProject4 (GLdouble winX, GLdouble winY, GLdouble winZ, GLdouble clipW, const GLdouble *model, const GLdouble *proj, const GLint *view, GLdouble nearVal, GLdouble farVal, GLdouble* objX, GLdouble* objY, GLdouble* objZ, GLdouble* objW);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __glu_h__ */
diff --git a/src/graphics/GL/glx.h b/src/graphics/GL/glx.h
new file mode 100644
index 0000000..d261ed3
--- /dev/null
+++ b/src/graphics/GL/glx.h
@@ -0,0 +1,552 @@
+/*
+ * Mesa 3-D graphics library
+ * Version: 6.3
+ *
+ * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
+ *
+ * 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
+ * BRIAN PAUL 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.
+ */
+
+
+#ifndef GLX_H
+#define GLX_H
+
+
+#ifdef __VMS
+#include "../../api.h"
+#include <GL/vms_x_fix.h>
+# ifdef __cplusplus
+/* VMS Xlib.h gives problems with C++.
+ * this avoids a bunch of trivial warnings */
+#pragma message disable nosimpint
+#endif
+#endif
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#ifdef __VMS
+# ifdef __cplusplus
+#pragma message enable nosimpint
+#endif
+#endif
+#include <GL/gl.h>
+
+
+#if defined(USE_MGL_NAMESPACE)
+#include "glx_mangle.h"
+#endif
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define GLX_VERSION_1_1 1
+#define GLX_VERSION_1_2 1
+#define GLX_VERSION_1_3 1
+#define GLX_VERSION_1_4 1
+
+#define GLX_EXTENSION_NAME "GLX"
+
+
+
+/*
+ * Tokens for glXChooseVisual and glXGetConfig:
+ */
+#define GLX_USE_GL 1
+#define GLX_BUFFER_SIZE 2
+#define GLX_LEVEL 3
+#define GLX_RGBA 4
+#define GLX_DOUBLEBUFFER 5
+#define GLX_STEREO 6
+#define GLX_AUX_BUFFERS 7
+#define GLX_RED_SIZE 8
+#define GLX_GREEN_SIZE 9
+#define GLX_BLUE_SIZE 10
+#define GLX_ALPHA_SIZE 11
+#define GLX_DEPTH_SIZE 12
+#define GLX_STENCIL_SIZE 13
+#define GLX_ACCUM_RED_SIZE 14
+#define GLX_ACCUM_GREEN_SIZE 15
+#define GLX_ACCUM_BLUE_SIZE 16
+#define GLX_ACCUM_ALPHA_SIZE 17
+
+
+/*
+ * Error codes returned by glXGetConfig:
+ */
+#define GLX_BAD_SCREEN 1
+#define GLX_BAD_ATTRIBUTE 2
+#define GLX_NO_EXTENSION 3
+#define GLX_BAD_VISUAL 4
+#define GLX_BAD_CONTEXT 5
+#define GLX_BAD_VALUE 6
+#define GLX_BAD_ENUM 7
+
+
+/*
+ * GLX 1.1 and later:
+ */
+#define GLX_VENDOR 1
+#define GLX_VERSION 2
+#define GLX_EXTENSIONS 3
+
+
+/*
+ * GLX 1.3 and later:
+ */
+#define GLX_CONFIG_CAVEAT 0x20
+#define GLX_DONT_CARE 0xFFFFFFFF
+#define GLX_X_VISUAL_TYPE 0x22
+#define GLX_TRANSPARENT_TYPE 0x23
+#define GLX_TRANSPARENT_INDEX_VALUE 0x24
+#define GLX_TRANSPARENT_RED_VALUE 0x25
+#define GLX_TRANSPARENT_GREEN_VALUE 0x26
+#define GLX_TRANSPARENT_BLUE_VALUE 0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE 0x28
+#define GLX_WINDOW_BIT 0x00000001
+#define GLX_PIXMAP_BIT 0x00000002
+#define GLX_PBUFFER_BIT 0x00000004
+#define GLX_AUX_BUFFERS_BIT 0x00000010
+#define GLX_FRONT_LEFT_BUFFER_BIT 0x00000001
+#define GLX_FRONT_RIGHT_BUFFER_BIT 0x00000002
+#define GLX_BACK_LEFT_BUFFER_BIT 0x00000004
+#define GLX_BACK_RIGHT_BUFFER_BIT 0x00000008
+#define GLX_DEPTH_BUFFER_BIT 0x00000020
+#define GLX_STENCIL_BUFFER_BIT 0x00000040
+#define GLX_ACCUM_BUFFER_BIT 0x00000080
+#define GLX_NONE 0x8000
+#define GLX_SLOW_CONFIG 0x8001
+#define GLX_TRUE_COLOR 0x8002
+#define GLX_DIRECT_COLOR 0x8003
+#define GLX_PSEUDO_COLOR 0x8004
+#define GLX_STATIC_COLOR 0x8005
+#define GLX_GRAY_SCALE 0x8006
+#define GLX_STATIC_GRAY 0x8007
+#define GLX_TRANSPARENT_RGB 0x8008
+#define GLX_TRANSPARENT_INDEX 0x8009
+#define GLX_VISUAL_ID 0x800B
+#define GLX_SCREEN 0x800C
+#define GLX_NON_CONFORMANT_CONFIG 0x800D
+#define GLX_DRAWABLE_TYPE 0x8010
+#define GLX_RENDER_TYPE 0x8011
+#define GLX_X_RENDERABLE 0x8012
+#define GLX_FBCONFIG_ID 0x8013
+#define GLX_RGBA_TYPE 0x8014
+#define GLX_COLOR_INDEX_TYPE 0x8015
+#define GLX_MAX_PBUFFER_WIDTH 0x8016
+#define GLX_MAX_PBUFFER_HEIGHT 0x8017
+#define GLX_MAX_PBUFFER_PIXELS 0x8018
+#define GLX_PRESERVED_CONTENTS 0x801B
+#define GLX_LARGEST_PBUFFER 0x801C
+#define GLX_WIDTH 0x801D
+#define GLX_HEIGHT 0x801E
+#define GLX_EVENT_MASK 0x801F
+#define GLX_DAMAGED 0x8020
+#define GLX_SAVED 0x8021
+#define GLX_WINDOW 0x8022
+#define GLX_PBUFFER 0x8023
+#define GLX_PBUFFER_HEIGHT 0x8040
+#define GLX_PBUFFER_WIDTH 0x8041
+#define GLX_RGBA_BIT 0x00000001
+#define GLX_COLOR_INDEX_BIT 0x00000002
+#define GLX_PBUFFER_CLOBBER_MASK 0x08000000
+
+
+/*
+ * GLX 1.4 and later:
+ */
+#define GLX_SAMPLE_BUFFERS 0x186a0 /*100000*/
+#define GLX_SAMPLES 0x186a1 /*100001*/
+
+
+
+typedef struct __GLXcontextRec *GLXContext;
+typedef XID GLXPixmap;
+typedef XID GLXDrawable;
+/* GLX 1.3 and later */
+typedef struct __GLXFBConfigRec *GLXFBConfig;
+typedef XID GLXFBConfigID;
+typedef XID GLXContextID;
+typedef XID GLXWindow;
+typedef XID GLXPbuffer;
+
+
+
+extern XVisualInfo* glXChooseVisual( Display *dpy, int screen,
+ int *attribList );
+
+extern GLXContext glXCreateContext( Display *dpy, XVisualInfo *vis,
+ GLXContext shareList, Bool direct );
+
+extern void glXDestroyContext( Display *dpy, GLXContext ctx );
+
+extern Bool glXMakeCurrent( Display *dpy, GLXDrawable drawable,
+ GLXContext ctx);
+
+extern void glXCopyContext( Display *dpy, GLXContext src, GLXContext dst,
+ unsigned long mask );
+
+extern void glXSwapBuffers( Display *dpy, GLXDrawable drawable );
+
+extern GLXPixmap glXCreateGLXPixmap( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap );
+
+extern void glXDestroyGLXPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern Bool glXQueryExtension( Display *dpy, int *errorb, int *event );
+
+extern Bool glXQueryVersion( Display *dpy, int *maj, int *min );
+
+extern Bool glXIsDirect( Display *dpy, GLXContext ctx );
+
+extern int glXGetConfig( Display *dpy, XVisualInfo *visual,
+ int attrib, int *value );
+
+extern GLXContext glXGetCurrentContext( void );
+
+extern GLXDrawable glXGetCurrentDrawable( void );
+
+extern void glXWaitGL( void );
+
+extern void glXWaitX( void );
+
+extern void glXUseXFont( Font font, int first, int count, int list );
+
+
+
+/* GLX 1.1 and later */
+extern const char *glXQueryExtensionsString( Display *dpy, int screen );
+
+extern const char *glXQueryServerString( Display *dpy, int screen, int name );
+
+extern const char *glXGetClientString( Display *dpy, int name );
+
+
+/* GLX 1.2 and later */
+extern Display *glXGetCurrentDisplay( void );
+
+
+/* GLX 1.3 and later */
+extern GLXFBConfig *glXChooseFBConfig( Display *dpy, int screen,
+ const int *attribList, int *nitems );
+
+extern int glXGetFBConfigAttrib( Display *dpy, GLXFBConfig config,
+ int attribute, int *value );
+
+extern GLXFBConfig *glXGetFBConfigs( Display *dpy, int screen,
+ int *nelements );
+
+extern XVisualInfo *glXGetVisualFromFBConfig( Display *dpy,
+ GLXFBConfig config );
+
+extern GLXWindow glXCreateWindow( Display *dpy, GLXFBConfig config,
+ Window win, const int *attribList );
+
+extern void glXDestroyWindow( Display *dpy, GLXWindow window );
+
+extern GLXPixmap glXCreatePixmap( Display *dpy, GLXFBConfig config,
+ Pixmap pixmap, const int *attribList );
+
+extern void glXDestroyPixmap( Display *dpy, GLXPixmap pixmap );
+
+extern GLXPbuffer glXCreatePbuffer( Display *dpy, GLXFBConfig config,
+ const int *attribList );
+
+extern void glXDestroyPbuffer( Display *dpy, GLXPbuffer pbuf );
+
+extern void glXQueryDrawable( Display *dpy, GLXDrawable draw, int attribute,
+ unsigned int *value );
+
+extern GLXContext glXCreateNewContext( Display *dpy, GLXFBConfig config,
+ int renderType, GLXContext shareList,
+ Bool direct );
+
+extern Bool glXMakeContextCurrent( Display *dpy, GLXDrawable draw,
+ GLXDrawable read, GLXContext ctx );
+
+extern GLXDrawable glXGetCurrentReadDrawable( void );
+
+extern int glXQueryContext( Display *dpy, GLXContext ctx, int attribute,
+ int *value );
+
+extern void glXSelectEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long mask );
+
+extern void glXGetSelectedEvent( Display *dpy, GLXDrawable drawable,
+ unsigned long *mask );
+
+
+/* GLX 1.4 and later */
+extern void (*glXGetProcAddress(const GLubyte *procname))( void );
+
+
+#ifndef GLX_GLXEXT_LEGACY
+
+#include <GL/glxext.h>
+
+#else
+
+
+/*
+ * 28. GLX_EXT_visual_info extension
+ */
+#ifndef GLX_EXT_visual_info
+#define GLX_EXT_visual_info 1
+
+#define GLX_X_VISUAL_TYPE_EXT 0x22
+#define GLX_TRANSPARENT_TYPE_EXT 0x23
+#define GLX_TRANSPARENT_INDEX_VALUE_EXT 0x24
+#define GLX_TRANSPARENT_RED_VALUE_EXT 0x25
+#define GLX_TRANSPARENT_GREEN_VALUE_EXT 0x26
+#define GLX_TRANSPARENT_BLUE_VALUE_EXT 0x27
+#define GLX_TRANSPARENT_ALPHA_VALUE_EXT 0x28
+#define GLX_TRUE_COLOR_EXT 0x8002
+#define GLX_DIRECT_COLOR_EXT 0x8003
+#define GLX_PSEUDO_COLOR_EXT 0x8004
+#define GLX_STATIC_COLOR_EXT 0x8005
+#define GLX_GRAY_SCALE_EXT 0x8006
+#define GLX_STATIC_GRAY_EXT 0x8007
+#define GLX_NONE_EXT 0x8000
+#define GLX_TRANSPARENT_RGB_EXT 0x8008
+#define GLX_TRANSPARENT_INDEX_EXT 0x8009
+
+#endif /* 28. GLX_EXT_visual_info extension */
+
+
+
+/*
+ * 41. GLX_SGI_video_sync
+ */
+#ifndef GLX_SGI_video_sync
+#define GLX_SGI_video_sync 1
+
+extern int glXGetVideoSyncSGI(unsigned int *count);
+extern int glXWaitVideoSyncSGI(int divisor, int remainder, unsigned int *count);
+
+#endif /* GLX_SGI_video_sync */
+
+
+
+/*
+ * 42. GLX_EXT_visual_rating
+ */
+#ifndef GLX_EXT_visual_rating
+#define GLX_EXT_visual_rating 1
+
+#define GLX_VISUAL_CAVEAT_EXT 0x20
+/*#define GLX_NONE_EXT 0x8000*/
+#define GLX_SLOW_VISUAL_EXT 0x8001
+#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
+
+#endif /* GLX_EXT_visual_rating */
+
+
+
+/*
+ * 47. GLX_EXT_import_context
+ */
+#ifndef GLX_EXT_import_context
+#define GLX_EXT_import_context 1
+
+#define GLX_SHARE_CONTEXT_EXT 0x800A
+#define GLX_VISUAL_ID_EXT 0x800B
+#define GLX_SCREEN_EXT 0x800C
+
+extern void glXFreeContextEXT(Display *dpy, GLXContext context);
+
+extern GLXContextID glXGetContextIDEXT(const GLXContext context);
+
+extern Display *glXGetCurrentDisplayEXT(void);
+
+extern GLXContext glXImportContextEXT(Display *dpy, GLXContextID contextID);
+
+extern int glXQueryContextInfoEXT(Display *dpy, GLXContext context,
+ int attribute,int *value);
+
+#endif /* GLX_EXT_import_context */
+
+
+
+/*
+ * 215. GLX_MESA_copy_sub_buffer
+ */
+#ifndef GLX_MESA_copy_sub_buffer
+#define GLX_MESA_copy_sub_buffer 1
+
+extern void glXCopySubBufferMESA( Display *dpy, GLXDrawable drawable,
+ int x, int y, int width, int height );
+
+#endif
+
+
+
+/*
+ * 216. GLX_MESA_pixmap_colormap
+ */
+#ifndef GLX_MESA_pixmap_colormap
+#define GLX_MESA_pixmap_colormap 1
+
+extern GLXPixmap glXCreateGLXPixmapMESA( Display *dpy, XVisualInfo *visual,
+ Pixmap pixmap, Colormap cmap );
+
+#endif /* GLX_MESA_pixmap_colormap */
+
+
+
+/*
+ * 217. GLX_MESA_release_buffers
+ */
+#ifndef GLX_MESA_release_buffers
+#define GLX_MESA_release_buffers 1
+
+extern Bool glXReleaseBuffersMESA( Display *dpy, GLXDrawable d );
+
+#endif /* GLX_MESA_release_buffers */
+
+
+
+/*
+ * 218. GLX_MESA_set_3dfx_mode
+ */
+#ifndef GLX_MESA_set_3dfx_mode
+#define GLX_MESA_set_3dfx_mode 1
+
+#define GLX_3DFX_WINDOW_MODE_MESA 0x1
+#define GLX_3DFX_FULLSCREEN_MODE_MESA 0x2
+
+extern Bool glXSet3DfxModeMESA( int mode );
+
+#endif /* GLX_MESA_set_3dfx_mode */
+
+
+
+/*
+ * ARB 2. GLX_ARB_get_proc_address
+ */
+#ifndef GLX_ARB_get_proc_address
+#define GLX_ARB_get_proc_address 1
+
+extern void (*glXGetProcAddressARB(const GLubyte *procName))();
+
+#endif /* GLX_ARB_get_proc_address */
+
+
+
+#endif /* GLX_GLXEXT_LEGACY */
+
+
+/**
+ ** The following aren't in glxext.h yet.
+ **/
+
+
+/*
+ * ???. GLX_NV_vertex_array_range
+ */
+#ifndef GLX_NV_vertex_array_range
+#define GLX_NV_vertex_array_range
+
+extern void *glXAllocateMemoryNV(GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+extern void glXFreeMemoryNV(GLvoid *pointer);
+typedef void * ( * PFNGLXALLOCATEMEMORYNVPROC) (GLsizei size, GLfloat readfreq, GLfloat writefreq, GLfloat priority);
+typedef void ( * PFNGLXFREEMEMORYNVPROC) (GLvoid *pointer);
+
+#endif /* GLX_NV_vertex_array_range */
+
+
+
+/*
+ * ???. GLX_MESA_agp_offset
+ */
+#ifndef GLX_MESA_agp_offset
+#define GLX_MESA_agp_offset 1
+
+extern GLuint glXGetAGPOffsetMESA(const GLvoid *pointer);
+typedef GLuint (* PFNGLXGETAGPOFFSETMESAPROC) (const GLvoid *pointer);
+
+#endif /* GLX_MESA_agp_offset */
+
+
+/*
+ * ???. GLX_MESA_allocate_memory
+ */
+#ifndef GLX_MESA_allocate_memory
+#define GLX_MESA_allocate_memory 1
+
+extern void *glXAllocateMemoryMESA(Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
+extern void glXFreeMemoryMESA(Display *dpy, int scrn, void *pointer);
+extern GLuint glXGetMemoryOffsetMESA(Display *dpy, int scrn, const void *pointer);
+typedef void * ( * PFNGLXALLOCATEMEMORYMESAPROC) (Display *dpy, int scrn, size_t size, float readfreq, float writefreq, float priority);
+typedef void ( * PFNGLXFREEMEMORYMESAPROC) (Display *dpy, int scrn, void *pointer);
+typedef GLuint (* PFNGLXGETMEMORYOFFSETMESAPROC) (Display *dpy, int scrn, const void *pointer);
+
+#endif /* GLX_MESA_allocate_memory */
+
+/*
+ * ARB ?. GLX_ARB_render_texture
+ */
+#ifndef GLX_ARB_render_texture
+#define GLX_ARB_render_texture 1
+
+extern Bool glXBindTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
+extern Bool glXReleaseTexImageARB(Display *dpy, GLXPbuffer pbuffer, int buffer);
+extern Bool glXDrawableAttribARB(Display *dpy, GLXDrawable draw, const int *attribList);
+
+#endif /* GLX_ARB_render_texture */
+
+
+/*
+ * Remove this when glxext.h is updated.
+ */
+#ifndef GLX_NV_float_buffer
+#define GLX_NV_float_buffer 1
+
+#define GLX_FLOAT_COMPONENTS_NV 0x20B0
+
+#endif /* GLX_NV_float_buffer */
+
+
+/*** Should these go here, or in another header? */
+/*
+** GLX Events
+*/
+typedef struct {
+ int event_type; /* GLX_DAMAGED or GLX_SAVED */
+ int draw_type; /* GLX_WINDOW or GLX_PBUFFER */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came for SendEvent request */
+ Display *display; /* display the event was read from */
+ GLXDrawable drawable; /* XID of Drawable */
+ unsigned int buffer_mask; /* mask indicating which buffers are affected */
+ unsigned int aux_buffer; /* which aux buffer was affected */
+ int x, y;
+ int width, height;
+ int count; /* if nonzero, at least this many more */
+} GLXPbufferClobberEvent;
+
+typedef union __GLXEvent {
+ GLXPbufferClobberEvent glxpbufferclobber;
+ long pad[24];
+} GLXEvent;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/graphics/GLBufferCache.cpp b/src/graphics/GLBufferCache.cpp
new file mode 100644
index 0000000..e88fc4f
--- /dev/null
+++ b/src/graphics/GLBufferCache.cpp
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GLBufferCache.h"
+
+#include "../base/Exception.h"
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+GLBufferCache::GLBufferCache()
+{
+}
+
+GLBufferCache::~GLBufferCache()
+{
+ deleteBuffers();
+}
+
+unsigned int GLBufferCache::getBuffer()
+{
+ unsigned int bufferID;
+ if (m_BufferIDs.empty()) {
+ glproc::GenBuffers(1, &bufferID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO: GenBuffers()");
+ } else {
+ bufferID = m_BufferIDs.back();
+ m_BufferIDs.pop_back();
+ }
+ return bufferID;
+}
+
+void GLBufferCache::returnBuffer(unsigned int bufferID)
+{
+ m_BufferIDs.push_back(bufferID);
+}
+
+void GLBufferCache::deleteBuffers()
+{
+ for (unsigned i=0; i<m_BufferIDs.size(); ++i) {
+ glproc::DeleteBuffers(1, &(m_BufferIDs[i]));
+ }
+ m_BufferIDs.clear();
+}
+
+}
diff --git a/src/graphics/GLBufferCache.h b/src/graphics/GLBufferCache.h
new file mode 100644
index 0000000..2fca9d4
--- /dev/null
+++ b/src/graphics/GLBufferCache.h
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GLBufferCache_H_
+#define _GLBufferCache_H_
+
+#include "../api.h"
+
+#include "../graphics/OGLHelper.h"
+
+#include <vector>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread/tss.hpp>
+
+namespace avg {
+
+class AVG_API GLBufferCache {
+public:
+ GLBufferCache();
+ virtual ~GLBufferCache();
+
+ unsigned int getBuffer();
+ void returnBuffer(unsigned int);
+
+private:
+ void deleteBuffers();
+
+ std::vector<unsigned int> m_BufferIDs;
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/GLConfig.cpp b/src/graphics/GLConfig.cpp
new file mode 100644
index 0000000..abe6aa4
--- /dev/null
+++ b/src/graphics/GLConfig.cpp
@@ -0,0 +1,54 @@
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GLConfig.h"
+
+#include "../base/Logger.h"
+
+namespace avg {
+
+GLConfig::GLConfig()
+{
+}
+
+GLConfig::GLConfig(bool bUsePOTTextures, bool bUseShaders, bool bUsePixelBuffers,
+ int multiSampleSamples)
+ : m_bUsePOTTextures(bUsePOTTextures),
+ m_bUseShaders(bUseShaders),
+ m_bUsePixelBuffers(bUsePixelBuffers),
+ m_MultiSampleSamples(multiSampleSamples)
+{
+}
+
+void GLConfig::log()
+{
+ AVG_TRACE(Logger::CONFIG, " Shader support: " << (m_bUseShaders?"true":"false"));
+ AVG_TRACE(Logger::CONFIG, " Pixel buffers: " << (m_bUsePixelBuffers?"true":"false"));
+ AVG_TRACE(Logger::CONFIG, " Power of 2 textures: " <<
+ (m_bUsePOTTextures?"true":"false"));
+ if (m_MultiSampleSamples == 1) {
+ AVG_TRACE(Logger::CONFIG, " No multisampling.");
+ } else {
+ AVG_TRACE(Logger::CONFIG, " Multisampling with " << m_MultiSampleSamples
+ << " samples");
+ }
+}
+
+}
diff --git a/src/graphics/GLConfig.h b/src/graphics/GLConfig.h
new file mode 100644
index 0000000..ebf6387
--- /dev/null
+++ b/src/graphics/GLConfig.h
@@ -0,0 +1,46 @@
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GLConfig_H_
+#define _GLConfig_H_
+
+#include "../api.h"
+
+namespace avg {
+
+struct AVG_API GLConfig {
+ GLConfig();
+ GLConfig(bool bUsePOTTextures, bool bUseShaders, bool bUsePixelBuffers,
+ int multiSampleSamples);
+
+ void log();
+
+ bool m_bUsePOTTextures;
+ bool m_bUseShaders;
+ bool m_bUsePixelBuffers;
+ int m_MultiSampleSamples;
+
+// OGLMemoryMode m_MemoryMode;
+};
+
+}
+
+#endif
+
diff --git a/src/graphics/GLContext.cpp b/src/graphics/GLContext.cpp
new file mode 100644
index 0000000..35af3fa
--- /dev/null
+++ b/src/graphics/GLContext.cpp
@@ -0,0 +1,469 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GLContext.h"
+
+#include "ShaderRegistry.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/MathHelper.h"
+
+#include <iostream>
+
+
+namespace avg {
+
+using namespace std;
+using namespace boost;
+thread_specific_ptr<GLContext*> GLContext::s_pCurrentContext;
+
+#ifdef _WIN32
+LONG WINAPI imagingWindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+ return DefWindowProc(hwnd, msg, wParam, lParam);
+}
+
+void registerWindowClass()
+{
+ static char * pClassName;
+ if (pClassName) {
+ return;
+ }
+ pClassName = "GL";
+
+ HINSTANCE hInstance = GetModuleHandle(NULL);
+ WNDCLASS wc;
+ memset(&wc, 0, sizeof(WNDCLASS));
+ wc.style = CS_OWNDC;
+ wc.lpfnWndProc = (WNDPROC)imagingWindowProc;
+ wc.hInstance = hInstance;
+ wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
+ wc.hCursor = LoadCursor(hInstance, IDC_ARROW);
+ wc.hbrBackground = NULL;
+ wc.lpszMenuName = NULL;
+ wc.lpszClassName = pClassName;
+
+ BOOL bOK = RegisterClass(&wc);
+ AVG_ASSERT(bOK);
+}
+#endif
+
+#ifdef linux
+static bool s_bX11Error;
+static int (*s_DefaultErrorHandler) (Display *, XErrorEvent *);
+
+int X11ErrorHandler(Display * pDisplay, XErrorEvent * pErrEvent)
+{
+ cerr << "X11 error creating offscreen context: " << (int)(pErrEvent->request_code)
+ << ", " << (int)(pErrEvent->minor_code) << endl;
+ s_bX11Error = true;
+ return 0;
+}
+#endif
+
+GLContext::GLContext(bool bUseCurrent, const GLConfig& GLConfig,
+ GLContext* pSharedContext)
+ : m_Context(0),
+ m_MaxTexSize(0),
+ m_bCheckedMemoryMode(false),
+ m_bEnableTexture(false),
+ m_bEnableGLColorArray(true),
+ m_BlendMode(BLEND_ADD)
+{
+ if (bUseCurrent) {
+ AVG_ASSERT(!pSharedContext);
+ }
+ if (s_pCurrentContext.get() == 0) {
+ s_pCurrentContext.reset(new (GLContext*));
+ }
+ m_GLConfig = GLConfig;
+ m_bOwnsContext = !bUseCurrent;
+ if (bUseCurrent) {
+#if defined(__APPLE__)
+ m_Context = CGLGetCurrentContext();
+#elif defined(__linux__)
+ m_pDisplay = glXGetCurrentDisplay();
+ m_Drawable = glXGetCurrentDrawable();
+ m_Context = glXGetCurrentContext();
+#elif defined(_WIN32)
+ m_hDC = wglGetCurrentDC();
+ m_Context = wglGetCurrentContext();
+#endif
+ *s_pCurrentContext = this;
+ } else {
+#ifdef __APPLE__
+ CGLPixelFormatObj pixelFormatObj;
+ GLint numPixelFormats;
+
+ CGLPixelFormatAttribute attribs[] = {(CGLPixelFormatAttribute)NULL};
+ CGLContextObj cglSharedContext;
+ if (pSharedContext) {
+ cglSharedContext = pSharedContext->m_Context;
+ pixelFormatObj = CGLGetPixelFormat(cglSharedContext);
+ } else {
+ cglSharedContext = 0;
+ CGLChoosePixelFormat(attribs, &pixelFormatObj, &numPixelFormats);
+ }
+
+ CGLError err = CGLCreateContext(pixelFormatObj, cglSharedContext, &m_Context);
+ if (err) {
+ cerr << CGLErrorString(err) << endl;
+ AVG_ASSERT(false);
+ }
+ CGLDestroyPixelFormat(pixelFormatObj);
+#elif defined(__linux__)
+ m_pDisplay = XOpenDisplay(0);
+ if (!m_pDisplay) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL, "No X windows display available.");
+ }
+ XVisualInfo *vi;
+ static int attributes[] = {GLX_RGBA,
+ GLX_RED_SIZE, 1,
+ GLX_GREEN_SIZE, 1,
+ GLX_BLUE_SIZE, 1,
+ 0};
+ vi = glXChooseVisual(m_pDisplay, DefaultScreen(m_pDisplay), attributes);
+ m_Context = glXCreateContext(m_pDisplay, vi, 0, GL_TRUE);
+ AVG_ASSERT(m_Context);
+ Pixmap pmp = XCreatePixmap(m_pDisplay, RootWindow(m_pDisplay, vi->screen),
+ 8, 8, vi->depth);
+ GLXPixmap pixmap = glXCreateGLXPixmap(m_pDisplay, vi, pmp);
+
+ s_bX11Error = false;
+ s_DefaultErrorHandler = XSetErrorHandler(X11ErrorHandler);
+ glXMakeCurrent(m_pDisplay, pixmap, m_Context);
+ XSetErrorHandler(s_DefaultErrorHandler);
+
+ if (s_bX11Error) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL, "X error creating OpenGL context.");
+ }
+ m_Drawable = glXGetCurrentDrawable();
+#elif defined(_WIN32)
+ registerWindowClass();
+ m_hwnd = CreateWindow("GL", "GL",
+ WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
+ 0, 0, 500, 300, 0, 0, GetModuleHandle(NULL), 0);
+ winOGLErrorCheck(m_hDC != 0, "CreateWindow");
+
+ m_hDC = GetDC(m_hwnd);
+ winOGLErrorCheck(m_hDC != 0, "GetDC");
+
+ PIXELFORMATDESCRIPTOR pfd;
+ ZeroMemory(&pfd, sizeof(pfd));
+ pfd.nSize = sizeof(pfd);
+ pfd.nVersion = 1;
+ pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
+ pfd.iPixelType = PFD_TYPE_RGBA;
+ pfd.cColorBits = 32;
+ pfd.cDepthBits = 32;
+ pfd.iLayerType = PFD_MAIN_PLANE;
+
+ int iFormat = ChoosePixelFormat(m_hDC, &pfd);
+ winOGLErrorCheck(iFormat != 0, "ChoosePixelFormat");
+ SetPixelFormat(m_hDC, iFormat, &pfd);
+ m_Context = wglCreateContext(m_hDC);
+ winOGLErrorCheck(m_Context != 0, "wglCreateContext");
+#endif
+ }
+
+ init();
+}
+
+GLContext::~GLContext()
+{
+ for (unsigned i=0; i<m_FBOIDs.size(); ++i) {
+ glproc::DeleteFramebuffers(1, &(m_FBOIDs[i]));
+ }
+ m_FBOIDs.clear();
+ if (*s_pCurrentContext == this) {
+ *s_pCurrentContext = 0;
+ }
+ if (m_bOwnsContext && m_Context) {
+#ifdef __APPLE__
+ CGLSetCurrentContext(0);
+ CGLDestroyContext(m_Context);
+ m_Context = 0;
+#elif defined _WIN32
+ wglDeleteContext(m_Context);
+ DeleteDC(m_hDC);
+ DestroyWindow(m_hwnd);
+#endif
+ }
+}
+
+void GLContext::init()
+{
+ activate();
+ glproc::init();
+ m_pShaderRegistry = ShaderRegistryPtr(new ShaderRegistry());
+ enableGLColorArray(false);
+ setBlendMode(BLEND_BLEND, false);
+ checkShaderSupport();
+ if (!m_GLConfig.m_bUsePOTTextures) {
+ m_GLConfig.m_bUsePOTTextures =
+ !queryOGLExtension("GL_ARB_texture_non_power_of_two");
+ }
+}
+
+void GLContext::activate()
+{
+#ifdef __APPLE__
+ CGLError err = CGLSetCurrentContext(m_Context);
+ AVG_ASSERT(err == kCGLNoError);
+#elif defined linux
+ glXMakeCurrent(m_pDisplay, m_Drawable, m_Context);
+#elif defined _WIN32
+ BOOL bOk = wglMakeCurrent(m_hDC, m_Context);
+ winOGLErrorCheck(bOk, "wglMakeCurrent");
+#endif
+ *s_pCurrentContext = this;
+}
+
+ShaderRegistryPtr GLContext::getShaderRegistry() const
+{
+ return m_pShaderRegistry;
+}
+
+void GLContext::pushTransform(const DPoint& translate, double angle, const DPoint& pivot)
+{
+ glPushMatrix();
+ glTranslated(translate.x, translate.y, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "pushTransform: glTranslated");
+ glTranslated(pivot.x, pivot.y, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "pushTransform: glTranslated");
+ glRotated(angle*180.0/M_PI, 0, 0, 1);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "pushTransform: glRotated");
+ glTranslated(-pivot.x, -pivot.y, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "pushTransform: glTranslated");
+}
+
+void GLContext::popTransform()
+{
+ glPopMatrix();
+}
+
+GLBufferCache& GLContext::getVertexBufferCache()
+{
+ return m_VertexBufferCache;
+}
+
+GLBufferCache& GLContext::getIndexBufferCache()
+{
+ return m_IndexBufferCache;
+}
+
+GLBufferCache& GLContext::getPBOCache()
+{
+ return m_PBOCache;
+}
+
+unsigned GLContext::genFBO()
+{
+ unsigned fboID;
+ if (m_FBOIDs.empty()) {
+ glproc::GenFramebuffers(1, &fboID);
+ } else {
+ fboID = m_FBOIDs.back();
+ m_FBOIDs.pop_back();
+ }
+ return fboID;
+}
+
+void GLContext::returnFBOToCache(unsigned fboID)
+{
+ m_FBOIDs.push_back(fboID);
+}
+
+void GLContext::enableTexture(bool bEnable)
+{
+ if (bEnable != m_bEnableTexture) {
+ if (bEnable) {
+ glEnable(GL_TEXTURE_2D);
+ } else {
+ glDisable(GL_TEXTURE_2D);
+ }
+ m_bEnableTexture = bEnable;
+ }
+}
+
+void GLContext::enableGLColorArray(bool bEnable)
+{
+ if (bEnable != m_bEnableGLColorArray) {
+ if (bEnable) {
+ glEnableClientState(GL_COLOR_ARRAY);
+ } else {
+ glDisableClientState(GL_COLOR_ARRAY);
+ }
+ m_bEnableGLColorArray = bEnable;
+ }
+}
+
+void checkBlendModeError(const char * sMode)
+{
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR) {
+ static bool bErrorReported = false;
+ if (!bErrorReported) {
+ AVG_TRACE(Logger::WARNING, "Blendmode "<< sMode <<
+ " not supported by OpenGL implementation.");
+ bErrorReported = true;
+ }
+ }
+}
+
+void GLContext::setBlendMode(BlendMode mode, bool bPremultipliedAlpha)
+{
+ GLenum srcFunc;
+ if (bPremultipliedAlpha) {
+ srcFunc = GL_CONSTANT_ALPHA;
+ } else {
+ srcFunc = GL_SRC_ALPHA;
+ }
+ if (mode != m_BlendMode || m_bPremultipliedAlpha != bPremultipliedAlpha) {
+ switch (mode) {
+ case BLEND_BLEND:
+ glproc::BlendEquation(GL_FUNC_ADD);
+ glproc::BlendFuncSeparate(srcFunc, GL_ONE_MINUS_SRC_ALPHA,
+ GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ checkBlendModeError("blend");
+ break;
+ case BLEND_ADD:
+ glproc::BlendEquation(GL_FUNC_ADD);
+ glproc::BlendFuncSeparate(srcFunc, GL_ONE, GL_ONE, GL_ONE);
+ checkBlendModeError("add");
+ break;
+ case BLEND_MIN:
+ glproc::BlendEquation(GL_MIN);
+ glproc::BlendFuncSeparate(srcFunc, GL_ONE_MINUS_SRC_ALPHA,
+ GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ checkBlendModeError("min");
+ break;
+ case BLEND_MAX:
+ glproc::BlendEquation(GL_MAX);
+ glproc::BlendFuncSeparate(srcFunc, GL_ONE_MINUS_SRC_ALPHA,
+ GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
+ checkBlendModeError("max");
+ break;
+ case BLEND_COPY:
+ glproc::BlendEquation(GL_FUNC_ADD);
+ glBlendFunc(GL_ONE, GL_ZERO);
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+
+ m_BlendMode = mode;
+ m_bPremultipliedAlpha = bPremultipliedAlpha;
+ }
+}
+
+const GLConfig& GLContext::getConfig()
+{
+ return m_GLConfig;
+}
+
+void GLContext::logConfig()
+{
+ AVG_TRACE(Logger::CONFIG, "OpenGL configuration: ");
+ AVG_TRACE(Logger::CONFIG, " OpenGL version: " << glGetString(GL_VERSION));
+ AVG_TRACE(Logger::CONFIG, " OpenGL vendor: " << glGetString(GL_VENDOR));
+ AVG_TRACE(Logger::CONFIG, " OpenGL renderer: " << glGetString(GL_RENDERER));
+ m_GLConfig.log();
+ switch (getMemoryModeSupported()) {
+ case MM_PBO:
+ AVG_TRACE(Logger::CONFIG, " Using pixel buffer objects.");
+ break;
+ case MM_OGL:
+ AVG_TRACE(Logger::CONFIG, " Not using GL memory extensions.");
+ break;
+ }
+ AVG_TRACE(Logger::CONFIG, " Max. texture size is " << getMaxTexSize());
+}
+
+bool GLContext::usePOTTextures()
+{
+ return m_GLConfig.m_bUsePOTTextures;
+}
+
+OGLMemoryMode GLContext::getMemoryModeSupported()
+{
+ if (!m_bCheckedMemoryMode) {
+ if ((queryOGLExtension("GL_ARB_pixel_buffer_object") ||
+ queryOGLExtension("GL_EXT_pixel_buffer_object")) &&
+ m_GLConfig.m_bUsePixelBuffers)
+ {
+ m_MemoryMode = MM_PBO;
+ } else {
+ m_MemoryMode = MM_OGL;
+ }
+ m_bCheckedMemoryMode = true;
+ }
+ return m_MemoryMode;
+}
+
+bool GLContext::isUsingShaders() const
+{
+ return m_GLConfig.m_bUseShaders;
+}
+
+int GLContext::getMaxTexSize()
+{
+ if (m_MaxTexSize == 0) {
+ glGetIntegerv(GL_MAX_TEXTURE_SIZE, &m_MaxTexSize);
+ }
+ return m_MaxTexSize;
+}
+
+GLContext::BlendMode GLContext::stringToBlendMode(const string& s)
+{
+ if (s == "blend") {
+ return GLContext::BLEND_BLEND;
+ } else if (s == "add") {
+ return GLContext::BLEND_ADD;
+ } else if (s == "min") {
+ return GLContext::BLEND_MIN;
+ } else if (s == "max") {
+ return GLContext::BLEND_MAX;
+ } else {
+ throw(Exception(AVG_ERR_UNSUPPORTED, "Blend mode "+s+" not supported."));
+ }
+}
+
+GLContext* GLContext::getCurrent()
+{
+ return *s_pCurrentContext;
+}
+
+void GLContext::checkShaderSupport()
+{
+ int glMajorVer;
+ int glMinorVer;
+ getGLShadingLanguageVersion(glMajorVer, glMinorVer);
+ bool bShaderVersionOK = (glMajorVer >= 2 || glMinorVer >= 10);
+ m_GLConfig.m_bUseShaders = (queryOGLExtension("GL_ARB_fragment_shader") &&
+ getMemoryModeSupported() == MM_PBO &&
+ !m_GLConfig.m_bUsePOTTextures &&
+ m_GLConfig.m_bUseShaders &&
+ bShaderVersionOK);
+}
+
+}
diff --git a/src/graphics/GLContext.h b/src/graphics/GLContext.h
new file mode 100644
index 0000000..b086d78
--- /dev/null
+++ b/src/graphics/GLContext.h
@@ -0,0 +1,132 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#ifndef _GLContext_H_
+#define _GLContext_H_
+#include "../api.h"
+
+#include "OGLHelper.h"
+#include "GLBufferCache.h"
+#include "GLConfig.h"
+
+#include "../base/Point.h"
+
+#ifdef __APPLE__
+#include <OpenGL/OpenGL.h>
+#undef check // Conflicts with boost
+#elif defined linux
+#include <GL/glx.h>
+#elif defined _WIN32
+#include <gl/gl.h>
+#include <gl/glu.h>
+#endif
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread/tss.hpp>
+
+namespace avg {
+
+class GLContext;
+typedef boost::shared_ptr<GLContext> GLContextPtr;
+class ShaderRegistry;
+typedef boost::shared_ptr<ShaderRegistry> ShaderRegistryPtr;
+
+class AVG_API GLContext {
+public:
+ GLContext(bool bUseCurrent=false,
+ const GLConfig& GLConfig=GLConfig(false, true, true, 1),
+ GLContext* pSharedContext=0);
+ virtual ~GLContext();
+ void init();
+
+ void activate();
+ ShaderRegistryPtr getShaderRegistry() const;
+
+ virtual void pushTransform(const DPoint& translate, double angle,
+ const DPoint& pivot);
+ virtual void popTransform();
+
+ // GL Object caching.
+ GLBufferCache& getVertexBufferCache();
+ GLBufferCache& getIndexBufferCache();
+ GLBufferCache& getPBOCache();
+ unsigned genFBO();
+ void returnFBOToCache(unsigned fboID);
+
+ // GL state cache.
+ void enableTexture(bool bEnable);
+ void enableGLColorArray(bool bEnable);
+ enum BlendMode {BLEND_BLEND, BLEND_ADD, BLEND_MIN, BLEND_MAX, BLEND_COPY};
+ void setBlendMode(BlendMode mode, bool bPremultipliedAlpha = false);
+
+ const GLConfig& getConfig();
+ void logConfig();
+ int getMaxTexSize();
+ bool usePOTTextures();
+ OGLMemoryMode getMemoryModeSupported();
+ bool isUsingShaders() const;
+
+ static BlendMode stringToBlendMode(const std::string& s);
+
+ static GLContext* getCurrent();
+
+private:
+ void checkShaderSupport();
+
+#ifdef __APPLE__
+ CGLContextObj m_Context;
+#elif defined linux
+ Display* m_pDisplay;
+ GLXDrawable m_Drawable;
+ GLXContext m_Context;
+#elif defined _WIN32
+ HWND m_hwnd;
+ HDC m_hDC;
+ HGLRC m_Context;
+#endif
+
+ bool m_bOwnsContext;
+
+ ShaderRegistryPtr m_pShaderRegistry;
+
+ GLBufferCache m_VertexBufferCache;
+ GLBufferCache m_IndexBufferCache;
+ GLBufferCache m_PBOCache;
+ std::vector<unsigned int> m_FBOIDs;
+
+ int m_MaxTexSize;
+ GLConfig m_GLConfig;
+ bool m_bCheckedMemoryMode;
+ OGLMemoryMode m_MemoryMode;
+
+ // OpenGL state
+ bool m_bEnableTexture;
+ bool m_bEnableGLColorArray;
+ BlendMode m_BlendMode;
+ bool m_bPremultipliedAlpha;
+
+ static boost::thread_specific_ptr<GLContext*> s_pCurrentContext;
+
+};
+
+}
+#endif
+
+
diff --git a/src/graphics/GLTexture.cpp b/src/graphics/GLTexture.cpp
new file mode 100644
index 0000000..d1a998a
--- /dev/null
+++ b/src/graphics/GLTexture.cpp
@@ -0,0 +1,300 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GLTexture.h"
+
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+#include "../base/MathHelper.h"
+#include "../base/ObjectCounter.h"
+
+#include "GLContext.h"
+#include "TextureMover.h"
+
+#include <string.h>
+#include <iostream>
+
+namespace avg {
+
+using namespace std;
+
+GLTexture::GLTexture(const IntPoint& size, PixelFormat pf, bool bMipmap,
+ unsigned wrapSMode, unsigned wrapTMode, bool bForcePOT)
+ : m_Size(size),
+ m_pf(pf),
+ m_bMipmap(bMipmap),
+ m_bDeleteTex(true)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ m_bUsePOT = GLContext::getCurrent()->usePOTTextures() || bForcePOT;
+ if (m_bUsePOT) {
+ m_GLSize.x = nextpow2(m_Size.x);
+ m_GLSize.y = nextpow2(m_Size.y);
+ } else {
+ m_GLSize = m_Size;
+ }
+
+ int maxTexSize = GLContext::getCurrent()->getMaxTexSize();
+ if (m_Size.x > maxTexSize || m_Size.y > maxTexSize) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL, "Texture too large (" + toString(m_Size)
+ + "). Maximum supported by graphics card is "
+ + toString(maxTexSize));
+ }
+ if (getGLType(m_pf) == GL_FLOAT && !isFloatFormatSupported()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Float textures not supported by OpenGL configuration.");
+ }
+
+ glGenTextures(1, &m_TexID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GLTexture: glGenTextures()");
+ glBindTexture(GL_TEXTURE_2D, m_TexID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GLTexture: glBindTexture()");
+ if (bMipmap) {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
+ } else {
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ }
+ glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapSMode);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapTMode);
+ glTexImage2D(GL_TEXTURE_2D, 0, getGLInternalFormat(), m_GLSize.x, m_GLSize.y, 0,
+ getGLFormat(m_pf), getGLType(m_pf), 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GLTexture: glTexImage2D()");
+
+ if (m_bUsePOT) {
+ // Make sure the texture is transparent and black before loading stuff
+ // into it to avoid garbage at the borders.
+ int TexMemNeeded = m_GLSize.x*m_GLSize.y*getBytesPerPixel(m_pf);
+ char * pPixels = new char[TexMemNeeded];
+ memset(pPixels, 0, TexMemNeeded);
+ glTexImage2D(GL_TEXTURE_2D, 0, getGLInternalFormat(), m_GLSize.x,
+ m_GLSize.y, 0, getGLFormat(m_pf), getGLType(m_pf),
+ pPixels);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::createTexture: glTexImage2D()");
+ delete[] pPixels;
+ }
+}
+
+GLTexture::GLTexture(unsigned glTexID, const IntPoint& size, PixelFormat pf, bool bMipmap,
+ bool bDeleteTex)
+ : m_Size(size),
+ m_GLSize(size),
+ m_pf(pf),
+ m_bMipmap(bMipmap),
+ m_bDeleteTex(bDeleteTex),
+ m_bUsePOT(false),
+ m_TexID(glTexID)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+GLTexture::~GLTexture()
+{
+ if (m_bDeleteTex) {
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glDeleteTextures(1, &m_TexID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GLTexture: DeleteTextures()");
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GLTexture::activate(int textureUnit)
+{
+ glproc::ActiveTexture(textureUnit);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GLTexture::activate ActiveTexture()");
+ glBindTexture(GL_TEXTURE_2D, m_TexID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GLTexture::activate BindTexture()");
+}
+
+void GLTexture::generateMipmaps()
+{
+ if (m_bMipmap) {
+ activate();
+ glproc::GenerateMipmap(GL_TEXTURE_2D);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GLTexture::generateMipmaps()");
+ }
+}
+
+void GLTexture::setWrapMode(unsigned wrapSMode, unsigned wrapTMode)
+{
+ activate();
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrapSMode);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrapTMode);
+}
+
+void GLTexture::enableStreaming()
+{
+ m_pMover = TextureMover::create(m_Size, m_pf, GL_STREAM_DRAW);
+}
+
+BitmapPtr GLTexture::lockStreamingBmp()
+{
+ AVG_ASSERT(m_pMover);
+ return m_pMover->lock();
+}
+
+void GLTexture::unlockStreamingBmp(bool bUpdated)
+{
+ AVG_ASSERT(m_pMover);
+ m_pMover->unlock();
+ if (bUpdated) {
+ m_pMover->moveToTexture(*this);
+ }
+}
+
+void GLTexture::moveBmpToTexture(BitmapPtr pBmp)
+{
+ TextureMoverPtr pMover = TextureMover::create(m_Size, m_pf, GL_DYNAMIC_DRAW);
+ pMover->moveBmpToTexture(pBmp, *this);
+}
+
+BitmapPtr GLTexture::moveTextureToBmp()
+{
+ TextureMoverPtr pMover = TextureMover::create(m_GLSize, m_pf, GL_DYNAMIC_READ);
+ return pMover->moveTextureToBmp(*this);
+}
+
+const IntPoint& GLTexture::getSize() const
+{
+ return m_Size;
+}
+
+const IntPoint& GLTexture::getGLSize() const
+{
+ return m_GLSize;
+}
+
+PixelFormat GLTexture::getPF() const
+{
+ return m_pf;
+}
+
+unsigned GLTexture::getID() const
+{
+ return m_TexID;
+}
+
+IntPoint GLTexture::getMipmapSize(int level) const
+{
+ AVG_ASSERT(!m_bUsePOT);
+ IntPoint size = m_Size;
+ for (int i=0; i<level; ++i) {
+ size.x = max(1, size.x >> 1);
+ size.y = max(1, size.y >> 1);
+ }
+ return size;
+}
+
+bool GLTexture::isFloatFormatSupported()
+{
+ return queryOGLExtension("GL_ARB_texture_float");
+}
+
+int GLTexture::getGLFormat(PixelFormat pf)
+{
+ switch (pf) {
+ case I8:
+ case I32F:
+ return GL_LUMINANCE;
+ case A8:
+ return GL_ALPHA;
+ case R8G8B8A8:
+ case R8G8B8X8:
+ return GL_RGBA;
+ case B8G8R8A8:
+ case B8G8R8X8:
+ case R32G32B32A32F:
+ return GL_BGRA;
+ case B5G6R5:
+ return GL_RGB;
+ default:
+ AVG_ASSERT(false);
+ return 0;
+ }
+}
+
+int GLTexture::getGLType(PixelFormat pf)
+{
+ switch (pf) {
+ case I8:
+ case A8:
+ return GL_UNSIGNED_BYTE;
+ case R8G8B8A8:
+ case R8G8B8X8:
+ case B8G8R8A8:
+ case B8G8R8X8:
+#ifdef __APPLE__
+ return GL_UNSIGNED_INT_8_8_8_8_REV;
+#else
+ return GL_UNSIGNED_BYTE;
+#endif
+ case R32G32B32A32F:
+ case I32F:
+ return GL_FLOAT;
+ case B5G6R5:
+ return GL_UNSIGNED_SHORT_5_6_5;
+ default:
+ AVG_ASSERT(false);
+ return 0;
+ }
+}
+
+int GLTexture::getGLInternalFormat() const
+{
+ switch (m_pf) {
+ case I8:
+ return GL_LUMINANCE;
+ case I32F:
+ return GL_LUMINANCE32F_ARB;
+ case A8:
+ return GL_ALPHA;
+ case R8G8B8A8:
+ case R8G8B8X8:
+ case B8G8R8A8:
+ case B8G8R8X8:
+ return GL_RGBA;
+ case R32G32B32A32F:
+ return GL_RGBA32F_ARB;
+ case B5G6R5:
+ return GL_RGB;
+ default:
+ AVG_ASSERT(false);
+ return 0;
+ }
+}
+
+void GLTexture::setDirty()
+{
+ m_bIsDirty = true;
+}
+
+bool GLTexture::isDirty() const
+{
+ return m_bIsDirty;
+}
+
+void GLTexture::resetDirty()
+{
+ m_bIsDirty = false;
+}
+
+
+}
diff --git a/src/graphics/GLTexture.h b/src/graphics/GLTexture.h
new file mode 100644
index 0000000..084de7f
--- /dev/null
+++ b/src/graphics/GLTexture.h
@@ -0,0 +1,94 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GLTexture_H_
+#define _GLTexture_H_
+
+#include "../api.h"
+#include "Bitmap.h"
+#include "OGLHelper.h"
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class TextureMover;
+typedef boost::shared_ptr<TextureMover> TextureMoverPtr;
+
+class AVG_API GLTexture {
+
+public:
+ GLTexture(const IntPoint& size, PixelFormat pf, bool bMipmap=false,
+ unsigned wrapSMode=GL_CLAMP_TO_EDGE, unsigned wrapTMode=GL_CLAMP_TO_EDGE,
+ bool bForcePOT=false);
+ GLTexture(unsigned glTexID, const IntPoint& size, PixelFormat pf, bool bMipmap=false,
+ bool bDeleteTex=false);
+ virtual ~GLTexture();
+
+ void activate(int textureUnit=GL_TEXTURE0);
+ void generateMipmaps();
+ void setWrapMode(unsigned wrapSMode, unsigned wrapTMode);
+
+ void enableStreaming();
+ BitmapPtr lockStreamingBmp();
+ void unlockStreamingBmp(bool bUpdated);
+ void moveBmpToTexture(BitmapPtr pBmp);
+ BitmapPtr moveTextureToBmp();
+
+ const IntPoint& getSize() const;
+ const IntPoint& getGLSize() const;
+ PixelFormat getPF() const;
+ unsigned getID() const;
+
+ IntPoint getMipmapSize(int level) const;
+
+ static bool isFloatFormatSupported();
+ static int getGLFormat(PixelFormat pf);
+ static int getGLType(PixelFormat pf);
+ int getGLInternalFormat() const;
+
+ void setDirty();
+ bool isDirty() const;
+ void resetDirty();
+
+private:
+ IntPoint m_Size;
+ IntPoint m_GLSize;
+ PixelFormat m_pf;
+ bool m_bMipmap;
+ bool m_bDeleteTex;
+ bool m_bUsePOT;
+
+ unsigned m_TexID;
+ bool m_bIsDirty;
+ TextureMoverPtr m_pMover;
+};
+
+typedef boost::shared_ptr<GLTexture> GLTexturePtr;
+
+}
+
+#endif
+
+
+
diff --git a/src/graphics/GPUBandpassFilter.cpp b/src/graphics/GPUBandpassFilter.cpp
new file mode 100644
index 0000000..28c7884
--- /dev/null
+++ b/src/graphics/GPUBandpassFilter.cpp
@@ -0,0 +1,96 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUBandpassFilter.h"
+#include "Bitmap.h"
+#include "ShaderRegistry.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+
+#define SHADERID "BANDPASS"
+
+using namespace std;
+
+namespace avg {
+
+GPUBandpassFilter::GPUBandpassFilter(const IntPoint& size, PixelFormat pfSrc,
+ double min, double max, double postScale, bool bInvert, bool bStandalone)
+ : GPUFilter(pfSrc, B8G8R8A8, bStandalone),
+ m_PostScale(postScale),
+ m_bInvert(bInvert),
+ m_MinFilter(size, pfSrc, R32G32B32A32F, min, true, false),
+ m_MaxFilter(size, pfSrc, R32G32B32A32F, max, true, false)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ setDimensions(size);
+ initShader();
+}
+
+GPUBandpassFilter::~GPUBandpassFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUBandpassFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ m_MinFilter.apply(pSrcTex);
+ m_MaxFilter.apply(pSrcTex);
+
+ getFBO()->activate();
+ OGLShaderPtr pShader = getShader(SHADERID);
+ pShader->activate();
+ pShader->setUniformIntParam("minTex", 0);
+ pShader->setUniformIntParam("maxTex", 1);
+ pShader->setUniformFloatParam("postScale", float(m_PostScale));
+ pShader->setUniformIntParam("bInvert", m_bInvert);
+ m_MaxFilter.getDestTex()->activate(GL_TEXTURE1);
+ draw(m_MinFilter.getDestTex());
+
+ glproc::UseProgramObject(0);
+}
+
+void GPUBandpassFilter::initShader()
+{
+ string sProgram =
+ "uniform sampler2D minTex;\n"
+ "uniform sampler2D maxTex;\n"
+ "uniform float postScale;\n"
+ "uniform bool bInvert;\n"
+
+ "void main(void)\n"
+ "{\n"
+ " vec4 min = texture2D(minTex, gl_TexCoord[0].st);\n"
+ " vec4 max = texture2D(maxTex, gl_TexCoord[0].st);\n"
+ " gl_FragColor = vec4(0.502, 0.502, 0.502, 0)+(max-min)*postScale;\n"
+ " if (bInvert) {\n"
+ " gl_FragColor = vec4(1.004,1.004,1.004,1)-gl_FragColor;\n"
+ " }\n"
+ " gl_FragColor.a = 1.0;\n"
+ "}\n"
+ ;
+
+ getOrCreateShader(SHADERID, sProgram);
+}
+
+} // namespace
diff --git a/src/graphics/GPUBandpassFilter.h b/src/graphics/GPUBandpassFilter.h
new file mode 100644
index 0000000..ee3d10e
--- /dev/null
+++ b/src/graphics/GPUBandpassFilter.h
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPUBandpassFilter_H_
+#define _GPUBandpassFilter_H_
+
+#include "../api.h"
+#include "GPUFilter.h"
+#include "GPUBlurFilter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+class AVG_API GPUBandpassFilter: public GPUFilter
+{
+public:
+ GPUBandpassFilter(const IntPoint& size, PixelFormat pfSrc, double min, double max,
+ double postScale, bool bInvert, bool bStandalone=true);
+ virtual ~GPUBandpassFilter();
+
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+
+private:
+ static void initShader();
+
+ double m_PostScale;
+ bool m_bInvert;
+
+ GPUBlurFilter m_MinFilter;
+ GPUBlurFilter m_MaxFilter;
+};
+
+} // namespace
+#endif
+
diff --git a/src/graphics/GPUBlurFilter.cpp b/src/graphics/GPUBlurFilter.cpp
new file mode 100644
index 0000000..62c49b1
--- /dev/null
+++ b/src/graphics/GPUBlurFilter.cpp
@@ -0,0 +1,148 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUBlurFilter.h"
+#include "Bitmap.h"
+#include "ShaderRegistry.h"
+#include "ImagingProjection.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/MathHelper.h"
+#include "../base/Exception.h"
+
+#include <string.h>
+#include <iostream>
+
+#define SHADERID_HORIZ "HORIZBLUR"
+#define SHADERID_VERT "VERTBLUR"
+
+using namespace std;
+
+namespace avg {
+
+GPUBlurFilter::GPUBlurFilter(const IntPoint& size, PixelFormat pfSrc, PixelFormat pfDest,
+ double stdDev, bool bClipBorders, bool bStandalone)
+ : GPUFilter(pfSrc, pfDest, bStandalone, 2)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+
+ setDimensions(size, stdDev, bClipBorders);
+ initShaders();
+ m_bClipBorders = bClipBorders;
+ setStdDev(stdDev);
+}
+
+GPUBlurFilter::~GPUBlurFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUBlurFilter::setStdDev(double stdDev)
+{
+ m_StdDev = stdDev;
+ m_pGaussCurveTex = calcBlurKernelTex(m_StdDev);
+ setDimensions(getSrcSize(), stdDev, m_bClipBorders);
+ IntRect destRect2(IntPoint(0,0), getDestRect().size());
+ m_pProjection2 = ImagingProjectionPtr(new ImagingProjection(
+ getDestRect().size(), destRect2));
+}
+
+void GPUBlurFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ int kernelWidth = m_pGaussCurveTex->getSize().x;
+ glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ OGLShaderPtr pHShader = getShader(SHADERID_HORIZ);
+ pHShader->activate();
+ pHShader->setUniformFloatParam("width", float(kernelWidth));
+ pHShader->setUniformIntParam("radius", (kernelWidth-1)/2);
+ pHShader->setUniformIntParam("texture", 0);
+ pHShader->setUniformIntParam("kernelTex", 1);
+ m_pGaussCurveTex->activate(GL_TEXTURE1);
+ draw(pSrcTex);
+
+ m_pProjection2->activate();
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ OGLShaderPtr pVShader = getShader(SHADERID_VERT);
+ pVShader->activate();
+ pVShader->setUniformFloatParam("width", float(kernelWidth));
+ pVShader->setUniformIntParam("radius", (kernelWidth-1)/2);
+ pVShader->setUniformIntParam("texture", 0);
+ pVShader->setUniformIntParam("kernelTex", 1);
+ getDestTex(1)->activate(GL_TEXTURE0);
+ m_pProjection2->draw();
+ glproc::UseProgramObject(0);
+}
+
+void GPUBlurFilter::initShaders()
+{
+ string sProgramHead =
+ "uniform sampler2D texture;\n"
+ "uniform float width;\n"
+ "uniform int radius;\n"
+ "uniform sampler2D kernelTex;\n"
+ ;
+
+ string sHorizProgram = sProgramHead +
+ "void main(void)\n"
+ "{\n"
+ " vec4 sum = vec4(0,0,0,0);\n"
+ " float dx = dFdx(gl_TexCoord[0].x);\n"
+ " for (int i=-radius; i<=radius; ++i) {\n"
+ " vec4 tex = texture2D(texture, gl_TexCoord[0].st+vec2(float(i)*dx,0));\n"
+ " float coeff = \n"
+ " texture2D(kernelTex, vec2((float(i+radius)+0.5)/width,0)).r;\n"
+ " sum += tex*coeff;\n"
+ " }\n"
+ " gl_FragColor = sum;\n"
+ "}\n"
+ ;
+ getOrCreateShader(SHADERID_HORIZ, sHorizProgram);
+
+ string sVertProgram = sProgramHead +
+ "void main(void)\n"
+ "{\n"
+ " vec4 sum = vec4(0,0,0,0);\n"
+ " float dy = dFdy(gl_TexCoord[0].y);\n"
+ " for (int i=-radius; i<=radius; ++i) {\n"
+ " vec4 tex = texture2D(texture, gl_TexCoord[0].st+vec2(0,float(i)*dy));\n"
+ " float coeff = \n"
+ " texture2D(kernelTex, vec2((float(i+radius)+0.5)/width,0)).r;\n"
+ " sum += tex*coeff;\n"
+ " }\n"
+ " gl_FragColor = sum;\n"
+ "}\n"
+ ;
+ getOrCreateShader(SHADERID_VERT, sVertProgram);
+}
+
+void GPUBlurFilter::setDimensions(IntPoint size, double stdDev, bool bClipBorders)
+{
+
+ if (bClipBorders) {
+ GPUFilter::setDimensions(size);
+ } else {
+ int radius = getBlurKernelRadius(stdDev);
+ IntPoint offset(radius, radius);
+ GPUFilter::setDimensions(size, IntRect(-offset, size+offset), GL_CLAMP_TO_BORDER);
+ }
+}
+
+}
diff --git a/src/graphics/GPUBlurFilter.h b/src/graphics/GPUBlurFilter.h
new file mode 100644
index 0000000..090dada
--- /dev/null
+++ b/src/graphics/GPUBlurFilter.h
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPUBlurFilter_H_
+#define _GPUBlurFilter_H_
+
+#include "../api.h"
+#include "GPUFilter.h"
+#include "GLTexture.h"
+
+namespace avg {
+
+class AVG_API GPUBlurFilter: public GPUFilter
+{
+public:
+ GPUBlurFilter(const IntPoint& size, PixelFormat pfSrc, PixelFormat pfDest,
+ double stdDev, bool bClipBorders, bool bStandalone=true);
+ virtual ~GPUBlurFilter();
+
+ void setStdDev(double stdDev);
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+
+private:
+ void initShaders();
+ void setDimensions(IntPoint size, double stdDev, bool bClipBorders);
+
+ double m_StdDev;
+ bool m_bClipBorders;
+
+ GLTexturePtr m_pGaussCurveTex;
+ ImagingProjectionPtr m_pProjection2;
+};
+
+typedef boost::shared_ptr<GPUBlurFilter> GPUBlurFilterPtr;
+
+}
+#endif
+
diff --git a/src/graphics/GPUBrightnessFilter.cpp b/src/graphics/GPUBrightnessFilter.cpp
new file mode 100644
index 0000000..235bc25
--- /dev/null
+++ b/src/graphics/GPUBrightnessFilter.cpp
@@ -0,0 +1,80 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUBrightnessFilter.h"
+#include "Bitmap.h"
+#include "ShaderRegistry.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+
+#define SHADERID "BRIGHTNESS"
+
+using namespace std;
+
+namespace avg {
+
+GPUBrightnessFilter::GPUBrightnessFilter(const IntPoint& size, PixelFormat pf,
+ double alpha, bool bStandalone)
+ : GPUFilter(pf, B8G8R8A8, bStandalone),
+ m_Alpha(alpha)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ setDimensions(size);
+ initShader();
+}
+
+GPUBrightnessFilter::~GPUBrightnessFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUBrightnessFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ OGLShaderPtr pShader = getShader(SHADERID);
+ pShader->activate();
+ pShader->setUniformIntParam("Texture", 0);
+ pShader->setUniformFloatParam("alpha", GLfloat(m_Alpha));
+ draw(pSrcTex);
+
+ glproc::UseProgramObject(0);
+}
+
+void GPUBrightnessFilter::initShader()
+{
+ string sProgram =
+ "uniform float alpha;\n"
+ "uniform sampler2D Texture;\n"
+
+ "void main(void)\n"
+ "{\n"
+ " vec4 tex =texture2D(Texture, gl_TexCoord[0].st);\n"
+ " gl_FragColor.rgb = tex.rgb*alpha;\n"
+ " gl_FragColor.a = tex.a;\n"
+ "}\n"
+ ;
+
+ getOrCreateShader(SHADERID, sProgram);
+}
+
+} // namespace
diff --git a/src/graphics/GPUBrightnessFilter.h b/src/graphics/GPUBrightnessFilter.h
new file mode 100644
index 0000000..66d0643
--- /dev/null
+++ b/src/graphics/GPUBrightnessFilter.h
@@ -0,0 +1,48 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPUBrightnessFilter_H_
+#define _GPUBrightnessFilter_H_
+
+#include "../api.h"
+#include "GPUFilter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+class AVG_API GPUBrightnessFilter: public GPUFilter
+{
+public:
+ GPUBrightnessFilter(const IntPoint& size, PixelFormat pf, double alpha,
+ bool bStandalone=true);
+ virtual ~GPUBrightnessFilter();
+
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+
+private:
+ static void initShader();
+
+ double m_Alpha;
+};
+
+} // namespace
+#endif
+
diff --git a/src/graphics/GPUChromaKeyFilter.cpp b/src/graphics/GPUChromaKeyFilter.cpp
new file mode 100644
index 0000000..868763c
--- /dev/null
+++ b/src/graphics/GPUChromaKeyFilter.cpp
@@ -0,0 +1,253 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUChromaKeyFilter.h"
+#include "Bitmap.h"
+#include "ShaderRegistry.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+
+#define SHADERID_CHROMAKEY "CHROMAKEY"
+#define SHADERID_EROSION "CHROMAKEY_EROSION"
+
+using namespace std;
+
+namespace avg {
+
+GPUChromaKeyFilter::GPUChromaKeyFilter(const IntPoint& size, PixelFormat pf,
+ bool bStandalone)
+ : GPUFilter(pf, B8G8R8A8, bStandalone, 2),
+ m_Color(0, 255, 0),
+ m_HTolerance(0.0),
+ m_STolerance(0.0),
+ m_LTolerance(0.0),
+ m_Softness(0.0),
+ m_Erosion(0),
+ m_SpillThreshold(0.0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+
+ setDimensions(size);
+ initShader();
+}
+
+GPUChromaKeyFilter::~GPUChromaKeyFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUChromaKeyFilter::setParams(const Pixel32& color, double hTolerance,
+ double sTolerance, double lTolerance, double softness, int erosion,
+ double spillThreshold)
+{
+ m_Color = color;
+ m_HTolerance = hTolerance;
+ m_STolerance = sTolerance;
+ m_LTolerance = lTolerance;
+ m_Softness = softness;
+ m_Erosion = erosion;
+ m_SpillThreshold = spillThreshold;
+ if (m_SpillThreshold <= m_HTolerance) {
+ m_SpillThreshold = m_HTolerance;
+ }
+}
+
+void GPUChromaKeyFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ // Set up double-buffering
+ int curBufferIndex = m_Erosion%2;
+ OGLShaderPtr pShader = getShader(SHADERID_CHROMAKEY);
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT+curBufferIndex);
+ pShader->activate();
+ pShader->setUniformIntParam("texture", 0);
+
+ double h, s, l;
+ m_Color.toHSL(h, s, l);
+ pShader->setUniformFloatParam("hKey", h);
+ pShader->setUniformFloatParam("hTolerance", m_HTolerance*360);
+ pShader->setUniformFloatParam("hSoftTolerance", (m_HTolerance+m_Softness)*360.0);
+ pShader->setUniformFloatParam("sKey", s);
+ pShader->setUniformFloatParam("sTolerance", m_STolerance);
+ pShader->setUniformFloatParam("sSoftTolerance", m_STolerance+m_Softness);
+ pShader->setUniformFloatParam("lKey", l);
+ pShader->setUniformFloatParam("lTolerance", m_LTolerance);
+ pShader->setUniformFloatParam("lSoftTolerance", m_LTolerance+m_Softness);
+ pShader->setUniformFloatParam("spillThreshold", m_SpillThreshold*360);
+ pShader->setUniformIntParam("bIsLast", int(m_Erosion==0));
+ draw(pSrcTex);
+
+ for (int i = 0; i < m_Erosion; ++i) {
+ curBufferIndex = (curBufferIndex+1)%2;
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT+curBufferIndex);
+ pShader = getShader(SHADERID_EROSION);
+ pShader->activate();
+ pShader->setUniformIntParam("texture", 0);
+ pShader->setUniformIntParam("bIsLast", int(i==m_Erosion-1));
+ draw(getDestTex((curBufferIndex+1)%2));
+ }
+ glproc::UseProgramObject(0);
+}
+
+void GPUChromaKeyFilter::initShader()
+{
+
+ string sProgramHead =
+ "uniform float alpha;\n"
+ "uniform sampler2D texture;\n"
+ "uniform float hKey;\n"
+ "uniform float hTolerance;\n"
+ "uniform float hSoftTolerance;\n"
+ "uniform float sTolerance;\n"
+ "uniform float sSoftTolerance;\n"
+ "uniform float sKey;\n"
+ "uniform float lTolerance;\n"
+ "uniform float lSoftTolerance;\n"
+ "uniform float spillThreshold;\n"
+ "uniform float lKey;\n"
+ "uniform bool bIsLast;\n"
+ + getStdShaderCode()
+ ;
+
+ string sProgram = sProgramHead +
+ "vec4 alphaMin(vec4 v1, vec4 v2)\n"
+ "{\n"
+ " if (v1.a < v2.a) {\n"
+ " return v1;\n"
+ " } else {\n"
+ " return v2;\n"
+ " }\n"
+ "}\n"
+
+ "vec4 alphaMax(vec4 v1, vec4 v2)\n"
+ "{\n"
+ " if (v1.a < v2.a) {\n"
+ " return v2;\n"
+ " } else {\n"
+ " return v1;\n"
+ " }\n"
+ "}\n"
+
+ "#define s2(a, b) temp = a; a = alphaMin(a, b); b = alphaMax(temp, b);\n"
+ "#define mn3(a, b, c) s2(a, b); s2(a, c);\n"
+ "#define mx3(a, b, c) s2(b, c); s2(a, c);\n"
+
+ "#define mnmx3(a, b, c) mx3(a, b, c); s2(a, b);\n"
+ "#define mnmx4(a, b, c, d) s2(a, b); s2(c, d); s2(a, c); s2(b, d); \n"
+
+ "// Based on McGuire, A fast, small-radius GPU median filter, in ShaderX6,\n"
+ "// February 2008. http://graphics.cs.williams.edu/papers/MedianShaderX6/ \n"
+ "vec4 getMedian(vec2 texCoord)\n"
+ "{\n"
+ " vec4 v[5];\n"
+ " float dx = dFdx(texCoord.x);\n"
+ " float dy = dFdy(texCoord.y);\n"
+ " v[0] = texture2D(texture, texCoord);\n"
+ " v[1] = texture2D(texture, texCoord+vec2(0,-dy));\n"
+ " v[2] = texture2D(texture, texCoord+vec2(0,dy));\n"
+ " v[3] = texture2D(texture, texCoord+vec2(-dx,0));\n"
+ " v[4] = texture2D(texture, texCoord+vec2(dx,0));\n"
+ " for (int i = 0; i < 5; ++i) {\n"
+ " v[i].a = (v[i].r+v[i].g+v[i].b)/3.0;\n"
+ " }\n"
+
+ " vec4 temp;\n"
+ " mnmx4(v[0], v[1], v[2], v[3]);\n"
+ " mnmx3(v[1], v[2], v[4]);\n"
+ " return v[2];\n"
+ "}\n"
+
+ "void main(void)\n"
+ "{\n"
+ " vec4 tex = getMedian(gl_TexCoord[0].st);\n"
+ " float h;\n"
+ " float s;\n"
+ " float l;\n"
+ " float alpha;\n"
+ " rgb2hsl(tex, h, s, l);\n"
+ " float hDiff = abs(h-hKey);\n"
+ " float sDiff = abs(s-sKey);\n"
+ " float lDiff = abs(l-lKey);\n"
+ " if (hDiff < hSoftTolerance && sDiff < sSoftTolerance \n"
+ " && lDiff < lSoftTolerance)\n"
+ " {\n"
+ " alpha = 0.0;\n"
+ " if (hDiff > hTolerance) {\n"
+ " alpha = (hDiff-hTolerance)/(hSoftTolerance-hTolerance);\n"
+ " }\n"
+ " if (sDiff > sTolerance) {\n"
+ " alpha = max(alpha,\n"
+ " (sDiff-sTolerance)/(sSoftTolerance-sTolerance));\n"
+ " }\n"
+ " if (lDiff > lTolerance) {\n"
+ " alpha = max(alpha,\n"
+ " (lDiff-lTolerance)/(lSoftTolerance-lTolerance));\n"
+ " }\n"
+ " } else {\n"
+ " alpha = 1.0;\n"
+ " }\n"
+ " if (alpha > 0.0 && hDiff < spillThreshold) {\n"
+ " if (spillThreshold > hTolerance) {\n"
+ " float factor = max(0.0, 1.0-(spillThreshold-hDiff)\n"
+ " /(spillThreshold-hTolerance));\n"
+ " s = s*factor;\n"
+ " }\n"
+ " tex.rgb = hsl2rgb(h, s, l);\n"
+ " }\n"
+ " if (bIsLast) {\n"
+ " gl_FragColor = vec4(tex.rgb*alpha, alpha);\n"
+ " } else {\n"
+ " gl_FragColor = vec4(tex.rgb, alpha);\n"
+ " }\n"
+ "}\n"
+ ;
+ getOrCreateShader(SHADERID_CHROMAKEY, sProgram);
+
+ string sErosionProgram =
+ "uniform sampler2D texture;\n"
+ "uniform bool bIsLast;\n"
+
+ "void main(void)\n"
+ "{\n"
+ " float minAlpha = 1.0;\n"
+ " float dx = dFdx(gl_TexCoord[0].x);\n"
+ " float dy = dFdy(gl_TexCoord[0].y);\n"
+ " for (float y = -1.0; y <= 1.0; ++y) {\n"
+ " for (float x = -1.0; x <= 1.0; ++x) {\n"
+ " float a = texture2D(texture, gl_TexCoord[0].st+vec2(x*dx,y*dy)).a;\n"
+ " minAlpha = min(minAlpha, a);\n"
+ " }\n"
+ " }\n"
+ " vec4 tex = texture2D(texture, gl_TexCoord[0].st);\n"
+ " if (bIsLast) {\n"
+ " gl_FragColor = vec4(tex.rgb*minAlpha, minAlpha);\n"
+ " } else {\n"
+ " gl_FragColor = vec4(tex.rgb, minAlpha);\n"
+ " }\n"
+ "}\n"
+ ;
+ getOrCreateShader(SHADERID_EROSION, sErosionProgram);
+
+}
+
+}
diff --git a/src/graphics/GPUChromaKeyFilter.h b/src/graphics/GPUChromaKeyFilter.h
new file mode 100644
index 0000000..5e734df
--- /dev/null
+++ b/src/graphics/GPUChromaKeyFilter.h
@@ -0,0 +1,58 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPUChromaKeyFilter_H_
+#define _GPUChromaKeyFilter_H_
+
+#include "../api.h"
+#include "GPUFilter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+class AVG_API GPUChromaKeyFilter: public GPUFilter
+{
+public:
+ GPUChromaKeyFilter(const IntPoint& size, PixelFormat pf, bool bStandalone=true);
+ virtual ~GPUChromaKeyFilter();
+
+ void setParams(const Pixel32& color, double hTolerance, double sTolerance,
+ double lTolerance, double softness, int erosion, double spillThreshold);
+
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+
+private:
+ void initShader();
+
+ Pixel32 m_Color;
+ double m_HTolerance;
+ double m_STolerance;
+ double m_LTolerance;
+ double m_Softness;
+ int m_Erosion;
+ double m_SpillThreshold;
+};
+
+typedef boost::shared_ptr<GPUChromaKeyFilter> GPUChromaKeyFilterPtr;
+
+}
+#endif
+
diff --git a/src/graphics/GPUFilter.cpp b/src/graphics/GPUFilter.cpp
new file mode 100644
index 0000000..4c31791
--- /dev/null
+++ b/src/graphics/GPUFilter.cpp
@@ -0,0 +1,318 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUFilter.h"
+#include "Bitmap.h"
+
+#include "VertexArray.h"
+#include "ImagingProjection.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+#include "../base/MathHelper.h"
+
+#include <iostream>
+#include <string.h>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+GPUFilter::GPUFilter(PixelFormat pfSrc, PixelFormat pfDest, bool bStandalone,
+ unsigned numTextures, bool bMipmap)
+ : m_PFSrc(pfSrc),
+ m_PFDest(pfDest),
+ m_bStandalone(bStandalone),
+ m_NumTextures(numTextures),
+ m_bMipmap(bMipmap),
+ m_SrcSize(0,0),
+ m_DestRect(0,0,0,0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+GPUFilter::~GPUFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUFilter::setDimensions(const IntPoint& srcSize)
+{
+ setDimensions(srcSize, IntRect(IntPoint(0,0), srcSize), GL_CLAMP_TO_EDGE);
+}
+
+void GPUFilter::setDimensions(const IntPoint& srcSize, const IntRect& destRect,
+ unsigned texMode)
+{
+ bool bProjectionChanged = false;
+ if (destRect != m_DestRect) {
+ m_pFBO = FBOPtr(new FBO(destRect.size(), m_PFDest, m_NumTextures, 1, false,
+ m_bMipmap));
+ m_DestRect = destRect;
+ bProjectionChanged = true;
+ }
+ if (m_bStandalone && srcSize != m_SrcSize) {
+ m_pSrcTex = GLTexturePtr(new GLTexture(srcSize, m_PFSrc, false, texMode,
+ texMode));
+ m_pSrcPBO = PBOPtr(new PBO(srcSize, m_PFSrc, GL_STREAM_DRAW));
+ bProjectionChanged = true;
+ }
+ m_SrcSize = srcSize;
+ if (bProjectionChanged) {
+ m_pProjection = ImagingProjectionPtr(new ImagingProjection(srcSize, destRect));
+ }
+}
+
+BitmapPtr GPUFilter::apply(BitmapPtr pBmpSource)
+{
+ AVG_ASSERT(m_pSrcTex);
+ AVG_ASSERT(m_pFBO);
+ m_pSrcPBO->moveBmpToTexture(pBmpSource, *m_pSrcTex);
+ apply(m_pSrcTex);
+ BitmapPtr pFilteredBmp = m_pFBO->getImage();
+ BitmapPtr pDestBmp;
+ if (pFilteredBmp->getPixelFormat() != pBmpSource->getPixelFormat()) {
+ pDestBmp = BitmapPtr(new Bitmap(m_DestRect.size(),
+ pBmpSource->getPixelFormat()));
+ pDestBmp->copyPixels(*pFilteredBmp);
+ } else {
+ pDestBmp = pFilteredBmp;
+ }
+ return pDestBmp;
+}
+
+void GPUFilter::apply(GLTexturePtr pSrcTex)
+{
+ m_pFBO->activate();
+ m_pProjection->activate();
+ applyOnGPU(pSrcTex);
+ m_pFBO->copyToDestTexture();
+}
+
+GLTexturePtr GPUFilter::getDestTex(int i) const
+{
+ return m_pFBO->getTex(i);
+}
+
+BitmapPtr GPUFilter::getImage() const
+{
+ return m_pFBO->getImage();
+}
+
+FBOPtr GPUFilter::getFBO()
+{
+ return m_pFBO;
+}
+
+const IntRect& GPUFilter::getDestRect() const
+{
+ return m_DestRect;
+}
+
+const IntPoint& GPUFilter::getSrcSize() const
+{
+ return m_SrcSize;
+}
+
+DRect GPUFilter::getRelDestRect() const
+{
+ DPoint srcSize(m_SrcSize);
+ return DRect(m_DestRect.tl.x/srcSize.x, m_DestRect.tl.y/srcSize.y,
+ m_DestRect.br.x/srcSize.x, m_DestRect.br.y/srcSize.y);
+}
+
+void GPUFilter::draw(GLTexturePtr pTex)
+{
+ pTex->activate(GL_TEXTURE0);
+ m_pProjection->draw();
+}
+
+const string& GPUFilter::getStdShaderCode() const
+{
+ static string sCode =
+ "void unPreMultiplyAlpha(inout vec4 color)\n"
+ "{\n"
+ " if (color.a > 0.0) {\n"
+ " color.rgb /= color.a;\n"
+ " }\n"
+ "}\n"
+ "\n"
+ "void preMultiplyAlpha(inout vec4 color)\n"
+ "{\n"
+ " color.rgb *= color.a;\n"
+ "}\n"
+ "\n"
+ "void rgb2hsl(vec4 rgba, out float h, out float s, out float l)\n"
+ "{\n"
+ " float maxComp = max(rgba.r, max(rgba.g, rgba.b));\n"
+ " float minComp = min(rgba.r, min(rgba.g, rgba.b));\n"
+ " l = (maxComp+minComp)/2.0;\n"
+ " if (maxComp == minComp) {\n"
+ " s = 0.0;\n"
+ " h = 0.0;\n"
+ " } else {\n"
+ " float delta = maxComp-minComp;\n"
+ " if (l < 0.5) {\n"
+ " s = delta/(maxComp+minComp);\n"
+ " } else {\n"
+ " s = delta/(2.0-(maxComp+minComp));\n"
+ " }\n"
+ " if (rgba.r == maxComp) {\n"
+ " h = (rgba.g-rgba.b)/delta;\n"
+ " if (h < 0.0) {\n"
+ " h += 6.0;\n"
+ " }\n"
+ " } else if (rgba.g == maxComp) {\n"
+ " h = 2.0+(rgba.b-rgba.r)/delta;\n"
+ " } else {\n"
+ " h = 4.0+(rgba.r-rgba.g)/delta;\n"
+ " }\n"
+ " h *= 60.0;\n"
+ " }\n"
+ "}\n"
+ "vec3 hsl2rgb(float h, float s, float l)\n"
+ "{\n"
+ " vec3 rgb = vec3(0.0, 0.0, 0.0);\n"
+ " float v;\n"
+ " if (l <= 0.5) {\n"
+ " v = l*(1.0+s);\n"
+ " } else {\n"
+ " v = l+s-l*s;\n"
+ " }\n"
+ " if (v > 0.0) {\n"
+ " float m = 2.0*l-v;\n"
+ " float sv = (v-m)/v;\n"
+ " h /= 60.0;\n"
+ " int sextant = int(h);\n"
+ " float fract = h-float(sextant);\n"
+ " float vsf = v * sv * fract;\n"
+ " float mid1 = m + vsf;\n"
+ " float mid2 = v - vsf;\n"
+ " if (sextant == 0) {\n"
+ " rgb.r = v;\n"
+ " rgb.g = mid1;\n"
+ " rgb.b = m;\n"
+ " } else if (sextant == 1) {\n"
+ " rgb.r = mid2;\n"
+ " rgb.g = v;\n"
+ " rgb.b = m;\n"
+ " } else if (sextant == 2) {\n"
+ " rgb.r = m;\n"
+ " rgb.g = v;\n"
+ " rgb.b = mid1;\n"
+ " } else if (sextant == 3) {\n"
+ " rgb.r = m;\n"
+ " rgb.g = mid2;\n"
+ " rgb.b = v;\n"
+ " } else if (sextant == 4) {\n"
+ " rgb.r = mid1;\n"
+ " rgb.g = m;\n"
+ " rgb.b = v;\n"
+ " } else if (sextant == 5) {\n"
+ " rgb.r = v;\n"
+ " rgb.g = m;\n"
+ " rgb.b = mid2;\n"
+ " }\n"
+ " }\n"
+ " return rgb;\n"
+ "}\n";
+
+ return sCode;
+}
+
+void dumpKernel(int width, float* pKernel)
+{
+ cerr << " Kernel width: " << width << endl;
+ float sum = 0;
+ for (int i = 0; i < width; ++i) {
+ sum += pKernel[i];
+ cerr << " " << pKernel[i] << endl;
+ }
+ cerr << "Sum of coefficients: " << sum << endl;
+}
+
+int GPUFilter::getBlurKernelRadius(double stdDev) const
+{
+ return int(ceil(stdDev*3));
+}
+
+GLTexturePtr GPUFilter::calcBlurKernelTex(double stdDev, double opacity) const
+{
+ AVG_ASSERT(opacity != -1);
+ int kernelWidth;
+ float* pKernel;
+ if (stdDev == 0) {
+ kernelWidth = 1;
+ pKernel = new float[1];
+ pKernel[0] = float(opacity);
+ } else {
+ float tempCoeffs[1024];
+ int i=0;
+ float coeff;
+ do {
+ coeff = float(exp(-i*i/(2*stdDev*stdDev))/sqrt(2*M_PI*stdDev*stdDev))
+ *float(opacity);
+ tempCoeffs[i] = coeff;
+ i++;
+ } while (coeff > 0.005 && i < 1024);
+ int kernelCenter = i - 2;
+ kernelWidth = kernelCenter*2+1;
+ pKernel = new float[kernelWidth];
+ float sum = 0;
+ for (int i = 0; i <= kernelCenter; ++i) {
+ pKernel[kernelCenter+i] = tempCoeffs[i];
+ sum += tempCoeffs[i];
+ if (i != 0) {
+ pKernel[kernelCenter-i] = tempCoeffs[i];
+ sum += tempCoeffs[i];
+ }
+ }
+ // Make sure the sum of coefficients is opacity despite the inaccuracies
+ // introduced by using a kernel of finite size.
+ for (int i = 0; i < kernelWidth; ++i) {
+ pKernel[i] *= float(opacity)/sum;
+ }
+ }
+// dumpKernel(kernelWidth, pKernel);
+
+ IntPoint size(kernelWidth, 1);
+ GLTexturePtr pTex(new GLTexture(size, R32G32B32A32F));
+ PBOPtr pFilterKernelPBO(new PBO(IntPoint(1024, 1), R32G32B32A32F, GL_STREAM_DRAW));
+ pFilterKernelPBO->activate();
+ void * pPBOPixels = glproc::MapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GPUFilter::calcBlurKernelTex MapBuffer()");
+ float * pCurFloat = (float*)pPBOPixels;
+ for (int i = 0; i < kernelWidth; ++i) {
+ for (int j = 0; j < 4; ++j) {
+ *pCurFloat = pKernel[i];
+ ++pCurFloat;
+ }
+ }
+ glproc::UnmapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GPUFilter::calcBlurKernelTex UnmapBuffer()");
+
+ pFilterKernelPBO->moveToTexture(*pTex);
+
+ delete[] pKernel;
+ return pTex;
+}
+
+}
diff --git a/src/graphics/GPUFilter.h b/src/graphics/GPUFilter.h
new file mode 100644
index 0000000..82d3f9c
--- /dev/null
+++ b/src/graphics/GPUFilter.h
@@ -0,0 +1,85 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPUFilter_H_
+#define _GPUFilter_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "VertexArray.h"
+#include "Bitmap.h"
+#include "PBO.h"
+#include "FBO.h"
+
+#include <boost/thread/tss.hpp>
+
+namespace avg {
+
+class ImagingProjection;
+typedef boost::shared_ptr<ImagingProjection> ImagingProjectionPtr;
+
+class AVG_API GPUFilter: public Filter
+{
+public:
+ GPUFilter(PixelFormat pfSrc, PixelFormat pfDest, bool bStandalone,
+ unsigned numTextures=1, bool bMipmap=false);
+ virtual ~GPUFilter();
+ void setDimensions(const IntPoint& srcSize);
+ void setDimensions(const IntPoint& srcSize, const IntRect& destRect,
+ unsigned texMode);
+
+ virtual BitmapPtr apply(BitmapPtr pBmpSource);
+ virtual void apply(GLTexturePtr pSrcTex);
+ virtual void applyOnGPU(GLTexturePtr pSrcTex) = 0;
+ GLTexturePtr getDestTex(int i=0) const;
+ BitmapPtr getImage() const;
+ FBOPtr getFBO();
+
+ const IntRect& getDestRect() const;
+ const IntPoint& getSrcSize() const;
+ DRect getRelDestRect() const;
+
+protected:
+ void draw(GLTexturePtr pTex);
+ const std::string& getStdShaderCode() const;
+ int getBlurKernelRadius(double stdDev) const;
+ GLTexturePtr calcBlurKernelTex(double stdDev, double opacity=1) const;
+
+private:
+ PixelFormat m_PFSrc;
+ PixelFormat m_PFDest;
+ bool m_bStandalone;
+ unsigned m_NumTextures;
+ bool m_bMipmap;
+
+ GLTexturePtr m_pSrcTex;
+ PBOPtr m_pSrcPBO;
+ FBOPtr m_pFBO;
+ IntPoint m_SrcSize;
+ IntRect m_DestRect;
+ ImagingProjectionPtr m_pProjection;
+};
+
+typedef boost::shared_ptr<GPUFilter> GPUFilterPtr;
+
+} // namespace
+#endif
+
diff --git a/src/graphics/GPUHueSatFilter.cpp b/src/graphics/GPUHueSatFilter.cpp
new file mode 100644
index 0000000..b58b4db
--- /dev/null
+++ b/src/graphics/GPUHueSatFilter.cpp
@@ -0,0 +1,124 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUHueSatFilter.h"
+#include "ShaderRegistry.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Logger.h"
+
+#define SHADERID_HSL_COLOR "HSL_COLOR"
+
+using namespace std;
+
+namespace avg {
+
+GPUHueSatFilter::GPUHueSatFilter(const IntPoint& size, PixelFormat pf,
+ bool bStandalone) :
+ GPUFilter(pf, B8G8R8A8, bStandalone, 2),
+ m_LightnessOffset(0.0),
+ m_Hue(0.0),
+ m_Saturation(0.0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ setDimensions(size);
+ initShader();
+}
+
+GPUHueSatFilter::~GPUHueSatFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUHueSatFilter::setParams(int hue, int saturation,
+ int light_add, bool colorize)
+{
+ m_Hue = float(hue);
+ m_Saturation = saturation / 100.0f;
+ m_LightnessOffset = light_add / 100.0f;
+ m_bColorize = colorize;
+}
+
+void GPUHueSatFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ OGLShaderPtr pShader = getShader(SHADERID_HSL_COLOR);
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ pShader->activate();
+ pShader->setUniformFloatParam("hue", m_Hue);
+ pShader->setUniformFloatParam("sat", m_Saturation);
+ pShader->setUniformFloatParam("l_offset", m_LightnessOffset);
+ pShader->setUniformIntParam("b_colorize", (int)m_bColorize);
+ pShader->setUniformIntParam("texture", 0);
+ draw(pSrcTex);
+ glproc::UseProgramObject(0);
+}
+
+void GPUHueSatFilter::initShader()
+{
+ string sProgramHead =
+ "const vec3 lumCoeff = vec3(0.2125, 0.7154, 0.0721);\n"
+ "const vec3 white = vec3(1.0, 1.0, 1.0);\n"
+ "const vec3 black = vec3(0.0, 0.0, 0.0);\n"
+ "uniform sampler2D texture;\n"
+ "uniform float hue;\n"
+ "uniform float sat;\n"
+ "uniform float l_offset;\n"
+ "uniform bool b_colorize;\n"
+ + getStdShaderCode()
+ ;
+ string sProgram = sProgramHead +
+ "void main(void)\n"
+ "{\n"
+ " float tmp;\n"
+ " float s;\n"
+ " float l;\n"
+ " float h;\n"
+ " vec4 tex = texture2D(texture, gl_TexCoord[0].st);\n"
+ " unPreMultiplyAlpha(tex);\n"
+ " rgb2hsl(tex, tmp, s, l);\n"
+ " if(b_colorize){\n"
+ " h = hue;\n"
+ " s = sat;\n"
+ " }\n"
+ " else{\n"
+ " h = hue+tmp;\n"
+ " }\n"
+ " vec4 rgbTex = vec4(hsl2rgb(mod(h, 360.0), s, l), tex.a);\n"
+ //Saturate in rgb - space to imitate photoshop filter
+ " if(!b_colorize){ \n"
+ " s = clamp(sat+s, 0.0, 2.0);\n"
+ " vec3 intensity = vec3(dot(rgbTex.rgb, lumCoeff));\n"
+ " rgbTex.rgb = mix(intensity, rgbTex.rgb, s);\n"
+ " }; \n"
+ //Brightness with black/white pixels to imitate photoshop lightness-offset
+ " if(l_offset >= 0.0){ \n"
+ " rgbTex = vec4(mix(rgbTex.rgb, white, l_offset), tex.a);\n"
+ " }\n"
+ " else if(l_offset < 0.0){ \n"
+ " rgbTex = vec4(mix(rgbTex.rgb, black, -l_offset), tex.a);\n"
+ " } \n"
+ " preMultiplyAlpha(rgbTex);\n"
+ " gl_FragColor = rgbTex;\n"
+ "}\n";
+ getOrCreateShader(SHADERID_HSL_COLOR, sProgram);
+}
+}//End namespace avg
+
diff --git a/src/graphics/GPUHueSatFilter.h b/src/graphics/GPUHueSatFilter.h
new file mode 100644
index 0000000..cc27c03
--- /dev/null
+++ b/src/graphics/GPUHueSatFilter.h
@@ -0,0 +1,54 @@
+//
+//// libavg - Media Playback Engine.
+//// Copyright (C) 2003-2011 Ulrich von Zadow
+////
+//// This library 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 of the License, or (at your option) any later version.
+////
+//// This library is distributed in the hope that it will be useful,
+//// but WITHOUT ANY WARRANTY; without even the implied warranty of
+//// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+//// Lesser General Public License for more details.
+////
+//// You should have received a copy of the GNU Lesser General Public
+//// License along with this library; if not, write to the Free Software
+//// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+////
+//// Current versions can be found at www.libavg.de
+////
+//
+
+#ifndef _GPUHueSatFilter_H_
+#define _GPUHueSatFilter_H_
+
+#include "../api.h"
+
+#include "GPUFilter.h"
+
+namespace avg {
+
+class AVG_API GPUHueSatFilter : public GPUFilter
+{
+public:
+ GPUHueSatFilter(const IntPoint& size, PixelFormat pf,
+ bool bStandalone=true);
+ virtual ~GPUHueSatFilter();
+
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+ void initShader();
+ void setParams(int hue, int saturation=1, int lightness_offset=0,
+ bool colorize=false);
+
+private:
+ float m_LightnessOffset;
+ float m_Hue;
+ float m_Saturation;
+ bool m_bColorize;
+};
+
+typedef boost::shared_ptr<GPUHueSatFilter> GPUHueSatFilterPtr;
+
+} //end namespace avg
+#endif
diff --git a/src/graphics/GPUInvertFilter.cpp b/src/graphics/GPUInvertFilter.cpp
new file mode 100644
index 0000000..ae6af1e
--- /dev/null
+++ b/src/graphics/GPUInvertFilter.cpp
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUInvertFilter.h"
+#include "ShaderRegistry.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Logger.h"
+
+#define SHADERID_INVERT_COLOR "INVERT_COLOR"
+
+using namespace std;
+
+namespace avg {
+
+GPUInvertFilter::GPUInvertFilter(const IntPoint& size, PixelFormat pf,
+ bool bStandalone) :
+ GPUFilter(pf, B8G8R8A8, bStandalone, 2)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ setDimensions(size);
+ initShader();
+}
+
+GPUInvertFilter::~GPUInvertFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUInvertFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ OGLShaderPtr pShader = getShader(SHADERID_INVERT_COLOR);
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ pShader->activate();
+ pShader->setUniformIntParam("texture", 0);
+ draw(pSrcTex);
+ glproc::UseProgramObject(0);
+}
+
+void GPUInvertFilter::initShader()
+{
+ string sProgramHead =
+ "uniform sampler2D texture;\n"
+ +getStdShaderCode()
+ ;
+ string sProgram = sProgramHead +
+ "void main(void)\n"
+ "{\n"
+ " float hue, s, l;\n"
+ " vec4 tex = texture2D(texture, gl_TexCoord[0].st);\n"
+ " unPreMultiplyAlpha(tex);\n"
+ " rgb2hsl(tex, hue, s, l);\n"
+ " vec4 result = vec4(hsl2rgb(hue, s, 1.0-l), tex.a);\n"
+ " preMultiplyAlpha(result);\n"
+ " gl_FragColor = result;\n"
+ "}\n";
+ getOrCreateShader(SHADERID_INVERT_COLOR, sProgram);
+}
+}//End namespace avg
+
diff --git a/src/graphics/GPUInvertFilter.h b/src/graphics/GPUInvertFilter.h
new file mode 100644
index 0000000..1997639
--- /dev/null
+++ b/src/graphics/GPUInvertFilter.h
@@ -0,0 +1,47 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+//
+
+#ifndef _GPUInvertFilter_H_
+#define _GPUInvertFilter_H_
+
+#include "../api.h"
+
+#include "GPUFilter.h"
+
+namespace avg {
+
+class AVG_API GPUInvertFilter : public GPUFilter
+{
+public:
+ GPUInvertFilter(const IntPoint& size, PixelFormat pf,
+ bool bStandalone=true);
+ virtual ~GPUInvertFilter();
+
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+ void initShader();
+
+};
+
+typedef boost::shared_ptr<GPUInvertFilter> GPUInvertFilterPtr;
+
+} //end namespace avg
+#endif
diff --git a/src/graphics/GPUNullFilter.cpp b/src/graphics/GPUNullFilter.cpp
new file mode 100644
index 0000000..1d7066d
--- /dev/null
+++ b/src/graphics/GPUNullFilter.cpp
@@ -0,0 +1,76 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUNullFilter.h"
+#include "Bitmap.h"
+#include "ShaderRegistry.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+
+#define SHADERID "NULL"
+
+using namespace std;
+
+namespace avg {
+
+GPUNullFilter::GPUNullFilter(const IntPoint& size, bool bStandalone)
+ : GPUFilter(B8G8R8A8, B8G8R8A8, bStandalone)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+
+ setDimensions(size);
+ initShader();
+}
+
+GPUNullFilter::~GPUNullFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUNullFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ OGLShaderPtr pShader = getShader(SHADERID);
+ pShader->activate();
+ pShader->setUniformIntParam("Texture", 0);
+ draw(pSrcTex);
+
+ glproc::UseProgramObject(0);
+}
+
+void GPUNullFilter::initShader()
+{
+ string sProgram =
+ "uniform sampler2D Texture;\n"
+
+ "void main(void)\n"
+ "{\n"
+ " vec4 tex = texture2D(Texture, gl_TexCoord[0].st);\n"
+ " gl_FragColor = tex;\n"
+ "}\n"
+ ;
+
+ getOrCreateShader(SHADERID, sProgram);
+}
+
+} // namespace
diff --git a/src/graphics/GPUNullFilter.h b/src/graphics/GPUNullFilter.h
new file mode 100644
index 0000000..27a6be1
--- /dev/null
+++ b/src/graphics/GPUNullFilter.h
@@ -0,0 +1,47 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPUNullFilter_H_
+#define _GPUNullFilter_H_
+
+#include "../api.h"
+#include "GPUFilter.h"
+#include "Bitmap.h"
+
+namespace avg {
+
+class AVG_API GPUNullFilter: public GPUFilter
+{
+public:
+ GPUNullFilter(const IntPoint& size, bool bStandalone=true);
+ virtual ~GPUNullFilter();
+
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+
+private:
+ void initShader();
+};
+
+typedef boost::shared_ptr<GPUNullFilter> GPUNullFilterPtr;
+
+}
+#endif
+
diff --git a/src/graphics/GPURGB2YUVFilter.cpp b/src/graphics/GPURGB2YUVFilter.cpp
new file mode 100644
index 0000000..2a2500a
--- /dev/null
+++ b/src/graphics/GPURGB2YUVFilter.cpp
@@ -0,0 +1,88 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPURGB2YUVFilter.h"
+#include "Bitmap.h"
+#include "ShaderRegistry.h"
+#include "ImagingProjection.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/MathHelper.h"
+#include "../base/Exception.h"
+
+#include <string.h>
+#include <iostream>
+
+#define SHADERID "RGB2YUV"
+
+using namespace std;
+
+namespace avg {
+
+GPURGB2YUVFilter::GPURGB2YUVFilter(const IntPoint& size)
+ : GPUFilter(B8G8R8X8, B8G8R8X8, false)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+
+ setDimensions(size);
+ initShader();
+}
+
+GPURGB2YUVFilter::~GPURGB2YUVFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPURGB2YUVFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ OGLShaderPtr pShader = getShader(SHADERID);
+ pShader->activate();
+ draw(pSrcTex);
+ glproc::UseProgramObject(0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "GPURGB2YUVFilter::applyOnGPU()");
+}
+
+BitmapPtr GPURGB2YUVFilter::getResults()
+{
+ BitmapPtr pBmp = getFBO()->getImage();
+
+ return pBmp;
+}
+
+void GPURGB2YUVFilter::initShader()
+{
+ // Uses jpeg coefficients.
+ string sProgram =
+ "uniform sampler2D texture;\n"
+ "\n"
+ "void main(void)\n"
+ "{\n"
+ " vec4 tex = texture2D(texture, gl_TexCoord[0].st);\n"
+ " float y = 0.299*tex.r + 0.587*tex.g + 0.114*tex.b;\n"
+ " float u = -0.168*tex.r - 0.330*tex.g + 0.498*tex.b + 0.5;\n"
+ " float v = 0.498*tex.r - 0.417*tex.g - 0.081*tex.b + 0.5;\n"
+ " gl_FragColor = vec4(v,u,y,1);\n"
+ "}\n"
+ ;
+ getOrCreateShader(SHADERID, sProgram);
+}
+
+}
diff --git a/src/graphics/GPURGB2YUVFilter.h b/src/graphics/GPURGB2YUVFilter.h
new file mode 100644
index 0000000..9dc9957
--- /dev/null
+++ b/src/graphics/GPURGB2YUVFilter.h
@@ -0,0 +1,49 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPURGB2YUVFilter_H_
+#define _GPURGB2YUVFilter_H_
+
+#include "../api.h"
+#include "GPUFilter.h"
+#include "GLTexture.h"
+
+namespace avg {
+
+class AVG_API GPURGB2YUVFilter: public GPUFilter
+{
+public:
+ GPURGB2YUVFilter(const IntPoint& size);
+ virtual ~GPURGB2YUVFilter();
+
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+
+ BitmapPtr getResults();
+
+private:
+ void initShader();
+};
+
+typedef boost::shared_ptr<GPURGB2YUVFilter> GPURGB2YUVFilterPtr;
+
+}
+#endif
+
diff --git a/src/graphics/GPUShadowFilter.cpp b/src/graphics/GPUShadowFilter.cpp
new file mode 100644
index 0000000..a435e5f
--- /dev/null
+++ b/src/graphics/GPUShadowFilter.cpp
@@ -0,0 +1,174 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GPUShadowFilter.h"
+#include "Bitmap.h"
+#include "ShaderRegistry.h"
+#include "ImagingProjection.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/MathHelper.h"
+#include "../base/Exception.h"
+
+#include <string.h>
+#include <iostream>
+
+#define SHADERID_HORIZ "HORIZBLUR"
+#define SHADERID_VERT "VERTBLUR"
+
+using namespace std;
+
+namespace avg {
+
+GPUShadowFilter::GPUShadowFilter(const IntPoint& size, const DPoint& offset,
+ double stdDev, double opacity, const Pixel32& color)
+ : GPUFilter(B8G8R8A8, B8G8R8A8, false, 2)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+
+ setDimensions(size, stdDev, offset);
+ initShaders();
+ setParams(offset, stdDev, opacity, color);
+}
+
+GPUShadowFilter::~GPUShadowFilter()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void GPUShadowFilter::setParams(const DPoint& offset, double stdDev, double opacity,
+ const Pixel32& color)
+{
+ m_Offset = offset;
+ m_StdDev = stdDev;
+ m_Opacity = opacity;
+ m_Color = color;
+ m_pGaussCurveTex = calcBlurKernelTex(m_StdDev, m_Opacity);
+ setDimensions(getSrcSize(), stdDev, offset);
+ IntRect destRect2(IntPoint(0,0), getDestRect().size());
+ m_pProjection2 = ImagingProjectionPtr(new ImagingProjection(
+ getDestRect().size(), destRect2));
+}
+
+void GPUShadowFilter::applyOnGPU(GLTexturePtr pSrcTex)
+{
+ int kernelWidth = m_pGaussCurveTex->getSize().x;
+ glDrawBuffer(GL_COLOR_ATTACHMENT1_EXT);
+ OGLShaderPtr pHShader = getShader(SHADERID_HORIZ);
+ pHShader->activate();
+ pHShader->setUniformFloatParam("width", float(kernelWidth));
+ pHShader->setUniformIntParam("radius", (kernelWidth-1)/2);
+ pHShader->setUniformIntParam("texture", 0);
+ pHShader->setUniformIntParam("kernelTex", 1);
+ IntPoint size = getSrcSize();
+ DPoint texOffset = DPoint(m_Offset.x/size.x, m_Offset.y/size.y);
+ pHShader->setUniformDPointParam("offset", texOffset);
+ m_pGaussCurveTex->activate(GL_TEXTURE1);
+ draw(pSrcTex);
+
+ m_pProjection2->activate();
+ glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);
+ OGLShaderPtr pVShader = getShader(SHADERID_VERT);
+ pVShader->activate();
+ pVShader->setUniformFloatParam("width", float(kernelWidth));
+ pVShader->setUniformIntParam("radius", (kernelWidth-1)/2);
+ pVShader->setUniformIntParam("hBlurTex", 0);
+ pVShader->setUniformIntParam("kernelTex", 1);
+ pVShader->setUniformColorParam("color", m_Color);
+
+ pSrcTex->activate(GL_TEXTURE2);
+ pVShader->setUniformIntParam("origTex", 2);
+ DRect destRect = getRelDestRect();
+ pVShader->setUniformDPointParam("destPos", destRect.tl);
+ pVShader->setUniformDPointParam("destSize", destRect.size());
+ getDestTex(1)->activate(GL_TEXTURE0);
+ m_pProjection2->draw();
+ glproc::UseProgramObject(0);
+}
+
+void GPUShadowFilter::initShaders()
+{
+ string sProgramHead =
+ "uniform float width;\n"
+ "uniform int radius;\n"
+ "uniform sampler2D kernelTex;\n"
+ + getStdShaderCode()
+ ;
+
+ string sHorizProgram = sProgramHead +
+ "uniform sampler2D texture;\n"
+ "uniform vec2 offset;\n"
+ "void main(void)\n"
+ "{\n"
+ " float sum = 0.;\n"
+ " float dx = dFdx(gl_TexCoord[0].x);\n"
+ " for (int i=-radius; i<=radius; ++i) {\n"
+ " float a = texture2D(texture,\n"
+ " gl_TexCoord[0].st-offset+vec2(float(i)*dx,0)).a;\n"
+ " float coeff = \n"
+ " texture2D(kernelTex, vec2((float(i+radius)+0.5)/width,0)).r;\n"
+ " sum += a*coeff;\n"
+ " }\n"
+ " gl_FragColor = vec4(sum, sum, sum, sum);\n"
+ "}\n"
+ ;
+ getOrCreateShader(SHADERID_HORIZ, sHorizProgram);
+
+ string sVertProgram = sProgramHead +
+ "uniform sampler2D hBlurTex;\n"
+ "uniform sampler2D origTex;\n"
+ "uniform float gamma;\n"
+ "uniform vec4 color;\n"
+ "uniform vec2 destPos;\n"
+ "uniform vec2 destSize;\n"
+ "void main(void)\n"
+ "{\n"
+ " float sum = 0.;\n"
+ " float dy = dFdy(gl_TexCoord[0].y);\n"
+ " for (int i=-radius; i<=radius; ++i) {\n"
+ " float a = texture2D(hBlurTex,\n"
+ " gl_TexCoord[0].st+vec2(0,float(i)*dy)).a;\n"
+ " float coeff = \n"
+ " texture2D(kernelTex, vec2((float(i+radius)+0.5)/width,0)).r;\n"
+ " sum += a*coeff;\n"
+ " }\n"
+ " sum = min(1., sum);\n"
+ " vec2 origCoord = gl_TexCoord[0].st;\n"
+ " origCoord = destPos + \n"
+ " vec2(origCoord.s*destSize.x, origCoord.t*destSize.y);\n"
+ " vec4 origCol = texture2D(origTex, origCoord);\n"
+ " gl_FragColor = origCol+(1.-origCol.a)*color*sum;\n"
+ "}\n"
+ ;
+ getOrCreateShader(SHADERID_VERT, sVertProgram);
+}
+
+void GPUShadowFilter::setDimensions(IntPoint size, double stdDev, const DPoint& offset)
+{
+ int radius = getBlurKernelRadius(stdDev);
+ IntPoint radiusOffset(radius, radius);
+ IntPoint intOffset(offset);
+ IntRect destRect(intOffset-radiusOffset, intOffset+size+radiusOffset+IntPoint(1,1));
+ destRect.expand(IntRect(IntPoint(0,0), size));
+ GPUFilter::setDimensions(size, destRect, GL_CLAMP_TO_BORDER);
+}
+
+}
diff --git a/src/graphics/GPUShadowFilter.h b/src/graphics/GPUShadowFilter.h
new file mode 100644
index 0000000..4ff3426
--- /dev/null
+++ b/src/graphics/GPUShadowFilter.h
@@ -0,0 +1,61 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _GPUShadowFilter_H_
+#define _GPUShadowFilter_H_
+
+#include "../api.h"
+#include "GPUFilter.h"
+#include "GLTexture.h"
+
+namespace avg {
+
+class AVG_API GPUShadowFilter: public GPUFilter
+{
+public:
+ GPUShadowFilter(const IntPoint& size, const DPoint& offset, double stdDev,
+ double opacity, const Pixel32& color);
+ virtual ~GPUShadowFilter();
+
+ void setParams(const DPoint& offset, double stdDev, double opacity,
+ const Pixel32& color);
+ virtual void applyOnGPU(GLTexturePtr pSrcTex);
+
+private:
+ void initShaders();
+ void dumpKernel();
+ void calcKernel();
+ void setDimensions(IntPoint size, double stdDev, const DPoint& offset);
+
+ DPoint m_Offset;
+ double m_StdDev;
+ double m_Opacity;
+ Pixel32 m_Color;
+
+ GLTexturePtr m_pGaussCurveTex;
+ ImagingProjectionPtr m_pProjection2;
+};
+
+typedef boost::shared_ptr<GPUShadowFilter> GPUShadowFilterPtr;
+
+} // namespace
+#endif
+
diff --git a/src/graphics/GraphicsTest.cpp b/src/graphics/GraphicsTest.cpp
new file mode 100644
index 0000000..03aead7
--- /dev/null
+++ b/src/graphics/GraphicsTest.cpp
@@ -0,0 +1,150 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GraphicsTest.h"
+#include "Bitmap.h"
+#include "Filterfliprgb.h"
+#include "Filtergrayscale.h"
+
+#include "../base/Directory.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <sstream>
+#include <math.h>
+
+namespace avg {
+
+using namespace avg;
+using namespace std;
+
+GraphicsTest::GraphicsTest(const string& sName, int indentLevel)
+ : Test(sName, indentLevel)
+{
+}
+
+void GraphicsTest::createResultImgDir()
+{
+ Directory dir("resultimages");
+ int ok = dir.open(true);
+ if (ok == 0) {
+ dir.empty();
+ } else {
+ stringstream s;
+ s << "Could not create result image dir '" << dir.getName() << "'.";
+ cerr << s.str() << endl;
+ throw Exception(AVG_ERR_VIDEO_GENERAL, s.str());
+ }
+}
+
+BitmapPtr GraphicsTest::loadTestBmp(const std::string& sFName, PixelFormat pf)
+{
+ try {
+ BitmapPtr pBmp(new Bitmap(getSrcDirName()+"testfiles/"+sFName+".png"));
+ if (pf == I8) {
+ return FilterGrayscale().apply(pBmp);
+ }
+ return pBmp;
+ } catch (Exception & ex) {
+ cerr << ex.getStr() << endl;
+ throw;
+ }
+}
+
+void GraphicsTest::testEqual(Bitmap& resultBmp, const string& sFName, PixelFormat pf,
+ double maxAverage, double maxStdDev)
+{
+ BitmapPtr pBaselineBmp;
+ try {
+ pBaselineBmp = BitmapPtr(new Bitmap(getSrcDirName()+"baseline/"+sFName+".png"));
+ switch (pf) {
+ case I8:
+ FilterGrayscale().applyInPlace(pBaselineBmp);
+ break;
+ default:
+ break;
+ }
+ } catch (Exception & ex) {
+ cerr << ex.getStr() << endl;
+ resultBmp.save("resultimages/"+sFName+".png");
+ throw;
+ }
+ testEqual(resultBmp, *pBaselineBmp, sFName, maxAverage, maxStdDev);
+}
+
+void GraphicsTest::testEqual(Bitmap& resultBmp, Bitmap& baselineBmp,
+ const string& sFName, double maxAverage, double maxStdDev)
+{
+ BitmapPtr pDiffBmp;
+ try {
+ pDiffBmp = resultBmp.subtract(baselineBmp);
+ } catch (Exception& e) {
+ TEST_FAILED("Error: " << e.getStr() << ". File: '" << sFName << "'.");
+ string sResultName = "resultimages/"+sFName;
+ resultBmp.save(sResultName+".png");
+ baselineBmp.save(sResultName+"_baseline.png");
+ }
+ if (pDiffBmp) {
+ double average = pDiffBmp->getAvg();
+ double stdDev = pDiffBmp->getStdDev();
+ if (average > maxAverage || stdDev > maxStdDev) {
+ TEST_FAILED("Error: Decoded image differs from baseline '" <<
+ sFName << "'. average=" << average << ", stdDev=" << stdDev);
+ // resultBmp.dump();
+ // baselineBmp.dump();
+ string sResultName = "resultimages/"+sFName;
+ resultBmp.save(sResultName+".png");
+ baselineBmp.save(sResultName+"_baseline.png");
+ BitmapPtr pDiffBmp = resultBmp.subtract(baselineBmp);
+ pDiffBmp->save(sResultName+"_diff.png");
+ }
+ }
+}
+
+void GraphicsTest::testEqualBrightness(Bitmap& resultBmp, Bitmap& baselineBmp,
+ double epsilon)
+{
+ double diff = fabs(resultBmp.getAvg()-baselineBmp.getAvg());
+ if (diff >= epsilon) {
+ TEST_FAILED("Error: Baseline brightness: " << baselineBmp.getAvg()
+ << ", Result brightness: " << resultBmp.getAvg() << ", difference: "
+ << diff);
+ }
+}
+
+int GraphicsTest::sumPixels(Bitmap& bmp)
+{
+ AVG_ASSERT(bmp.getBytesPerPixel() == 4);
+ int sum = 0;
+ IntPoint size = bmp.getSize();
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pLine = bmp.getPixels()+y*bmp.getStride();
+ for (int x = 0; x < size.x; x++) {
+ sum += pLine[x*4];
+ sum += pLine[x*4+1];
+ sum += pLine[x*4+2];
+ }
+ }
+ return sum;
+}
+
+};
+
diff --git a/src/graphics/GraphicsTest.h b/src/graphics/GraphicsTest.h
new file mode 100644
index 0000000..ad3bd9b
--- /dev/null
+++ b/src/graphics/GraphicsTest.h
@@ -0,0 +1,52 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "../api.h"
+#include "Bitmap.h"
+
+#include "../base/Test.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API GraphicsTest: public Test {
+public:
+ GraphicsTest(const std::string& sName, int indentLevel);
+
+ static void createResultImgDir();
+
+protected:
+ BitmapPtr loadTestBmp(const std::string& sFName, PixelFormat pf = NO_PIXELFORMAT);
+ virtual void testEqual(Bitmap& resultBmp, const std::string& sFName,
+ PixelFormat pf = NO_PIXELFORMAT, double maxAverage=0.01,
+ double maxStdDev=0.05);
+ virtual void testEqual(Bitmap& resultBmp, Bitmap& baselineBmp,
+ const std::string& sFName, double maxAverage=0.01, double maxStdDev=0.05);
+ void testEqualBrightness(Bitmap& resultBmp, Bitmap& baselineBmp, double epsilon);
+
+private:
+ int sumPixels(Bitmap& bmp);
+
+};
+
+
+}
diff --git a/src/graphics/HistoryPreProcessor.cpp b/src/graphics/HistoryPreProcessor.cpp
new file mode 100644
index 0000000..9c9f5eb
--- /dev/null
+++ b/src/graphics/HistoryPreProcessor.cpp
@@ -0,0 +1,157 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org.
+//
+
+#include "HistoryPreProcessor.h"
+
+#include "Bitmap.h"
+#include "Filterfill.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+#define FAST_HISTORY_SPEED 16
+
+namespace avg {
+
+HistoryPreProcessor::HistoryPreProcessor(IntPoint dimensions,
+ unsigned int updateInterval, bool bBrighter)
+ : m_FrameCounter(0),
+ m_UpdateInterval(updateInterval),
+ m_bBrighter(bBrighter)
+{
+ m_pHistoryBmp = BitmapPtr(new Bitmap(dimensions, I16));
+ reset();
+}
+
+HistoryPreProcessor::~HistoryPreProcessor()
+{
+}
+
+void HistoryPreProcessor::setInterval(unsigned int updateInterval)
+{
+ m_FrameCounter = 0;
+ m_UpdateInterval = updateInterval;
+}
+
+unsigned int HistoryPreProcessor::getInterval()
+{
+ return m_UpdateInterval;
+}
+
+void HistoryPreProcessor::reset()
+{
+ m_State = NO_IMAGE;
+}
+
+void HistoryPreProcessor::updateHistory(BitmapPtr pNewBmp)
+{
+ AVG_ASSERT(pNewBmp->getSize() == m_pHistoryBmp->getSize());
+ switch (m_State) {
+ case NO_IMAGE:
+ m_pHistoryBmp->copyPixels(*pNewBmp);
+ m_State = INITIALIZING;
+ m_NumInitImages = 0;
+ break;
+ case INITIALIZING:
+ calcAvg<FAST_HISTORY_SPEED>(pNewBmp);
+ m_NumInitImages++;
+ if (m_NumInitImages == FAST_HISTORY_SPEED*2) {
+ m_State = NORMAL;
+ }
+ break;
+ case NORMAL:
+ if (m_FrameCounter < m_UpdateInterval-1) {
+ m_FrameCounter++;
+ } else {
+ m_FrameCounter = 0;
+ calcAvg<256>(pNewBmp);
+ }
+ break;
+ }
+}
+
+void HistoryPreProcessor::applyInPlace(BitmapPtr pBmp)
+{
+ updateHistory(pBmp);
+ unsigned short * pSrc = (unsigned short*)m_pHistoryBmp->getPixels();
+ int srcStride = m_pHistoryBmp->getStride()/m_pHistoryBmp->getBytesPerPixel();
+ int destStride = pBmp->getStride();
+ unsigned char * pDest = pBmp->getPixels();
+ IntPoint size = pBmp->getSize();
+ for (int y = 0; y < size.y; y++) {
+ const unsigned short * pSrcPixel = pSrc;
+ unsigned char * pDestPixel = pDest;
+ if (m_bBrighter) {
+ for (int x = 0; x < size.x; x++) {
+ unsigned char Src = *pSrcPixel/256;
+ if ((*pDestPixel) > Src) {
+ *pDestPixel = *pDestPixel-Src;
+ } else {
+ *pDestPixel = 0;
+ }
+ pDestPixel++;
+ pSrcPixel++;
+ }
+ } else {
+ for (int x = 0; x < size.x; x++) {
+ unsigned char Src = *pSrcPixel/256;
+ if ((*pDestPixel) < Src) {
+ *pDestPixel = Src-*pDestPixel;
+ } else {
+ *pDestPixel = 0;
+ }
+ pDestPixel++;
+ pSrcPixel++;
+ }
+ }
+ pDest += destStride;
+ pSrc += srcStride;
+ }
+}
+
+// Fast pseudo-normalization with an integer factor.
+void HistoryPreProcessor::normalizeHistogram(BitmapPtr pBmp, unsigned char max)
+{
+ if (max < 128) {
+ max = 128;
+ }
+ int factor = int(256.0/max);
+ unsigned char * pLine = pBmp->getPixels();
+ IntPoint size = pBmp->getSize();
+ int stride = pBmp->getStride();
+ for (int y = 0; y < size.y; y++) {
+ unsigned char * pPixel = pLine;
+ for (int x = 0; x < size.x; x++) {
+ *pPixel *= factor;
+ pPixel++;
+ }
+ pLine += stride;
+ }
+}
+
+}
+
diff --git a/src/graphics/HistoryPreProcessor.h b/src/graphics/HistoryPreProcessor.h
new file mode 100644
index 0000000..e4984e1
--- /dev/null
+++ b/src/graphics/HistoryPreProcessor.h
@@ -0,0 +1,89 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org.
+//
+
+#ifndef _HistoryPreProcessor_H_
+#define _HistoryPreProcessor_H_
+
+#include "../api.h"
+#include "Filter.h"
+#include "Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API HistoryPreProcessor: public Filter
+{
+ public:
+ HistoryPreProcessor(IntPoint dimensions, unsigned int updateInterval,
+ bool bBrighter);
+ virtual ~HistoryPreProcessor();
+ virtual void applyInPlace(BitmapPtr pBmp);
+ void setInterval(unsigned int updateInterval);
+ unsigned int getInterval();
+ void reset();
+
+ private:
+ HistoryPreProcessor(const HistoryPreProcessor&) {};
+ void updateHistory(BitmapPtr pNewBmp);
+ void normalizeHistogram(BitmapPtr pBmp, unsigned char Max);
+ template<int SPEED> void calcAvg(BitmapPtr pNewBmp);
+
+ BitmapPtr m_pHistoryBmp;
+ unsigned int m_FrameCounter;
+ unsigned int m_UpdateInterval;
+ typedef enum {NO_IMAGE, INITIALIZING, NORMAL} State;
+ State m_State;
+ int m_NumInitImages;
+ bool m_bBrighter;
+};
+
+template<int SPEED>
+void HistoryPreProcessor::calcAvg(BitmapPtr pNewBmp)
+{
+ const int SRC_NUMERATOR = SPEED-1;
+ const int SRC_DENOMINATOR = SPEED;
+ const int DEST_FACTOR = 256/SPEED;
+ const unsigned char * pSrc = pNewBmp->getPixels();
+ unsigned short * pDest = (unsigned short*)(m_pHistoryBmp->getPixels());
+ int destStride = m_pHistoryBmp->getStride()/m_pHistoryBmp->getBytesPerPixel();
+ IntPoint size = m_pHistoryBmp->getSize();
+ for (int y = 0; y < size.y; y++) {
+ const unsigned char * pSrcPixel = pSrc;
+ unsigned short * pDestPixel = pDest;
+ for (int x = 0; x < size.x; x++) {
+ int t = SRC_NUMERATOR*int(*pDestPixel)/SRC_DENOMINATOR;
+ *pDestPixel = (t) + int(*pSrcPixel)*DEST_FACTOR;
+ pDestPixel++;
+ pSrcPixel++;
+ }
+ pDest += destStride;
+ pSrc += pNewBmp->getStride();
+ }
+
+}
+
+typedef boost::shared_ptr<HistoryPreProcessor> HistoryPreProcessorPtr;
+
+}
+#endif
diff --git a/src/graphics/ImagingProjection.cpp b/src/graphics/ImagingProjection.cpp
new file mode 100644
index 0000000..9aef8b2
--- /dev/null
+++ b/src/graphics/ImagingProjection.cpp
@@ -0,0 +1,85 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ImagingProjection.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+ImagingProjection::ImagingProjection(IntPoint size)
+ : m_pVA(new VertexArray)
+{
+ init(size, IntRect(IntPoint(0,0), size));
+}
+
+ImagingProjection::ImagingProjection(IntPoint srcSize, IntRect destRect)
+ : m_pVA(new VertexArray)
+{
+ init(srcSize, destRect);
+}
+
+ImagingProjection::~ImagingProjection()
+{
+}
+
+void ImagingProjection::activate()
+{
+ IntPoint destSize = m_DestRect.size();
+ glViewport(0, 0, destSize.x, destSize.y);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ gluOrtho2D(0, destSize.x, 0, destSize.y);
+
+ glMatrixMode(GL_MODELVIEW);
+ glLoadIdentity();
+ IntPoint offset = m_DestRect.tl;
+ glTranslated(-offset.x, -offset.y, 0);
+ glScaled(m_SrcSize.x, m_SrcSize.y, 1);
+
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "ImagingProjection::activate()");
+}
+
+void ImagingProjection::draw()
+{
+ m_pVA->draw();
+}
+
+void ImagingProjection::init(IntPoint srcSize, IntRect destRect)
+{
+ m_SrcSize = srcSize;
+ m_DestRect = destRect;
+ DRect dest = destRect;
+ DPoint p1 = DPoint(dest.tl.x/srcSize.x, dest.tl.y/srcSize.y);
+ DPoint p3 = DPoint(dest.br.x/srcSize.x, dest.br.y/srcSize.y);
+ DPoint p2 = DPoint(p1.x, p3.y);
+ DPoint p4 = DPoint(p3.x, p1.y);
+ m_pVA->reset();
+ m_pVA->appendPos(p1, p1);
+ m_pVA->appendPos(p2, p2);
+ m_pVA->appendPos(p3, p3);
+ m_pVA->appendPos(p4, p4);
+ m_pVA->appendQuadIndexes(1,0,2,3);
+}
+
+}
+
diff --git a/src/graphics/ImagingProjection.h b/src/graphics/ImagingProjection.h
new file mode 100644
index 0000000..79a186c
--- /dev/null
+++ b/src/graphics/ImagingProjection.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ImagingProjection_H_
+#define _ImagingProjection_H_
+
+#include "../api.h"
+
+#include "VertexArray.h"
+#include "../base/Point.h"
+#include "../base/Rect.h"
+
+namespace avg {
+
+class AVG_API ImagingProjection
+{
+public:
+ ImagingProjection(IntPoint size);
+ ImagingProjection(IntPoint srcSize, IntRect destRect);
+ virtual ~ImagingProjection();
+
+ void activate();
+ void draw();
+
+private:
+ void init(IntPoint srcSize, IntRect destRect);
+
+ IntPoint m_SrcSize;
+ IntRect m_DestRect;
+ IntPoint m_Offset;
+ VertexArrayPtr m_pVA;
+};
+
+typedef boost::shared_ptr<ImagingProjection> ImagingProjectionPtr;
+
+}
+
+
+#endif
+
+
diff --git a/src/graphics/Makefile.am b/src/graphics/Makefile.am
new file mode 100644
index 0000000..5432298
--- /dev/null
+++ b/src/graphics/Makefile.am
@@ -0,0 +1,64 @@
+INCLUDES = -I.. @GL_CFLAGS@ @PYTHON_INCLUDES@ @GDK_PIXBUF_CFLAGS@
+
+ALL_H = Bitmap.h Filter.h GLContext.h\
+ Pixel32.h Pixel24.h Pixel16.h Pixel8.h Pixeldefs.h PixelFormat.h \
+ Filtercolorize.h Filterfill.h Filterfillrect.h Filterflip.h FilterflipX.h \
+ Filterfliprgb.h Filterflipuv.h Filtergrayscale.h Filter3x3.h \
+ FilterId.h HistoryPreProcessor.h FilterConvol.h FilterHighpass.h \
+ FilterFastBandpass.h Filterfliprgba.h FilterFastDownscale.h \
+ FilterGauss.h FilterBandpass.h FilterBlur.h FilterMask.h \
+ OGLHelper.h OGLShader.h GL/gl.h GL/glext.h GL/glu.h GL/glx.h \
+ VertexArray.h OGLImagingContext.h GPUNullFilter.h GPUChromaKeyFilter.h \
+ GPUBrightnessFilter.h GPUBlurFilter.h GPUShadowFilter.h GraphicsTest.h\
+ GPUFilter.h GPUBandpassFilter.h GPUHueSatFilter.h GPUInvertFilter.h \
+ FilterIntensity.h FilterNormalize.h FilterFloodfill.h FilterDilation.h \
+ FilterErosion.h FilterGetAlpha.h FBO.h GLTexture.h PBO.h TextureMover.h\
+ ContribDefs.h TwoPassScale.h FilterResizeBilinear.h FilterThreshold.h \
+ FilterResizeGaussian.h FilterUnmultiplyAlpha.h ShaderRegistry.h \
+ ImagingProjection.h BitmapManager.h BitmapManagerThread.h \
+ BitmapManagerMsg.h GLBufferCache.h GLConfig.h BmpTextureMover.h \
+ GPURGB2YUVFilter.h
+ALL_CPP = Bitmap.cpp Filter.cpp Pixel32.cpp Filtergrayscale.cpp PixelFormat.cpp \
+ Filtercolorize.cpp Filterflip.cpp FilterflipX.cpp Filterfliprgb.cpp \
+ Filterflipuv.cpp Filter3x3.cpp HistoryPreProcessor.cpp FilterHighpass.cpp \
+ FilterFastBandpass.cpp Filterfliprgba.cpp FilterFastDownscale.cpp \
+ FilterGauss.cpp FilterBandpass.cpp FilterBlur.cpp FilterMask.cpp \
+ OGLHelper.cpp OGLShader.cpp GPUNullFilter.cpp GPUChromaKeyFilter.cpp \
+ GPUHueSatFilter.cpp GPUInvertFilter.cpp VertexArray.cpp OGLImagingContext.cpp \
+ GPUBrightnessFilter.cpp GPUBlurFilter.cpp GPUShadowFilter.cpp GraphicsTest.cpp \
+ GPUFilter.cpp GPUBandpassFilter.cpp FilterIntensity.cpp GLContext.cpp \
+ FilterNormalize.cpp FilterDilation.cpp FilterErosion.cpp \
+ FilterGetAlpha.cpp FBO.cpp GLTexture.cpp PBO.cpp TextureMover.cpp \
+ FilterResizeBilinear.cpp FilterResizeGaussian.cpp FilterThreshold.cpp \
+ FilterUnmultiplyAlpha.cpp ShaderRegistry.cpp \
+ ImagingProjection.cpp BitmapManager.cpp BitmapManagerThread.cpp \
+ BitmapManagerMsg.cpp GLBufferCache.cpp GLConfig.cpp BmpTextureMover.cpp \
+ GPURGB2YUVFilter.cpp
+
+if APPLE
+ X_LIBS =
+else
+ X_LIBS = -lX11
+endif
+
+TESTS=testgraphics testgpu
+
+EXTRA_DIST = $(wildcard baseline/*.png) $(wildcard testfiles/*.png)
+
+noinst_LTLIBRARIES = libgraphics.la
+libgraphics_la_SOURCES = $(ALL_CPP) $(ALL_H)
+noinst_PROGRAMS=testgraphics testgpu benchmarkgraphics
+testgraphics_SOURCES=testgraphics.cpp $(ALL_H)
+testgraphics_LDADD = ./libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ $(X_LIBS) @GDK_PIXBUF_LIBS@
+
+benchmarkgraphics_SOURCES=benchmarkgraphics.cpp $(ALL_H)
+benchmarkgraphics_LDADD = ./libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ @GDK_PIXBUF_LIBS@
+
+testgpu_SOURCES=testgpu.cpp $(ALL_H)
+testgpu_LDADD = ./libgraphics.la ../base/libbase.la -ldl \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ $(X_LIBS) \
+ @GL_LIBS@ @GLU_LIBS@ @SDL_LIBS@ \
+ @GDK_PIXBUF_LIBS@
+
diff --git a/src/graphics/Makefile.in b/src/graphics/Makefile.in
new file mode 100644
index 0000000..e3d238e
--- /dev/null
+++ b/src/graphics/Makefile.in
@@ -0,0 +1,839 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+TESTS = testgraphics$(EXEEXT) testgpu$(EXEEXT)
+noinst_PROGRAMS = testgraphics$(EXEEXT) testgpu$(EXEEXT) \
+ benchmarkgraphics$(EXEEXT)
+subdir = src/graphics
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libgraphics_la_LIBADD =
+am__objects_1 = Bitmap.lo Filter.lo Pixel32.lo Filtergrayscale.lo \
+ PixelFormat.lo Filtercolorize.lo Filterflip.lo FilterflipX.lo \
+ Filterfliprgb.lo Filterflipuv.lo Filter3x3.lo \
+ HistoryPreProcessor.lo FilterHighpass.lo FilterFastBandpass.lo \
+ Filterfliprgba.lo FilterFastDownscale.lo FilterGauss.lo \
+ FilterBandpass.lo FilterBlur.lo FilterMask.lo OGLHelper.lo \
+ OGLShader.lo GPUNullFilter.lo GPUChromaKeyFilter.lo \
+ GPUHueSatFilter.lo GPUInvertFilter.lo VertexArray.lo \
+ OGLImagingContext.lo GPUBrightnessFilter.lo GPUBlurFilter.lo \
+ GPUShadowFilter.lo GraphicsTest.lo GPUFilter.lo \
+ GPUBandpassFilter.lo FilterIntensity.lo GLContext.lo \
+ FilterNormalize.lo FilterDilation.lo FilterErosion.lo \
+ FilterGetAlpha.lo FBO.lo GLTexture.lo PBO.lo TextureMover.lo \
+ FilterResizeBilinear.lo FilterResizeGaussian.lo \
+ FilterThreshold.lo FilterUnmultiplyAlpha.lo ShaderRegistry.lo \
+ ImagingProjection.lo BitmapManager.lo BitmapManagerThread.lo \
+ BitmapManagerMsg.lo GLBufferCache.lo GLConfig.lo \
+ BmpTextureMover.lo GPURGB2YUVFilter.lo
+am__objects_2 =
+am_libgraphics_la_OBJECTS = $(am__objects_1) $(am__objects_2)
+libgraphics_la_OBJECTS = $(am_libgraphics_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+PROGRAMS = $(noinst_PROGRAMS)
+am_benchmarkgraphics_OBJECTS = benchmarkgraphics.$(OBJEXT) \
+ $(am__objects_2)
+benchmarkgraphics_OBJECTS = $(am_benchmarkgraphics_OBJECTS)
+benchmarkgraphics_DEPENDENCIES = ./libgraphics.la ../base/libbase.la
+am_testgpu_OBJECTS = testgpu.$(OBJEXT) $(am__objects_2)
+testgpu_OBJECTS = $(am_testgpu_OBJECTS)
+am__DEPENDENCIES_1 =
+testgpu_DEPENDENCIES = ./libgraphics.la ../base/libbase.la \
+ $(am__DEPENDENCIES_1)
+am_testgraphics_OBJECTS = testgraphics.$(OBJEXT) $(am__objects_2)
+testgraphics_OBJECTS = $(am_testgraphics_OBJECTS)
+testgraphics_DEPENDENCIES = ./libgraphics.la ../base/libbase.la \
+ $(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libgraphics_la_SOURCES) $(benchmarkgraphics_SOURCES) \
+ $(testgpu_SOURCES) $(testgraphics_SOURCES)
+DIST_SOURCES = $(libgraphics_la_SOURCES) $(benchmarkgraphics_SOURCES) \
+ $(testgpu_SOURCES) $(testgraphics_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.. @GL_CFLAGS@ @PYTHON_INCLUDES@ @GDK_PIXBUF_CFLAGS@
+ALL_H = Bitmap.h Filter.h GLContext.h\
+ Pixel32.h Pixel24.h Pixel16.h Pixel8.h Pixeldefs.h PixelFormat.h \
+ Filtercolorize.h Filterfill.h Filterfillrect.h Filterflip.h FilterflipX.h \
+ Filterfliprgb.h Filterflipuv.h Filtergrayscale.h Filter3x3.h \
+ FilterId.h HistoryPreProcessor.h FilterConvol.h FilterHighpass.h \
+ FilterFastBandpass.h Filterfliprgba.h FilterFastDownscale.h \
+ FilterGauss.h FilterBandpass.h FilterBlur.h FilterMask.h \
+ OGLHelper.h OGLShader.h GL/gl.h GL/glext.h GL/glu.h GL/glx.h \
+ VertexArray.h OGLImagingContext.h GPUNullFilter.h GPUChromaKeyFilter.h \
+ GPUBrightnessFilter.h GPUBlurFilter.h GPUShadowFilter.h GraphicsTest.h\
+ GPUFilter.h GPUBandpassFilter.h GPUHueSatFilter.h GPUInvertFilter.h \
+ FilterIntensity.h FilterNormalize.h FilterFloodfill.h FilterDilation.h \
+ FilterErosion.h FilterGetAlpha.h FBO.h GLTexture.h PBO.h TextureMover.h\
+ ContribDefs.h TwoPassScale.h FilterResizeBilinear.h FilterThreshold.h \
+ FilterResizeGaussian.h FilterUnmultiplyAlpha.h ShaderRegistry.h \
+ ImagingProjection.h BitmapManager.h BitmapManagerThread.h \
+ BitmapManagerMsg.h GLBufferCache.h GLConfig.h BmpTextureMover.h \
+ GPURGB2YUVFilter.h
+
+ALL_CPP = Bitmap.cpp Filter.cpp Pixel32.cpp Filtergrayscale.cpp PixelFormat.cpp \
+ Filtercolorize.cpp Filterflip.cpp FilterflipX.cpp Filterfliprgb.cpp \
+ Filterflipuv.cpp Filter3x3.cpp HistoryPreProcessor.cpp FilterHighpass.cpp \
+ FilterFastBandpass.cpp Filterfliprgba.cpp FilterFastDownscale.cpp \
+ FilterGauss.cpp FilterBandpass.cpp FilterBlur.cpp FilterMask.cpp \
+ OGLHelper.cpp OGLShader.cpp GPUNullFilter.cpp GPUChromaKeyFilter.cpp \
+ GPUHueSatFilter.cpp GPUInvertFilter.cpp VertexArray.cpp OGLImagingContext.cpp \
+ GPUBrightnessFilter.cpp GPUBlurFilter.cpp GPUShadowFilter.cpp GraphicsTest.cpp \
+ GPUFilter.cpp GPUBandpassFilter.cpp FilterIntensity.cpp GLContext.cpp \
+ FilterNormalize.cpp FilterDilation.cpp FilterErosion.cpp \
+ FilterGetAlpha.cpp FBO.cpp GLTexture.cpp PBO.cpp TextureMover.cpp \
+ FilterResizeBilinear.cpp FilterResizeGaussian.cpp FilterThreshold.cpp \
+ FilterUnmultiplyAlpha.cpp ShaderRegistry.cpp \
+ ImagingProjection.cpp BitmapManager.cpp BitmapManagerThread.cpp \
+ BitmapManagerMsg.cpp GLBufferCache.cpp GLConfig.cpp BmpTextureMover.cpp \
+ GPURGB2YUVFilter.cpp
+
+@APPLE_FALSE@X_LIBS = -lX11
+@APPLE_TRUE@X_LIBS =
+EXTRA_DIST = $(wildcard baseline/*.png) $(wildcard testfiles/*.png)
+noinst_LTLIBRARIES = libgraphics.la
+libgraphics_la_SOURCES = $(ALL_CPP) $(ALL_H)
+testgraphics_SOURCES = testgraphics.cpp $(ALL_H)
+testgraphics_LDADD = ./libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ $(X_LIBS) @GDK_PIXBUF_LIBS@
+
+benchmarkgraphics_SOURCES = benchmarkgraphics.cpp $(ALL_H)
+benchmarkgraphics_LDADD = ./libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @GDK_PIXBUF_LIBS@
+
+testgpu_SOURCES = testgpu.cpp $(ALL_H)
+testgpu_LDADD = ./libgraphics.la ../base/libbase.la -ldl \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ $(X_LIBS) \
+ @GL_LIBS@ @GLU_LIBS@ @SDL_LIBS@ \
+ @GDK_PIXBUF_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/graphics/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/graphics/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libgraphics.la: $(libgraphics_la_OBJECTS) $(libgraphics_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libgraphics_la_OBJECTS) $(libgraphics_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+benchmarkgraphics$(EXEEXT): $(benchmarkgraphics_OBJECTS) $(benchmarkgraphics_DEPENDENCIES)
+ @rm -f benchmarkgraphics$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(benchmarkgraphics_OBJECTS) $(benchmarkgraphics_LDADD) $(LIBS)
+testgpu$(EXEEXT): $(testgpu_OBJECTS) $(testgpu_DEPENDENCIES)
+ @rm -f testgpu$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(testgpu_OBJECTS) $(testgpu_LDADD) $(LIBS)
+testgraphics$(EXEEXT): $(testgraphics_OBJECTS) $(testgraphics_DEPENDENCIES)
+ @rm -f testgraphics$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(testgraphics_OBJECTS) $(testgraphics_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Bitmap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitmapManager.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitmapManagerMsg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BitmapManagerThread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BmpTextureMover.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FBO.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filter3x3.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterBandpass.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterBlur.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterDilation.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterErosion.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterFastBandpass.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterFastDownscale.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterGauss.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterGetAlpha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterHighpass.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterIntensity.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterMask.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterNormalize.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterResizeBilinear.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterResizeGaussian.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterThreshold.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterUnmultiplyAlpha.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filtercolorize.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filterflip.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterflipX.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filterfliprgb.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filterfliprgba.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filterflipuv.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Filtergrayscale.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GLBufferCache.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GLConfig.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GLContext.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GLTexture.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUBandpassFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUBlurFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUBrightnessFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUChromaKeyFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUHueSatFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUInvertFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUNullFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPURGB2YUVFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GPUShadowFilter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/GraphicsTest.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HistoryPreProcessor.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ImagingProjection.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OGLHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OGLImagingContext.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OGLShader.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PBO.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Pixel32.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PixelFormat.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ShaderRegistry.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TextureMover.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VertexArray.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/benchmarkgraphics.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testgpu.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testgraphics.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/graphics/OGLHelper.cpp b/src/graphics/OGLHelper.cpp
new file mode 100644
index 0000000..dad80f8
--- /dev/null
+++ b/src/graphics/OGLHelper.cpp
@@ -0,0 +1,477 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "OGLHelper.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+
+#ifndef _WIN32
+#include <dlfcn.h>
+#endif
+
+#include <cstdio>
+#include <iostream>
+#include <sstream>
+#include <cstring>
+#include <cstdlib>
+#include <assert.h>
+
+#if defined(__APPLE__)
+#include <OpenGL/OpenGL.h>
+#endif
+
+using namespace std;
+
+namespace avg {
+
+namespace glproc {
+ PFNGLGENBUFFERSPROC GenBuffers;
+ PFNGLBUFFERDATAPROC BufferData;
+ PFNGLBUFFERSUBDATAPROC BufferSubData;
+ PFNGLDELETEBUFFERSPROC DeleteBuffers;
+ PFNGLBINDBUFFERPROC BindBuffer;
+ PFNGLMAPBUFFERPROC MapBuffer;
+ PFNGLUNMAPBUFFERPROC UnmapBuffer;
+ PFNGLGETBUFFERSUBDATAPROC GetBufferSubData;
+
+ PFNGLCREATESHADEROBJECTARBPROC CreateShaderObject;
+ PFNGLSHADERSOURCEARBPROC ShaderSource;
+ PFNGLCOMPILESHADERARBPROC CompileShader;
+ PFNGLCREATEPROGRAMOBJECTARBPROC CreateProgramObject;
+ PFNGLATTACHOBJECTARBPROC AttachObject;
+ PFNGLLINKPROGRAMARBPROC LinkProgram;
+ PFNGLGETOBJECTPARAMETERIVARBPROC GetObjectParameteriv;
+ PFNGLGETINFOLOGARBPROC GetInfoLog;
+ PFNGLUSEPROGRAMOBJECTARBPROC UseProgramObject;
+ PFNGLGETUNIFORMLOCATIONARBPROC GetUniformLocation;
+ PFNGLUNIFORM1IARBPROC Uniform1i;
+ PFNGLUNIFORM1FARBPROC Uniform1f;
+ PFNGLUNIFORM2FARBPROC Uniform2f;
+ PFNGLUNIFORM3FARBPROC Uniform3f;
+ PFNGLUNIFORM4FARBPROC Uniform4f;
+ PFNGLUNIFORM1FVARBPROC Uniform1fv;
+ PFNGLUNIFORMMATRIX4FVARBPROC UniformMatrix4fv;
+
+ PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate;
+ PFNGLBLENDEQUATIONPROC BlendEquation;
+ PFNGLBLENDCOLORPROC BlendColor;
+ PFNGLACTIVETEXTUREPROC ActiveTexture;
+ PFNGLGENERATEMIPMAPEXTPROC GenerateMipmap;
+
+ PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC CheckFramebufferStatus;
+ PFNGLGENFRAMEBUFFERSEXTPROC GenFramebuffers;
+ PFNGLBINDFRAMEBUFFEREXTPROC BindFramebuffer;
+ PFNGLFRAMEBUFFERTEXTURE2DEXTPROC FramebufferTexture2D;
+ PFNGLDELETEFRAMEBUFFERSEXTPROC DeleteFramebuffers;
+ PFNGLGENRENDERBUFFERSEXTPROC GenRenderbuffers;
+ PFNGLBINDRENDERBUFFEREXTPROC BindRenderbuffer;
+ PFNGLRENDERBUFFERSTORAGEEXTPROC RenderbufferStorage;
+ PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC RenderbufferStorageMultisample;
+ PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC FramebufferRenderbuffer;
+ PFNGLBLITFRAMEBUFFEREXTPROC BlitFramebuffer;
+ PFNGLDELETERENDERBUFFERSEXTPROC DeleteRenderbuffers;
+ PFNGLDRAWBUFFERSPROC DrawBuffers;
+#ifdef linux
+ PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
+ PFNGLXWAITVIDEOSYNCSGIPROC WaitVideoSyncSGI;
+#endif
+#ifdef _WIN32
+ PFNWGLEXTSWAPCONTROLPROC SwapIntervalEXT;
+#endif
+
+ void * s_hGLLib = 0;
+}
+
+void OGLErrorCheck(int avgcode, const char* pszWhere)
+{
+ GLenum err = glGetError();
+ if (err != GL_NO_ERROR) {
+ stringstream s;
+ s << "OpenGL error in " << pszWhere <<": " << gluErrorString(err)
+ << " (#" << err << ") ";
+ AVG_TRACE(Logger::ERROR, s.str());
+ if (err != GL_INVALID_OPERATION) {
+ OGLErrorCheck(avgcode, " --");
+ }
+ AVG_ASSERT(false);
+ }
+}
+
+#ifdef _WIN32
+void winOGLErrorCheck(BOOL bOK, const string& sWhere)
+{
+ if (!bOK) {
+ char szErr[512];
+ FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM),
+ 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ szErr, 512, 0);
+ AVG_TRACE(Logger::ERROR, sWhere+":"+szErr);
+ AVG_ASSERT(false);
+ }
+}
+#endif
+
+bool queryOGLExtension(const char *extName)
+{
+ char *p;
+ size_t extNameLen = strlen(extName);
+
+ p = (char *)glGetString(GL_EXTENSIONS);
+ AVG_ASSERT(p != 0);
+
+ char * end = p + strlen(p);
+
+ while (p < end) {
+ size_t n = strcspn(p, " ");
+ if ((extNameLen == n) && (strncmp(extName, p, n) == 0)) {
+ return true;
+ }
+ p += (n + 1);
+ }
+ return false;
+}
+
+bool queryGLXExtension(const char *extName)
+{
+#if (defined __APPLE__) || (defined _WIN32)
+ return false;
+#else
+ int extNameLen = strlen(extName);
+
+ Display * display = XOpenDisplay(0);
+ char * p = (char *)glXQueryExtensionsString(display, DefaultScreen(display));
+ if (NULL == p) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL, "Couldn't get GLX extension string.");
+ }
+
+ char * end = p + strlen(p);
+
+ while (p < end) {
+ int n = strcspn(p, " ");
+ if ((extNameLen == n) && (strncmp(extName, p, n) == 0)) {
+// If we close the display connection on some drivers (at least fglrx/Ubuntu 11.04),
+// libavg crashes soon afterwards.
+// XCloseDisplay(display);
+ return true;
+ }
+ p += (n + 1);
+ }
+// XCloseDisplay(display);
+ return false;
+#endif
+}
+
+void getGLVersion(int& major, int& minor)
+{
+ const char* pVersion = (const char*)glGetString(GL_VERSION);
+ sscanf(pVersion, "%d.%d", &major, &minor);
+}
+
+void getGLShadingLanguageVersion(int& major, int& minor)
+{
+ int glMajor, glMinor;
+ getGLVersion(glMajor, glMinor);
+
+ major = 0;
+ minor = 0;
+ if (glMajor == 1) {
+ if (queryOGLExtension("GL_ARB_shading_language_100")) {
+ major = 1;
+ minor = 0;
+ }
+ } else {
+ const char* pVersion = (const char*)glGetString(GL_SHADING_LANGUAGE_VERSION);
+ sscanf(pVersion, "%d.%d", &major, &minor);
+ }
+}
+
+string AVG_API oglModeToString(int mode)
+{
+ switch (mode) {
+ case GL_ALPHA:
+ return "GL_ALPHA";
+ case GL_RGB:
+ return "GL_RGB";
+ case GL_RGBA:
+ return "GL_RGBA";
+ case GL_BGR:
+ return "GL_BGR";
+ case GL_BGRA:
+ return "GL_BGRA";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+#ifdef _WIN32
+#define GL_ALL_CLIENT_ATTRIB_BITS GL_CLIENT_ALL_ATTRIB_BITS
+#endif
+
+string oglMemoryMode2String(OGLMemoryMode mode)
+{
+ switch (mode) {
+ case MM_PBO:
+ return "PBO";
+ case MM_OGL:
+ return "OGL";
+ default:
+ return "invalid gl mem mode";
+ }
+}
+
+// TODO: Unused, possibly broken
+void pushGLState()
+{
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+ glPushClientAttrib(GL_ALL_CLIENT_ATTRIB_BITS);
+ glMatrixMode(GL_PROJECTION);
+ glPushMatrix();
+ glMatrixMode(GL_TEXTURE);
+ glPushMatrix();
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "pushGLState()");
+}
+
+void popGLState()
+{
+ glMatrixMode(GL_MODELVIEW);
+ glPopMatrix();
+ glMatrixMode(GL_TEXTURE);
+ glPopMatrix();
+ glMatrixMode(GL_PROJECTION);
+ glPopMatrix();
+ glPopClientAttrib();
+ glPopAttrib();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "popGLState()");
+}
+
+void AVG_API clearGLBuffers(GLbitfield mask)
+{
+ glClearColor(0.0, 0.0, 0.0, 0.0);
+ if (mask & GL_STENCIL_BUFFER_BIT) {
+ glStencilMask(~0);
+ glClearStencil(0);
+ }
+ glClear(mask);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "clearGLBuffers()");
+ if (mask & GL_STENCIL_BUFFER_BIT) {
+ glStencilMask(0);
+ }
+}
+
+
+void invalidGLCall()
+{
+ assert(false);
+}
+
+void loadGLLibrary()
+{
+#ifdef _WIN32
+ const char * pszFName = "OPENGL32.DLL";
+ char szErr[512];
+
+ glproc::s_hGLLib = (void *)LoadLibrary(pszFName);
+
+ if (glproc::s_hGLLib == 0) {
+ FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM),
+ 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ szErr, 512, 0);
+ throw Exception(AVG_ERR_VIDEO_GENERAL, string("Loading ") + pszFName + "failed: "
+ + szErr);
+ }
+#else
+#ifdef __APPLE__
+ const char * pszFName = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
+#else
+ const char * pszFName = "libGL.so.1";
+#endif
+ glproc::s_hGLLib = dlopen(pszFName, RTLD_NOW);
+ if (glproc::s_hGLLib == 0) {
+ const char * pszErr = (char *)dlerror();
+ throw Exception(AVG_ERR_VIDEO_GENERAL, string("Loading ") + pszFName + "failed: "
+ + pszErr);
+ }
+#endif
+}
+
+GLfunction getProcAddress(const string& sName)
+{
+ AVG_ASSERT(glproc::s_hGLLib);
+#ifdef _WIN32
+ GLfunction pProc = (GLfunction)wglGetProcAddress(sName.c_str());
+/*
+ if (!pProc) {
+ char szErr[512];
+ FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | FORMAT_MESSAGE_FROM_SYSTEM),
+ 0, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+ szErr, 512, 0);
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ string("wglGetProcAddress("+sName+") failed: ") + szErr);
+ }
+*/
+#else
+ GLfunction pProc = (GLfunction)dlsym(glproc::s_hGLLib, sName.c_str());
+ if (!pProc) {
+ // If the name didn't work, try using an underscore :-).
+ string sName_ = string("_")+sName;
+ pProc = (GLfunction)dlsym(glproc::s_hGLLib, sName_.c_str());
+ }
+#endif
+ return(pProc);
+}
+
+GLfunction getFuzzyProcAddress(const char * psz)
+{
+ GLfunction pProc = getProcAddress(psz);
+ if (!pProc) {
+ string s = string(psz)+"EXT";
+ pProc = getProcAddress(s);
+ }
+ if (!pProc) {
+ string s = string(psz)+"ARB";
+ pProc = getProcAddress(s);
+ }
+ if (!pProc) {
+ pProc = invalidGLCall;
+ }
+ return pProc;
+}
+#ifdef linux
+GLfunction getglXProcAddress(const char * psz)
+{
+ GLfunction pProc = (GLfunction)glXGetProcAddress((const GLubyte *)psz);
+ if (!pProc) {
+ pProc = invalidGLCall;
+ }
+ return pProc;
+}
+#endif
+
+#ifdef _WIN32
+GLfunction getwglProcAddress(const char * psz)
+{
+ GLfunction pProc = (GLfunction)wglGetProcAddress((LPCSTR)psz);
+ if (!pProc) {
+ pProc = invalidGLCall;
+ }
+ return pProc;
+}
+#endif
+
+namespace glproc {
+
+ void init() {
+ static bool s_bInitialized = false;
+ if (s_bInitialized) {
+ return;
+ }
+ s_bInitialized = true;
+ loadGLLibrary();
+
+ GenBuffers = (PFNGLGENBUFFERSPROC)getFuzzyProcAddress("glGenBuffers");
+ BufferData = (PFNGLBUFFERDATAPROC)getFuzzyProcAddress("glBufferData");
+ BufferSubData = (PFNGLBUFFERSUBDATAPROC)getFuzzyProcAddress("glBufferSubData");
+ DeleteBuffers = (PFNGLDELETEBUFFERSPROC)getFuzzyProcAddress("glDeleteBuffers");
+ BindBuffer = (PFNGLBINDBUFFERPROC)getFuzzyProcAddress("glBindBuffer");
+ MapBuffer = (PFNGLMAPBUFFERPROC)getFuzzyProcAddress("glMapBuffer");
+ UnmapBuffer = (PFNGLUNMAPBUFFERPROC)getFuzzyProcAddress("glUnmapBuffer");
+ GetBufferSubData = (PFNGLGETBUFFERSUBDATAPROC)getFuzzyProcAddress
+ ("glGetBufferSubData");
+
+ CreateShaderObject = (PFNGLCREATESHADEROBJECTARBPROC)
+ getFuzzyProcAddress("glCreateShaderObject");
+ ShaderSource = (PFNGLSHADERSOURCEARBPROC)
+ getFuzzyProcAddress("glShaderSource");
+ CompileShader = (PFNGLCOMPILESHADERARBPROC)
+ getFuzzyProcAddress("glCompileShader");
+ CreateProgramObject = (PFNGLCREATEPROGRAMOBJECTARBPROC)
+ getFuzzyProcAddress("glCreateProgramObject");
+ AttachObject = (PFNGLATTACHOBJECTARBPROC)
+ getFuzzyProcAddress("glAttachObject");
+ LinkProgram = (PFNGLLINKPROGRAMARBPROC)getFuzzyProcAddress("glLinkProgram");
+ GetObjectParameteriv = (PFNGLGETOBJECTPARAMETERIVARBPROC)
+ getFuzzyProcAddress("glGetObjectParameteriv");
+ GetInfoLog = (PFNGLGETINFOLOGARBPROC)getFuzzyProcAddress("glGetInfoLog");
+ UseProgramObject =(PFNGLUSEPROGRAMOBJECTARBPROC)
+ getFuzzyProcAddress("glUseProgramObject");
+ GetUniformLocation = (PFNGLGETUNIFORMLOCATIONARBPROC)
+ getFuzzyProcAddress("glGetUniformLocation");
+ Uniform1i = (PFNGLUNIFORM1IARBPROC)getFuzzyProcAddress("glUniform1i");
+ Uniform1f = (PFNGLUNIFORM1FARBPROC)getFuzzyProcAddress("glUniform1f");
+ Uniform2f = (PFNGLUNIFORM2FARBPROC)getFuzzyProcAddress("glUniform2f");
+ Uniform3f = (PFNGLUNIFORM3FARBPROC)getFuzzyProcAddress("glUniform3f");
+ Uniform4f = (PFNGLUNIFORM4FARBPROC)getFuzzyProcAddress("glUniform4f");
+ Uniform1fv = (PFNGLUNIFORM1FVARBPROC)getFuzzyProcAddress("glUniform1fv");
+ UniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVARBPROC)
+ getFuzzyProcAddress("glUniformMatrix4fv");
+
+ BlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC)
+ getFuzzyProcAddress("glBlendFuncSeparate");
+ BlendEquation = (PFNGLBLENDEQUATIONPROC)getFuzzyProcAddress("glBlendEquation");
+ BlendColor = (PFNGLBLENDCOLORPROC)getFuzzyProcAddress("glBlendColor");
+ ActiveTexture = (PFNGLACTIVETEXTUREPROC)getFuzzyProcAddress("glActiveTexture");
+ GenerateMipmap = (PFNGLGENERATEMIPMAPEXTPROC)getFuzzyProcAddress
+ ("glGenerateMipmap");
+
+ CheckFramebufferStatus = (PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC)
+ getFuzzyProcAddress("glCheckFramebufferStatus");
+ GenFramebuffers = (PFNGLGENFRAMEBUFFERSEXTPROC)
+ getFuzzyProcAddress("glGenFramebuffers");
+ BindFramebuffer = (PFNGLBINDFRAMEBUFFEREXTPROC)
+ getFuzzyProcAddress("glBindFramebuffer");
+ FramebufferTexture2D = (PFNGLFRAMEBUFFERTEXTURE2DEXTPROC)
+ getFuzzyProcAddress("glFramebufferTexture2D");
+ DeleteFramebuffers = (PFNGLDELETEFRAMEBUFFERSEXTPROC)
+ getFuzzyProcAddress("glDeleteFramebuffers");
+ GenRenderbuffers = (PFNGLGENRENDERBUFFERSEXTPROC)
+ getFuzzyProcAddress("glGenRenderbuffers");
+ BindRenderbuffer = (PFNGLBINDRENDERBUFFEREXTPROC)
+ getFuzzyProcAddress("glBindRenderbuffer");
+ RenderbufferStorage= (PFNGLRENDERBUFFERSTORAGEEXTPROC)
+ getFuzzyProcAddress("glRenderbufferStorage");
+ RenderbufferStorageMultisample = (PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC)
+ getFuzzyProcAddress("glRenderbufferStorageMultisample");
+ FramebufferRenderbuffer = (PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC)
+ getFuzzyProcAddress("glFramebufferRenderbuffer");
+ BlitFramebuffer = (PFNGLBLITFRAMEBUFFEREXTPROC)
+ getFuzzyProcAddress("glBlitFramebuffer");
+ DeleteRenderbuffers = (PFNGLDELETERENDERBUFFERSEXTPROC)
+ getFuzzyProcAddress("glDeleteRenderbuffers");
+ DrawBuffers = (PFNGLDRAWBUFFERSPROC)
+ getFuzzyProcAddress("glDrawBuffers");
+#ifdef linux
+ SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
+ getglXProcAddress("glXSwapIntervalSGI");
+ WaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)
+ getglXProcAddress("glXWaitVideoSyncSGI");
+#endif
+
+#ifdef _WIN32
+ SwapIntervalEXT = (PFNWGLEXTSWAPCONTROLPROC)
+ getwglProcAddress("wglSwapIntervalEXT");
+#endif
+ }
+}
+
+}
diff --git a/src/graphics/OGLHelper.h b/src/graphics/OGLHelper.h
new file mode 100644
index 0000000..514142a
--- /dev/null
+++ b/src/graphics/OGLHelper.h
@@ -0,0 +1,141 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _OGLHelper_H_
+#define _OGLHelper_H_
+
+#include "../api.h"
+#ifdef _WIN32
+#include <windows.h>
+#undef ERROR
+#undef WARNING
+#include <GL/gl.h>
+#include <GL/glu.h>
+#include "GL/glext.h"
+#else
+#include "GL/gl.h"
+#include "GL/glu.h"
+#endif
+#ifdef linux
+#define GLX_GLXEXT_PROTOTYPES
+#include <GL/glx.h>
+#endif
+#ifdef _WIN32
+//TODO: Does anyone know where these are declared?
+typedef void (APIENTRY *PFNWGLEXTSWAPCONTROLPROC) (int);
+typedef int (*PFNWGLEXTGETSWAPINTERVALPROC) (void);
+#endif
+
+#include <string>
+
+namespace avg {
+
+void AVG_API OGLErrorCheck(int avgcode, const char* pszWhere);
+#ifdef _WIN32
+void AVG_API winOGLErrorCheck(BOOL bOK, const std::string& sWhere);
+#endif
+bool AVG_API queryOGLExtension(const char* extName);
+bool AVG_API queryGLXExtension(const char* extName);
+void AVG_API getGLVersion(int& major, int& minor);
+void AVG_API getGLShadingLanguageVersion(int& major, int& minor);
+std::string AVG_API oglModeToString(int mode);
+
+enum OGLMemoryMode {
+ MM_OGL, // Standard OpenGL
+ MM_PBO // pixel buffer objects
+};
+
+std::string oglMemoryMode2String(OGLMemoryMode mode);
+
+void AVG_API pushGLState();
+void AVG_API popGLState();
+
+void AVG_API clearGLBuffers(GLbitfield mask);
+
+typedef void (*GLfunction)();
+GLfunction AVG_API getFuzzyProcAddress(const char * psz);
+
+namespace glproc {
+ extern AVG_API PFNGLGENBUFFERSPROC GenBuffers;
+ extern AVG_API PFNGLBUFFERDATAPROC BufferData;
+ extern AVG_API PFNGLBUFFERSUBDATAPROC BufferSubData;
+ extern AVG_API PFNGLDELETEBUFFERSPROC DeleteBuffers;
+ extern AVG_API PFNGLBINDBUFFERPROC BindBuffer;
+ extern AVG_API PFNGLMAPBUFFERPROC MapBuffer;
+ extern AVG_API PFNGLUNMAPBUFFERPROC UnmapBuffer;
+ extern AVG_API PFNGLGETBUFFERSUBDATAPROC GetBufferSubData;
+
+ extern AVG_API PFNGLCREATESHADEROBJECTARBPROC CreateShaderObject;
+ extern AVG_API PFNGLSHADERSOURCEARBPROC ShaderSource;
+ extern AVG_API PFNGLCOMPILESHADERARBPROC CompileShader;
+ extern AVG_API PFNGLCREATEPROGRAMOBJECTARBPROC CreateProgramObject;
+ extern AVG_API PFNGLATTACHOBJECTARBPROC AttachObject;
+ extern AVG_API PFNGLLINKPROGRAMARBPROC LinkProgram;
+ extern AVG_API PFNGLGETOBJECTPARAMETERIVARBPROC GetObjectParameteriv;
+ extern AVG_API PFNGLGETINFOLOGARBPROC GetInfoLog;
+ extern AVG_API PFNGLUSEPROGRAMOBJECTARBPROC UseProgramObject;
+ extern AVG_API PFNGLGETUNIFORMLOCATIONARBPROC GetUniformLocation;
+ extern AVG_API PFNGLUNIFORM1IARBPROC Uniform1i;
+ extern AVG_API PFNGLUNIFORM1FARBPROC Uniform1f;
+ extern AVG_API PFNGLUNIFORM2FARBPROC Uniform2f;
+ extern AVG_API PFNGLUNIFORM3FARBPROC Uniform3f;
+ extern AVG_API PFNGLUNIFORM4FARBPROC Uniform4f;
+ extern AVG_API PFNGLUNIFORM1FVARBPROC Uniform1fv;
+ extern AVG_API PFNGLUNIFORMMATRIX4FVARBPROC UniformMatrix4fv;
+
+ extern AVG_API PFNGLBLENDFUNCSEPARATEPROC BlendFuncSeparate;
+ extern AVG_API PFNGLBLENDEQUATIONPROC BlendEquation;
+ extern AVG_API PFNGLBLENDCOLORPROC BlendColor;
+ extern AVG_API PFNGLACTIVETEXTUREPROC ActiveTexture;
+ extern AVG_API PFNGLGENERATEMIPMAPEXTPROC GenerateMipmap;
+
+ extern AVG_API PFNGLCHECKFRAMEBUFFERSTATUSEXTPROC CheckFramebufferStatus;
+ extern AVG_API PFNGLGENFRAMEBUFFERSEXTPROC GenFramebuffers;
+ extern AVG_API PFNGLBINDFRAMEBUFFEREXTPROC BindFramebuffer;
+ extern AVG_API PFNGLFRAMEBUFFERTEXTURE2DEXTPROC FramebufferTexture2D;
+ extern AVG_API PFNGLDELETEFRAMEBUFFERSEXTPROC DeleteFramebuffers;
+ extern AVG_API PFNGLGENRENDERBUFFERSEXTPROC GenRenderbuffers;
+ extern AVG_API PFNGLBINDRENDERBUFFEREXTPROC BindRenderbuffer;
+ extern AVG_API PFNGLRENDERBUFFERSTORAGEEXTPROC RenderbufferStorage;
+ extern AVG_API PFNGLRENDERBUFFERSTORAGEMULTISAMPLEEXTPROC
+ RenderbufferStorageMultisample;
+ extern AVG_API PFNGLFRAMEBUFFERRENDERBUFFEREXTPROC FramebufferRenderbuffer;
+ extern AVG_API PFNGLBLITFRAMEBUFFEREXTPROC BlitFramebuffer;
+ extern AVG_API PFNGLDELETERENDERBUFFERSEXTPROC DeleteRenderbuffers;
+ extern AVG_API PFNGLDRAWBUFFERSPROC DrawBuffers;
+
+#ifdef linux
+ extern PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
+ extern PFNGLXWAITVIDEOSYNCSGIPROC WaitVideoSyncSGI;
+#endif
+#ifdef _WIN32
+ extern AVG_API PFNWGLEXTSWAPCONTROLPROC SwapIntervalEXT;
+#endif
+ void init();
+
+ extern void * s_hGLLib;
+}
+
+
+}
+
+#endif
+
diff --git a/src/graphics/OGLImagingContext.cpp b/src/graphics/OGLImagingContext.cpp
new file mode 100644
index 0000000..692b430
--- /dev/null
+++ b/src/graphics/OGLImagingContext.cpp
@@ -0,0 +1,105 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "OGLImagingContext.h"
+#undef check
+#include "ShaderRegistry.h"
+#include "GPUFilter.h"
+
+#include "../base/Exception.h"
+
+#ifdef _WIN32
+// XXX: If the following includes are not there, the MS linker optimizes away
+// the classes so they can't be used by plugins anymore (!). Adding /OPT:NOREF
+// to the linker flags doesn't help.
+#include "FilterGetAlpha.h"
+#include "FilterErosion.h"
+#include "FilterDilation.h"
+#include "FilterGetAlpha.h"
+#include "FilterResizeBilinear.h"
+#include "FilterResizeGaussian.h"
+#include "FilterThreshold.h"
+#endif
+
+#include <iostream>
+
+namespace avg {
+
+using namespace std;
+
+OGLImagingContext::OGLImagingContext()
+ : GLContext()
+{
+ init();
+
+ if (!isSupported()) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ "GPU imaging not supported by current OpenGL configuration.");
+ }
+
+ setStandardState();
+}
+
+OGLImagingContext::~OGLImagingContext()
+{
+}
+
+bool OGLImagingContext::isSupported()
+{
+ int glMajorVer;
+ int glMinorVer;
+ int slMajorVer;
+ int slMinorVer;
+ getGLVersion(glMajorVer, glMinorVer);
+ getGLShadingLanguageVersion(slMajorVer, slMinorVer);
+ return (glMajorVer > 1 && queryOGLExtension("GL_ARB_texture_rectangle") &&
+ queryOGLExtension("GL_ARB_pixel_buffer_object") &&
+ queryOGLExtension("GL_EXT_framebuffer_object"));
+}
+
+void OGLImagingContext::setStandardState()
+{
+ // Shading etc.
+ glDisable(GL_BLEND);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "glDisable(GL_BLEND)");
+ glShadeModel(GL_FLAT);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "glShadeModel(GL_FLAT)");
+ glDisable(GL_DEPTH_TEST);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "glDisable(GL_DEPTH_TEST)");
+ glDisable(GL_STENCIL_TEST);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "glDisable(GL_STENCIL_TEST)");
+
+ // Texturing
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "glTexEnvf()");
+ glBlendFunc(GL_ONE, GL_ZERO);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "glBlendFunc()");
+ glDisable(GL_MULTISAMPLE);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "glDisable(GL_MULTISAMPLE);");
+
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+}
+
+}
+
diff --git a/src/graphics/OGLImagingContext.h b/src/graphics/OGLImagingContext.h
new file mode 100644
index 0000000..8a5f962
--- /dev/null
+++ b/src/graphics/OGLImagingContext.h
@@ -0,0 +1,58 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#ifndef _OGLImagingContext_H_
+#define _OGLImagingContext_H_
+#include "../api.h"
+#include "../base/Point.h"
+
+#include "OGLHelper.h"
+#include "GLContext.h"
+
+#ifdef __APPLE__
+#include <AGL/agl.h>
+#else
+#ifdef linux
+#include <GL/glx.h>
+#else
+#ifdef _WIN32
+#include <gl/gl.h>
+#include <gl/glu.h>
+#endif
+#endif
+#endif
+
+namespace avg {
+
+class AVG_API OGLImagingContext: public GLContext {
+public:
+ OGLImagingContext();
+ virtual ~OGLImagingContext();
+
+ bool isSupported();
+
+private:
+ void setStandardState();
+
+
+};
+}
+#endif
+
diff --git a/src/graphics/OGLShader.cpp b/src/graphics/OGLShader.cpp
new file mode 100644
index 0000000..7e17690
--- /dev/null
+++ b/src/graphics/OGLShader.cpp
@@ -0,0 +1,167 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "OGLShader.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/Matrix3x4.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+OGLShader::OGLShader(string sProgram)
+ : m_sProgram(sProgram)
+{
+ m_hFragmentShader = glproc::CreateShaderObject(GL_FRAGMENT_SHADER);
+ const char * pProgramStr = m_sProgram.c_str();
+ glproc::ShaderSource(m_hFragmentShader, 1, &pProgramStr, 0);
+ glproc::CompileShader(m_hFragmentShader);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "OGLShader::OGLShader: glCompileShader()");
+ dumpInfoLog(m_hFragmentShader);
+
+ m_hProgram = glproc::CreateProgramObject();
+ glproc::AttachObject(m_hProgram, m_hFragmentShader);
+ glproc::LinkProgram(m_hProgram);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "OGLShader::OGLShader: glLinkProgram()");
+
+ GLint bLinked;
+ glproc::GetObjectParameteriv(m_hProgram, GL_OBJECT_LINK_STATUS_ARB, &bLinked);
+ dumpInfoLog(m_hProgram);
+ if (!bLinked) {
+ AVG_TRACE(Logger::ERROR, "Linking shader program failed. Aborting.");
+ exit(-1);
+ }
+
+}
+
+OGLShader::~OGLShader()
+{
+}
+
+void OGLShader::activate()
+{
+ glproc::UseProgramObject(m_hProgram);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "OGLShader::activate: glUseProgramObject()");
+}
+
+GLhandleARB OGLShader::getProgram()
+{
+ return m_hProgram;
+}
+
+void OGLShader::setUniformIntParam(const std::string& sName, int val)
+{
+ int loc = safeGetUniformLoc(sName);
+ glproc::Uniform1i(loc, val);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ (string("OGLShader: glUniform(")+sName+")").c_str());
+}
+
+void OGLShader::setUniformFloatParam(const std::string& sName, float val)
+{
+ int loc = safeGetUniformLoc(sName);
+ glproc::Uniform1f(loc, val);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ (string("OGLShader: glUniform(")+sName+")").c_str());
+}
+
+void OGLShader::setUniformFloatParam(const std::string& sName, double val)
+{
+ return setUniformFloatParam(sName, float(val));
+}
+
+void OGLShader::setUniformFloatArrayParam(const std::string& sName, int count,
+ float* pVal)
+{
+ int loc = safeGetUniformLoc(sName);
+ glproc::Uniform1fv(loc, count, pVal);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ (string("OGLShader: glUniform(")+sName+")").c_str());
+}
+
+void OGLShader::setUniformDPointParam(const std::string& sName, DPoint pt)
+{
+ int loc = safeGetUniformLoc(sName);
+ glproc::Uniform2f(loc, (float)pt.x, (float)pt.y);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ (string("OGLShader: glUniform(")+sName+")").c_str());
+}
+
+void OGLShader::setUniformColorParam(const std::string& sName, Pixel32 col)
+{
+ int loc = safeGetUniformLoc(sName);
+ glproc::Uniform4f(loc, col.getR()/255.f, col.getG()/255.f, col.getB()/255.f,
+ col.getA()/255.f);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ (string("OGLShader: glUniform(")+sName+")").c_str());
+}
+
+void OGLShader::setUniformVec4fParam(const std::string& sName, float x, float y, float z,
+ float w)
+{
+ int loc = safeGetUniformLoc(sName);
+ glproc::Uniform4f(loc, x, y, z, w);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ (string("OGLShader: glUniform(")+sName+")").c_str());
+}
+
+void OGLShader::dumpInfoLog(GLhandleARB hObj)
+{
+ int InfoLogLength;
+ GLcharARB * pInfoLog;
+
+ glproc::GetObjectParameteriv(hObj, GL_OBJECT_INFO_LOG_LENGTH_ARB, &InfoLogLength);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "OGLShader::dumpInfoLog: glGetObjectParameteriv()");
+ bool bLogContainsGarbage = (string((char *)glGetString(GL_VENDOR))
+ != "NVIDIA Corporation");
+ if (InfoLogLength > 1 && !bLogContainsGarbage) {
+ pInfoLog = (GLcharARB*)malloc(InfoLogLength);
+ int CharsWritten;
+ glproc::GetInfoLog(hObj, InfoLogLength, &CharsWritten, pInfoLog);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "OGLShader::dumpInfoLog: glGetInfoLog()");
+ AVG_TRACE(Logger::WARNING, pInfoLog);
+ free(pInfoLog);
+ }
+}
+
+int OGLShader::safeGetUniformLoc(const std::string& sName)
+{
+ // TODO: This takes too much time if it's called whenever the parameter is set.
+ map<string, int>::iterator pos = m_UniformLocationMap.find(sName);
+ if (pos == m_UniformLocationMap.end()) {
+ int loc = glproc::GetUniformLocation(m_hProgram, sName.c_str());
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "OGLShader::setUniformIntParam: GetUniformLocation()");
+ m_UniformLocationMap[sName] = loc;
+ return loc;
+ } else {
+ return pos->second;
+ }
+}
+
+
+}
diff --git a/src/graphics/OGLShader.h b/src/graphics/OGLShader.h
new file mode 100644
index 0000000..ba91ff9
--- /dev/null
+++ b/src/graphics/OGLShader.h
@@ -0,0 +1,74 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _OGLShader_H_
+#define _OGLShader_H_
+
+#include "../api.h"
+#include "OGLHelper.h"
+#include "Pixel32.h"
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+class Matrix3x4;
+
+class AVG_API OGLShader {
+ public:
+ virtual ~OGLShader();
+
+ void activate();
+ GLhandleARB getProgram();
+
+ void setUniformIntParam(const std::string& sName, int val);
+ void setUniformFloatParam(const std::string& sName, float val);
+ void setUniformFloatParam(const std::string& sName, double val);
+ void setUniformFloatArrayParam(const std::string& sName, int count, float* pVal);
+ void setUniformDPointParam(const std::string& sName, DPoint pt);
+ void setUniformColorParam(const std::string& sName, Pixel32 col);
+ void setUniformVec4fParam(const std::string& sName, float x, float y, float z,
+ float w);
+
+ private:
+ OGLShader(std::string sProgram);
+ friend class ShaderRegistry;
+
+ void dumpInfoLog(GLhandleARB hObj);
+ int safeGetUniformLoc(const std::string& sName);
+
+ GLhandleARB m_hFragmentShader;
+ GLhandleARB m_hProgram;
+ std::string m_sProgram;
+ std::map<std::string, int> m_UniformLocationMap;
+};
+
+typedef boost::shared_ptr<OGLShader> OGLShaderPtr;
+
+}
+
+#endif
+
diff --git a/src/graphics/PBO.cpp b/src/graphics/PBO.cpp
new file mode 100644
index 0000000..a54eab0
--- /dev/null
+++ b/src/graphics/PBO.cpp
@@ -0,0 +1,219 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "PBO.h"
+#include "GLContext.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include <iostream>
+#include <cstring>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+PBO::PBO(const IntPoint& size, PixelFormat pf, unsigned usage)
+ : TextureMover(size, pf),
+ m_Usage(usage)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ m_PBOID = GLContext::getCurrent()->getPBOCache().getBuffer();
+
+ unsigned target = getTarget();
+ glproc::BindBuffer(target, m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO: BindBuffer()");
+ int memNeeded = size.x*size.y*getBytesPerPixel(pf);
+ glproc::BufferData(target, memNeeded, 0, usage);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO: BufferData()");
+ glproc::BindBuffer(target, 0);
+}
+
+PBO::~PBO()
+{
+ glproc::BindBuffer(getTarget(), m_PBOID);
+ glproc::BufferData(getTarget(), 0, 0, m_Usage);
+ GLContext* pContext = GLContext::getCurrent();
+ if (pContext) {
+ pContext->getPBOCache().returnBuffer(m_PBOID);
+ }
+ glproc::BindBuffer(getTarget(), 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO: DeleteBuffers()");
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void PBO::activate()
+{
+ glproc::BindBuffer(getTarget(), m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::activate()");
+
+}
+
+void PBO::moveBmpToTexture(BitmapPtr pBmp, GLTexture& tex)
+{
+
+ AVG_ASSERT(pBmp->getSize() == tex.getSize());
+ AVG_ASSERT(getSize() == pBmp->getSize());
+ AVG_ASSERT(pBmp->getPixelFormat() == getPF());
+ AVG_ASSERT(tex.getPF() == getPF());
+ AVG_ASSERT(!isReadPBO());
+ glproc::BindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::moveBmpToTexture BindBuffer()");
+ void * pPBOPixels = glproc::MapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::moveBmpToTexture MapBuffer()");
+ Bitmap PBOBitmap(getSize(), getPF(), (unsigned char *)pPBOPixels,
+ getSize().x*getBytesPerPixel(getPF()), false);
+ PBOBitmap.copyPixels(*pBmp);
+ glproc::UnmapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::setImage: UnmapBuffer()");
+
+ tex.setDirty();
+ moveToTexture(tex);
+}
+
+BitmapPtr PBO::moveTextureToBmp(GLTexture& tex, int mipmapLevel)
+{
+ moveTextureToPBO(tex, mipmapLevel);
+ return movePBOToBmp();
+}
+
+void PBO::moveTextureToPBO(GLTexture& tex, int mipmapLevel)
+{
+ AVG_ASSERT(isReadPBO());
+ AVG_ASSERT(getSize() == tex.getGLSize());
+ AVG_ASSERT(getPF() == tex.getPF());
+ glproc::BindBuffer(GL_PIXEL_PACK_BUFFER_EXT, m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::getImage BindBuffer()");
+
+ tex.activate(GL_TEXTURE0);
+
+ glGetTexImage(GL_TEXTURE_2D, mipmapLevel, GLTexture::getGLFormat(getPF()),
+ GLTexture::getGLType(getPF()), 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::getImage: glGetTexImage()");
+ if (mipmapLevel == 0) {
+ m_ActiveSize = tex.getSize();
+ m_BufferStride = tex.getGLSize().x;
+ } else {
+ m_ActiveSize = tex.getMipmapSize(mipmapLevel);
+ m_BufferStride = tex.getMipmapSize(mipmapLevel).x;
+ }
+}
+
+BitmapPtr PBO::movePBOToBmp() const
+{
+ AVG_ASSERT(isReadPBO());
+ glproc::BindBuffer(GL_PIXEL_PACK_BUFFER_EXT, m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::getImage BindBuffer()");
+ void * pPBOPixels = glproc::MapBuffer(GL_PIXEL_PACK_BUFFER_EXT, GL_READ_ONLY);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::getImage MapBuffer()");
+ Bitmap PBOBitmap(m_ActiveSize, getPF(), (unsigned char *)pPBOPixels,
+ m_BufferStride*getBytesPerPixel(getPF()), false);
+ BitmapPtr pBmp(new Bitmap(m_ActiveSize, getPF()));
+ pBmp->copyPixels(PBOBitmap);
+ glproc::UnmapBuffer(GL_PIXEL_PACK_BUFFER_EXT);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::getImage: UnmapBuffer()");
+ glproc::BindBuffer(GL_PIXEL_PACK_BUFFER_EXT, 0);
+
+ return pBmp;
+}
+
+BitmapPtr PBO::lock()
+{
+ AVG_ASSERT(!isReadPBO());
+ BitmapPtr pBmp;
+ glproc::BindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::lockBmp: glBindBuffer()");
+ glproc::BufferData(GL_PIXEL_UNPACK_BUFFER_EXT,
+ getSize().x*getSize().y*getBytesPerPixel(getPF()), 0, m_Usage);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::lockBmp: glBufferData()");
+ unsigned char * pBuffer = (unsigned char *)
+ glproc::MapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, GL_WRITE_ONLY);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::lockBmp: glMapBuffer()");
+ glproc::BindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::lockBmp: glBindBuffer(0)");
+
+ pBmp = BitmapPtr(new Bitmap(getSize(), getPF(), pBuffer,
+ getSize().x*getBytesPerPixel(getPF()), false));
+ return pBmp;
+}
+
+void PBO::unlock()
+{
+ AVG_ASSERT(!isReadPBO());
+ glproc::BindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::unlockBmp: glBindBuffer()");
+ glproc::UnmapBuffer(GL_PIXEL_UNPACK_BUFFER_EXT);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::unlockBmp: glUnmapBuffer()");
+ glproc::BindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::unlockBmp: glBindBuffer(0)");
+}
+
+void PBO::moveToTexture(GLTexture& tex)
+{
+ AVG_ASSERT(!isReadPBO());
+ IntPoint size = tex.getSize();
+ if (size.x > getSize().x) {
+ size.x = getSize().x;
+ }
+ if (size.y > getSize().y) {
+ size.y = getSize().y;
+ }
+ glproc::BindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, m_PBOID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBOTexture::lockBmp: glBindBuffer()");
+ tex.activate(GL_TEXTURE0);
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, size.x, size.y,
+ GLTexture::getGLFormat(getPF()), GLTexture::getGLType(getPF()), 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "PBO::setImage: glTexSubImage2D()");
+ glproc::BindBuffer(GL_PIXEL_UNPACK_BUFFER_EXT, 0);
+ tex.setDirty();
+ tex.generateMipmaps();
+}
+
+bool PBO::isReadPBO() const
+{
+ switch (m_Usage) {
+ case GL_STATIC_DRAW:
+ case GL_DYNAMIC_DRAW:
+ case GL_STREAM_DRAW:
+ return false;
+ case GL_STATIC_READ:
+ case GL_DYNAMIC_READ:
+ case GL_STREAM_READ:
+ return true;
+ default:
+ AVG_ASSERT(false);
+ return false;
+ }
+}
+
+unsigned PBO::getTarget() const
+{
+ if (isReadPBO()) {
+ return GL_PIXEL_PACK_BUFFER_EXT;
+ } else {
+ return GL_PIXEL_UNPACK_BUFFER_EXT;
+ }
+}
+
+}
diff --git a/src/graphics/PBO.h b/src/graphics/PBO.h
new file mode 100644
index 0000000..9c8d614
--- /dev/null
+++ b/src/graphics/PBO.h
@@ -0,0 +1,71 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _PBO_H_
+#define _PBO_H_
+
+#include "../api.h"
+#include "TextureMover.h"
+
+#include "Bitmap.h"
+#include "OGLHelper.h"
+#include "GLTexture.h"
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API PBO: public TextureMover {
+public:
+ PBO(const IntPoint& size, PixelFormat pf, unsigned usage);
+ virtual ~PBO();
+
+ void activate();
+
+ void moveBmpToTexture(BitmapPtr pBmp, GLTexture& tex);
+ virtual BitmapPtr moveTextureToBmp(GLTexture& tex, int mipmapLevel=0);
+
+ BitmapPtr lock();
+ void unlock();
+ void moveToTexture(GLTexture& tex);
+ void moveTextureToPBO(GLTexture& tex, int mipmapLevel=0);
+ BitmapPtr movePBOToBmp() const;
+
+ bool isReadPBO() const;
+
+private:
+ unsigned getTarget() const;
+
+ unsigned m_Usage;
+ unsigned m_PBOID;
+ IntPoint m_ActiveSize;
+ int m_BufferStride;
+};
+
+typedef boost::shared_ptr<PBO> PBOPtr;
+
+}
+
+#endif
+
+
diff --git a/src/graphics/Pixel16.h b/src/graphics/Pixel16.h
new file mode 100644
index 0000000..bafbcec
--- /dev/null
+++ b/src/graphics/Pixel16.h
@@ -0,0 +1,180 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Pixel16_H_
+#define _Pixel16_H_
+
+#include "../api.h"
+#include "Pixeldefs.h"
+#include "Pixel24.h"
+#include "Pixel32.h"
+
+#include <stdlib.h>
+#include <math.h>
+
+namespace avg {
+
+// 16 bit pixel class. A pixel in this class contains 5 bits of
+// red, 6 of green and 5 of blue (in that order).
+class AVG_API Pixel16
+{
+ public:
+ Pixel16 ();
+ Pixel16 (unsigned char r, unsigned char g, unsigned char b);
+ void Set (unsigned char r, unsigned char g, unsigned char b);
+ void SetR (unsigned char r);
+ void SetG (unsigned char g);
+ void SetB (unsigned char b);
+ unsigned char getR () const;
+ unsigned char getG () const;
+ unsigned char getB () const;
+
+ Pixel16 operator = (const Pixel32& Pix);
+ operator Pixel32 () const;
+ Pixel16 operator = (const Pixel24& Pix);
+ operator Pixel24 () const;
+
+ bool operator ==(const Pixel16 Pix) const;
+
+ bool operator !=(const Pixel16 Pix) const;
+
+ // Simple and fast 'distance' between two pixels. Just adds the
+ // distances between the color components and treats colors
+ // equally.
+ int BoxDist (const Pixel16 Pix) const;
+
+ private:
+ unsigned short m_Data;
+};
+
+inline Pixel16::Pixel16()
+{
+}
+
+
+inline Pixel16::Pixel16(unsigned char r, unsigned char g, unsigned char b)
+{
+ Set (r, g, b);
+}
+
+
+inline void Pixel16::Set (unsigned char r, unsigned char g, unsigned char b)
+{
+#ifdef PIXEL_BGRA_ORDER
+ m_Data = ((r&0xF8) << 8) | ((g&0xFC) << 3) | (b>>3);
+#else
+ m_Data = (b&0xF8) << 8 | ((g&0xFC) << 3) | (r>>3);
+#endif
+}
+
+inline void Pixel16::SetR(unsigned char r)
+{
+#ifdef PIXEL_BGRA_ORDER
+ m_Data = (m_Data&0x07FF)|((r&0xF8)<<8);
+#else
+ m_Data = (m_Data&0xFFE0)|(r>>3);
+#endif
+}
+
+inline void Pixel16::SetG(unsigned char g)
+{
+ m_Data = (m_Data&0xF81F)|((g&0xFC)<<3);
+}
+
+
+inline void Pixel16::SetB(unsigned char b)
+{
+#ifdef PIXEL_BGRA_ORDER
+ m_Data = (m_Data&0xFFE0)|(b>>3);
+#else
+ m_Data = (m_Data&0x07FF)|((b&0xF8)<<8);
+#endif
+}
+
+inline unsigned char Pixel16::getR() const
+{
+#ifdef PIXEL_BGRA_ORDER
+ return (m_Data&0xF800)>>8;
+#else
+ return (m_Data&0x001F)<<3;
+#endif
+}
+
+
+inline unsigned char Pixel16::getG() const
+{
+ return (m_Data&0x07E0)>>3;
+}
+
+inline unsigned char Pixel16::getB() const
+{
+#ifdef PIXEL_BGRA_ORDER
+ return (m_Data&0x001F)<<3;
+#else
+ return (m_Data&0xF800)>>8;
+#endif
+}
+
+inline Pixel16 Pixel16::operator = (const Pixel32& Pix)
+{
+ Set (Pix.getR(), Pix.getG(), Pix.getB());
+ return *this;
+}
+
+inline Pixel16::operator Pixel32 () const
+{
+ // TODO: Make faster.
+ return Pixel32 (getR(), getG(), getB(), 255);
+}
+
+inline Pixel16 Pixel16::operator = (const Pixel24& Pix)
+{
+ Set (Pix.getR(), Pix.getG(), Pix.getB());
+
+ return *this;
+}
+
+inline Pixel16::operator Pixel24 () const
+{
+ // TODO: Make faster.
+ return Pixel24 (getR(), getG(), getB());
+}
+
+inline int Pixel16::BoxDist (const Pixel16 Pix) const
+{
+ return (abs ((int)getR()-Pix.getR()) +
+ abs ((int)getG()-Pix.getG()) +
+ abs ((int)getB()-Pix.getB()));
+}
+
+inline bool Pixel16::operator ==(const Pixel16 Pix) const
+{
+ return (*(const short *)this == *(const short*)&Pix);
+}
+
+inline bool Pixel16::operator !=(const Pixel16 Pix) const
+{
+ return (!(*this == Pix));
+}
+
+
+}
+#endif
diff --git a/src/graphics/Pixel24.h b/src/graphics/Pixel24.h
new file mode 100644
index 0000000..cc0d637
--- /dev/null
+++ b/src/graphics/Pixel24.h
@@ -0,0 +1,190 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Pixel24_H_
+#define _Pixel24_H_
+
+#include "../api.h"
+#include "Pixeldefs.h"
+#include "Pixel32.h"
+#include "Pixel8.h"
+
+#include "../base/Exception.h"
+
+#include <stdlib.h>
+
+namespace avg {
+
+class AVG_API Pixel24
+{
+ public:
+ Pixel24 ();
+ Pixel24 (unsigned char r, unsigned char g, unsigned char b);
+ void set (unsigned char r, unsigned char g, unsigned char b);
+ void setR (unsigned char r);
+ void setG (unsigned char g);
+ void setB (unsigned char b);
+ unsigned char getR () const;
+ unsigned char getG () const;
+ unsigned char getB () const;
+ void flipRB();
+
+ template<class SrcPixel>
+ Pixel24 operator = (const SrcPixel& Pix)
+ {
+ setR (Pix.getR());
+ setG (Pix.getG());
+ setB (Pix.getB());
+
+ return *this;
+ }
+
+ Pixel24 operator = (const Pixel8& Pix)
+ {
+ m_Data[0] = Pix.get();
+ m_Data[1] = m_Data[0];
+ m_Data[2] = m_Data[0];
+ return *this;
+ }
+
+
+ operator Pixel32 () const;
+
+ bool operator ==(const Pixel24&) const;
+ bool operator !=(const Pixel24&) const;
+ void operator +=(const Pixel24&);
+ void operator -=(const Pixel24&);
+
+ // Simple and fast 'distance' between two pixels. Just adds the
+ // distances between the color components and treats colors
+ // equally.
+ int boxDist (const Pixel24 Pix) const;
+
+ // Returns a weighed average between two pixels. Factor must be
+ // between 0 and 256. Factor=256 means Pix1 is the result, Factor=0
+ // means Pix2 is the result.
+ static Pixel24 Blend (int Factor, const Pixel24 Pix1,
+ const Pixel24 Pix2);
+
+ private:
+ unsigned char m_Data[3];
+};
+
+inline Pixel24::Pixel24()
+{
+}
+
+inline Pixel24::Pixel24(unsigned char r, unsigned char g, unsigned char b)
+{
+ set (r, g, b);
+}
+
+inline void Pixel24::set(unsigned char r, unsigned char g, unsigned char b)
+{
+ m_Data[REDPOS] = r;
+ m_Data[GREENPOS] = g;
+ m_Data[BLUEPOS] = b;
+}
+
+inline void Pixel24::setR(unsigned char r)
+{
+ m_Data[REDPOS] = r;
+}
+
+inline void Pixel24::setG(unsigned char g)
+{
+ m_Data[GREENPOS] = g;
+}
+
+inline void Pixel24::setB(unsigned char b)
+{
+ m_Data[BLUEPOS] = b;
+}
+
+inline unsigned char Pixel24::getR() const
+{
+ return m_Data[REDPOS];
+}
+
+inline unsigned char Pixel24::getG() const
+{
+ return m_Data[GREENPOS];
+}
+
+inline unsigned char Pixel24::getB() const
+{
+ return m_Data[BLUEPOS];
+}
+
+inline void Pixel24::flipRB()
+{
+ unsigned char tmp = m_Data[BLUEPOS];
+ m_Data[BLUEPOS] = m_Data[REDPOS];
+ m_Data[REDPOS] = tmp;
+}
+
+inline int Pixel24::boxDist (const Pixel24 Pix) const
+{
+ return (abs ((int)getR()-Pix.getR()) +
+ abs ((int)getG()-Pix.getG()) +
+ abs ((int)getB()-Pix.getB()));
+}
+
+inline Pixel24 Pixel24::Blend (int Factor, const Pixel24 Pix1, const Pixel24 Pix2)
+{
+ AVG_ASSERT(Factor >= 0 && Factor <= 256);
+
+ return Pixel24 ((Pix1.getR()*Factor+Pix2.getR()*(256-Factor))>>8,
+ (Pix1.getG()*Factor+Pix2.getG()*(256-Factor))>>8,
+ (Pix1.getB()*Factor+Pix2.getB()*(256-Factor))>>8);
+}
+
+inline Pixel24::operator Pixel32 () const
+{
+ return Pixel32 (getR(), getG(), getB(), 255);
+}
+
+inline bool Pixel24::operator ==(const Pixel24& Pix) const
+{
+ return (getR() == Pix.getR() && getG() == Pix.getG() && getB() == Pix.getB());
+}
+
+inline bool Pixel24::operator !=(const Pixel24& Pix) const
+{
+ return (!(*this == Pix));
+}
+
+inline void Pixel24::operator += (const Pixel24& Pix)
+{
+ m_Data[0] += Pix.m_Data[0];
+ m_Data[1] += Pix.m_Data[1];
+ m_Data[2] += Pix.m_Data[2];
+}
+
+inline void Pixel24::operator -= (const Pixel24& Pix)
+{
+ m_Data[0] -= Pix.m_Data[0];
+ m_Data[1] -= Pix.m_Data[1];
+ m_Data[2] -= Pix.m_Data[2];
+}
+
+}
+#endif
diff --git a/src/graphics/Pixel32.cpp b/src/graphics/Pixel32.cpp
new file mode 100644
index 0000000..ccde488
--- /dev/null
+++ b/src/graphics/Pixel32.cpp
@@ -0,0 +1,132 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Pixel32.h"
+
+#include "../base/Exception.h"
+
+#include <string>
+#include <sstream>
+#include <iostream>
+#include <iomanip>
+#include <algorithm>
+#include <stdio.h>
+
+namespace avg {
+
+using namespace std;
+
+void Pixel32::toHSL(double& h, double& s, double& l)
+{
+ double r = double(m_Data[REDPOS])/255;
+ double g = double(m_Data[GREENPOS])/255;
+ double b = double(m_Data[BLUEPOS])/255;
+ double maxComp = max(r, max(g, b));
+ double minComp = min(r, min(g, b));
+ l = (maxComp+minComp)/2.0;
+ if (maxComp == minComp) {
+ s = 0.0;
+ h = 0.0;
+ } else {
+ double delta = maxComp-minComp;
+ if (l < 0.5) {
+ s = delta/(maxComp+minComp);
+ } else {
+ s = delta/(2.0-(maxComp+minComp));
+ }
+ if (r == maxComp) {
+ h = (g-b)/delta;
+ if (h < 0.0) {
+ h += 6.0;
+ }
+ } else if (g == maxComp) {
+ h = 2.0+(b-r)/delta;
+ } else if (b == maxComp) {
+ h = 4.0+(r-g)/delta;
+ }
+ h *= 60.0;
+ }
+}
+
+std::string Pixel32::getColorString() const
+{
+ stringstream s;
+ s.fill('0');
+ s << hex << setw(2) << (int)(m_Data[0]) << setw(2) << (int)(m_Data[1]) <<
+ setw(2) << (int)(m_Data[2]) << setw(2) << (int)(m_Data[3]);
+ return s.str();
+}
+
+Pixel32 colorStringToColor(const string & s)
+{
+ int r,g,b;
+ if ((s.length() != 6) || (sscanf(s.c_str(), "%2x%2x%2x", &r, &g, &b) != 3)) {
+ throw(Exception (AVG_ERR_INVALID_ARGS, "colorstring cannot be parsed."));
+ }
+ return Pixel32(r,g,b);
+}
+
+void YUVtoBGR32Pixel(Pixel32* pDest, int y, int u, int v)
+{
+ // u = Cb, v = Cr
+ int u1 = u - 128;
+ int v1 = v - 128;
+ int tempy = 298*(y-16);
+ int b = (tempy + 516 * u1 ) >> 8;
+ int g = (tempy - 100 * u1 - 208 * v1) >> 8;
+ int r = (tempy + 409 * v1) >> 8;
+
+ if (b<0) b = 0;
+ if (b>255) b= 255;
+ if (g<0) g = 0;
+ if (g>255) g= 255;
+ if (r<0) r = 0;
+ if (r>255) r= 255;
+ pDest->set(b,g,r,255);
+}
+
+void YUVJtoBGR32Pixel(Pixel32* pDest, int y, int u, int v)
+{
+ // u = Cb, v = Cr
+ int u1 = u - 128;
+ int v1 = v - 128;
+ int tempy = 256*y;
+ int b = (tempy + 452 * u1 ) >> 8;
+ int g = (tempy - 88 * u1 - 182 * v1) >> 8;
+ int r = (tempy + 358 * v1) >> 8;
+
+ if (b<0) b = 0;
+ if (b>255) b= 255;
+ if (g<0) g = 0;
+ if (g>255) g= 255;
+ if (r<0) r = 0;
+ if (r>255) r= 255;
+ pDest->set(b,g,r,255);
+}
+
+std::ostream& operator <<(std::ostream& os, const Pixel32& pix)
+{
+ os << pix.getColorString();
+ return os;
+}
+
+
+}
diff --git a/src/graphics/Pixel32.h b/src/graphics/Pixel32.h
new file mode 100644
index 0000000..ad9ff3e
--- /dev/null
+++ b/src/graphics/Pixel32.h
@@ -0,0 +1,207 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Pixel32_H_
+#define _Pixel32_H_
+
+#include "../api.h"
+
+#include "Pixeldefs.h"
+
+#include <string>
+#include <math.h>
+#include <stdlib.h>
+
+namespace avg {
+
+class Pixel32
+{
+
+public:
+ Pixel32();
+ Pixel32(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+ Pixel32(unsigned char r, unsigned char g, unsigned char b);
+ void set(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
+ void set(unsigned char r, unsigned char g, unsigned char b);
+ void setR(unsigned char r);
+ void setG(unsigned char g);
+ void setB(unsigned char b);
+ void setA(unsigned char a);
+ unsigned char getR() const;
+ unsigned char getG() const;
+ unsigned char getB() const;
+ unsigned char getA() const;
+ void flipRB();
+ void toHSL(double& h, double& s, double& l);
+
+ bool operator ==(const Pixel32 pix) const;
+ bool operator !=(const Pixel32 pix) const;
+ void operator +=(const Pixel32 pix);
+ void operator -=(const Pixel32 pix);
+ Pixel32 operator *(float f) const;
+
+ // Simple and fast 'distance' between two pixels. Just adds the
+ // distances between the color components and treats colors
+ // equally.
+ int boxDist(const Pixel32 pix) const;
+
+ std::string AVG_API getColorString() const;
+
+ private:
+ unsigned char m_Data[4];
+};
+
+AVG_API std::ostream& operator <<(std::ostream& os, const Pixel32& pix);
+
+AVG_API Pixel32 colorStringToColor(const std::string& s);
+
+void YUVtoBGR32Pixel(Pixel32* pDest, int y, int u, int v);
+void YUVJtoBGR32Pixel(Pixel32* pDest, int y, int u, int v);
+
+inline Pixel32::Pixel32()
+{
+}
+
+
+inline Pixel32::Pixel32(unsigned char r, unsigned char g, unsigned char b,
+ unsigned char a)
+{
+ set (r, g, b, a);
+}
+
+
+inline Pixel32::Pixel32(unsigned char r, unsigned char g, unsigned char b)
+{
+ set (r, g, b, 255);
+}
+
+
+inline void Pixel32::set(unsigned char r, unsigned char g, unsigned char b,
+ unsigned char a)
+{
+ m_Data[REDPOS] = r;
+ m_Data[GREENPOS] = g;
+ m_Data[BLUEPOS] = b;
+ m_Data[ALPHAPOS] = a;
+}
+
+inline void Pixel32::set(unsigned char r, unsigned char g, unsigned char b)
+{
+ m_Data[REDPOS] = r;
+ m_Data[GREENPOS] = g;
+ m_Data[BLUEPOS] = b;
+}
+
+inline void Pixel32::setR(unsigned char r)
+{
+ m_Data[REDPOS] = r;
+}
+
+
+inline void Pixel32::setG(unsigned char g)
+{
+ m_Data[GREENPOS] = g;
+}
+
+
+inline void Pixel32::setB(unsigned char b)
+{
+ m_Data[BLUEPOS] = b;
+}
+
+inline void Pixel32::setA(unsigned char a)
+{
+ m_Data[ALPHAPOS] = a;
+}
+
+
+inline unsigned char Pixel32::getR() const
+{
+ return m_Data[REDPOS];
+}
+
+
+inline unsigned char Pixel32::getG() const
+{
+ return m_Data[GREENPOS];
+}
+
+
+inline unsigned char Pixel32::getB() const
+{
+ return m_Data[BLUEPOS];
+}
+
+
+inline unsigned char Pixel32::getA() const
+{
+ return m_Data[ALPHAPOS];
+}
+
+inline void Pixel32::flipRB()
+{
+ unsigned char tmp = m_Data[BLUEPOS];
+ m_Data[BLUEPOS] = m_Data[REDPOS];
+ m_Data[REDPOS] = tmp;
+}
+
+inline int Pixel32::boxDist(const Pixel32 pix) const
+{
+ return (abs ((int)getR()-pix.getR()) +
+ abs ((int)getG()-pix.getG()) +
+ abs ((int)getB()-pix.getB()));
+}
+
+inline bool Pixel32::operator ==(const Pixel32 pix) const
+{
+ return (*(const int *)this == *(const int*)&pix);
+}
+
+inline bool Pixel32::operator !=(const Pixel32 pix) const
+{
+ return (!(*this == pix));
+}
+
+inline void Pixel32::operator +=(const Pixel32 pix)
+{
+ m_Data[0] += pix.m_Data[0];
+ m_Data[1] += pix.m_Data[1];
+ m_Data[2] += pix.m_Data[2];
+}
+
+inline void Pixel32::operator -=(const Pixel32 pix)
+{
+ m_Data[0] -= pix.m_Data[0];
+ m_Data[1] -= pix.m_Data[1];
+ m_Data[2] -= pix.m_Data[2];
+}
+
+inline Pixel32 Pixel32::operator *(float f) const
+{
+ return Pixel32((unsigned char)(f*getR()),
+ (unsigned char)(f*getG()),
+ (unsigned char)(f*getB()));
+}
+
+
+
+}
+#endif
diff --git a/src/graphics/Pixel8.h b/src/graphics/Pixel8.h
new file mode 100644
index 0000000..3581797
--- /dev/null
+++ b/src/graphics/Pixel8.h
@@ -0,0 +1,150 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Pixel8_H_
+#define _Pixel8_H_
+
+#include "../api.h"
+#include "Pixeldefs.h"
+#include "Pixel32.h"
+
+#include <stdlib.h>
+
+namespace avg {
+
+class AVG_API Pixel8
+{
+ public:
+ Pixel8 ();
+ Pixel8 (unsigned char i);
+ void set (unsigned char i);
+ unsigned char get () const;
+ unsigned char getR () const;
+ unsigned char getG () const;
+ unsigned char getB () const;
+ void flipRB();
+
+ template<class SrcPixel>
+ Pixel8 operator = (const SrcPixel& Pix)
+ {
+ set ((Pix.getR()*54+Pix.getG()*183+Pix.getB()*19)/256);
+ return *this;
+ }
+
+ Pixel8 operator = (const Pixel8& Pix)
+ {
+ set (Pix.get());
+ return *this;
+ }
+
+ operator Pixel32 () const;
+
+ bool operator ==(const Pixel8&) const;
+ bool operator !=(const Pixel8&) const;
+ void operator +=(const Pixel8&);
+ void operator -=(const Pixel8&);
+
+ // Simple and fast 'distance' between two pixels. Just adds the
+ // distances between the color components and treats colors
+ // equally.
+ int boxDist (const Pixel8 Pix) const;
+
+ // Returns a weighed average between two pixels. Factor must be
+ // between 0 and 256. Factor=256 means Pix1 is the result, Factor=0
+ // means Pix2 is the result.
+ static Pixel8 Blend (int Factor, const Pixel8 Pix1,
+ const Pixel8 Pix2);
+
+ private:
+ unsigned char m_i;
+};
+
+inline Pixel8::Pixel8()
+{
+}
+
+inline Pixel8::Pixel8(unsigned char i)
+{
+ set (i);
+}
+
+inline void Pixel8::set(unsigned char i)
+{
+ m_i = i;
+}
+
+inline unsigned char Pixel8::get() const
+{
+ return m_i;
+}
+
+inline unsigned char Pixel8::getR() const
+{
+ return m_i;
+}
+
+inline unsigned char Pixel8::getG() const
+{
+ return m_i;
+}
+
+inline unsigned char Pixel8::getB() const
+{
+ return m_i;
+}
+
+inline int Pixel8::boxDist (const Pixel8 Pix) const
+{
+ return (abs ((int)get()-Pix.get()));
+}
+
+inline Pixel8 Pixel8::Blend (int Factor, const Pixel8 Pix1, const Pixel8 Pix2)
+{
+ return Pixel8 ((Pix1.get()*Factor+Pix2.get()*(256-Factor))>>8);
+}
+
+inline Pixel8::operator Pixel32 () const
+{
+ return Pixel32 (m_i, m_i, m_i, 255);
+}
+
+inline bool Pixel8::operator ==(const Pixel8& Pix) const
+{
+ return (get() == Pix.get());
+}
+
+inline bool Pixel8::operator !=(const Pixel8& Pix) const
+{
+ return (!(*this == Pix));
+}
+
+inline void Pixel8::operator += (const Pixel8& Pix)
+{
+ m_i += Pix.m_i;
+}
+
+inline void Pixel8::operator -= (const Pixel8& Pix)
+{
+ m_i -= Pix.m_i;
+}
+
+}
+#endif
diff --git a/src/graphics/PixelFormat.cpp b/src/graphics/PixelFormat.cpp
new file mode 100644
index 0000000..2104713
--- /dev/null
+++ b/src/graphics/PixelFormat.cpp
@@ -0,0 +1,268 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "PixelFormat.h"
+
+#include "../base/StringHelper.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+#include <ostream>
+
+using namespace std;
+
+namespace avg {
+
+std::ostream& operator <<(std::ostream& os, PixelFormat pf)
+{
+ os << getPixelFormatString(pf);
+ return os;
+}
+
+string getPixelFormatString(PixelFormat pf)
+{
+ switch (pf) {
+ case B5G6R5:
+ return "B5G6R5";
+ case B8G8R8:
+ return "B8G8R8";
+ case B8G8R8A8:
+ return "B8G8R8A8";
+ case B8G8R8X8:
+ return "B8G8R8X8";
+ case A8B8G8R8:
+ return "A8B8G8R8";
+ case X8B8G8R8:
+ return "X8B8G8R8";
+ case R5G6B5:
+ return "R5G6B5";
+ case R8G8B8:
+ return "R8G8B8";
+ case R8G8B8A8:
+ return "R8G8B8A8";
+ case R8G8B8X8:
+ return "R8G8B8X8";
+ case A8R8G8B8:
+ return "A8R8G8B8";
+ case X8R8G8B8:
+ return "X8R8G8B8";
+ case I8:
+ return "I8";
+ case I16:
+ return "I16";
+ case YCbCr411:
+ return "YCbCr411";
+ case YCbCr422:
+ return "YCbCr422";
+ case YUYV422:
+ return "YUYV422";
+ case YCbCr420p:
+ return "YCbCr420p";
+ case YCbCrJ420p:
+ return "YCbCrJ420p";
+ case YCbCrA420p:
+ return "YCbCrA420p";
+ case BAYER8:
+ return "BAYER8";
+ case BAYER8_RGGB:
+ return "BAYER8_RGGB";
+ case BAYER8_GBRG:
+ return "BAYER8_GBRG";
+ case BAYER8_GRBG:
+ return "BAYER8_GRBG";
+ case BAYER8_BGGR:
+ return "BAYER8_BGGR";
+ case R32G32B32A32F:
+ return "R32G32B32A32F";
+ case I32F:
+ return "I32F";
+ case NO_PIXELFORMAT:
+ return "NO_PIXELFORMAT";
+ default:
+ return "Unknown " + toString(int(pf));
+ }
+}
+
+PixelFormat stringToPixelFormat(const string& s)
+{
+ if (s == "B5G6R5") {
+ return B5G6R5;
+ }
+ if (s == "B8G8R8" || s == "BGR") {
+ return B8G8R8;
+ }
+ if (s == "B8G8R8A8") {
+ return B8G8R8A8;
+ }
+ if (s == "B8G8R8X8") {
+ return B8G8R8X8;
+ }
+ if (s == "A8B8G8R8") {
+ return A8B8G8R8;
+ }
+ if (s == "X8B8G8R8") {
+ return X8B8G8R8;
+ }
+ if (s == "R5G6B5") {
+ return R5G6B5;
+ }
+ if (s == "R8G8B8" || s == "RGB") {
+ return R8G8B8;
+ }
+ if (s == "R8G8B8A8") {
+ return R8G8B8A8;
+ }
+ if (s == "R8G8B8X8") {
+ return R8G8B8X8;
+ }
+ if (s == "A8R8G8B8") {
+ return A8R8G8B8;
+ }
+ if (s == "X8R8G8B8") {
+ return X8R8G8B8;
+ }
+ if (s == "I8") {
+ return I8;
+ }
+ if (s == "I16") {
+ return I16;
+ }
+ if (s == "YCbCr411" || s == "YUV411") {
+ return YCbCr411;
+ }
+ if (s == "YCbCr422" || s == "YUV422") {
+ return YCbCr422;
+ }
+ if (s == "YUYV422") {
+ return YUYV422;
+ }
+ if (s == "YCbCr420p") {
+ return YCbCr420p;
+ }
+ if (s == "YCbCrJ420p") {
+ return YCbCrJ420p;
+ }
+ if (s == "YCbCrA420p") {
+ return YCbCrA420p;
+ }
+ if (s == "BAYER8") {
+ return BAYER8;
+ }
+ if (s == "BAYER8_RGGB") {
+ return BAYER8_RGGB;
+ }
+ if (s == "BAYER8_GBRG") {
+ return BAYER8_GBRG;
+ }
+ if (s == "BAYER8_GRBG") {
+ return BAYER8_GRBG;
+ }
+ if (s == "BAYER8_BGGR") {
+ return BAYER8_BGGR;
+ }
+ if (s == "R32G32B32A32F") {
+ return R32G32B32A32F;
+ }
+ if (s == "I32F") {
+ return I32F;
+ }
+ return NO_PIXELFORMAT;
+}
+
+bool pixelFormatIsColored(PixelFormat pf)
+{
+ return (pf != I8 && pf != I16 && pf != I32F);
+}
+
+bool pixelFormatIsBayer(PixelFormat pf)
+{
+ return (pf == BAYER8 || pf == BAYER8_RGGB || pf == BAYER8_GBRG
+ || pf == BAYER8_GRBG || pf == BAYER8_BGGR);
+}
+
+bool pixelFormatHasAlpha(PixelFormat pf)
+{
+ return pf == B8G8R8A8 || pf == A8B8G8R8 || pf == R8G8B8A8 || pf == A8R8G8B8 ||
+ pf == YCbCrA420p;
+}
+
+bool pixelFormatIsPlanar(PixelFormat pf)
+{
+ return pf == YCbCr420p || pf == YCbCrJ420p || pf == YCbCrA420p;
+}
+
+unsigned getNumPixelFormatPlanes(PixelFormat pf)
+{
+ switch (pf) {
+ case YCbCr420p:
+ case YCbCrJ420p:
+ return 3;
+ case YCbCrA420p:
+ return 4;
+ default:
+ return 1;
+ }
+}
+
+unsigned getBytesPerPixel(PixelFormat pf)
+{
+ switch (pf) {
+ case R32G32B32A32F:
+ return 16;
+ case A8B8G8R8:
+ case X8B8G8R8:
+ case A8R8G8B8:
+ case X8R8G8B8:
+ case B8G8R8A8:
+ case B8G8R8X8:
+ case R8G8B8A8:
+ case R8G8B8X8:
+ case I32F:
+ return 4;
+ case R8G8B8:
+ case B8G8R8:
+ return 3;
+ case B5G6R5:
+ case R5G6B5:
+ case I16:
+ return 2;
+ case I8:
+ case A8:
+ case BAYER8:
+ case BAYER8_RGGB:
+ case BAYER8_GBRG:
+ case BAYER8_GRBG:
+ case BAYER8_BGGR:
+ return 1;
+ case YUYV422:
+ case YCbCr422:
+ return 2;
+ default:
+ AVG_TRACE(Logger::ERROR, "getBytesPerPixel(): Unknown format " <<
+ getPixelFormatString(pf) << ".");
+ AVG_ASSERT(false);
+ return 0;
+ }
+}
+
+
+
+}
diff --git a/src/graphics/PixelFormat.h b/src/graphics/PixelFormat.h
new file mode 100644
index 0000000..a0e0816
--- /dev/null
+++ b/src/graphics/PixelFormat.h
@@ -0,0 +1,63 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _PixelFormat_H_
+#define _PixelFormat_H_
+
+#include "../api.h"
+#include <string>
+
+namespace avg {
+
+typedef enum {
+ B5G6R5, B8G8R8, B8G8R8A8, B8G8R8X8, A8B8G8R8, X8B8G8R8,
+ R5G6B5, R8G8B8, R8G8B8A8, R8G8B8X8, A8R8G8B8, X8R8G8B8,
+ I8, I16,
+ A8,
+ YCbCr411,
+ YCbCr422,
+ YUYV422,
+ YCbCr420p,
+ YCbCrJ420p,
+ YCbCrA420p,
+ BAYER8,
+ BAYER8_RGGB,
+ BAYER8_GBRG,
+ BAYER8_GRBG,
+ BAYER8_BGGR,
+ R32G32B32A32F, // 32bit per channel float rgba
+ I32F,
+ NO_PIXELFORMAT
+} PixelFormat;
+
+AVG_API std::ostream& operator <<(std::ostream& os, PixelFormat pf);
+
+std::string AVG_API getPixelFormatString(PixelFormat pf);
+PixelFormat AVG_API stringToPixelFormat(const std::string& s);
+bool AVG_API pixelFormatIsColored(PixelFormat pf);
+bool AVG_API pixelFormatIsBayer(PixelFormat pf);
+bool AVG_API pixelFormatHasAlpha(PixelFormat pf);
+bool AVG_API pixelFormatIsPlanar(PixelFormat pf);
+unsigned AVG_API getNumPixelFormatPlanes(PixelFormat pf);
+unsigned getBytesPerPixel(PixelFormat pf);
+
+}
+#endif
diff --git a/src/graphics/Pixeldefs.h b/src/graphics/Pixeldefs.h
new file mode 100644
index 0000000..c9fad2e
--- /dev/null
+++ b/src/graphics/Pixeldefs.h
@@ -0,0 +1,29 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Pixeldefs_H_
+#define _Pixeldefs_H_
+
+#define PIXEL_RGBA_ORDER
+
+enum {REDPOS=0, GREENPOS=1, BLUEPOS=2, ALPHAPOS=3};
+
+#endif
diff --git a/src/graphics/ShaderRegistry.cpp b/src/graphics/ShaderRegistry.cpp
new file mode 100644
index 0000000..540a391
--- /dev/null
+++ b/src/graphics/ShaderRegistry.cpp
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ShaderRegistry.h"
+
+#include "GLContext.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+ShaderRegistryPtr ShaderRegistry::get()
+{
+ return GLContext::getCurrent()->getShaderRegistry();
+}
+
+ShaderRegistry::ShaderRegistry()
+{
+}
+
+ShaderRegistry::~ShaderRegistry()
+{
+}
+
+OGLShaderPtr ShaderRegistry::getOrCreateShader(const std::string& sID,
+ const std::string& sProgram)
+{
+ OGLShaderPtr pShader = getShader(sID);
+ if (!pShader) {
+ m_ShaderMap[sID] = OGLShaderPtr(new OGLShader(sProgram));
+ }
+ return pShader;
+}
+
+OGLShaderPtr ShaderRegistry::getShader(const std::string& sID)
+{
+ ShaderMap::iterator it = m_ShaderMap.find(sID);
+ if (it == m_ShaderMap.end()) {
+ return OGLShaderPtr();
+ } else {
+ return it->second;
+ }
+}
+
+OGLShaderPtr getOrCreateShader(const std::string& sID, const std::string& sProgram)
+{
+ return ShaderRegistry::get()->getOrCreateShader(sID, sProgram);
+}
+
+OGLShaderPtr getShader(const std::string& sID)
+{
+ return ShaderRegistry::get()->getShader(sID);
+}
+
+}
+
diff --git a/src/graphics/ShaderRegistry.h b/src/graphics/ShaderRegistry.h
new file mode 100644
index 0000000..07de0bb
--- /dev/null
+++ b/src/graphics/ShaderRegistry.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ShaderRegistry_H_
+#define _ShaderRegistry_H_
+
+#include "../api.h"
+
+#include "OGLShader.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <map>
+
+namespace avg {
+
+class ShaderRegistry;
+typedef boost::shared_ptr<ShaderRegistry> ShaderRegistryPtr;
+
+class AVG_API ShaderRegistry {
+public:
+ static ShaderRegistryPtr get();
+ ShaderRegistry();
+ virtual ~ShaderRegistry();
+
+ OGLShaderPtr getOrCreateShader(const std::string& sID, const std::string& sProgram);
+ OGLShaderPtr getShader(const std::string& sID);
+
+private:
+ typedef std::map<std::string, OGLShaderPtr> ShaderMap;
+ ShaderMap m_ShaderMap;
+
+};
+
+OGLShaderPtr getOrCreateShader(const std::string& sID, const std::string& sProgram);
+OGLShaderPtr getShader(const std::string& sID);
+
+
+}
+
+#endif
diff --git a/src/graphics/TextureMover.cpp b/src/graphics/TextureMover.cpp
new file mode 100644
index 0000000..92ea55b
--- /dev/null
+++ b/src/graphics/TextureMover.cpp
@@ -0,0 +1,77 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TextureMover.h"
+#include "PBO.h"
+#include "BmpTextureMover.h"
+#include "GLContext.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <cstring>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+TextureMoverPtr TextureMover::create(OGLMemoryMode memoryMode, IntPoint size,
+ PixelFormat pf, unsigned usage)
+{
+ switch (memoryMode) {
+ case MM_PBO:
+ return TextureMoverPtr(new PBO(size, pf, usage));
+ case MM_OGL:
+ return TextureMoverPtr(new BmpTextureMover(size, pf));
+ default:
+ AVG_ASSERT(false);
+ return TextureMoverPtr();
+ }
+}
+
+TextureMoverPtr TextureMover::create(IntPoint size, PixelFormat pf, unsigned usage)
+{
+ OGLMemoryMode memMode = GLContext::getCurrent()->getMemoryModeSupported();
+ return create(memMode, size, pf, usage);
+}
+
+TextureMover::TextureMover(const IntPoint& size, PixelFormat pf)
+ : m_Size(size),
+ m_pf(pf)
+{
+}
+
+TextureMover::~TextureMover()
+{
+}
+
+PixelFormat TextureMover::getPF() const
+{
+ return m_pf;
+}
+
+const IntPoint& TextureMover::getSize() const
+{
+ return m_Size;
+}
+
+}
diff --git a/src/graphics/TextureMover.h b/src/graphics/TextureMover.h
new file mode 100644
index 0000000..571286e
--- /dev/null
+++ b/src/graphics/TextureMover.h
@@ -0,0 +1,71 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TextureMover_H_
+#define _TextureMover_H_
+
+#include "../api.h"
+#include "PixelFormat.h"
+#include "OGLHelper.h"
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class Bitmap;
+typedef boost::shared_ptr<Bitmap> BitmapPtr;
+class GLTexture;
+typedef boost::shared_ptr<GLTexture> GLTexturePtr;
+
+class TextureMover;
+typedef boost::shared_ptr<TextureMover> TextureMoverPtr;
+
+class AVG_API TextureMover {
+public:
+ static TextureMoverPtr create(OGLMemoryMode memoryMode, IntPoint size, PixelFormat pf,
+ unsigned usage);
+ static TextureMoverPtr create(IntPoint size, PixelFormat pf, unsigned usage);
+
+ TextureMover(const IntPoint& size, PixelFormat pf);
+ virtual ~TextureMover();
+
+ virtual void moveBmpToTexture(BitmapPtr pBmp, GLTexture& tex) = 0;
+ virtual BitmapPtr moveTextureToBmp(GLTexture& tex, int mipmapLevel=0) = 0;
+
+ virtual BitmapPtr lock() = 0;
+ virtual void unlock() = 0;
+ virtual void moveToTexture(GLTexture& tex) = 0;
+
+ PixelFormat getPF() const;
+ const IntPoint& getSize() const;
+
+private:
+ IntPoint m_Size;
+ PixelFormat m_pf;
+};
+
+}
+
+#endif
+
+
diff --git a/src/graphics/TwoPassScale.h b/src/graphics/TwoPassScale.h
new file mode 100644
index 0000000..2f8348a
--- /dev/null
+++ b/src/graphics/TwoPassScale.h
@@ -0,0 +1,354 @@
+// Fast and accurate bitmap scaling. Original code by Eran Yariv and Jake Montgomery,
+// posted on codeguru.com.
+
+#ifndef _TwoPassScale_h_
+#define _TwoPassScale_h_
+
+#include "ContribDefs.h"
+
+#include "../base/Exception.h"
+
+#include <math.h>
+#include <algorithm>
+#include <cstring>
+
+namespace avg {
+
+typedef struct
+{
+ int *Weights; // Normalized weights of neighboring pixels
+ int Left,Right; // Bounds of source pixels window
+} ContributionType; // Contirbution information for a single pixel
+
+typedef struct
+{
+ ContributionType *ContribRow; // Row (or column) of contribution weights
+ int WindowSize, // Filter window size (of affecting source pixels)
+ LineLength; // Length of line (no. or rows / cols)
+} LineContribType; // Contribution information for an entire line (row or column)
+
+class CDataA_UBYTE
+{
+public:
+ typedef unsigned char PixelClass;
+ class _Accumulator {
+ public:
+ _Accumulator ()
+ {
+ val = 0;
+ };
+ void Accumulate (int Weight, PixelClass &value)
+ {
+ val += (Weight * value);
+ };
+
+ void Store (PixelClass* value)
+ {
+ *value = (unsigned char) ((val + 128)/256);
+ };
+ int val;
+ };
+};
+
+class CDataRGB_UBYTE
+{
+public:
+ typedef unsigned char PixelClass[3];
+ class _Accumulator {
+ public:
+ _Accumulator ()
+ {
+ val [0] = val [1] = val [2] = 0;
+ };
+ void Accumulate (int Weight, PixelClass &value)
+ {
+ val [0] += (Weight * value [0]);
+ val [1] += (Weight * value [1]);
+ val [2] += (Weight * value [2]);
+ };
+
+ void Store (PixelClass* value)
+ {
+ (*value) [0] = (unsigned char) ((val [0] + 128)/256);
+ (*value) [1] = (unsigned char) ((val [1] + 128)/256);
+ (*value) [2] = (unsigned char) ((val [2] + 128)/256);
+ };
+ int val [3];
+ };
+};
+
+class CDataRGBA_UBYTE {
+public:
+ typedef unsigned char PixelClass[4];
+ class _Accumulator {
+ public:
+ _Accumulator ()
+ {
+ val [0] = val [1] = val [2] = val [3] = 0;
+ };
+ void Accumulate (int dWeight, PixelClass &value)
+ {
+ val [0] += (dWeight * (value [0]));
+ val [1] += (dWeight * (value [1]));
+ val [2] += (dWeight * (value [2]));
+ val [3] += (dWeight * (value [3]));
+ };
+
+ void Store (PixelClass* value)
+ {
+ (*value) [0] = (unsigned char) ((val [0] + 128)/256);
+ (*value) [1] = (unsigned char) ((val [1] + 128)/256);
+ (*value) [2] = (unsigned char) ((val [2] + 128)/256);
+ (*value) [3] = (unsigned char) ((val [3] + 128)/256);
+ };
+ int val [4];
+ };
+};
+
+template <class DataClass>
+class TwoPassScale
+{
+public:
+ typedef typename DataClass::PixelClass PixelClass;
+
+ TwoPassScale (const ContribDef& contribDef)
+ : m_ContribDef (contribDef)
+ {};
+
+ virtual ~TwoPassScale() {};
+
+ void Scale(PixelClass * pSrcData, const IntPoint& srcSize, int srcStride,
+ PixelClass *pDstData, const IntPoint& dstSize, int dstStride);
+
+private:
+ LineContribType *AllocContributions (unsigned uLineLength,
+ unsigned uWindowSize);
+
+ void FreeContributions (LineContribType * p);
+
+ LineContribType *CalcContributions (unsigned uLineSize,
+ unsigned uSrcSize);
+
+ void ScaleRow(PixelClass *pSrc, int uSrcWidth, PixelClass *pDest, int uResWidth,
+ LineContribType *pContrib);
+
+ void HorizScale(PixelClass * pSrcData, const IntPoint& srcSize, int srcStride,
+ PixelClass *pDestData, const IntPoint& destSize, int destStride);
+
+ void VertScale(PixelClass *pSrcData, const IntPoint& srcSize, int srcStride,
+ PixelClass *pDestData, const IntPoint& destSize, int destStride);
+
+ const ContribDef& m_ContribDef;
+};
+
+template <class DataClass>
+LineContribType *
+TwoPassScale<DataClass>::AllocContributions (unsigned uLineLength, unsigned uWindowSize)
+{
+ LineContribType *res = new LineContribType;
+ // Init structure header
+ res->WindowSize = uWindowSize;
+ res->LineLength = uLineLength;
+ // Allocate list of contributions
+ res->ContribRow = new ContributionType[uLineLength];
+ for (unsigned u = 0 ; u < uLineLength ; u++)
+ {
+ // Allocate contributions for every pixel
+ res->ContribRow[u].Weights = new int[uWindowSize];
+ }
+ return res;
+}
+
+template <class DataClass>
+void
+TwoPassScale<DataClass>::FreeContributions (LineContribType * p)
+{
+ for (int u = 0; u < p->LineLength; u++)
+ {
+ // Free contribs for every pixel
+ delete [] p->ContribRow[u].Weights;
+ }
+ delete [] p->ContribRow; // Free list of pixels contribs
+ delete p; // Free contribs header
+}
+
+template <class DataClass>
+LineContribType *
+TwoPassScale<DataClass>::CalcContributions(unsigned uLineSize, unsigned uSrcSize)
+{
+ double dScale = double(uLineSize)/uSrcSize;
+ double dWidth;
+ double dFScale = 1.0;
+ double dFilterWidth = m_ContribDef.GetWidth();
+
+ if (dScale < 1.0) {
+ // Minification
+ dWidth = dFilterWidth / dScale;
+ dFScale = dScale;
+ } else {
+ // Magnification
+ dWidth= dFilterWidth;
+ }
+
+ // Window size is the number of sampled pixels
+ int iWindowSize = 2 * (int)ceil(dWidth) + 1;
+
+ // Allocate a new line contributions strucutre
+ LineContribType *res = AllocContributions (uLineSize, iWindowSize);
+
+ for (unsigned u = 0; u < uLineSize; u++) {
+ // Scan through line of contributions
+ double dCenter = (u+0.5)/dScale-0.5; // Reverse mapping
+ // Find the significant edge points that affect the pixel
+ int iLeft = std::max (0, (int)floor (dCenter - dWidth));
+ int iRight = std::min ((int)ceil (dCenter + dWidth), int(uSrcSize) - 1);
+
+ // Cut edge points to fit in filter window in case of spill-off
+ if (iRight - iLeft + 1 > iWindowSize) {
+ if (iLeft < (int(uSrcSize) - 1 / 2)) {
+ iLeft++;
+ } else {
+ iRight--;
+ }
+ }
+ res->ContribRow[u].Left = iLeft;
+ res->ContribRow[u].Right = iRight;
+
+ int dTotalWeight = 0; // Zero sum of weights
+ for (int iSrc = iLeft; iSrc <= iRight; iSrc++) {
+ // Calculate weights
+ int CurWeight = int (dFScale * (m_ContribDef.Filter (dFScale *
+ (dCenter - (double)iSrc)))*256);
+ res->ContribRow[u].Weights[iSrc-iLeft] = CurWeight;
+ dTotalWeight += CurWeight;
+ }
+ AVG_ASSERT(dTotalWeight >= 0); // An error in the filter function can cause this
+ int UsedWeight = 0;
+ if (dTotalWeight > 0) {
+ // Normalize weight of neighbouring points
+ for (int iSrc = iLeft; iSrc < iRight; iSrc++) {
+ // Normalize point
+ int CurWeight = (res->ContribRow[u].Weights[iSrc-iLeft]*256)/dTotalWeight;
+ res->ContribRow[u].Weights[iSrc-iLeft] = CurWeight;
+ UsedWeight += CurWeight;
+ }
+ // The last point gets everything that's left over so the sum is
+ // always correct.
+ res->ContribRow[u].Weights[iRight-iLeft] = 256 - UsedWeight;
+ }
+ }
+ return res;
+}
+
+template <class DataClass>
+void
+TwoPassScale<DataClass>::ScaleRow(PixelClass *pSrc, int uSrcWidth,
+ PixelClass *pDest, int uResWidth, LineContribType *pContrib)
+{
+ PixelClass * pDestPixel = pDest;
+ for (int x = 0; x < uResWidth; x++) {
+ typename DataClass::_Accumulator a;
+ int iLeft = pContrib->ContribRow[x].Left; // Retrieve left boundries
+ int iRight = pContrib->ContribRow[x].Right; // Retrieve right boundries
+ int * Weights = pContrib->ContribRow[x].Weights;
+ for (int i = iLeft; i <= iRight; i++) {
+ // Scan between boundries
+ // Accumulate weighted effect of each neighboring pixel
+ a.Accumulate(Weights[i-iLeft], pSrc[i]);
+ }
+ a.Store(pDestPixel);
+ pDestPixel++;
+ }
+}
+
+template <class DataClass>
+void TwoPassScale<DataClass>::HorizScale(PixelClass * pSrcData, const IntPoint& srcSize,
+ int srcStride, PixelClass *pDestData, const IntPoint& destSize, int destStride)
+{
+ PixelClass * pSrc = pSrcData;
+ PixelClass * pDest = pDestData;
+ if (srcSize.x == destSize.x) {
+ // No scaling required, just copy
+ for (int y = 0; y < destSize.y; y++) {
+ memcpy(pDest, pSrc, sizeof (PixelClass) * srcSize.x);
+ pSrc += srcStride;
+ pDest += destStride;
+ }
+ } else {
+ LineContribType * pContrib = CalcContributions(destSize.x, srcSize.x);
+ for (int y = 0; y < destSize.y; y++) {
+ ScaleRow(pSrc, srcSize.x, pDest, destSize.x, pContrib);
+ pSrc += srcStride;
+ pDest += destStride;
+ }
+ FreeContributions(pContrib); // Free contributions structure
+ }
+}
+
+
+template <class DataClass>
+void TwoPassScale<DataClass>::VertScale(PixelClass *pSrcData, const IntPoint& srcSize,
+ int srcStride, PixelClass *pDestData, const IntPoint& destSize, int destStride)
+{
+ PixelClass * pSrc = pSrcData;
+ PixelClass * pDest = pDestData;
+ if (srcSize.y == destSize.y) {
+ // No scaling required, just copy
+ for (int y = 0; y < destSize.y; y++) {
+ memcpy(pDest, pSrc, sizeof (PixelClass) * srcSize.x);
+ pSrc += srcStride;
+ pDest += destStride;
+ }
+ } else {
+ LineContribType * pContrib = CalcContributions(destSize.y, srcSize.y);
+ for (int y = 0; y < destSize.y; y++) {
+ PixelClass * pDestPixel = pDest;
+ int * pWeights = pContrib->ContribRow[y].Weights;
+ int iLeft = pContrib->ContribRow[y].Left;
+ int iRight = pContrib->ContribRow[y].Right;
+ PixelClass * pSrcPixelBase = pSrc+iLeft*srcStride;
+ for (int x = 0; x < destSize.x; x++) {
+ typename DataClass::_Accumulator a;
+ int * pWeight = pWeights;
+ PixelClass * pSrcPixel = pSrcPixelBase;
+ pSrcPixelBase++;
+ for (int i = iLeft; i <= iRight; i++) {
+ // Scan between boundries
+ // Accumulate weighted effect of each neighboring pixel
+ a.Accumulate(*pWeight, *pSrcPixel);
+ pWeight++;
+ pSrcPixel += srcStride;
+ }
+ a.Store(pDestPixel);
+ pDestPixel++;
+ }
+ pDest += destStride;
+ }
+ FreeContributions(pContrib); // Free contributions structure
+ }
+}
+
+
+template <class DataClass>
+void TwoPassScale<DataClass>::Scale(PixelClass * pSrcData, const IntPoint& srcSize,
+ int srcStride, PixelClass *pDstData, const IntPoint& dstSize, int dstStride)
+{
+ // Allocate temp image
+ PixelClass *pTempData = new PixelClass[srcSize.y*dstSize.x];
+ IntPoint tempSize(dstSize.x, srcSize.y);
+ int tempStride = dstSize.x;
+
+ // Scale source image horizontally into temporary image
+ HorizScale(pSrcData, srcSize, srcStride/sizeof(PixelClass),
+ pTempData, tempSize, tempStride);
+
+ // Scale temporary image vertically into result image
+ VertScale (pTempData, tempSize, tempStride,
+ pDstData, dstSize, dstStride/sizeof(PixelClass));
+ delete [] pTempData;
+}
+
+}
+
+#endif
+
diff --git a/src/graphics/VertexArray.cpp b/src/graphics/VertexArray.cpp
new file mode 100644
index 0000000..2b658e1
--- /dev/null
+++ b/src/graphics/VertexArray.cpp
@@ -0,0 +1,230 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VertexArray.h"
+
+#include "GLContext.h"
+
+#include "../base/Exception.h"
+#include "../base/WideLine.h"
+#include "../base/ObjectCounter.h"
+
+#include <iostream>
+#include <stddef.h>
+#include <string.h>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+const int MIN_VERTEXES = 100;
+const int MIN_INDEXES = 100;
+
+VertexArray::VertexArray(int reserveVerts, int reserveIndexes)
+ : m_NumVerts(0),
+ m_NumIndexes(0),
+ m_ReserveVerts(reserveVerts),
+ m_ReserveIndexes(reserveIndexes),
+ m_bDataChanged(true)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ if (m_ReserveVerts < MIN_VERTEXES) {
+ m_ReserveVerts = MIN_VERTEXES;
+ }
+ if (m_ReserveIndexes < MIN_INDEXES) {
+ m_ReserveIndexes = MIN_INDEXES;
+ }
+ m_pVertexData = new T2V3C4Vertex[m_ReserveVerts];
+ m_pIndexData = new unsigned int[m_ReserveIndexes];
+
+ if (m_ReserveVerts != MIN_VERTEXES || m_ReserveIndexes != MIN_INDEXES) {
+ glproc::GenBuffers(1, &m_GLVertexBufferID);
+ glproc::GenBuffers(1, &m_GLIndexBufferID);
+ } else {
+ GLContext* pContext = GLContext::getCurrent();
+ m_GLVertexBufferID = pContext->getVertexBufferCache().getBuffer();
+ m_GLIndexBufferID = pContext->getIndexBufferCache().getBuffer();
+ }
+}
+
+VertexArray::~VertexArray()
+{
+ GLContext* pContext = GLContext::getCurrent();
+ if (pContext) {
+ if (m_ReserveVerts == MIN_VERTEXES) {
+ pContext->getVertexBufferCache().returnBuffer(m_GLVertexBufferID);
+ } else {
+ glproc::DeleteBuffers(1, &m_GLVertexBufferID);
+ }
+ if (m_ReserveIndexes == MIN_INDEXES) {
+ pContext->getIndexBufferCache().returnBuffer(m_GLIndexBufferID);
+ } else {
+ glproc::DeleteBuffers(1, &m_GLIndexBufferID);
+ }
+ }
+ delete[] m_pVertexData;
+ delete[] m_pIndexData;
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void VertexArray::appendPos(const DPoint& pos, const DPoint& texPos, const Pixel32& color)
+{
+ if (m_NumVerts >= m_ReserveVerts-1) {
+ grow();
+ }
+ T2V3C4Vertex* pVertex = &(m_pVertexData[m_NumVerts]);
+ pVertex->m_Pos[0] = (GLfloat)pos.x;
+ pVertex->m_Pos[1] = (GLfloat)pos.y;
+ pVertex->m_Pos[2] = 0.0;
+ pVertex->m_Tex[0] = (GLfloat)texPos.x;
+ pVertex->m_Tex[1] = (GLfloat)texPos.y;
+ pVertex->m_Color = color;
+ m_bDataChanged = true;
+ m_NumVerts++;
+}
+
+void VertexArray::appendTriIndexes(int v0, int v1, int v2)
+{
+ if (m_NumIndexes >= m_ReserveIndexes-3) {
+ grow();
+ }
+ m_pIndexData[m_NumIndexes] = v0;
+ m_pIndexData[m_NumIndexes+1] = v1;
+ m_pIndexData[m_NumIndexes+2] = v2;
+ m_NumIndexes += 3;
+}
+
+void VertexArray::appendQuadIndexes(int v0, int v1, int v2, int v3)
+{
+ if (m_NumIndexes >= m_ReserveIndexes-6) {
+ grow();
+ }
+ m_pIndexData[m_NumIndexes] = v0;
+ m_pIndexData[m_NumIndexes+1] = v1;
+ m_pIndexData[m_NumIndexes+2] = v2;
+ m_pIndexData[m_NumIndexes+3] = v1;
+ m_pIndexData[m_NumIndexes+4] = v2;
+ m_pIndexData[m_NumIndexes+5] = v3;
+ m_NumIndexes += 6;
+}
+
+void VertexArray::addLineData(Pixel32 color, const DPoint& p1, const DPoint& p2,
+ double width, double tc1, double tc2)
+{
+ WideLine wl(p1, p2, width);
+ int curVertex = getCurVert();
+ appendPos(wl.pl0, DPoint(tc1, 1), color);
+ appendPos(wl.pr0, DPoint(tc1, 0), color);
+ appendPos(wl.pl1, DPoint(tc2, 1), color);
+ appendPos(wl.pr1, DPoint(tc2, 0), color);
+ appendQuadIndexes(curVertex+1, curVertex, curVertex+3, curVertex+2);
+}
+
+void VertexArray::reset()
+{
+ m_NumVerts = 0;
+ m_NumIndexes = 0;
+}
+
+void VertexArray::update()
+{
+ if (m_bDataChanged) {
+ glproc::BindBuffer(GL_ARRAY_BUFFER, m_GLVertexBufferID);
+ glproc::BufferData(GL_ARRAY_BUFFER, m_ReserveVerts*sizeof(T2V3C4Vertex), 0,
+ GL_DYNAMIC_DRAW);
+ void * pBuffer = glproc::MapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
+ memcpy(pBuffer, m_pVertexData, m_NumVerts*sizeof(T2V3C4Vertex));
+ glproc::UnmapBuffer(GL_ARRAY_BUFFER);
+
+ glproc::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_GLIndexBufferID);
+ glproc::BufferData(GL_ELEMENT_ARRAY_BUFFER,
+ m_ReserveIndexes*sizeof(unsigned int), 0, GL_DYNAMIC_DRAW);
+ pBuffer = glproc::MapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY);
+ memcpy(pBuffer, m_pIndexData, m_NumIndexes*sizeof(unsigned int));
+ glproc::UnmapBuffer(GL_ELEMENT_ARRAY_BUFFER);
+
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "VertexArray::update");
+ }
+ m_bDataChanged = false;
+}
+
+void VertexArray::draw()
+{
+ update();
+ glproc::BindBuffer(GL_ARRAY_BUFFER, m_GLVertexBufferID);
+ glTexCoordPointer(2, GL_FLOAT, sizeof(T2V3C4Vertex), 0);
+ glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(T2V3C4Vertex),
+ (void *)(offsetof(T2V3C4Vertex, m_Color)));
+ glVertexPointer(3, GL_FLOAT, sizeof(T2V3C4Vertex),
+ (void *)(offsetof(T2V3C4Vertex, m_Pos)));
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "VertexArray::draw:1");
+
+ glproc::BindBuffer(GL_ELEMENT_ARRAY_BUFFER, m_GLIndexBufferID);
+ // TODO: glDrawRangeElements is allegedly faster.
+ glDrawElements(GL_TRIANGLES, m_NumIndexes, GL_UNSIGNED_INT, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "VertexArray::draw():2");
+}
+
+int VertexArray::getCurVert() const
+{
+ return m_NumVerts;
+}
+
+int VertexArray::getCurIndex() const
+{
+ return m_NumIndexes;
+}
+
+void VertexArray::grow()
+{
+ bool bChanged = false;
+ if (m_NumVerts >= m_ReserveVerts-1) {
+ bChanged = true;
+ int oldReserveVerts = m_ReserveVerts;
+ m_ReserveVerts = int(m_ReserveVerts*1.5);
+ if (m_ReserveVerts < m_NumVerts) {
+ m_ReserveVerts = m_NumVerts;
+ }
+ T2V3C4Vertex* pVertexData = m_pVertexData;
+ m_pVertexData = new T2V3C4Vertex[m_ReserveVerts];
+ memcpy(m_pVertexData, pVertexData, sizeof(T2V3C4Vertex)*oldReserveVerts);
+ delete[] pVertexData;
+ }
+ if (m_NumIndexes >= m_ReserveIndexes-6) {
+ bChanged = true;
+ int oldReserveIndexes = m_ReserveIndexes;
+ m_ReserveIndexes = int(m_ReserveIndexes*1.5);
+ if (m_ReserveIndexes < m_NumIndexes) {
+ m_ReserveIndexes = m_NumIndexes;
+ }
+ unsigned int * pIndexData = m_pIndexData;
+ m_pIndexData = new unsigned int[m_ReserveIndexes];
+ memcpy(m_pIndexData, pIndexData, sizeof(unsigned int)*oldReserveIndexes);
+ delete[] pIndexData;
+ }
+ if (bChanged) {
+ m_bDataChanged = true;
+ }
+}
+
+}
+
diff --git a/src/graphics/VertexArray.h b/src/graphics/VertexArray.h
new file mode 100644
index 0000000..5db9e4f
--- /dev/null
+++ b/src/graphics/VertexArray.h
@@ -0,0 +1,82 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VertexArray_H_
+#define _VertexArray_H_
+
+#include "../api.h"
+
+#include "Pixel32.h"
+#include "OGLHelper.h"
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+struct T2V3C4Vertex {
+ GLfloat m_Tex[2];
+ Pixel32 m_Color;
+ GLfloat m_Pos[3];
+};
+
+class AVG_API VertexArray {
+public:
+ VertexArray(int reserveVerts = 0, int reserveIndexes = 0);
+ virtual ~VertexArray();
+
+ virtual void appendPos(const DPoint& pos,
+ const DPoint& texPos, const Pixel32& color = Pixel32(0,0,0,0));
+ void appendTriIndexes(int v0, int v1, int v2);
+ void appendQuadIndexes(int v0, int v1, int v2, int v3);
+ void addLineData(Pixel32 color, const DPoint& p1, const DPoint& p2, double width,
+ double tc1=0, double tc2=1);
+ void reset();
+
+ void update();
+ void draw();
+
+ int getCurVert() const;
+ int getCurIndex() const;
+ void dump() const;
+
+private:
+ void grow();
+
+ int m_NumVerts;
+ int m_NumIndexes;
+ int m_ReserveVerts;
+ int m_ReserveIndexes;
+ T2V3C4Vertex * m_pVertexData;
+ unsigned int * m_pIndexData;
+
+ bool m_bDataChanged;
+
+ unsigned int m_GLVertexBufferID;
+ unsigned int m_GLIndexBufferID;
+};
+
+typedef boost::shared_ptr<VertexArray> VertexArrayPtr;
+
+}
+
+#endif
diff --git a/src/graphics/baseline/BandpassResult.png b/src/graphics/baseline/BandpassResult.png
new file mode 100644
index 0000000..d931127
--- /dev/null
+++ b/src/graphics/baseline/BandpassResult.png
Binary files differ
diff --git a/src/graphics/baseline/BlurResult.png b/src/graphics/baseline/BlurResult.png
new file mode 100644
index 0000000..2875491
--- /dev/null
+++ b/src/graphics/baseline/BlurResult.png
Binary files differ
diff --git a/src/graphics/baseline/ChromaKeyMedianResult.png b/src/graphics/baseline/ChromaKeyMedianResult.png
new file mode 100644
index 0000000..8112708
--- /dev/null
+++ b/src/graphics/baseline/ChromaKeyMedianResult.png
Binary files differ
diff --git a/src/graphics/baseline/ChromaKeyResult0.png b/src/graphics/baseline/ChromaKeyResult0.png
new file mode 100644
index 0000000..e78bd88
--- /dev/null
+++ b/src/graphics/baseline/ChromaKeyResult0.png
Binary files differ
diff --git a/src/graphics/baseline/ChromaKeyResult1.png b/src/graphics/baseline/ChromaKeyResult1.png
new file mode 100644
index 0000000..79e6be9
--- /dev/null
+++ b/src/graphics/baseline/ChromaKeyResult1.png
Binary files differ
diff --git a/src/graphics/baseline/ChromaKeyResult2.png b/src/graphics/baseline/ChromaKeyResult2.png
new file mode 100644
index 0000000..4c08c24
--- /dev/null
+++ b/src/graphics/baseline/ChromaKeyResult2.png
Binary files differ
diff --git a/src/graphics/baseline/ChromaKeySpillResult1.png b/src/graphics/baseline/ChromaKeySpillResult1.png
new file mode 100644
index 0000000..bbafa78
--- /dev/null
+++ b/src/graphics/baseline/ChromaKeySpillResult1.png
Binary files differ
diff --git a/src/graphics/baseline/ChromaKeySpillResult2.png b/src/graphics/baseline/ChromaKeySpillResult2.png
new file mode 100644
index 0000000..71b65cf
--- /dev/null
+++ b/src/graphics/baseline/ChromaKeySpillResult2.png
Binary files differ
diff --git a/src/graphics/baseline/ChromaKeySpillResult3.png b/src/graphics/baseline/ChromaKeySpillResult3.png
new file mode 100644
index 0000000..65f7ab7
--- /dev/null
+++ b/src/graphics/baseline/ChromaKeySpillResult3.png
Binary files differ
diff --git a/src/graphics/baseline/DilationResult.png b/src/graphics/baseline/DilationResult.png
new file mode 100644
index 0000000..bfa45d8
--- /dev/null
+++ b/src/graphics/baseline/DilationResult.png
Binary files differ
diff --git a/src/graphics/baseline/ErosionResult.png b/src/graphics/baseline/ErosionResult.png
new file mode 100644
index 0000000..5b8042d
--- /dev/null
+++ b/src/graphics/baseline/ErosionResult.png
Binary files differ
diff --git a/src/graphics/baseline/FastBandpassResult.png b/src/graphics/baseline/FastBandpassResult.png
new file mode 100644
index 0000000..048e358
--- /dev/null
+++ b/src/graphics/baseline/FastBandpassResult.png
Binary files differ
diff --git a/src/graphics/baseline/FastDownscaleResult.png b/src/graphics/baseline/FastDownscaleResult.png
new file mode 100644
index 0000000..bf11cf6
--- /dev/null
+++ b/src/graphics/baseline/FastDownscaleResult.png
Binary files differ
diff --git a/src/graphics/baseline/FloodfillResult.png b/src/graphics/baseline/FloodfillResult.png
new file mode 100644
index 0000000..2a6fd14
--- /dev/null
+++ b/src/graphics/baseline/FloodfillResult.png
Binary files differ
diff --git a/src/graphics/baseline/Gauss15Result.png b/src/graphics/baseline/Gauss15Result.png
new file mode 100644
index 0000000..6d90b6e
--- /dev/null
+++ b/src/graphics/baseline/Gauss15Result.png
Binary files differ
diff --git a/src/graphics/baseline/Gauss1Result.png b/src/graphics/baseline/Gauss1Result.png
new file mode 100644
index 0000000..595fd37
--- /dev/null
+++ b/src/graphics/baseline/Gauss1Result.png
Binary files differ
diff --git a/src/graphics/baseline/Gauss3Result.png b/src/graphics/baseline/Gauss3Result.png
new file mode 100644
index 0000000..7e07df3
--- /dev/null
+++ b/src/graphics/baseline/Gauss3Result.png
Binary files differ
diff --git a/src/graphics/baseline/Gauss5Result.png b/src/graphics/baseline/Gauss5Result.png
new file mode 100644
index 0000000..2e9693d
--- /dev/null
+++ b/src/graphics/baseline/Gauss5Result.png
Binary files differ
diff --git a/src/graphics/baseline/GetAlphaResult.png b/src/graphics/baseline/GetAlphaResult.png
new file mode 100644
index 0000000..1b5d9bf
--- /dev/null
+++ b/src/graphics/baseline/GetAlphaResult.png
Binary files differ
diff --git a/src/graphics/baseline/HighpassResult.png b/src/graphics/baseline/HighpassResult.png
new file mode 100644
index 0000000..dd84a51
--- /dev/null
+++ b/src/graphics/baseline/HighpassResult.png
Binary files differ
diff --git a/src/graphics/baseline/HslColorizeResult0.png b/src/graphics/baseline/HslColorizeResult0.png
new file mode 100644
index 0000000..adc6596
--- /dev/null
+++ b/src/graphics/baseline/HslColorizeResult0.png
Binary files differ
diff --git a/src/graphics/baseline/HslColorizeResult1.png b/src/graphics/baseline/HslColorizeResult1.png
new file mode 100644
index 0000000..51ead87
--- /dev/null
+++ b/src/graphics/baseline/HslColorizeResult1.png
Binary files differ
diff --git a/src/graphics/baseline/HslColorizeResult2.png b/src/graphics/baseline/HslColorizeResult2.png
new file mode 100644
index 0000000..02c9b0a
--- /dev/null
+++ b/src/graphics/baseline/HslColorizeResult2.png
Binary files differ
diff --git a/src/graphics/baseline/HslHueResult0.png b/src/graphics/baseline/HslHueResult0.png
new file mode 100644
index 0000000..9621451
--- /dev/null
+++ b/src/graphics/baseline/HslHueResult0.png
Binary files differ
diff --git a/src/graphics/baseline/HslHueResult1.png b/src/graphics/baseline/HslHueResult1.png
new file mode 100644
index 0000000..ac2e3f8
--- /dev/null
+++ b/src/graphics/baseline/HslHueResult1.png
Binary files differ
diff --git a/src/graphics/baseline/HslHueResult2.png b/src/graphics/baseline/HslHueResult2.png
new file mode 100644
index 0000000..015d3b3
--- /dev/null
+++ b/src/graphics/baseline/HslHueResult2.png
Binary files differ
diff --git a/src/graphics/baseline/LineResultB8G8R8.png b/src/graphics/baseline/LineResultB8G8R8.png
new file mode 100644
index 0000000..0b49fba
--- /dev/null
+++ b/src/graphics/baseline/LineResultB8G8R8.png
Binary files differ
diff --git a/src/graphics/baseline/LineResultB8G8R8A8.png b/src/graphics/baseline/LineResultB8G8R8A8.png
new file mode 100644
index 0000000..198295a
--- /dev/null
+++ b/src/graphics/baseline/LineResultB8G8R8A8.png
Binary files differ
diff --git a/src/graphics/baseline/LineResultI8.png b/src/graphics/baseline/LineResultI8.png
new file mode 100644
index 0000000..f6756a1
--- /dev/null
+++ b/src/graphics/baseline/LineResultI8.png
Binary files differ
diff --git a/src/graphics/baseline/MaskResultB8G8R8.png b/src/graphics/baseline/MaskResultB8G8R8.png
new file mode 100644
index 0000000..308dc09
--- /dev/null
+++ b/src/graphics/baseline/MaskResultB8G8R8.png
Binary files differ
diff --git a/src/graphics/baseline/MaskResultB8G8R8X8.png b/src/graphics/baseline/MaskResultB8G8R8X8.png
new file mode 100644
index 0000000..308dc09
--- /dev/null
+++ b/src/graphics/baseline/MaskResultB8G8R8X8.png
Binary files differ
diff --git a/src/graphics/baseline/MaskResultI8.png b/src/graphics/baseline/MaskResultI8.png
new file mode 100644
index 0000000..2e00267
--- /dev/null
+++ b/src/graphics/baseline/MaskResultI8.png
Binary files differ
diff --git a/src/graphics/baseline/ResizeBilinearResultB8G8R8A8.png b/src/graphics/baseline/ResizeBilinearResultB8G8R8A8.png
new file mode 100644
index 0000000..8a536aa
--- /dev/null
+++ b/src/graphics/baseline/ResizeBilinearResultB8G8R8A8.png
Binary files differ
diff --git a/src/graphics/baseline/ResizeBilinearResultB8G8R8X8.png b/src/graphics/baseline/ResizeBilinearResultB8G8R8X8.png
new file mode 100644
index 0000000..8debdce
--- /dev/null
+++ b/src/graphics/baseline/ResizeBilinearResultB8G8R8X8.png
Binary files differ
diff --git a/src/graphics/baseline/ThresholdResult.png b/src/graphics/baseline/ThresholdResult.png
new file mode 100644
index 0000000..afd19c4
--- /dev/null
+++ b/src/graphics/baseline/ThresholdResult.png
Binary files differ
diff --git a/src/graphics/baseline/YUV2RGBResult1.png b/src/graphics/baseline/YUV2RGBResult1.png
new file mode 100644
index 0000000..5e4821c
--- /dev/null
+++ b/src/graphics/baseline/YUV2RGBResult1.png
Binary files differ
diff --git a/src/graphics/baseline/bandpass_i8-64x64.png b/src/graphics/baseline/bandpass_i8-64x64.png
new file mode 100644
index 0000000..ffa4953
--- /dev/null
+++ b/src/graphics/baseline/bandpass_i8-64x64.png
Binary files differ
diff --git a/src/graphics/baseline/bandpass_spike.png b/src/graphics/baseline/bandpass_spike.png
new file mode 100644
index 0000000..00048ae
--- /dev/null
+++ b/src/graphics/baseline/bandpass_spike.png
Binary files differ
diff --git a/src/graphics/baseline/blur05_flat.png b/src/graphics/baseline/blur05_flat.png
new file mode 100644
index 0000000..95700b1
--- /dev/null
+++ b/src/graphics/baseline/blur05_flat.png
Binary files differ
diff --git a/src/graphics/baseline/blur05_spike.png b/src/graphics/baseline/blur05_spike.png
new file mode 100644
index 0000000..1bb2eb9
--- /dev/null
+++ b/src/graphics/baseline/blur05_spike.png
Binary files differ
diff --git a/src/graphics/baseline/blur1_spike.png b/src/graphics/baseline/blur1_spike.png
new file mode 100644
index 0000000..3446bcc
--- /dev/null
+++ b/src/graphics/baseline/blur1_spike.png
Binary files differ
diff --git a/src/graphics/baseline/blur3_spike.png b/src/graphics/baseline/blur3_spike.png
new file mode 100644
index 0000000..e0dd5ee
--- /dev/null
+++ b/src/graphics/baseline/blur3_spike.png
Binary files differ
diff --git a/src/graphics/baseline/blur_rgb24-64x64.png b/src/graphics/baseline/blur_rgb24-64x64.png
new file mode 100644
index 0000000..1acf9ea
--- /dev/null
+++ b/src/graphics/baseline/blur_rgb24-64x64.png
Binary files differ
diff --git a/src/graphics/baseline/blur_rgb24alpha-64x64.png b/src/graphics/baseline/blur_rgb24alpha-64x64.png
new file mode 100644
index 0000000..24c9687
--- /dev/null
+++ b/src/graphics/baseline/blur_rgb24alpha-64x64.png
Binary files differ
diff --git a/src/graphics/baseline/copyPixels_B8G8R8X8_I8.png b/src/graphics/baseline/copyPixels_B8G8R8X8_I8.png
new file mode 100644
index 0000000..59d5c74
--- /dev/null
+++ b/src/graphics/baseline/copyPixels_B8G8R8X8_I8.png
Binary files differ
diff --git a/src/graphics/baseline/copyPixels_R8G8B8X8_I8.png b/src/graphics/baseline/copyPixels_R8G8B8X8_I8.png
new file mode 100644
index 0000000..a59d0bf
--- /dev/null
+++ b/src/graphics/baseline/copyPixels_R8G8B8X8_I8.png
Binary files differ
diff --git a/src/graphics/benchmarkgraphics.cpp b/src/graphics/benchmarkgraphics.cpp
new file mode 100644
index 0000000..7449096
--- /dev/null
+++ b/src/graphics/benchmarkgraphics.cpp
@@ -0,0 +1,253 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#include "Bitmap.h"
+#include "Pixel32.h"
+#include "Pixel24.h"
+#include "Pixel16.h"
+#include "Filtergrayscale.h"
+#include "Filterfill.h"
+#include "Filterflip.h"
+#include "Filterfliprgb.h"
+#include "Filterflipuv.h"
+#include "Filter3x3.h"
+#include "FilterConvol.h"
+#include "HistoryPreProcessor.h"
+#include "FilterHighpass.h"
+#include "FilterGauss.h"
+#include "FilterBlur.h"
+#include "FilterBandpass.h"
+
+#include "../base/TimeSource.h"
+
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace avg;
+using namespace std;
+
+template<class TEST>
+void runPerformanceTest(int numRuns=500)
+{
+ TEST PerfTest;
+ long long StartTime = TimeSource::get()->getCurrentMicrosecs();
+ for (int i = 0; i < numRuns; ++i) {
+ PerfTest.run();
+ }
+ double ActiveTime = (TimeSource::get()->getCurrentMicrosecs()-StartTime)/1000.;
+ cerr << PerfTest.getName() << ": " << ActiveTime/numRuns << " ms" << endl;
+
+}
+
+class PerfTestBase {
+public:
+ PerfTestBase(string sName)
+ : m_sName(sName)
+ {
+ }
+
+ std::string getName()
+ {
+ return m_sName;
+ }
+
+private:
+ std::string m_sName;
+};
+
+class LoadPNGPerfTest: public PerfTestBase {
+public:
+ LoadPNGPerfTest()
+ : PerfTestBase("LoadPNGPerfTest")
+ {
+ }
+
+ void run()
+ {
+ BitmapPtr pBmp(new Bitmap("testfiles/rgb24alpha-64x64.png"));
+ }
+};
+
+class FillI8PerfTest: public PerfTestBase {
+public:
+ FillI8PerfTest()
+ : PerfTestBase("FillI8PerfTest")
+ {
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1024,1024), I8));
+ }
+
+ void run()
+ {
+ FilterFill<Pixel8> Filter = FilterFill<Pixel8>(Pixel8(0));
+ Filter.applyInPlace(m_pBmp);
+ }
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+class FillRGBPerfTest: public PerfTestBase {
+public:
+ FillRGBPerfTest()
+ : PerfTestBase("FillRGBPerfTest")
+ {
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1024,1024), R8G8B8));
+ }
+
+ void run()
+ {
+ FilterFill<Pixel24> Filter = FilterFill<Pixel24>(Pixel24(0,0,0));
+ Filter.applyInPlace(m_pBmp);
+ }
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+class FillRGBAPerfTest: public PerfTestBase {
+public:
+ FillRGBAPerfTest()
+ : PerfTestBase("FillRGBAPerfTest")
+ {
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1024,1024), R8G8B8A8));
+ }
+
+ void run()
+ {
+ FilterFill<Pixel32> Filter = FilterFill<Pixel32>(Pixel32(0,0,0,0));
+ Filter.applyInPlace(m_pBmp);
+ }
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+class EqualityI8PerfTest: public PerfTestBase {
+public:
+ EqualityI8PerfTest()
+ : PerfTestBase("EqualityI8PerfTest")
+ {
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1024,1024), I8));
+ }
+
+ void run()
+ {
+ Bitmap CopyBmp = *m_pBmp;
+ }
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+class CopyI8PerfTest: public PerfTestBase {
+public:
+ CopyI8PerfTest()
+ : PerfTestBase("CopyI8PerfTest")
+ {
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1024,1024), I8));
+ }
+
+ void run()
+ {
+ Bitmap CopyBmp(*m_pBmp);
+ }
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+class CopyRGBPerfTest: public PerfTestBase {
+public:
+ CopyRGBPerfTest()
+ : PerfTestBase("CopyRGBPerfTest")
+ {
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1024,1024), R8G8B8));
+ }
+
+ void run()
+ {
+ Bitmap CopyBmp(*m_pBmp);
+ }
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+class CopyRGBAPerfTest: public PerfTestBase {
+public:
+ CopyRGBAPerfTest()
+ : PerfTestBase("CopyRGBAPerfTest")
+ {
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1024,1024), R8G8B8A8));
+ }
+
+ void run()
+ {
+ Bitmap CopyBmp(*m_pBmp);
+ }
+
+private:
+ BitmapPtr m_pBmp;
+};
+
+class YUV2RGBPerfTest: public PerfTestBase {
+public:
+ YUV2RGBPerfTest()
+ : PerfTestBase("YUV2RGBPerfTest")
+ {
+ m_pYBmp = BitmapPtr(new Bitmap(IntPoint(1024, 1024), I8));
+ m_pUBmp = BitmapPtr(new Bitmap(IntPoint(512, 512), I8));
+ m_pVBmp = BitmapPtr(new Bitmap(IntPoint(512, 512), I8));
+ }
+
+ void run()
+ {
+ Bitmap RGBBmp(IntPoint(1024, 1024), B8G8R8X8);
+ RGBBmp.copyYUVPixels(*m_pYBmp, *m_pUBmp, *m_pVBmp, false);
+ }
+
+private:
+ BitmapPtr m_pYBmp;
+ BitmapPtr m_pUBmp;
+ BitmapPtr m_pVBmp;
+
+};
+
+void runPerformanceTests()
+{
+ runPerformanceTest<LoadPNGPerfTest>();
+ runPerformanceTest<FillI8PerfTest>();
+ runPerformanceTest<FillRGBPerfTest>();
+ runPerformanceTest<FillRGBAPerfTest>();
+ runPerformanceTest<EqualityI8PerfTest>();
+ runPerformanceTest<CopyI8PerfTest>();
+ runPerformanceTest<CopyRGBPerfTest>();
+ runPerformanceTest<CopyRGBAPerfTest>();
+ runPerformanceTest<YUV2RGBPerfTest>(200);
+}
+
+int main(int nargs, char** args)
+{
+ runPerformanceTests();
+}
+
diff --git a/src/graphics/testfiles/chromakey-median.png b/src/graphics/testfiles/chromakey-median.png
new file mode 100644
index 0000000..5858c4b
--- /dev/null
+++ b/src/graphics/testfiles/chromakey-median.png
Binary files differ
diff --git a/src/graphics/testfiles/chromakey.png b/src/graphics/testfiles/chromakey.png
new file mode 100644
index 0000000..b2cfc2e
--- /dev/null
+++ b/src/graphics/testfiles/chromakey.png
Binary files differ
diff --git a/src/graphics/testfiles/dilation.png b/src/graphics/testfiles/dilation.png
new file mode 100644
index 0000000..7981594
--- /dev/null
+++ b/src/graphics/testfiles/dilation.png
Binary files differ
diff --git a/src/graphics/testfiles/erosion.png b/src/graphics/testfiles/erosion.png
new file mode 100644
index 0000000..899e2c4
--- /dev/null
+++ b/src/graphics/testfiles/erosion.png
Binary files differ
diff --git a/src/graphics/testfiles/flat.png b/src/graphics/testfiles/flat.png
new file mode 100644
index 0000000..51d2c55
--- /dev/null
+++ b/src/graphics/testfiles/flat.png
Binary files differ
diff --git a/src/graphics/testfiles/floodfill.png b/src/graphics/testfiles/floodfill.png
new file mode 100644
index 0000000..6a9e5b5
--- /dev/null
+++ b/src/graphics/testfiles/floodfill.png
Binary files differ
diff --git a/src/graphics/testfiles/hsl.png b/src/graphics/testfiles/hsl.png
new file mode 100644
index 0000000..9621451
--- /dev/null
+++ b/src/graphics/testfiles/hsl.png
Binary files differ
diff --git a/src/graphics/testfiles/i8-64x64.png b/src/graphics/testfiles/i8-64x64.png
new file mode 100644
index 0000000..ec88c8c
--- /dev/null
+++ b/src/graphics/testfiles/i8-64x64.png
Binary files differ
diff --git a/src/graphics/testfiles/rgb24-64x64.png b/src/graphics/testfiles/rgb24-64x64.png
new file mode 100644
index 0000000..cca71fe
--- /dev/null
+++ b/src/graphics/testfiles/rgb24-64x64.png
Binary files differ
diff --git a/src/graphics/testfiles/rgb24-65x65.png b/src/graphics/testfiles/rgb24-65x65.png
new file mode 100644
index 0000000..ada2689
--- /dev/null
+++ b/src/graphics/testfiles/rgb24-65x65.png
Binary files differ
diff --git a/src/graphics/testfiles/rgb24alpha-64x64.png b/src/graphics/testfiles/rgb24alpha-64x64.png
new file mode 100644
index 0000000..41b69c3
--- /dev/null
+++ b/src/graphics/testfiles/rgb24alpha-64x64.png
Binary files differ
diff --git a/src/graphics/testfiles/spike.png b/src/graphics/testfiles/spike.png
new file mode 100644
index 0000000..958e95d
--- /dev/null
+++ b/src/graphics/testfiles/spike.png
Binary files differ
diff --git a/src/graphics/testgpu.cpp b/src/graphics/testgpu.cpp
new file mode 100644
index 0000000..bf7a995
--- /dev/null
+++ b/src/graphics/testgpu.cpp
@@ -0,0 +1,404 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GraphicsTest.h"
+#include "GLTexture.h"
+#include "GPUBrightnessFilter.h"
+#include "GPUBlurFilter.h"
+#include "GPUBandpassFilter.h"
+#include "GPUChromaKeyFilter.h"
+#include "GPUHueSatFilter.h"
+#include "GPURGB2YUVFilter.h"
+#include "FilterResizeBilinear.h"
+#include "OGLImagingContext.h"
+#include "BmpTextureMover.h"
+#include "PBO.h"
+
+#include "../base/TestSuite.h"
+#include "../base/Exception.h"
+#include "../base/Test.h"
+#include "../base/StringHelper.h"
+
+#include <math.h>
+#include <iostream>
+
+using namespace avg;
+using namespace std;
+
+
+class TextureMoverTest: public GraphicsTest {
+public:
+ TextureMoverTest()
+ : GraphicsTest("TextureMoverTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ for (int i=0; i<2; ++i) {
+ bool bPOT = (i==1);
+ runImageTest(bPOT, MM_PBO, "rgb24-65x65");
+ runImageTest(bPOT, MM_OGL, "rgb24-65x65");
+ runImageTest(bPOT, MM_PBO, "rgb24alpha-64x64");
+ runImageTest(bPOT, MM_OGL, "rgb24alpha-64x64");
+ }
+ runMipmapTest(MM_OGL, "rgb24alpha-64x64");
+ runMipmapTest(MM_PBO, "rgb24alpha-64x64");
+ runMipmapTest(MM_OGL, "rgb24-65x65");
+ runMipmapTest(MM_PBO, "rgb24-65x65");
+ }
+
+private:
+ void runImageTest(bool bPOT, OGLMemoryMode memoryMode, const string& sFName)
+ {
+ cerr << " Testing " << sFName << ", " << oglMemoryMode2String(memoryMode);
+ if (bPOT) {
+ cerr << ", POT" << endl;
+ } else {
+ cerr << ", NPOT" << endl;
+ }
+ BitmapPtr pOrigBmp = loadTestBmp(sFName);
+ {
+ cerr << " move functions." << endl;
+ GLTexturePtr pTex = GLTexturePtr(new GLTexture(pOrigBmp->getSize(),
+ pOrigBmp->getPixelFormat(), false, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
+ bPOT));
+ TextureMoverPtr pWriteMover = TextureMover::create(memoryMode,
+ pOrigBmp->getSize(), pOrigBmp->getPixelFormat(), GL_DYNAMIC_DRAW);
+ pWriteMover->moveBmpToTexture(pOrigBmp, *pTex);
+ BitmapPtr pDestBmp = readback(memoryMode, pOrigBmp, pTex);
+ testEqual(*pDestBmp, *pOrigBmp, "pbo", 0.01, 0.1);
+ }
+
+ {
+ cerr << " lock functions." << endl;
+ GLTexturePtr pTex = GLTexturePtr(new GLTexture(pOrigBmp->getSize(),
+ pOrigBmp->getPixelFormat(), false, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE,
+ bPOT));
+ TextureMoverPtr pMover = TextureMover::create(memoryMode,
+ pOrigBmp->getSize(), pOrigBmp->getPixelFormat(), GL_DYNAMIC_DRAW);
+ BitmapPtr pTransferBmp = pMover->lock();
+ pTransferBmp->copyPixels(*pOrigBmp);
+ pMover->unlock();
+ pMover->moveToTexture(*pTex);
+ BitmapPtr pDestBmp = readback(memoryMode, pOrigBmp, pTex);
+ testEqual(*pDestBmp, *pOrigBmp, "pbo", 0.01, 0.1);
+ }
+ }
+
+ void runMipmapTest(OGLMemoryMode memoryMode, const string& sFName)
+ {
+ cerr << " Testing mipmap support, " << sFName << ", " <<
+ oglMemoryMode2String(memoryMode) << endl;
+ BitmapPtr pOrigBmp = loadTestBmp(sFName);
+ GLTexturePtr pTex = GLTexturePtr(new GLTexture(pOrigBmp->getSize(),
+ pOrigBmp->getPixelFormat(), true));
+ pTex->moveBmpToTexture(pOrigBmp);
+ pTex->generateMipmaps();
+ TextureMoverPtr pReadMover = TextureMover::create(memoryMode,
+ pOrigBmp->getSize(), pOrigBmp->getPixelFormat(), GL_DYNAMIC_READ);
+ BitmapPtr pResultBmp = pReadMover->moveTextureToBmp(*pTex, 1);
+ IntPoint newSize(pOrigBmp->getSize()/2);
+ TEST(pResultBmp->getSize() == newSize);
+ FilterResizeBilinear resizer(newSize);
+ BitmapPtr pBaselineBmp = resizer.apply(pOrigBmp);
+ testEqual(*pResultBmp, *pBaselineBmp, "pbo-mipmap", 2, 7);
+ }
+
+ BitmapPtr readback(OGLMemoryMode memoryMode, const BitmapPtr& pOrigBmp,
+ const GLTexturePtr& pTex)
+ {
+ TextureMoverPtr pReadMover = TextureMover::create(memoryMode,
+ pTex->getGLSize(), pOrigBmp->getPixelFormat(), GL_DYNAMIC_READ);
+ return pReadMover->moveTextureToBmp(*pTex);
+ }
+};
+
+class BrightnessFilterTest: public GraphicsTest {
+public:
+ BrightnessFilterTest()
+ : GraphicsTest("BrightnessFilterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runImageTests("rgb24-64x64");
+ runImageTests("rgb24alpha-64x64");
+ }
+
+private:
+ void runImageTests(const string& sFName)
+ {
+ cerr << " Testing " << sFName << endl;
+ BitmapPtr pBmp = loadTestBmp(sFName);
+ BitmapPtr pDestBmp;
+ pDestBmp = GPUBrightnessFilter(pBmp->getSize(), pBmp->getPixelFormat(), 1)
+ .apply(pBmp);
+ testEqual(*pDestBmp, *pBmp, string("brightness_")+sFName, 0.2, 0.5);
+ }
+};
+
+class ChromaKeyFilterTest: public GraphicsTest {
+public:
+ ChromaKeyFilterTest()
+ : GraphicsTest("ChromaKeyFilterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("chromakey");
+ BitmapPtr pDestBmp;
+ GPUChromaKeyFilter filter(pBmp->getSize(), pBmp->getPixelFormat());
+ for (int erosion = 0; erosion < 3; ++erosion) {
+ filter.setParams(Pixel32(0,255,0), 0.1, 0.2, 0.1, 0.1, erosion, 0);
+ pDestBmp = filter.apply(pBmp);
+ testEqual(*pDestBmp, "ChromaKeyResult"+toString(erosion), R8G8B8X8, 0.3,
+ 0.7);
+ }
+ filter.setParams(Pixel32(0,255,0), 0.0, 0.0, 0.0, 0.0, 0, 0.1);
+ pDestBmp = filter.apply(pBmp);
+ testEqual(*pDestBmp, "ChromaKeySpillResult1", R8G8B8X8, 0.3, 0.7);
+ filter.setParams(Pixel32(0,255,0), 0.1, 0.1, 0.1, 0.0, 0, 0.1);
+ pDestBmp = filter.apply(pBmp);
+ testEqual(*pDestBmp, "ChromaKeySpillResult2", R8G8B8X8, 0.3, 0.7);
+ filter.setParams(Pixel32(0,255,0), 0.1, 0.1, 0.1, 0.0, 0, 0.2);
+ pDestBmp = filter.apply(pBmp);
+ testEqual(*pDestBmp, "ChromaKeySpillResult3", R8G8B8X8, 0.3, 0.7);
+
+ pBmp = loadTestBmp("chromakey-median");
+ filter.setParams(Pixel32(0,255,0), 0.1, 0.1, 0.1, 0.0, 0, 0.0);
+ pDestBmp = filter.apply(pBmp);
+ testEqual(*pDestBmp, "ChromaKeyMedianResult", R8G8B8X8, 1, 6);
+ }
+};
+
+class HslColorFilterTest: public GraphicsTest {
+public:
+ HslColorFilterTest()
+ : GraphicsTest("HslColorFilterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("hsl");
+ BitmapPtr pDestBmp;
+ GPUHueSatFilter filter(pBmp->getSize(), pBmp->getPixelFormat());
+ //Test hue functionality
+ for (int run = 0; run < 3; run++) {
+ filter.setParams(run*90);
+ pDestBmp = filter.apply(pBmp);
+ testEqual(*pDestBmp, "HslHueResult"+toString(run), R8G8B8X8, 0, 0);
+ }
+ //Test colorize functionality
+ for (int run = 0; run < 3; run++) {
+ filter.setParams(run*90, 1, 0, true);
+ pDestBmp = filter.apply(pBmp);
+ testEqual(*pDestBmp, "HslColorizeResult"+toString(run), R8G8B8X8, 0, 0);
+ }
+ }
+};
+
+class BlurFilterTest: public GraphicsTest {
+public:
+ BlurFilterTest()
+ : GraphicsTest("BlurFilterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp;
+ BitmapPtr pDestBmp;
+/*
+ // This has the effect of printing out all the brightness differences for
+ //different kernel sizes.
+ pBmp = loadTestBmp("spike");
+ for (double stddev = 0.5; stddev < 5; stddev += 0.25) {
+ pDestBmp = GPUBlurFilter(pBmp->getSize(), pBmp->getPixelFormat(), stddev)
+ .apply(pBmp);
+ testEqualBrightness(*pDestBmp, *pBmp, 1);
+ }
+*/
+ pBmp = loadTestBmp("spike");
+ GPUBlurFilter filter(pBmp->getSize(), pBmp->getPixelFormat(), R32G32B32A32F, 0.5,
+ false);
+ runImageTest(pBmp, filter, 0.5, "blur05_spike");
+ runImageTest(pBmp, filter, 1, "blur1_spike");
+ runImageTest(pBmp, filter, 3, "blur3_spike");
+
+ pBmp = loadTestBmp("flat");
+ filter = GPUBlurFilter(pBmp->getSize(), pBmp->getPixelFormat(), R32G32B32A32F, 5,
+ false);
+ runImageTest(pBmp, filter, 5, "blur05_flat", true);
+
+ runImageTest("rgb24-64x64");
+ runImageTest("rgb24alpha-64x64");
+ }
+
+private:
+ void runImageTest(const string& sFName)
+ {
+ BitmapPtr pBmp = loadTestBmp(sFName);
+ GPUBlurFilter filter(pBmp->getSize(), pBmp->getPixelFormat(), R32G32B32A32F, 2,
+ false);
+ runImageTest(pBmp, filter, 2, string("blur_")+sFName, true);
+ }
+
+ void runImageTest(BitmapPtr pBmp, GPUBlurFilter& filter, double stdDev,
+ string sBmpName, bool bIgnoreBrightness = false)
+ {
+ cerr << " Testing " << sBmpName << ", stddev " << stdDev << endl;
+ filter.setStdDev(stdDev);
+ BitmapPtr pDestBmp = filter.apply(pBmp);
+ if (!bIgnoreBrightness) {
+ testEqualBrightness(*pDestBmp, *pBmp, 0.03);
+ }
+ testEqual(*pDestBmp, sBmpName, B8G8R8X8, 0.01, 0.1);
+ }
+};
+
+class BandpassFilterTest: public GraphicsTest {
+public:
+ BandpassFilterTest()
+ : GraphicsTest("BandpassFilterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runImageTests("spike", B8G8R8X8);
+ runImageTests("i8-64x64", I8);
+ }
+
+private:
+ void runImageTests(const string& sFName, PixelFormat pf)
+ {
+ cerr << " Testing " << sFName << endl;
+ BitmapPtr pBmp = loadTestBmp(sFName, pf);
+ GPUBandpassFilter f(pBmp->getSize(), pf, 0.5, 1.5, 1, false);
+ BitmapPtr pDestBmp = f.apply(pBmp);
+ TEST(fabs(pDestBmp->getAvg() -128) < 0.06);
+ testEqual(*pDestBmp, "bandpass_"+sFName, pf, 0.2, 0.5);
+ TEST(pDestBmp->getPixelFormat() == pf);
+ }
+};
+
+class RGB2YUVFilterTest: public GraphicsTest {
+public:
+ RGB2YUVFilterTest()
+ : GraphicsTest("RGB2YUVFilterTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pOrigBmp = loadTestBmp("rgb24-64x64");
+ GLTexturePtr pTex = GLTexturePtr(new GLTexture(pOrigBmp->getSize(),
+ pOrigBmp->getPixelFormat()));
+ pTex->moveBmpToTexture(pOrigBmp);
+ GPURGB2YUVFilter f(pOrigBmp->getSize());
+ f.apply(pTex);
+ BitmapPtr pResultBmp = f.getResults();
+ pResultBmp = convertYUVX444ToRGB(pResultBmp);
+ testEqual(*pResultBmp, *pOrigBmp, "RGB2YUV", 1, 2);
+ }
+
+ BitmapPtr convertYUVX444ToRGB(const BitmapPtr& pYUVBmp)
+ {
+ // This is a wierd pixel format that's not used anywhere else, so support
+ // hasn't been moved to the Bitmap class.
+ BitmapPtr pRGBBmp(new Bitmap(pYUVBmp->getSize(), B8G8R8X8));
+ int height = pRGBBmp->getSize().y;
+ int width = pRGBBmp->getSize().y;
+ int strideInPixels = pRGBBmp->getStride()/4;
+
+ for (int y = 0; y < height; ++y) {
+ const unsigned char * pSrc = pYUVBmp->getPixels() + pYUVBmp->getStride()*y;
+ Pixel32 * pDest = (Pixel32*)pRGBBmp->getPixels() + strideInPixels*y;
+ for (int x = 0; x < width; x++) {
+ YUVJtoBGR32Pixel(pDest, pSrc[0], pSrc[1], pSrc[2]);
+ pSrc += 4;
+ pDest ++;
+ }
+ }
+ return pRGBBmp;
+ }
+};
+
+
+class GPUTestSuite: public TestSuite {
+public:
+ GPUTestSuite()
+ : TestSuite("GPUTestSuite")
+ {
+ addTest(TestPtr(new TextureMoverTest));
+ addTest(TestPtr(new BrightnessFilterTest));
+ addTest(TestPtr(new RGB2YUVFilterTest));
+ if (GLTexture::isFloatFormatSupported()) {
+ addTest(TestPtr(new ChromaKeyFilterTest));
+ addTest(TestPtr(new HslColorFilterTest));
+ addTest(TestPtr(new BlurFilterTest));
+ addTest(TestPtr(new BandpassFilterTest));
+ } else {
+ cerr << "Skipping some GPU tests since float textures are not supported by "
+ << endl << "the OpenGL configuration." << endl;
+ }
+ }
+};
+
+
+int main(int nargs, char** args)
+{
+ bool bOK = true;
+ try {
+ OGLImagingContext context;
+ try {
+ if (!queryOGLExtension("GL_ARB_fragment_shader")) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Fragment shaders not supported on this Machine. ");
+ }
+ GPUTestSuite suite;
+ suite.runTests();
+ bOK = suite.isOk();
+ } catch (Exception& ex) {
+ cerr << "Exception: " << ex.getStr() << endl;
+ }
+ } catch (Exception& ex) {
+ if (ex.getCode() == AVG_ERR_ASSERT_FAILED) {
+ cerr << ex.getStr() << endl;
+ bOK = false;
+ } else {
+ cerr << "Skipping GPU imaging test." << endl;
+ cerr << "Reason: " << ex.getStr() << endl;
+ bOK = true;
+ }
+ }
+
+ if (bOK) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
diff --git a/src/graphics/testgraphics.cpp b/src/graphics/testgraphics.cpp
new file mode 100644
index 0000000..57a19cc
--- /dev/null
+++ b/src/graphics/testgraphics.cpp
@@ -0,0 +1,1063 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "GraphicsTest.h"
+#include "Bitmap.h"
+#include "Pixel32.h"
+#include "Pixel24.h"
+#include "Pixel16.h"
+#include "Filtercolorize.h"
+#include "Filtergrayscale.h"
+#include "Filterfill.h"
+#include "Filterflip.h"
+#include "Filterfliprgb.h"
+#include "Filterflipuv.h"
+#include "Filter3x3.h"
+#include "FilterConvol.h"
+#include "HistoryPreProcessor.h"
+#include "FilterHighpass.h"
+#include "FilterFastBandpass.h"
+#include "FilterGauss.h"
+#include "FilterBlur.h"
+#include "FilterBandpass.h"
+#include "FilterFastDownscale.h"
+#include "FilterMask.h"
+#include "FilterThreshold.h"
+#include "FilterFloodfill.h"
+#include "FilterDilation.h"
+#include "FilterErosion.h"
+#include "FilterGetAlpha.h"
+#include "FilterResizeBilinear.h"
+#include "FilterUnmultiplyAlpha.h"
+
+#include "../base/TestSuite.h"
+#include "../base/Exception.h"
+#include "../base/MathHelper.h"
+
+#ifdef _WIN32
+#pragma warning(push)
+#pragma warning(disable: 4251)
+#endif
+#ifdef _WIN32
+#pragma warning(pop)
+#endif
+
+#include <cstring>
+#include <iostream>
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace avg;
+using namespace std;
+
+BitmapPtr initBmp(PixelFormat pf)
+{
+ int height;
+ if (pf == YCbCr422) {
+ height = 10;
+ } else {
+ height = 7;
+
+ }
+ BitmapPtr pBmp(new Bitmap(IntPoint(4, height), pf));
+ for(int y = 0; y < height; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ unsigned char * pPixel =
+ pBmp->getPixels()+y*pBmp->getStride()+x*pBmp->getBytesPerPixel();
+ *(pPixel) = x;
+ if (pBmp->getBytesPerPixel() > 1) {
+ *(pPixel+1) = 0;
+ }
+ if (pBmp->getBytesPerPixel() > 2) {
+ *(pPixel+2) = x;
+ *(pPixel) = 16*y;
+ }
+ if (pBmp->getBytesPerPixel() > 3) {
+ *(pPixel+3) = 0x80;
+ }
+ }
+ }
+ return pBmp;
+}
+
+// TODO: This is very incomplete!
+class PixelTest: public GraphicsTest {
+public:
+ PixelTest()
+ : GraphicsTest("PixelTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ double h, s, l;
+ Pixel32(255, 0, 0).toHSL(h, s, l);
+ TEST(h == 0 && s == 1.0 && l == 0.5);
+ Pixel32(0, 255, 0).toHSL(h, s, l);
+ TEST(h == 120 && s == 1.0 && l == 0.5);
+ Pixel32(0, 0, 255).toHSL(h, s, l);
+ TEST(h == 240 && s == 1.0 && l == 0.5);
+ Pixel32(255, 255, 0).toHSL(h, s, l);
+ TEST(h == 60 && s == 1.0 && l == 0.5);
+ Pixel32(255, 0, 255).toHSL(h, s, l);
+ TEST(h == 300 && s == 1.0 && l == 0.5);
+ Pixel32(0, 255, 255).toHSL(h, s, l);
+ TEST(h == 180 && s == 1.0 && l == 0.5);
+ Pixel32(0, 0, 0).toHSL(h, s, l);
+ TEST(s == 0.0 && l == 0.0);
+ Pixel32(255, 255, 255).toHSL(h, s, l);
+ TEST(s == 0.0 && l == 1.0);
+ Pixel32(128, 128, 128).toHSL(h, s, l);
+ TEST(s == 0.0 && fabs(l-0.5) < 0.02);
+ }
+
+};
+
+class BitmapTest: public GraphicsTest {
+public:
+ BitmapTest()
+ : GraphicsTest("BitmapTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests(B8G8R8A8);
+ runPFTests(R8G8B8A8);
+ runPFTests(R8G8B8X8);
+ runPFTests(R8G8B8);
+ runPFTests(I8);
+ runPFTests(I16);
+ runPFTests(YCbCr422);
+ runLineTest(B8G8R8A8, Pixel32(0,0,255,255));
+ runLineTest(B8G8R8, Pixel24(0,0,255));
+ runLineTest(I8, Pixel8(255));
+
+ cerr << " Testing OwnsBits." << endl;
+ unsigned char pData[4*7*3];
+ for (int i = 0; i < 4*7*3; ++i) {
+ pData[i] = i;
+ }
+ Bitmap Bmp1 = Bitmap(IntPoint(4,7), R8G8B8, pData, 12, true, "");
+ Bitmap Bmp2 = Bitmap(IntPoint(4,7), R8G8B8, pData, 12, false, "");
+ testEqual(Bmp1, Bmp2, "BmpOwnsBits");
+ {
+ cerr << " Testing copyPixels - R8G8B8X8->R8G8B8->R8G8B8X8." << endl;
+ BitmapPtr pBmp = initBmp(R8G8B8X8);
+ Bitmap Bmp1(IntPoint(4,7), R8G8B8);
+ Bmp1.copyPixels(*pBmp);
+ Bitmap Bmp2(IntPoint(4,7), R8G8B8X8);
+ Bmp2.copyPixels(Bmp1);
+ for(int y = 0; y < 7; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ *(Bmp2.getPixels()+y*Bmp2.getStride()+x
+ *Bmp2.getBytesPerPixel()+3) = 0x80;
+ }
+ }
+ testEqual(Bmp2, *pBmp, "BmpCopyPixels_1");
+ }
+ {
+ cerr << " Testing copyPixels - R8G8B8A8->R8G8B8->R8G8B8A8." << endl;
+ BitmapPtr pBmp = initBmp(R8G8B8A8);
+ BitmapPtr pBaselineBmp = initBmp(R8G8B8A8);
+ BitmapPtr pCopyBmp = BitmapPtr(new Bitmap(IntPoint(4,7), R8G8B8));
+ pCopyBmp->copyPixels(*pBmp);
+ pBmp->copyPixels(*pCopyBmp);
+ for(int y = 0; y < 7; ++y) {
+ for (int x = 0; x < 4; ++x) {
+ *(pBmp->getPixels()+y*pBmp->getStride()+x
+ *pBmp->getBytesPerPixel()+3) = 0x80;
+ }
+ }
+ testEqual(*pBmp, *pBaselineBmp, "BmpCopyPixels_2");
+ }
+ {
+ cerr << " Testing copyPixels - I8->I16->I8." << endl;
+ BitmapPtr pBmp = initBmp(I8);
+ BitmapPtr pBaselineBmp = initBmp(I8);
+ BitmapPtr pCopyBmp = BitmapPtr(new Bitmap(IntPoint(4,7), I16));
+ pCopyBmp->copyPixels(*pBmp);
+ pBmp->copyPixels(*pCopyBmp);
+ testEqual(*pBmp, *pBaselineBmp, "BmpCopyPixels_3");
+ }
+ {
+ cerr << " Testing copyPixels - R8G8B8A8->R32G32B32A32F->R8G8B8A8." << endl;
+ BitmapPtr pBmp = initBmp(R8G8B8A8);
+ BitmapPtr pBaselineBmp = initBmp(R8G8B8A8);
+ BitmapPtr pCopyBmp = BitmapPtr(new Bitmap(IntPoint(4,7), R32G32B32A32F));
+ pCopyBmp->copyPixels(*pBmp);
+ pBmp->copyPixels(*pCopyBmp);
+ testEqual(*pBmp, *pBaselineBmp, "BmpCopyPixels_3");
+ }
+ {
+ cerr << " Testing copyPixels - B5G6R5->B8G8R8->B5G6R5." << endl;
+ BitmapPtr pBmp = initBmp(B5G6R5);
+ BitmapPtr pBaselineBmp = initBmp(B5G6R5);
+ BitmapPtr pCopyBmp = BitmapPtr(new Bitmap(IntPoint(4,7), B8G8R8));
+ pCopyBmp->copyPixels(*pBmp);
+ pBmp->copyPixels(*pCopyBmp);
+ testEqual(*pBmp, *pBaselineBmp, "BmpCopyPixels_4");
+ }
+ testCopyToGreyscale(R8G8B8X8);
+ testCopyToGreyscale(B8G8R8X8);
+ testSubtract();
+ {
+ cerr << " Testing statistics." << endl;
+ cerr << " I8" << endl;
+ testStatistics(I8, Pixel8(0), Pixel8(0), Pixel8(2), Pixel8(2));
+ cerr << " R8G8B8A8" << endl;
+ testStatistics(R8G8B8A8, Pixel32(0,0,0,0), Pixel32(0,0,0,0),
+ Pixel32(255,255,255,255), Pixel32(255,255,255,255), 127.5, 90.1561);
+ cerr << " R8G8B8X8" << endl;
+ testStatistics(R8G8B8X8, Pixel32(0,0,0,255), Pixel32(0,0,0,255),
+ Pixel32(2,2,2,255), Pixel32(2,2,2,255));
+ cerr << " R8G8B8" << endl;
+ testStatistics(R8G8B8, Pixel24(0,0,0), Pixel24(0,0,0),
+ Pixel24(2,2,2), Pixel24(2,2,2));
+ cerr << " ChannelAvg" << endl;
+ testChannelAvg();
+ }
+ {
+ cerr << " Testing YUV->RGB conversion." << endl;
+ testYUV2RGB();
+ }
+ runSaveTest(B8G8R8A8);
+ runSaveTest(B8G8R8X8);
+ }
+
+private:
+ void runPFTests(PixelFormat pf)
+ {
+ cerr << " Testing " << pf << endl;
+ BitmapPtr pBmp = initBmp(pf);
+ {
+ cerr << " Testing size." <<endl;
+ if (pf == YCbCr422) {
+ TEST(pBmp->getSize() == IntPoint(4,10));
+ } else {
+ TEST(pBmp->getSize() == IntPoint(4,7));
+ }
+ }
+ {
+ cerr << " Testing copy constructor." << endl;
+ Bitmap bmpCopy1(*pBmp);
+ testEqual(bmpCopy1, *pBmp, "BmpCopyConstructor");
+ }
+ {
+ cerr << " Testing assignment operator." << endl;
+ Bitmap bmpCopy2 = *pBmp;
+ testEqual(bmpCopy2, *pBmp, "BmpAssignment");
+ }
+ {
+ cerr << " Testing sub-bitmap constructor." << endl;
+ Bitmap bmpCopy3 (*pBmp, IntRect(IntPoint(0,0), pBmp->getSize()));
+ testEqual(bmpCopy3, *pBmp, "BmpSubBmpCtor");
+ }
+ if (pf == I8) {
+ cerr << " Testing getHistogram." << endl;
+ HistogramPtr pHist = pBmp->getHistogram();
+ TEST((*pHist)[0] == 7);
+ TEST((*pHist)[1] == 7);
+ TEST((*pHist)[2] == 7);
+ TEST((*pHist)[3] == 7);
+ bool bOk = true;
+ for (int i = 4; i < 256; ++i) {
+ if (bOk) {
+ bOk = ((*pHist)[i] == 0);
+ }
+ }
+ TEST(bOk);
+ }
+ }
+
+ void runSaveTest(PixelFormat pf)
+ {
+ cerr << " Testing save for " << pf << endl;
+ BitmapPtr pBmp = initBmp(pf);
+ pBmp->save("test.png");
+ Bitmap LoadedBmp("test.png");
+ ::remove("test.png");
+ testEqual(LoadedBmp, *pBmp, "BmpSave");
+ }
+
+ template<class PIXEL>
+ void runLineTest(PixelFormat pf, PIXEL color)
+ {
+ cerr << " Testing line drawing for " << pf << endl;
+ Bitmap bmp(IntPoint(15, 15), pf);
+ memset(bmp.getPixels(), 0, bmp.getStride()*15);
+ bmp.drawLine(IntPoint(7,7), IntPoint( 0, 2), color);
+ bmp.drawLine(IntPoint(7,7), IntPoint( 0,12), color);
+ bmp.drawLine(IntPoint(7,7), IntPoint( 2, 0), color);
+ bmp.drawLine(IntPoint(7,7), IntPoint( 2,14), color);
+ bmp.drawLine(IntPoint(7,7), IntPoint(12, 0), color);
+ bmp.drawLine(IntPoint(7,7), IntPoint(12,14), color);
+ bmp.drawLine(IntPoint(7,7), IntPoint(14, 2), color);
+ bmp.drawLine(IntPoint(7,7), IntPoint(14,12), color);
+ string sFName = getSrcDirName() + "baseline/LineResult" + getPixelFormatString(pf)
+ + ".png";
+ Bitmap baselineBmp(sFName);
+ Bitmap baselineBmp2(IntPoint(15,15), pf);
+ baselineBmp2.copyPixels(baselineBmp);
+ testEqual(bmp, baselineBmp2, "BmpLineDraw");
+ }
+
+ void testCopyToGreyscale(PixelFormat pf)
+ {
+ cerr << " Testing copyPixels - " << pf << "->I8." << endl;
+ BitmapPtr pBmp(new Bitmap(IntPoint(4,4), pf));
+ for (int y=0; y<4; ++y) {
+ for (int x=0; x<4; ++x) {
+ unsigned char * pPixel =
+ pBmp->getPixels()+y*pBmp->getStride()+x*pBmp->getBytesPerPixel();
+ pPixel[0] = x*64;
+ pPixel[1] = 128;
+ pPixel[2] = y*64;
+ pPixel[3] = 255;
+ }
+ }
+ BitmapPtr pCopyBmp = BitmapPtr(new Bitmap(IntPoint(4,4), I8));
+ pCopyBmp->copyPixels(*pBmp);
+ testEqual(*pCopyBmp, string("copyPixels_")+getPixelFormatString(pf)+"_I8",
+ I8, 0.5, 0.5);
+ }
+
+ void testSubtract()
+ {
+ BitmapPtr pBmp1(new Bitmap(IntPoint(4,1), I8));
+ BitmapPtr pBmp2(new Bitmap(IntPoint(4,1), I8));
+ for (int x=0; x<4; ++x) {
+ pBmp1->getPixels()[x] = x;
+ pBmp2->getPixels()[x] = 0;
+ }
+ BitmapPtr pDiffBmp = pBmp1->subtract(*pBmp2);
+ testEqual(*pDiffBmp, *pBmp1, "BmpSubtract1");
+ pDiffBmp = pBmp2->subtract(*pBmp1);
+ testEqual(*pDiffBmp, *pBmp1, "BmpSubtract2");
+ }
+
+ template<class PIXEL>
+ void testStatistics(PixelFormat pf, const PIXEL& p00, const PIXEL& p01,
+ const PIXEL& p10, const PIXEL& p11, double avg=1, double stdDev=1)
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(2,2), pf));
+ pBmp->setPixel(IntPoint(0,0), p00);
+ pBmp->setPixel(IntPoint(0,1), p01);
+ pBmp->setPixel(IntPoint(1,0), p10);
+ pBmp->setPixel(IntPoint(1,1), p11);
+ TEST(almostEqual(pBmp->getAvg(), avg, 0.001));
+ TEST(almostEqual(pBmp->getStdDev(), stdDev, 0.001));
+ }
+
+ void testChannelAvg()
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(2,2), R8G8B8));
+ pBmp->setPixel(IntPoint(0,0), Pixel24(0,0,0));
+ pBmp->setPixel(IntPoint(0,1), Pixel24(128,0,0));
+ pBmp->setPixel(IntPoint(1,0), Pixel24(128,128,0));
+ pBmp->setPixel(IntPoint(1,1), Pixel24(128,128,128));
+ TEST(almostEqual(pBmp->getChannelAvg(0), 96));
+ TEST(almostEqual(pBmp->getChannelAvg(1), 64));
+ TEST(almostEqual(pBmp->getChannelAvg(2), 32));
+ }
+
+ void testYUV2RGB()
+ {
+ BitmapPtr pYBmp = BitmapPtr(new Bitmap(IntPoint(16, 16), I8));
+ for (int x=0; x<16; ++x) {
+ FilterFillRect<Pixel8>(IntRect(x, 0, x+1, 16), 255-x*16).applyInPlace(pYBmp);
+ }
+ BitmapPtr pUBmp = BitmapPtr(new Bitmap(IntPoint(8, 8), I8));
+ BitmapPtr pVBmp = BitmapPtr(new Bitmap(IntPoint(8, 8), I8));
+ FilterFillRect<Pixel8>(IntRect(0, 0, 8, 4), 128).applyInPlace(pUBmp);
+ FilterFillRect<Pixel8>(IntRect(0, 0, 8, 4), 128).applyInPlace(pVBmp);
+ for (int y=4; y<8; ++y) {
+ FilterFillRect<Pixel8>(IntRect(0, y, 8, y+1), y*64).applyInPlace(pUBmp);
+ FilterFillRect<Pixel8>(IntRect(0, y, 8, y+1), 255-y*64).applyInPlace(pVBmp);
+ }
+ BitmapPtr pRGBBmp = BitmapPtr(new Bitmap(IntPoint(16, 16), B8G8R8X8));
+ FilterFill<Pixel32>(Pixel32(255,0,0,255)).applyInPlace(pRGBBmp);
+ pRGBBmp->copyYUVPixels(*pYBmp, *pUBmp, *pVBmp, false);
+ testEqual(*pRGBBmp, "YUV2RGBResult1", B8G8R8X8, 0.5, 0.5);
+ }
+
+};
+
+class FilterColorizeTest: public GraphicsTest {
+public:
+ FilterColorizeTest()
+ : GraphicsTest("FilterColorizeTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests(R8G8B8A8);
+ runPFTests(R8G8B8);
+ }
+
+private:
+ void runPFTests(PixelFormat pf) {
+ BitmapPtr pBmp = initBmp(pf);
+ FilterColorize(15, 0).applyInPlace(pBmp);
+ FilterColorize(100, 50).applyInPlace(pBmp);
+ FilterColorize(50, 100).applyInPlace(pBmp);
+ }
+};
+
+class FilterGrayscaleTest: public GraphicsTest {
+public:
+ FilterGrayscaleTest()
+ : GraphicsTest("FilterGrayscaleTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests(R8G8B8A8);
+ runPFTests(R8G8B8);
+ runPFTests(I8);
+ }
+
+private:
+ void runPFTests(PixelFormat pf) {
+ BitmapPtr pBmp = initBmp(pf);
+ FilterGrayscale().applyInPlace(pBmp);
+ }
+};
+
+class FilterFillTest: public GraphicsTest {
+public:
+ FilterFillTest()
+ : GraphicsTest("FilterFillTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests<Pixel32>(R8G8B8A8, Pixel32(255,80,0,255));
+ runPFTests<Pixel24>(R8G8B8, Pixel24(255,80,0));
+ }
+
+private:
+ template<class PixelC>
+ void runPFTests(PixelFormat pf, PixelC color) {
+ BitmapPtr pBmp = initBmp(pf);
+ FilterFill<PixelC>(color).applyInPlace(pBmp);
+ }
+};
+
+class FilterFlipTest: public GraphicsTest {
+public:
+ FilterFlipTest()
+ : GraphicsTest("FilterFlipTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests(R8G8B8A8);
+ runPFTests(B8G8R8X8);
+ runPFTests(R8G8B8);
+ runPFTests(I8);
+ }
+
+private:
+ void runPFTests(PixelFormat pf) {
+ BitmapPtr pBmp = initBmp(pf);
+ {
+ BitmapPtr pBmp1 = FilterFlip().apply(pBmp);
+ BitmapPtr pBmp2 = FilterFlip().apply(pBmp1);
+ TEST(*pBmp == *pBmp2);
+ }
+ pBmp = initBmp(pf);
+ {
+ Bitmap baselineBmp = *pBmp;
+ FilterFlip().applyInPlace(pBmp);
+ FilterFlip().applyInPlace(pBmp);
+ TEST(*pBmp == baselineBmp);
+ }
+ }
+};
+
+class FilterFlipRGBTest: public GraphicsTest {
+public:
+ FilterFlipRGBTest()
+ : GraphicsTest("FilterFlipRGBTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests(B8G8R8A8);
+ runPFTests(R8G8B8A8);
+ runPFTests(R8G8B8);
+ }
+
+private:
+ void runPFTests(PixelFormat pf) {
+ BitmapPtr pBmp = initBmp(pf);
+ {
+ BitmapPtr pBmp1 = FilterFlipRGB().apply(pBmp);
+ BitmapPtr pBmp2 = FilterFlipRGB().apply(pBmp1);
+ TEST(*pBmp == *pBmp2);
+ }
+ {
+ Bitmap baselineBmp = *pBmp;
+ FilterFlipRGB().applyInPlace(pBmp);
+ FilterFlipRGB().applyInPlace(pBmp);
+ TEST(*pBmp == baselineBmp);
+ }
+ }
+};
+
+class FilterFlipUVTest: public GraphicsTest {
+public:
+ FilterFlipUVTest()
+ : GraphicsTest("FilterFlipUVTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = initBmp(YCbCr422);
+ {
+ BitmapPtr pBmp1 = FilterFlipUV().apply(pBmp);
+ BitmapPtr pBmp2 = FilterFlipUV().apply(pBmp1);
+ TEST(*pBmp == *pBmp2);
+ }
+ {
+ Bitmap baselineBmp = *pBmp;
+ FilterFlipUV().applyInPlace(pBmp);
+ FilterFlipUV().applyInPlace(pBmp);
+ TEST(*pBmp == baselineBmp);
+ }
+ }
+};
+
+class FilterComboTest: public GraphicsTest {
+public:
+ FilterComboTest()
+ : GraphicsTest("FilterComboTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ try {
+ char * pSrcDir = getenv("srcdir");
+ string sFilename;
+ if (pSrcDir) {
+ sFilename = (string)pSrcDir+"/";
+ }
+ sFilename += "../test/rgb24-64x64.png";
+ Bitmap tempBmp(sFilename);
+ PixelFormat pf = R8G8B8;
+ BitmapPtr pBmp;
+ pBmp = createBmp(tempBmp.getSize(), pf);
+ pBmp->copyPixels(tempBmp);
+ FilterColorize(15, 50).applyInPlace(pBmp);
+ FilterFlipRGB().applyInPlace(pBmp);
+ } catch (Exception & ex) {
+ cerr << ex.getStr() << endl;
+ setFailed();
+ }
+ }
+
+private:
+ BitmapPtr createBmp(const IntPoint& size, PixelFormat pf)
+ {
+ BitmapPtr pBmp;
+ pBmp = BitmapPtr(new Bitmap(size, pf));
+ return pBmp;
+ }
+};
+
+class FilterConvolTest: public GraphicsTest {
+public:
+ FilterConvolTest()
+ : GraphicsTest("FilterConvolTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests<Pixel24>(R8G8B8);
+ runPFTests<Pixel32>(R8G8B8X8);
+ //FIXME runPFTests<Pixel8>(I8);
+ }
+
+private:
+ template<class PIXEL>
+ void runPFTests(PixelFormat pf)
+ {
+ BitmapPtr pBmp(new Bitmap(IntPoint(4, 4), pf));
+ initBmp<PIXEL>(pBmp);
+ double mat[9] =
+ {1,0,2,
+ 0,1,0,
+ 3,0,4};
+ BitmapPtr pNewBmp = FilterConvol<PIXEL>(&(mat[0]),3,3).apply(pBmp);
+ TEST(pNewBmp->getSize() == IntPoint(2,2));
+ unsigned char * pLine0 = pNewBmp->getPixels();
+ TEST(*(PIXEL*)pLine0 == PIXEL(1,0,0));
+ TEST(*(((PIXEL*)pLine0)+1) == PIXEL(4,0,0));
+ unsigned char * pLine1 = pNewBmp->getPixels()+pNewBmp->getStride();
+ TEST(*(PIXEL*)(pLine1) == PIXEL(0,0,9));
+ TEST(*((PIXEL*)(pLine1)+1) == PIXEL(0,0,16));
+
+ }
+
+ template<class PIXEL>
+ void initBmp(BitmapPtr pBmp)
+ {
+ PIXEL * pPixels = (PIXEL *)(pBmp->getPixels());
+ PIXEL color = PIXEL(0,0,0);
+ FilterFill<PIXEL>(color).applyInPlace(pBmp);
+ pPixels[0] = PIXEL(1,0,0);
+ pPixels[3] = PIXEL(2,0,0);
+ pPixels = (PIXEL*)((char *)pPixels+3*pBmp->getStride());
+ pPixels[0] = PIXEL(0,0,3);
+ pPixels[3] = PIXEL(0,0,4);
+ }
+};
+
+class Filter3x3Test: public GraphicsTest {
+public:
+ Filter3x3Test()
+ : GraphicsTest("Filter3x3Test", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runPFTests<Pixel24>(R8G8B8);
+ runPFTests<Pixel32>(R8G8B8X8);
+ }
+
+private:
+ template<class PIXEL>
+ void runPFTests(PixelFormat pf)
+ {
+ BitmapPtr pBmp(new Bitmap(IntPoint(4, 4), pf));
+ initBmp<PIXEL>(pBmp);
+ double mat[3][3] =
+ {{1,0,2},
+ {0,1,0},
+ {3,0,4}};
+ BitmapPtr pNewBmp = Filter3x3(mat).apply(pBmp);
+ TEST(pNewBmp->getSize() == IntPoint(2,2));
+ unsigned char * pLine0 = pNewBmp->getPixels();
+ TEST(*(PIXEL*)pLine0 == PIXEL(1,0,0));
+ TEST(*(((PIXEL*)pLine0)+1) == PIXEL(4,0,0));
+ unsigned char * pLine1 = pNewBmp->getPixels()+pNewBmp->getStride();
+ TEST(*(PIXEL*)(pLine1) == PIXEL(0,0,9));
+ TEST(*((PIXEL*)(pLine1)+1) == PIXEL(0,0,16));
+
+ }
+
+ template<class PIXEL>
+ void initBmp(BitmapPtr pBmp)
+ {
+ PIXEL * pPixels = (PIXEL *)(pBmp->getPixels());
+ PIXEL color = PIXEL(0,0,0);
+ FilterFill<PIXEL>(color).applyInPlace(pBmp);
+ pPixels[0] = PIXEL(1,0,0);
+ pPixels[3] = PIXEL(2,0,0);
+ pPixels = (PIXEL*)((char *)pPixels+3*pBmp->getStride());
+ pPixels[0] = PIXEL(0,0,3);
+ pPixels[3] = PIXEL(0,0,4);
+ }
+};
+
+class HistoryPreProcessorTest: public GraphicsTest {
+public:
+ HistoryPreProcessorTest()
+ : GraphicsTest("HistoryPreProcessor", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBaseBmp = initBmp(I8);
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(*pBaseBmp));
+ BitmapPtr nullBmp = FilterFill<Pixel8>(0).apply(pBmp);
+ pBmp->copyPixels(*pBaseBmp);
+ HistoryPreProcessor filt(pBaseBmp->getSize(), 1, true);
+ pBmp = filt.apply(pBaseBmp);
+ testEqual(*pBmp, *nullBmp, "HistoryPreprocessor1");
+ for(int i=0;i<1;i++){
+ pBmp = filt.apply(pBaseBmp);
+ testEqual(*pBmp, *nullBmp, "HistoryPreprocessor2");
+ }
+ }
+
+};
+
+class FilterFastBandpassTest: public GraphicsTest {
+public:
+ FilterFastBandpassTest()
+ : GraphicsTest("FilterFastBandpassTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(16,16), I8));
+ FilterFill<Pixel8>(0).applyInPlace(pBmp);
+ *(pBmp->getPixels()+pBmp->getStride()*7+7) = 255;
+ BitmapPtr pDestBmp = FilterFastBandpass().apply(pBmp);
+ testEqual(*pDestBmp, "FastBandpassResult", I8);
+ }
+};
+
+
+class FilterHighpassTest: public GraphicsTest {
+public:
+ FilterHighpassTest()
+ : GraphicsTest("FilterHighpassTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(16,16), I8));
+ FilterFill<Pixel8>(0).applyInPlace(pBmp);
+ *(pBmp->getPixels()+pBmp->getStride()*7+7) = 255;
+ BitmapPtr pDestBmp = FilterHighpass().apply(pBmp);
+ testEqual(*pDestBmp, "HighpassResult", I8);
+ }
+};
+
+
+class FilterGaussTest: public GraphicsTest {
+public:
+ FilterGaussTest()
+ : GraphicsTest("FilterGaussTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(16,16), I8));
+ FilterFill<Pixel8>(0).applyInPlace(pBmp);
+ *(pBmp->getPixels()+pBmp->getStride()*7+7) = 255;
+ BitmapPtr pDestBmp = FilterGauss(3).apply(pBmp);
+ testEqual(*pDestBmp, "Gauss3Result", I8);
+ pDestBmp = FilterGauss(1).apply(pBmp);
+ testEqual(*pDestBmp, "Gauss1Result", I8);
+ pDestBmp = FilterGauss(1.5).apply(pBmp);
+ testEqual(*pDestBmp, "Gauss15Result", I8);
+ pDestBmp = FilterGauss(5).apply(pBmp);
+ testEqual(*pDestBmp, "Gauss5Result", I8);
+ }
+};
+
+
+class FilterBlurTest: public GraphicsTest {
+public:
+ FilterBlurTest()
+ : GraphicsTest("FilterBlurTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(16,16), I8));
+ FilterFill<Pixel8>(0).applyInPlace(pBmp);
+ *(pBmp->getPixels()+pBmp->getStride()*7+7) = 255;
+ BitmapPtr pDestBmp = FilterBlur().apply(pBmp);
+ testEqual(*pDestBmp, "BlurResult", I8);
+ }
+};
+
+
+class FilterBandpassTest: public GraphicsTest {
+public:
+ FilterBandpassTest()
+ : GraphicsTest("FilterBandpassTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(16,16), I8));
+ FilterFill<Pixel8>(0).applyInPlace(pBmp);
+ *(pBmp->getPixels()+pBmp->getStride()*7+7) = 255;
+
+ BitmapPtr pDestBmp = FilterBandpass(1.9,3).apply(pBmp);
+ testEqual(*pDestBmp, "BandpassResult", I8);
+ }
+};
+
+class FilterFastDownscaleTest: public GraphicsTest {
+public:
+ FilterFastDownscaleTest()
+ : GraphicsTest("FilterFastDownscaleTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(IntPoint(4,4), I8));
+ FilterFill<Pixel8>(0).applyInPlace(pBmp);
+ *(pBmp->getPixels()+pBmp->getStride()*3+3) = 252;
+
+ BitmapPtr pDestBmp = FilterFastDownscale(2).apply(pBmp);
+ testEqual(*pDestBmp, "FastDownscaleResult", I8);
+ }
+};
+
+class FilterMaskTest: public GraphicsTest {
+public:
+ FilterMaskTest()
+ : GraphicsTest("FilterMaskTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ runTestsWithBmp(initBmp(I8), "I8");
+ runTestsWithBmp(initBmp(B8G8R8), "B8G8R8");
+ runTestsWithBmp(initBmp(B8G8R8X8), "B8G8R8X8");
+ }
+
+private:
+ void runTestsWithBmp(BitmapPtr pBmp, const string& sName)
+ {
+ BitmapPtr pMaskBmp = BitmapPtr(new Bitmap(pBmp->getSize(), I8));
+ FilterFill<Pixel8>(0).applyInPlace(pMaskBmp);
+ for (int y = 0; y < pBmp->getSize().y; y++) {
+ pMaskBmp->setPixel(IntPoint(1, y), Pixel8(128));
+ pMaskBmp->setPixel(IntPoint(2, y), Pixel8(255));
+ pMaskBmp->setPixel(IntPoint(3, y), Pixel8(255));
+ }
+
+ BitmapPtr pDestBmp = FilterMask(pMaskBmp).apply(pBmp);
+ string sFName = string("baseline/MaskResult")+sName+".png";
+// pDestBmp->save(sFName);
+ sFName = getSrcDirName()+sFName;
+ BitmapPtr pRGBXBaselineBmp = BitmapPtr(new Bitmap(sFName));
+ BitmapPtr pBaselineBmp = BitmapPtr(
+ new Bitmap(pRGBXBaselineBmp->getSize(), pBmp->getPixelFormat()));
+ pBaselineBmp->copyPixels(*pRGBXBaselineBmp);
+ TEST(*pDestBmp == *pBaselineBmp);
+ }
+};
+
+class FilterThresholdTest: public GraphicsTest {
+public:
+ FilterThresholdTest()
+ : GraphicsTest("FilterThresholdTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp(initBmp(I8));
+ BitmapPtr pDestBmp = FilterThreshold(1).apply(pBmp);
+ string sFName = "baseline/ThresholdResult.png";
+// pDestBmp->save(sFName);
+ sFName = getSrcDirName()+sFName;
+ BitmapPtr pRGBXBaselineBmp = BitmapPtr(new Bitmap(sFName));
+ BitmapPtr pBaselineBmp = BitmapPtr(
+ new Bitmap(pRGBXBaselineBmp->getSize(), pBmp->getPixelFormat()));
+ pBaselineBmp->copyPixels(*pRGBXBaselineBmp);
+ TEST(*pDestBmp == *pBaselineBmp);
+ }
+};
+
+class FilterFloodfillTest: public GraphicsTest {
+public:
+ FilterFloodfillTest()
+ : GraphicsTest("FilterFloodfillTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("floodfill");
+ BitmapPtr pDestBmp = FilterFloodfill<ColorTester>(
+ ColorTester(Pixel32(255,255,255,255)), IntPoint(4,3)).apply(pBmp);
+ testEqual(*pDestBmp, "FloodfillResult", B8G8R8A8, 0, 0);
+ }
+
+};
+
+class FilterDilationTest: public GraphicsTest {
+public:
+ FilterDilationTest()
+ : GraphicsTest("FilterDilationTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("dilation", I8);
+ BitmapPtr pDestBmp = FilterDilation().apply(pBmp);
+ testEqual(*pDestBmp, "DilationResult", I8, 0, 0);
+ }
+
+};
+
+class FilterErosionTest: public GraphicsTest {
+public:
+ FilterErosionTest()
+ : GraphicsTest("FilterErosionTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("erosion", I8);
+ BitmapPtr pDestBmp = FilterErosion().apply(pBmp);
+ testEqual(*pDestBmp, "ErosionResult", I8, 0, 0);
+ }
+
+};
+
+class FilterAlphaTest: public GraphicsTest {
+public:
+ FilterAlphaTest()
+ : GraphicsTest("FilterAlphaTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("rgb24alpha-64x64", R8G8B8A8);
+ BitmapPtr pAlphaBmp = FilterGetAlpha().apply(pBmp);
+ testEqual(*pAlphaBmp, "GetAlphaResult", I8, 0, 0);
+ BitmapPtr pDestBmp(new Bitmap(*pBmp));
+ pDestBmp->setAlpha(*pAlphaBmp);
+ testEqual(*pDestBmp, *pBmp, "SetAlphaResult", 0, 0);
+ }
+
+};
+
+class FilterResizeBilinearTest: public GraphicsTest {
+public:
+ FilterResizeBilinearTest()
+ : GraphicsTest("FilterResizeBilinearTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("rgb24alpha-64x64", B8G8R8A8);
+ runTestWithBitmap(pBmp);
+ pBmp = loadTestBmp("rgb24-64x64", B8G8R8X8);
+ runTestWithBitmap(pBmp);
+ }
+
+private:
+ void runTestWithBitmap(BitmapPtr pBmp)
+ {
+ BitmapPtr pDestBmp = FilterResizeBilinear(IntPoint(32,32)).apply(pBmp);
+ string sName = string("ResizeBilinearResult")
+ +getPixelFormatString(pBmp->getPixelFormat());
+ testEqual(*pDestBmp, sName, pBmp->getPixelFormat());
+ }
+
+};
+
+class FilterUnmultiplyAlphaTest: public GraphicsTest {
+public:
+ FilterUnmultiplyAlphaTest()
+ : GraphicsTest("FilterUnmultiplyAlphaTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp(new Bitmap(IntPoint(16, 1), B8G8R8A8));
+ for (int x = 0; x < 16; ++x) {
+ unsigned char * pPixel = pBmp->getPixels()+x*4;
+ unsigned char val = 17*x;
+ *(pPixel+REDPOS) = val;
+ *(pPixel+GREENPOS) = val;
+ *(pPixel+BLUEPOS) = val;
+ *(pPixel+ALPHAPOS) = val;
+ }
+ FilterUnmultiplyAlpha().applyInPlace(pBmp);
+ QUIET_TEST(*(pBmp->getPixels()+ALPHAPOS) == 0);
+ for (int x = 1; x < 16; ++x) {
+ unsigned char * pPixel = pBmp->getPixels()+x*4;
+ QUIET_TEST(*(pPixel+REDPOS) == 255);
+ QUIET_TEST(*(pPixel+GREENPOS) == 255);
+ QUIET_TEST(*(pPixel+BLUEPOS) == 255);
+ QUIET_TEST(*(pPixel+ALPHAPOS) == 17*x);
+ }
+ }
+
+private:
+
+};
+
+class GraphicsTestSuite: public TestSuite {
+public:
+ GraphicsTestSuite()
+ : TestSuite("GraphicsTestSuite")
+ {
+ addTest(TestPtr(new PixelTest));
+ addTest(TestPtr(new BitmapTest));
+ addTest(TestPtr(new Filter3x3Test));
+ addTest(TestPtr(new FilterConvolTest));
+ addTest(TestPtr(new FilterColorizeTest));
+ addTest(TestPtr(new FilterGrayscaleTest));
+ addTest(TestPtr(new FilterFillTest));
+ addTest(TestPtr(new FilterFlipTest));
+ addTest(TestPtr(new FilterFlipRGBTest));
+ addTest(TestPtr(new FilterFlipUVTest));
+ addTest(TestPtr(new FilterComboTest));
+ addTest(TestPtr(new HistoryPreProcessorTest));
+ addTest(TestPtr(new FilterHighpassTest));
+ addTest(TestPtr(new FilterGaussTest));
+ addTest(TestPtr(new FilterBlurTest));
+ addTest(TestPtr(new FilterBandpassTest));
+ addTest(TestPtr(new FilterFastBandpassTest));
+ addTest(TestPtr(new FilterFastDownscaleTest));
+ addTest(TestPtr(new FilterMaskTest));
+ addTest(TestPtr(new FilterThresholdTest));
+ addTest(TestPtr(new FilterFloodfillTest));
+ addTest(TestPtr(new FilterDilationTest));
+ addTest(TestPtr(new FilterErosionTest));
+ addTest(TestPtr(new FilterAlphaTest));
+ addTest(TestPtr(new FilterResizeBilinearTest));
+ addTest(TestPtr(new FilterUnmultiplyAlphaTest));
+ }
+};
+
+
+int main(int nargs, char** args)
+{
+ GraphicsTest::createResultImgDir();
+ GraphicsTestSuite suite;
+ suite.runTests();
+ bool bOK = suite.isOk();
+
+ if (bOK) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
diff --git a/src/imaging/Blob.cpp b/src/imaging/Blob.cpp
new file mode 100644
index 0000000..59726af
--- /dev/null
+++ b/src/imaging/Blob.cpp
@@ -0,0 +1,616 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "Blob.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include "../graphics/Filterfill.h"
+#include "../graphics/Pixel8.h"
+
+#include <stdlib.h>
+#include <math.h>
+
+#include <climits>
+#include <iostream>
+#include <algorithm>
+
+using namespace std;
+
+namespace avg {
+
+Blob::Blob(const Run& run)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ m_Runs.reserve(50);
+ m_Runs.push_back(run);
+ m_pParent = BlobPtr();
+
+ m_bStatsAvailable = false;
+}
+
+Blob::~Blob()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+RunArray *Blob::getRuns()
+{
+ return &m_Runs;
+}
+
+void Blob::addRun(const Run& run)
+{
+ AVG_ASSERT((m_Runs.end()-1)->m_Row <= run.m_Row);
+ m_Runs.push_back(run);
+}
+
+
+void Blob::merge(const BlobPtr& pOtherBlob)
+{
+ AVG_ASSERT(pOtherBlob);
+ RunArray * pOtherRuns = pOtherBlob->getRuns();
+ m_Runs.insert(m_Runs.end(), pOtherRuns->begin(), pOtherRuns->end());
+ pOtherRuns->clear();
+}
+
+void Blob::render(BitmapPtr pSrcBmp, BitmapPtr pDestBmp, Pixel32 color,
+ int min, int max, bool bFinger, bool bMarkCenter, Pixel32 centerColor)
+{
+ AVG_ASSERT(pSrcBmp);
+ AVG_ASSERT(pDestBmp);
+ AVG_ASSERT(pSrcBmp->getBytesPerPixel() == 1);
+ AVG_ASSERT(pDestBmp->getBytesPerPixel() == 4);
+ AVG_ASSERT(pSrcBmp->getSize() == pDestBmp->getSize());
+ unsigned char *pSrc;
+ unsigned char *pDest;
+ unsigned char *pColor = (unsigned char *)(&color);
+ int intensityScale = 2*256/(std::max(max-min, 1));
+ for (RunArray::iterator it = m_Runs.begin(); it != m_Runs.end(); ++it) {
+ AVG_ASSERT(it->m_Row < pSrcBmp->getSize().y);
+ AVG_ASSERT(it->m_StartCol >= 0);
+ AVG_ASSERT(it->m_EndCol <= pSrcBmp->getSize().x);
+ pSrc = pSrcBmp->getPixels()+it->m_Row*pSrcBmp->getStride();
+ pDest = pDestBmp->getPixels()+it->m_Row*pDestBmp->getStride();
+ int x = it->m_StartCol;
+ pSrc += x;
+ pDest+= x*4;
+ while (x < it->m_EndCol) {
+ int factor = (*pSrc-min)*intensityScale;
+ if (factor < 0) {
+ factor = 0;
+ }
+ if (factor > 255) {
+ factor = 255;
+ }
+ *(pDest++) = ((*pColor)*factor) >> 8;
+ *(pDest++) = ((*(pColor+1))*factor) >> 8;
+ *(pDest++) = ((*(pColor+2))*factor) >> 8;
+ *(pDest++) = ((*(pColor+3))*factor) >> 8;
+ pSrc++;
+ x++;
+ }
+ }
+ AVG_ASSERT(m_bStatsAvailable);
+ if (bMarkCenter) {
+ IntPoint center = IntPoint(int(m_Center.x+0.5), int(m_Center.y+0.5));
+
+ IntPoint end0 = IntPoint(m_ScaledBasis[0])+center;
+ pDestBmp->drawLine(center, end0, centerColor);
+ IntPoint end1 = IntPoint(m_ScaledBasis[1])+center;
+ pDestBmp->drawLine(center, end1, centerColor);
+
+ if (bFinger && m_RelatedBlobs.size() > 0) {
+ // Draw finger direction
+ BlobPtr pHandBlob = (m_RelatedBlobs)[0].lock();
+ if (pHandBlob) {
+ pDestBmp->drawLine(center, IntPoint(pHandBlob->getCenter()),
+ Pixel32(0xD7, 0xC9, 0x56, 0xFF));
+ }
+ }
+ if (!m_Contour.empty()) {
+ for (vector<IntPoint>::iterator it = m_Contour.begin()+1;
+ it != m_Contour.end(); ++it)
+ {
+ IntPoint pt1 = *(it-1);
+ IntPoint pt2 = *it;
+ pDestBmp->drawLine(pt1, pt2, centerColor);
+ }
+ pDestBmp->drawLine(*(m_Contour.end()-1), *m_Contour.begin(), centerColor);
+ }
+ }
+}
+
+bool Blob::contains(IntPoint pt)
+{
+ for (RunArray::iterator it = m_Runs.begin(); it != m_Runs.end(); ++it) {
+ if (it->m_Row == pt.y && it->m_StartCol <= pt.x && it->m_EndCol > pt.x) {
+ return true;
+ }
+ }
+ return false;
+}
+
+void Blob::calcStats()
+{
+ m_Center = calcCenter();
+ m_EstimatedNextCenter = m_Center;
+ m_Area = calcArea();
+ m_BoundingBox = calcBBox();
+ /*
+ more useful numbers that can be calculated from c
+ see e.g.
+ <http://www.cs.cf.ac.uk/Dave/Vision_lecture/node36.html#SECTION00173000000000000000>
+
+ Orientation = tan−1(2(c_xy)/(c_xx − c_yy)) /2
+ Inertia = c_xx + c_yy
+ Eccentricity = ...
+ */
+ double c_xx = 0; // Variance in x direction
+ double c_yy =0; // Variance in y direction
+ double c_xy = 0; // Covariance
+ double ll=0;
+ double l1;
+ double l2;
+ double tmp_x;
+ double tmp_y;
+ double mag;
+ for (RunArray::iterator r = m_Runs.begin(); r != m_Runs.end();++r) {
+ //This is the evaluated expression for the variance when using runs...
+ ll = r->length();
+ c_yy += ll* (r->m_Row- m_Center.y)*(r->m_Row- m_Center.y);
+ c_xx += ( (r->m_EndCol-1) * r->m_EndCol * (2*r->m_EndCol-1)
+ - (r->m_StartCol-1) * r->m_StartCol * (2*r->m_StartCol -1))/6.
+ - m_Center.x * ((r->m_EndCol-1)*r->m_EndCol-(r->m_StartCol-1)*r->m_StartCol)
+ + ll* m_Center.x*m_Center.x;
+ c_xy += (r->m_Row-m_Center.y)*0.5*( (r->m_EndCol-1)*r->m_EndCol
+ - (r->m_StartCol-1)*r->m_StartCol)
+ + ll *(m_Center.x*m_Center.y - m_Center.x*r->m_Row);
+ }
+
+ c_xx /= m_Area;
+ c_yy /= m_Area;
+ c_xy /= m_Area;
+
+ m_Inertia = c_xx + c_yy;
+
+ double T = sqrt( (c_xx - c_yy) * (c_xx - c_yy) + 4*c_xy*c_xy);
+ m_Eccentricity = ((c_xx + c_yy) + T)/((c_xx+c_yy) - T);
+ m_Orientation = 0.5*atan2(2*c_xy,c_xx-c_yy);
+ // The l_i are variances (unit L^2) so to arrive at numbers that
+ // correspond to lengths in the picture we use sqrt
+ // Ensure that eigenvectors always have standard orientation, i.e. the determinant
+ // of the matrix with the eigenvectors as columns is >0
+ // E_1.x E_2.y - E_1.y E_2.x > 0
+ if (fabs(c_xy) > 1e-30) {
+ //FIXME. check l1!=0 l2!=0. li=0 happens for line-like components
+ l1 = 0.5 * ((c_xx+c_yy) + sqrt((c_xx+c_yy)*(c_xx+c_yy)-4*(c_xx*c_yy-c_xy*c_xy)));
+ l2 = 0.5 * ((c_xx+c_yy) - sqrt((c_xx+c_yy)*(c_xx+c_yy)-4*(c_xx*c_yy-c_xy*c_xy)));
+ tmp_x = c_xy/l1 - c_xx*c_yy/(c_xy*l1)+ (c_xx/c_xy);
+ tmp_y = 1.;
+ mag = sqrt(tmp_x*tmp_x + tmp_y*tmp_y);
+ m_EigenVector[0].x = tmp_x/mag;
+ m_EigenVector[0].y = tmp_y/mag;
+ m_EigenValues.x = l1;
+ tmp_x = c_xy/l2 - c_xx*c_yy/(c_xy*l2)+ (c_xx/c_xy);
+ tmp_y = 1.;
+ mag = sqrt(tmp_x*tmp_x + tmp_y*tmp_y);
+ m_EigenVector[1].x = tmp_x/mag;
+ m_EigenVector[1].y = tmp_y/mag;
+ m_EigenValues.y = l2;
+ if (m_EigenVector[0].x*m_EigenVector[1].y - m_EigenVector[0].y*m_EigenVector[1].x
+ < 0)
+ {
+ m_EigenVector[0] *= -1;
+ }
+ } else {
+ //matrix already diagonal
+ if (c_xx > c_yy) {
+ m_EigenVector[0].x = 1;
+ m_EigenVector[0].y = 0;
+ m_EigenVector[1].x = 0;
+ m_EigenVector[1].y = 1;
+ m_EigenValues.x = c_xx;
+ m_EigenValues.y = c_yy;
+ } else {
+ m_EigenVector[0].x = 0;
+ m_EigenVector[0].y = -1;
+ m_EigenVector[1].x = 1;
+ m_EigenVector[1].y = 0;
+ m_EigenValues.x = c_yy;
+ m_EigenValues.y = c_xx;
+ }
+ }
+ m_ScaledBasis[0].x = m_EigenVector[0].x*sqrt(m_EigenValues.x);
+ m_ScaledBasis[0].y = m_EigenVector[0].y*sqrt(m_EigenValues.x);
+ m_ScaledBasis[1].x = m_EigenVector[1].x*sqrt(m_EigenValues.y);
+ m_ScaledBasis[1].y = m_EigenVector[1].y*sqrt(m_EigenValues.y);
+
+ m_bStatsAvailable = true;
+}
+
+const DPoint& Blob::getCenter() const
+{
+ return m_Center;
+}
+
+const DPoint& Blob::getEstimatedNextCenter() const
+{
+ return m_EstimatedNextCenter;
+}
+
+double Blob::getArea() const
+{
+ return m_Area;
+}
+
+const IntRect& Blob::getBoundingBox() const
+{
+ return m_BoundingBox;
+}
+
+double Blob::getEccentricity() const
+{
+ return m_Eccentricity;
+}
+
+double Blob::getInertia() const
+{
+ return m_Inertia;
+}
+
+double Blob::getOrientation() const
+{
+ return m_Orientation;
+}
+
+const DPoint & Blob::getScaledBasis(int i) const
+{
+ return m_ScaledBasis[i];
+}
+
+const DPoint & Blob::getEigenVector(int i) const
+{
+ return m_EigenVector[i];
+}
+
+const DPoint & Blob::getEigenValues() const
+{
+ return m_EigenValues;
+}
+
+void Blob::calcNextCenter(DPoint oldCenter)
+{
+ m_EstimatedNextCenter = m_Center + (m_Center - oldCenter);
+}
+
+void Blob::clearRelated()
+{
+ m_RelatedBlobs.clear();
+}
+
+void Blob::addRelated(BlobPtr pBlob)
+{
+ m_RelatedBlobs.push_back(pBlob);
+}
+
+const BlobPtr Blob::getFirstRelated()
+{
+ if (m_RelatedBlobs.empty()) {
+ return BlobPtr();
+ } else {
+ return m_RelatedBlobs[0].lock();
+ }
+}
+
+DPoint Blob::calcCenter()
+{
+ DPoint center(0,0);
+ double c = 0;
+ for (RunArray::iterator r = m_Runs.begin(); r != m_Runs.end(); ++r) {
+ center += r->m_Center*r->length();
+ c += r->length();
+ }
+ center = center/c;
+ return center;
+}
+
+IntRect Blob::calcBBox()
+{
+ int x1 = INT_MAX;
+ int y1 = INT_MAX;
+ int x2 = 0;
+ int y2 = 0;
+ for (RunArray::iterator r = m_Runs.begin(); r!=m_Runs.end(); ++r) {
+ x1 = std::min(x1, r->m_StartCol);
+ y1 = std::min(y1, r->m_Row);
+ x2 = std::max(x2, r->m_EndCol);
+ y2 = std::max(y2, r->m_Row);
+ }
+ return IntRect(x1, y1, x2, y2);
+}
+
+int Blob::calcArea()
+{
+ int res = 0;
+ for (RunArray::iterator r = m_Runs.begin(); r != m_Runs.end(); ++r) {
+ res+= r->length();
+ }
+ return res;
+}
+
+void Blob::initRowPositions()
+{
+ int offset = m_BoundingBox.tl.y;
+ RunArray::iterator it = m_Runs.begin();
+ for (int i = 0; i < m_BoundingBox.height(); i++) {
+ while (it->m_Row-offset < i) {
+ it++;
+ }
+ m_RowPositions.push_back(it);
+ }
+}
+
+IntPoint getNeighbor(const IntPoint& pt, int dir)
+{
+ IntPoint neighborPt(pt);
+ // dir encoding:
+ // 3 2 1
+ // 4 pt 0
+ // 5 6 7
+ switch(dir) {
+ case 0:
+ case 1:
+ case 7:
+ neighborPt.x++;
+ break;
+ case 3:
+ case 4:
+ case 5:
+ neighborPt.x--;
+ break;
+ default:
+ break;
+ };
+ switch(dir) {
+ case 1:
+ case 2:
+ case 3:
+ neighborPt.y--;
+ break;
+ case 5:
+ case 6:
+ case 7:
+ neighborPt.y++;
+ break;
+ default:
+ break;
+ };
+ return neighborPt;
+}
+
+IntPoint Blob::findNeighborInside(const IntPoint& pt, int& dir)
+{
+ if (dir & 1) {
+ dir += 2;
+ } else {
+ dir++;
+ }
+ if (dir > 7) {
+ dir -= 8;
+ }
+
+ for (int i = 0; i < 8; i++) {
+ IntPoint curPt = getNeighbor(pt, dir);
+ if (ptIsInBlob(curPt)) {
+ return curPt;
+ } else {
+ dir--;
+ if (dir < 0) {
+ dir += 8;
+ }
+ }
+ }
+ AVG_ASSERT(false);
+ return pt;
+}
+
+bool runIsLess(const Run& r1, const Run& r2)
+{
+ return r1.m_Row < r2.m_Row;
+}
+
+void Blob::calcContour(int precision)
+{
+ sort(m_Runs.begin(), m_Runs.end(), runIsLess);
+ initRowPositions();
+
+ // Moore Neighbor Tracing.
+ IntPoint boundaryPt(m_Runs[0].m_StartCol, m_Runs[0].m_Row);
+ IntPoint firstPt(boundaryPt);
+ int i = precision;
+ int dir = 1;
+ do {
+ i++;
+ if (i >= precision) {
+ m_Contour.push_back(boundaryPt);
+ i = 0;
+ }
+ boundaryPt = findNeighborInside(boundaryPt, dir);
+ } while (firstPt != boundaryPt);
+}
+
+ContourSeq Blob::getContour()
+{
+ return m_Contour;
+}
+
+bool Blob::ptIsInBlob(const IntPoint& pt)
+{
+ if (m_BoundingBox.contains(pt)) {
+ RunArray::iterator it = m_RowPositions[pt.y-m_BoundingBox.tl.y];
+ while (it->m_Row == pt.y) {
+ if (pt.x >= it->m_StartCol && pt.x < it->m_EndCol) {
+ return true;
+ }
+ it++;
+ }
+ }
+ return false;
+}
+
+bool areConnected(const Run & run1, const Run & run2)
+{
+ if (run1.m_StartCol > run2.m_StartCol) {
+ return run2.m_EndCol > run1.m_StartCol;
+ } else {
+ return run1.m_EndCol > run2.m_StartCol;
+ }
+}
+
+void storeRuns(BlobVectorPtr pBlobs, RunArray* pUpperRuns, RunArray* pLowerRuns)
+{
+ for (RunArray::iterator run1_it = pUpperRuns->begin(); run1_it != pUpperRuns->end();
+ ++run1_it)
+ {
+ for (RunArray::iterator run2_it = pLowerRuns->begin();
+ run2_it != pLowerRuns->end(); ++run2_it)
+ {
+ if (run2_it->m_StartCol > run1_it->m_EndCol) {
+ break;
+ }
+ if (areConnected(*run1_it, *run2_it)) {
+ BlobPtr pBlob = run1_it->m_pBlob.lock();
+ while (pBlob->m_pParent) {
+ pBlob = pBlob->m_pParent;
+ }
+ if (!(run2_it->m_pBlob.expired())) {
+ BlobPtr c_blob = run2_it->m_pBlob.lock();
+ while (c_blob->m_pParent) {
+ c_blob = c_blob->m_pParent;
+ }
+ if (c_blob != pBlob) {
+ // When we merge, make sure the smaller blob is merged
+ // into the bigger one to avoid a speed hit.
+ if (pBlob->getRuns()->size() > c_blob->getRuns()->size()) {
+ pBlob->merge(c_blob); //destroys c_blobs runs_list
+ c_blob->m_pParent = pBlob;
+ } else {
+ c_blob->merge(pBlob);
+ pBlob->m_pParent = c_blob;
+ }
+ }
+ } else {
+ run2_it->m_pBlob = pBlob;
+ pBlob->addRun(*run2_it);
+ }
+ }
+ }
+ }
+ for (RunArray::iterator run2_it = pLowerRuns->begin(); run2_it != pLowerRuns->end();
+ ++run2_it)
+ {
+ if (run2_it->m_pBlob.expired()) {
+ BlobPtr pBlob = BlobPtr(new Blob(*run2_it));
+ pBlobs->push_back(pBlob);
+ run2_it->m_pBlob = pBlob;
+ }
+ }
+}
+
+void findRunsInLine(BitmapPtr pBmp, int y, RunArray* pRuns, unsigned char threshold)
+{
+ int runStart=0;
+ int runStop=0;
+ const unsigned char * pPixel = pBmp->getPixels()+y*pBmp->getStride();
+ bool bIsInRun = *pPixel > threshold;
+
+ int width = pBmp->getSize().x;
+ for (int x = 0; x < width; x++) {
+ bool bPixelInRun = *pPixel > threshold;
+ if (bIsInRun != bPixelInRun) {
+ if (bIsInRun) {
+ // Only if the run is longer than one pixel.
+ if (x-runStart > 1) {
+ runStop = x;
+ pRuns->push_back(Run(y, runStart, runStop));
+ runStart = x;
+ }
+ } else {
+ runStop = x - 1;
+ if (runStop-runStart == 0 && !pRuns->empty()) {
+ // Single dark pixel: ignore the pixel, revive the last run.
+ runStart = pRuns->back().m_StartCol;
+ pRuns->pop_back();
+ } else {
+ runStart = x;
+ }
+ }
+ bIsInRun = bPixelInRun;
+ }
+ pPixel++;
+ }
+ if (bIsInRun) {
+ pRuns->push_back(Run(y, runStart, width));
+ }
+}
+
+BlobVectorPtr findConnectedComponents(BitmapPtr pBmp, unsigned char threshold)
+{
+ AVG_ASSERT(pBmp->getPixelFormat() == I8);
+ BlobVectorPtr pBlobs = BlobVectorPtr(new BlobVector);
+ IntPoint size = pBmp->getSize();
+ RunArray* pUpperRuns = new RunArray();
+ RunArray* pLowerRuns = new RunArray();
+
+ int y = 0;
+ findRunsInLine(pBmp, 0, pUpperRuns, threshold);
+ for (RunArray::iterator it = pUpperRuns->begin(); it!=pUpperRuns->end(); ++it) {
+ BlobPtr pBlob = BlobPtr(new Blob(*it));
+ pBlobs->push_back(pBlob);
+ it->m_pBlob = pBlob;
+ }
+
+ for (y = 1; y < size.y; y++) {
+ findRunsInLine(pBmp, y, pLowerRuns, threshold);
+ storeRuns(pBlobs, pUpperRuns, pLowerRuns);
+ RunArray* pTmpRuns = pUpperRuns;
+ pUpperRuns = pLowerRuns;
+ pLowerRuns = pTmpRuns;
+ pLowerRuns->clear();
+ }
+ BlobVectorPtr pResultBlobs = BlobVectorPtr(new BlobVector);
+ for (BlobVector::iterator it = pBlobs->begin(); it != pBlobs->end(); ++it) {
+ if (!(*it)->m_pParent) {
+ pResultBlobs->push_back(*it);
+ (*it)->calcStats();
+ }
+ }
+ delete pUpperRuns;
+ delete pLowerRuns;
+ return pResultBlobs;
+}
+
+
+}
diff --git a/src/imaging/Blob.h b/src/imaging/Blob.h
new file mode 100644
index 0000000..5ced2c6
--- /dev/null
+++ b/src/imaging/Blob.h
@@ -0,0 +1,120 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#ifndef _ConnectedComps_H_
+#define _ConnectedComps_H_
+
+#include "../api.h"
+#include "Run.h"
+
+#include "../graphics/Bitmap.h"
+#include "../graphics/Pixel32.h"
+
+#include "../base/Point.h"
+
+#include <vector>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+namespace avg {
+
+class Blob;
+typedef boost::shared_ptr<class Blob> BlobPtr;
+typedef boost::weak_ptr<class Blob> BlobWeakPtr;
+typedef std::vector<BlobPtr> BlobVector;
+typedef std::vector<BlobWeakPtr> BlobWeakPtrVector;
+typedef boost::shared_ptr<BlobVector> BlobVectorPtr;
+typedef std::vector<IntPoint> ContourSeq;
+
+class AVG_API Blob
+{
+ public:
+ Blob(const Run& run);
+ ~Blob();
+
+ void addRun(const Run& run);
+ void merge(const BlobPtr& other);
+ RunArray* getRuns();
+ void render(BitmapPtr pSrcBmp, BitmapPtr pDestBmp, Pixel32 Color,
+ int Min, int Max, bool bFinger, bool bMarkCenter,
+ Pixel32 CenterColor= Pixel32(0x00, 0x00, 0xFF, 0xFF));
+ bool contains(IntPoint pt);
+
+ void calcStats();
+ void calcContour(int Precision);
+ ContourSeq getContour();
+
+ const DPoint& getCenter() const;
+ const DPoint& getEstimatedNextCenter() const;
+ double getArea() const;
+ const IntRect & getBoundingBox() const;
+ double getEccentricity() const;
+ double getInertia() const;
+ double getOrientation() const;
+ const DPoint& getScaledBasis(int i) const;
+ const DPoint& getEigenVector(int i) const;
+ const DPoint& getEigenValues() const;
+
+ void calcNextCenter(DPoint oldCenter);
+ void clearRelated();
+ void addRelated(BlobPtr pBlob);
+ const BlobPtr getFirstRelated();
+
+ BlobPtr m_pParent;
+
+ private:
+ Blob(const Blob &);
+ DPoint calcCenter();
+ IntRect calcBBox();
+ int calcArea();
+ void initRowPositions();
+ IntPoint findNeighborInside(const IntPoint& Pt, int& Dir);
+ bool ptIsInBlob(const IntPoint& Pt);
+
+ RunArray m_Runs; // This array is unsorted until contours are calculated.
+ std::vector<RunArray::iterator> m_RowPositions;
+ BlobWeakPtrVector m_RelatedBlobs; // For fingers, this contains the hand.
+ // For hands, this contains the fingers.
+
+ bool m_bStatsAvailable;
+ DPoint m_EstimatedNextCenter;
+ DPoint m_Center;
+ double m_Area;
+ IntRect m_BoundingBox;
+ double m_Eccentricity;
+ double m_Inertia;
+ double m_Orientation;
+ DPoint m_ScaledBasis[2];
+ DPoint m_EigenVector[2];
+ DPoint m_EigenValues;
+
+ ContourSeq m_Contour;
+};
+
+BlobVectorPtr AVG_API findConnectedComponents(BitmapPtr pBmp,
+ unsigned char threshold);
+
+}
+
+#endif
diff --git a/src/imaging/CMUCamera.cpp b/src/imaging/CMUCamera.cpp
new file mode 100644
index 0000000..1991916
--- /dev/null
+++ b/src/imaging/CMUCamera.cpp
@@ -0,0 +1,385 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "CMUCamera.h"
+#include "CMUCameraUtils.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/OSHelper.h"
+#include "../base/StringHelper.h"
+
+#include <windows.h>
+#include <1394Camera.h>
+
+using namespace std;
+
+namespace avg {
+
+CMUCamera::CMUCamera(long long guid, bool bFW800, IntPoint Size,
+ PixelFormat camPF, PixelFormat destPF, double FrameRate)
+ : Camera(camPF, destPF),
+ m_Size(Size),
+ m_FrameRate(FrameRate),
+ m_WhitebalanceU(-1),
+ m_WhitebalanceV(-1),
+ m_pCamera(0)
+{
+ m_pCamera = new C1394Camera();
+ int err;
+ unsigned long videoFormat, videoMode;
+ getVideoFormatAndMode(m_Size, getCamPF(), &videoFormat, &videoMode);
+
+ // Find and open camera
+ if (m_pCamera->RefreshCameraList() <= 0) {
+ throw Exception(AVG_ERR_CAMERA_NONFATAL, "No Firewire cameras found");
+ }
+ int i = getCamIndex(guid);
+ err = m_pCamera->SelectCamera(i);
+ err = m_pCamera->InitCamera(TRUE);
+ AVG_ASSERT(err == CAM_SUCCESS);
+
+ if (bFW800) {
+ m_pCamera->Set1394b(true);
+ }
+
+ // Setup video format and rate
+ err = m_pCamera->SetVideoFormat(videoFormat);
+ checkCMUError(err, AVG_ERR_CAMERA_NONFATAL,
+ string("CMUCamera: Error setting video format ") + toString(videoFormat) +
+ ", mode: " + toString(videoMode));
+ err = m_pCamera->SetVideoMode(videoMode);
+ checkCMUError(err, AVG_ERR_CAMERA_NONFATAL,
+ string("CMUCamera: Error setting video mode ") + toString(videoMode) +
+ ", format: " + toString(videoFormat));
+ err = m_pCamera->SetVideoFrameRate(getFrameRateConst(m_FrameRate));
+ checkCMUError(err, AVG_ERR_CAMERA_NONFATAL, "Error setting frame rate");
+
+ // Start capturing images
+ err = m_pCamera->StartImageAcquisition();
+ if (err != CAM_SUCCESS) {
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,
+ "CMUCamera: Could not start image acquisition. " +
+ CMUErrorToString(err));
+ }
+
+ // Set camera features
+ for (FeatureMap::iterator it=m_Features.begin(); it != m_Features.end(); it++) {
+ setFeature(it->first, it->second, true);
+ }
+ setWhitebalance(m_WhitebalanceU, m_WhitebalanceV, true);
+
+ if (camPF == BAYER8) {
+ char sModel[256], sVendor[256];
+ m_pCamera->GetCameraName(sModel, 256);
+ m_pCamera->GetCameraVendor(sVendor, 256);
+
+ if (strcmp(sModel, "DFx 31BF03") == 0) {
+ AVG_TRACE(Logger::CONFIG, "Applying bayer pattern fixup for IS DFx31BF03 camera");
+ setCamPF(BAYER8_GRBG);
+ } else if (strcmp(sVendor, "Point Grey Research") == 0) {
+ AVG_TRACE(Logger::CONFIG, "Applying bayer pattern fixup for PointGrey cameras");
+ enablePtGreyBayer();
+ }
+
+ }
+}
+
+CMUCamera::~CMUCamera()
+{
+ m_pCamera->StopImageAcquisition();
+ delete m_pCamera;
+}
+
+
+IntPoint CMUCamera::getImgSize()
+{
+ return m_Size;
+}
+
+BitmapPtr CMUCamera::getImage(bool bWait)
+{
+ if (bWait) {
+ unsigned rc = WaitForSingleObject(m_pCamera->GetFrameEvent(), INFINITE);
+ AVG_ASSERT(rc == WAIT_OBJECT_0);
+ } else {
+ unsigned rc = WaitForSingleObject(m_pCamera->GetFrameEvent(), 0);
+ if (rc == WAIT_TIMEOUT) {
+ // No frame yet
+ return BitmapPtr();
+ }
+ AVG_ASSERT(rc == WAIT_OBJECT_0);
+ }
+ int rc2 = m_pCamera->AcquireImageEx(FALSE, NULL);
+ if (rc2 != CAM_SUCCESS) {
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,
+ "CMUCamera: Could not acquire image from camera. " +
+ CMUErrorToString(rc2));
+ }
+ unsigned long captureBufferLength;
+ unsigned char* pCaptureBuffer = m_pCamera->GetRawData(&captureBufferLength);
+
+ BitmapPtr pCamBmp(new Bitmap(m_Size, getCamPF(), pCaptureBuffer,
+ captureBufferLength / m_Size.y, false, "TempCameraBmp"));
+ return convertCamFrameToDestPF(pCamBmp);
+}
+
+
+const string& CMUCamera::getDevice() const
+{
+ return m_sDevice;
+}
+
+const std::string& CMUCamera::getDriverName() const
+{
+ static string sDriverName = "CMU 1394 Digital Camera Driver";
+ return sDriverName;
+}
+
+double CMUCamera::getFrameRate() const
+{
+ return m_FrameRate;
+}
+
+int CMUCamera::getFeature(CameraFeature Feature) const
+{
+ unsigned short val1;
+ unsigned short val2;
+ internalGetFeature(Feature, &val1, &val2);
+ return val1;
+}
+
+void CMUCamera::setFeature(CameraFeature Feature, int Value, bool bIgnoreOldValue)
+{
+ if (bIgnoreOldValue || m_Features[Feature] != Value) {
+ m_Features[Feature] = Value;
+ if (Feature == CAM_FEATURE_STROBE_DURATION) {
+ if (m_pCamera->HasStrobe()) {
+ C1394CameraControlStrobe* pControl = m_pCamera->GetStrobeControl(0);
+ int err = pControl->SetValue(Value);
+ checkCMUWarning(err == CAM_SUCCESS, "Error setting camera strobe.");
+ } else {
+ AVG_TRACE(Logger::WARNING, "Camera does not support strobe.");
+ }
+ } else {
+ CAMERA_FEATURE cmuFeature = getFeatureID(Feature);
+ if (m_pCamera->HasFeature(cmuFeature)) {
+ bool bAuto = (Value == -1);
+
+ C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature);
+ int err1 = pControl->SetAutoMode(bAuto);
+ int err2 = CAM_SUCCESS;
+ if (!bAuto) {
+ err2 = pControl->SetValue(Value);
+ }
+ checkCMUWarning(err1 == CAM_SUCCESS && err2 == CAM_SUCCESS,
+ string("Error setting camera feature: ") +
+ cameraFeatureToString(Feature));
+ } else {
+ AVG_TRACE(Logger::WARNING, string("Camera does not support feature: ") +
+ cameraFeatureToString(Feature));
+ }
+ }
+ }
+}
+
+void CMUCamera::setFeatureOneShot(CameraFeature Feature)
+{
+ CAMERA_FEATURE cmuFeature = getFeatureID(Feature);
+ if (cmuFeature != FEATURE_INVALID_FEATURE && m_pCamera->HasFeature(cmuFeature)) {
+ C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature);
+ int err1 = pControl->SetOnOff(false);
+ int err2 = pControl->SetAutoMode(false);
+ int err3 = pControl->SetOnePush(true);
+ checkCMUWarning(err1 == CAM_SUCCESS && err2 == CAM_SUCCESS
+ && err3 == CAM_SUCCESS,
+ string("Error setting feature: ") + cameraFeatureToString(Feature));
+ } else {
+ AVG_TRACE(Logger::WARNING, string("Camera does not support feature: ") +
+ cameraFeatureToString(Feature));
+ }
+}
+
+int CMUCamera::getWhitebalanceU() const
+{
+ unsigned short val1;
+ unsigned short val2;
+ internalGetFeature(CAM_FEATURE_WHITE_BALANCE, &val1, &val2);
+ return val1;
+}
+
+int CMUCamera::getWhitebalanceV() const
+{
+ unsigned short val1;
+ unsigned short val2;
+ internalGetFeature(CAM_FEATURE_WHITE_BALANCE, &val1, &val2);
+ return val2;
+}
+
+void CMUCamera::setWhitebalance(int u, int v, bool bIgnoreOldValue)
+{
+ if (bIgnoreOldValue || m_WhitebalanceU != u || m_WhitebalanceV != v) {
+ m_WhitebalanceU = u;
+ m_WhitebalanceV = v;
+ CAMERA_FEATURE cmuFeature = getFeatureID(CAM_FEATURE_WHITE_BALANCE);
+ if (m_pCamera->HasFeature(FEATURE_WHITE_BALANCE)) {
+ bool bAuto = (u == -1);
+
+ C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature);
+ int err1 = pControl->SetAutoMode(bAuto);
+ int err2 = CAM_SUCCESS;
+ if (!bAuto) {
+ err2 = pControl->SetValue(u, v);
+ }
+ checkCMUWarning(err1 == CAM_SUCCESS && err2 == CAM_SUCCESS,
+ string("Error setting camera feature: ") +
+ cameraFeatureToString(CAM_FEATURE_WHITE_BALANCE));
+ } else {
+ AVG_TRACE(Logger::WARNING, string("Camera does not support feature: ") +
+ cameraFeatureToString(CAM_FEATURE_WHITE_BALANCE));
+ }
+ }
+}
+void CMUCamera::dumpCameras()
+{
+ C1394Camera* pCamera = new C1394Camera();
+
+ if (pCamera->RefreshCameraList() <= 0) {
+ return;
+ }
+ if (pCamera->GetNumberCameras() == 0) {
+ return;
+ }
+ cerr << "CMU Driver Firewire Cameras: " << endl;
+ for (int i=0; i<pCamera->GetNumberCameras(); ++i) {
+ pCamera->SelectCamera(i);
+ char sz[256];
+ cerr << " -----------------------" << endl;
+ pCamera->GetCameraVendor(sz, 256);
+ cerr << " Vendor: " << sz << endl;
+ pCamera->GetCameraName(sz, 256);
+ cerr << " Name: " << sz << endl;
+ long long camGuid;
+ pCamera->GetCameraUniqueID((PLARGE_INTEGER)&camGuid);
+ cerr << " GUID: " << camGuid << endl;
+ }
+ delete pCamera;
+}
+
+int CMUCamera::getCamIndex(long long guid)
+{
+ if (guid == 0) {
+ return 0;
+ } else {
+ for (int i=0; i<m_pCamera->GetNumberCameras(); ++i) {
+ m_pCamera->SelectCamera(i);
+ long long camGuid;
+ m_pCamera->GetCameraUniqueID((PLARGE_INTEGER)&camGuid);
+ if (camGuid == guid) {
+ return i;
+ }
+ }
+ AVG_TRACE(Logger::WARNING, string("Camera with guid ") + toString(guid)
+ + " not present. Using first camera.");
+ return 0;
+ }
+}
+
+void CMUCamera::internalGetFeature(CameraFeature Feature, unsigned short* val1,
+ unsigned short* val2) const
+{
+ *val1 = -1;
+ *val2 = -1;
+ CAMERA_FEATURE cmuFeature = getFeatureID(Feature);
+ if (m_pCamera->HasFeature(cmuFeature)) {
+ C1394CameraControl* pControl = m_pCamera->GetCameraControl(cmuFeature);
+ pControl->Status();
+ pControl->GetValue(val1, val2);
+ } else {
+ AVG_TRACE(Logger::WARNING, string("Error reading camera feature: ") +
+ cameraFeatureToString(Feature));
+ }
+}
+
+void CMUCamera::enablePtGreyBayer()
+{
+ int err;
+ unsigned long advOffset = m_pCamera->GetAdvancedFeatureOffset();
+
+ unsigned long imageDataFormat;
+ err = m_pCamera->ReadQuadlet(advOffset+0x48, &imageDataFormat);
+ AVG_ASSERT(err == CAM_SUCCESS);
+ if (imageDataFormat & 0x80000000) {
+ err = m_pCamera->WriteQuadlet(advOffset+0x48, 0x80000081);
+ AVG_ASSERT(err == CAM_SUCCESS);
+ unsigned long bayerFormat;
+ err = m_pCamera->ReadQuadlet(advOffset+0x40, &bayerFormat);
+ AVG_ASSERT(err == CAM_SUCCESS);
+ PixelFormat exactPF = fwBayerStringToPF(bayerFormat);
+ setCamPF(exactPF);
+ } else {
+ AVG_TRACE(Logger::ERROR, "imageDataFormat not supported.");
+ }
+}
+
+void CMUCamera::checkCMUError(int code, int type, const string & sMsg) const
+{
+ if (code != CAM_SUCCESS) {
+ throw Exception(type, sMsg);
+ }
+}
+
+void CMUCamera::checkCMUWarning(bool bOk, const string& sMsg) const
+{
+ if (!bOk) {
+ AVG_TRACE(Logger::WARNING, sMsg);
+ }
+}
+
+string CMUCamera::CMUErrorToString(int code)
+{
+ if (code == CAM_ERROR) {
+ return "WinI/O returned: " + getWinErrMsg(GetLastError());
+ }
+ string msg = "1394Camera returned: ";
+ switch (code) {
+ case CAM_ERROR_UNSUPPORTED:
+ return msg + "CAM_ERROR_UNSUPPORTED.";
+ case CAM_ERROR_NOT_INITIALIZED:
+ return msg + "CAM_ERROR_NOT_INITIALIZED.";
+ case CAM_ERROR_INVALID_VIDEO_SETTINGS:
+ return msg + "CAM_ERROR_INVALID_VIDEO_SETTINGS.";
+ case CAM_ERROR_BUSY:
+ return msg + "CAM_ERROR_BUSY.";
+ case CAM_ERROR_INSUFFICIENT_RESOURCES:
+ return msg + "CAM_ERROR_INSUFFICIENT_RESOURCES.";
+ case CAM_ERROR_PARAM_OUT_OF_RANGE:
+ return msg + "CAM_ERROR_PARAM_OUT_OF_RANGE.";
+ case CAM_ERROR_FRAME_TIMEOUT:
+ return msg + "CAM_ERROR_FRAME_TIMEOUT.";
+ default:
+ return msg + "unknown error.";
+ }
+}
+
+}
diff --git a/src/imaging/CMUCamera.h b/src/imaging/CMUCamera.h
new file mode 100644
index 0000000..58dc129
--- /dev/null
+++ b/src/imaging/CMUCamera.h
@@ -0,0 +1,79 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _CMUCamera_H_
+#define _CMUCamera_H_
+
+#include "../api.h"
+#include "Camera.h"
+
+#include <string>
+
+class C1394Camera;
+
+namespace avg {
+
+class AVG_API CMUCamera : public Camera {
+public:
+ CMUCamera(long long guid, bool bFW800, IntPoint Size, PixelFormat camPF,
+ PixelFormat destPF, double FrameRate);
+ virtual ~CMUCamera();
+
+ virtual IntPoint getImgSize();
+ virtual BitmapPtr getImage(bool bWait);
+
+ virtual const std::string& getDevice() const;
+ virtual const std::string& getDriverName() const;
+ virtual double getFrameRate() const;
+
+ virtual int getFeature(CameraFeature Feature) const;
+ virtual void setFeature(CameraFeature Feature, int Value, bool bIgnoreOldValue=false);
+ virtual void setFeatureOneShot(CameraFeature Feature);
+ virtual int getWhitebalanceU() const;
+ virtual int getWhitebalanceV() const;
+ virtual void setWhitebalance(int u, int v, bool bIgnoreOldValue=false);
+
+ static void dumpCameras();
+
+private:
+ int getCamIndex(long long guid);
+ void internalGetFeature(CameraFeature Feature, unsigned short* val1,
+ unsigned short* val2) const;
+ void enablePtGreyBayer();
+ void checkCMUError(int code, int type, const std::string& sMsg) const;
+ void checkCMUWarning(bool bOk, const std::string& sMsg) const;
+ std::string CMUErrorToString(int code);
+
+ std::string m_sDevice;
+ IntPoint m_Size;
+ double m_FrameRate;
+
+ mutable C1394Camera * m_pCamera; // The CMU1394 lib is not const-correct.
+ FeatureMap m_Features;
+ int m_WhitebalanceU;
+ int m_WhitebalanceV;
+};
+
+}
+
+#endif
diff --git a/src/imaging/CMUCameraUtils.cpp b/src/imaging/CMUCameraUtils.cpp
new file mode 100644
index 0000000..85b2af7
--- /dev/null
+++ b/src/imaging/CMUCameraUtils.cpp
@@ -0,0 +1,221 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "CMUCameraUtils.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+
+namespace avg {
+
+using namespace std;
+
+#define FORMAT_0 0
+// Format 0 Modes
+#define MODE_160_120_YUV444 0
+#define MODE_320x240_YUV422 1
+#define MODE_640x480_YUV411 2
+#define MODE_640x480_YUV422 3
+#define MODE_640x480_RGB 4
+#define MODE_640x480_MONO 5
+#define MODE_640x480_MONO16 6
+
+#define FORMAT_1 1
+// Format 1 Modes
+#define MODE_800x600_YUV422 0
+#define MODE_800x600_RGB 1
+#define MODE_800x600_MONO 2
+#define MODE_1024x768_YUV422 3
+#define MODE_1024x768_RGB 4
+#define MODE_1024x768_MONO 5
+#define MODE_800x600_MONO16 6
+#define MODE_1024x768_MONO16 7
+
+#define FORMAT_2 2
+#define MODE_1280x960_YUV422 0
+#define MODE_1280x960_RGB 1
+#define MODE_1280x960_MONO 2
+#define MODE_1600x1200_YUV422 3
+#define MODE_1600x1200_RGB 4
+#define MODE_1600x1200_MONO 5
+#define MODE_1280x960_MONO16 6
+#define MODE_1600x1200_MONO16 7
+
+// Framerates
+#define FRAMERATE_1_875 0
+#define FRAMERATE_3_75 1
+#define FRAMERATE_7_5 2
+#define FRAMERATE_15 3
+#define FRAMERATE_30 4
+#define FRAMERATE_60 5
+#define FRAMERATE_120 6
+#define FRAMERATE_240 7
+
+void getVideoFormatAndMode(IntPoint& Size, PixelFormat pf,
+ unsigned long* pVideoFormat, unsigned long* pVideoMode)
+{
+ *pVideoMode = -1;
+ *pVideoFormat = -1;
+ if (Size.x == 320 && Size.y == 240) {
+ *pVideoFormat = FORMAT_0;
+ if (pf == YCbCr422) {
+ *pVideoMode = MODE_320x240_YUV422;
+ }
+ } else if (Size.x == 640 && Size.y == 480) {
+ *pVideoFormat = FORMAT_0;
+ if (pf == I8 || pf == BAYER8) {
+ *pVideoMode = MODE_640x480_MONO;
+ } else if (pf == I16) {
+ *pVideoMode = MODE_640x480_MONO16;
+ } else if (pf == YCbCr411) {
+ *pVideoMode = MODE_640x480_YUV411;
+ } else if (pf == YCbCr422) {
+ *pVideoMode = MODE_640x480_YUV422;
+ } else if (pf == R8G8B8 || pf == B8G8R8) {
+ *pVideoMode = MODE_640x480_RGB;
+ }
+ } else if (Size.x == 800 && Size.y == 600) {
+ *pVideoFormat = FORMAT_1;
+ if (pf == I8 || pf == BAYER8) {
+ *pVideoMode = MODE_800x600_MONO;
+ } else if (pf == I16) {
+ *pVideoMode = MODE_800x600_MONO16;
+ } else if (pf == YCbCr422) {
+ *pVideoMode = MODE_800x600_YUV422;
+ } else if (pf == R8G8B8 || pf == B8G8R8) {
+ *pVideoMode = MODE_800x600_RGB;
+ }
+ } else if (Size.x == 1024 && Size.y == 768) {
+ *pVideoFormat = FORMAT_1;
+ if (pf == I8 || pf == BAYER8) {
+ *pVideoMode = MODE_1024x768_MONO;
+ } else if (pf == I16) {
+ *pVideoMode = MODE_1024x768_MONO16;
+ } else if (pf == YCbCr422) {
+ *pVideoMode = MODE_1024x768_YUV422;
+ } else if (pf == R8G8B8 || pf == B8G8R8) {
+ *pVideoMode = MODE_1024x768_RGB;
+ }
+ } else if (Size.x == 1280 && Size.y == 960) {
+ *pVideoFormat = FORMAT_2;
+ if (pf == I8 || pf == BAYER8) {
+ *pVideoMode = MODE_1280x960_MONO;
+ } else if (pf == I16) {
+ *pVideoMode = MODE_1280x960_MONO16;
+ } else if (pf == YCbCr422) {
+ *pVideoMode = MODE_1280x960_YUV422;
+ } else if (pf == R8G8B8 || pf == B8G8R8) {
+ *pVideoMode = MODE_1280x960_RGB;
+ }
+ } else if (Size.x == 1600 && Size.y == 1200) {
+ *pVideoFormat = FORMAT_2;
+ if (pf == I8 || pf == BAYER8) {
+ *pVideoMode = MODE_1600x1200_MONO;
+ } else if (pf == I16) {
+ *pVideoMode = MODE_1600x1200_MONO16;
+ } else if (pf == YCbCr422) {
+ *pVideoMode = MODE_1600x1200_YUV422;
+ } else if (pf == R8G8B8 || pf == B8G8R8) {
+ *pVideoMode = MODE_1600x1200_RGB;
+ }
+ }
+ if (*pVideoMode == -1 || *pVideoFormat == -1) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Unsupported or illegal camera mode ("+toString(Size.x)+", "+toString(Size.y)+
+ "), "+getPixelFormatString(pf)+".");
+ }
+}
+
+unsigned long getFrameRateConst(double FrameRate)
+{
+ if (FrameRate == 1.875) {
+ return FRAMERATE_1_875;
+ } else if (FrameRate == 3.75) {
+ return FRAMERATE_3_75;
+ } else if (FrameRate == 7.5) {
+ return FRAMERATE_7_5;
+ } else if (FrameRate == 15) {
+ return FRAMERATE_15;
+ } else if (FrameRate == 30) {
+ return FRAMERATE_30;
+ } else if (FrameRate == 60) {
+ return FRAMERATE_60;
+ } else if (FrameRate == 120) {
+ return FRAMERATE_120;
+ } else if (FrameRate == 240) {
+ return FRAMERATE_240;
+ } else {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Unsupported or illegal value ("+toString(FrameRate)+
+ ") for camera framerate.");
+ }
+}
+
+CAMERA_FEATURE getFeatureID(CameraFeature Feature)
+{
+ switch(Feature) {
+ case CAM_FEATURE_BRIGHTNESS:
+ return FEATURE_BRIGHTNESS;
+ case CAM_FEATURE_EXPOSURE:
+ return FEATURE_AUTO_EXPOSURE;
+ case CAM_FEATURE_SHARPNESS:
+ return FEATURE_SHARPNESS;
+ case CAM_FEATURE_WHITE_BALANCE:
+ return FEATURE_WHITE_BALANCE;
+ case CAM_FEATURE_HUE:
+ return FEATURE_HUE;
+ case CAM_FEATURE_SATURATION:
+ return FEATURE_SATURATION;
+ case CAM_FEATURE_GAMMA:
+ return FEATURE_GAMMA;
+ case CAM_FEATURE_SHUTTER:
+ return FEATURE_SHUTTER;
+ case CAM_FEATURE_GAIN:
+ return FEATURE_GAIN;
+ case CAM_FEATURE_IRIS:
+ return FEATURE_IRIS;
+ case CAM_FEATURE_FOCUS:
+ return FEATURE_FOCUS;
+ case CAM_FEATURE_TEMPERATURE:
+ return FEATURE_TEMPERATURE;
+ case CAM_FEATURE_TRIGGER:
+ return FEATURE_TRIGGER_MODE;
+ case CAM_FEATURE_ZOOM:
+ return FEATURE_ZOOM;
+ case CAM_FEATURE_PAN:
+ return FEATURE_PAN;
+ case CAM_FEATURE_TILT:
+ return FEATURE_TILT;
+ case CAM_FEATURE_OPTICAL_FILTER:
+ return FEATURE_OPTICAL_FILTER;
+ case CAM_FEATURE_CAPTURE_SIZE:
+ return FEATURE_CAPTURE_SIZE;
+ case CAM_FEATURE_CAPTURE_QUALITY:
+ return FEATURE_CAPTURE_QUALITY;
+ default:
+ return FEATURE_INVALID_FEATURE;
+ }
+}
+
+}
diff --git a/src/imaging/CMUCameraUtils.h b/src/imaging/CMUCameraUtils.h
new file mode 100644
index 0000000..8172928
--- /dev/null
+++ b/src/imaging/CMUCameraUtils.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _CMUCameraUtils_H_
+#define _CMUCameraUtils_H_
+
+#include "../api.h"
+#include "Camera.h"
+
+#include <windows.h>
+#include <1394Camera.h>
+
+#include <string>
+
+namespace avg {
+
+void getVideoFormatAndMode(IntPoint& Size, PixelFormat pf,
+ unsigned long* pVideoFormat, unsigned long* pVideoMode);
+unsigned long getFrameRateConst(double FrameRate);
+CAMERA_FEATURE getFeatureID(CameraFeature Feature);
+
+}
+
+#endif
diff --git a/src/imaging/Camera.cpp b/src/imaging/Camera.cpp
new file mode 100644
index 0000000..cfd13ab
--- /dev/null
+++ b/src/imaging/Camera.cpp
@@ -0,0 +1,244 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Camera.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../graphics/Filterfliprgb.h"
+
+#if defined(AVG_ENABLE_1394_2)
+#include "../imaging/FWCamera.h"
+#endif
+#ifdef AVG_ENABLE_V4L2
+#include "../imaging/V4LCamera.h"
+#endif
+#ifdef AVG_ENABLE_CMU1394
+#include "../imaging/CMUCamera.h"
+#endif
+#ifdef AVG_ENABLE_DSHOW
+#include "../imaging/DSCamera.h"
+#endif
+#include "../imaging/FakeCamera.h"
+
+#include <cstdlib>
+#include <string.h>
+
+#ifdef WIN32
+#define strtoll(p, e, b) _strtoi64(p, e, b)
+#endif
+
+namespace avg {
+
+using namespace std;
+
+Camera::Camera(PixelFormat camPF, PixelFormat destPF)
+ : m_CamPF(camPF),
+ m_DestPF(destPF)
+{
+// cerr << "Camera: " << getPixelFormatString(camPF) << "-->"
+// << getPixelFormatString(destPF) << endl;
+}
+
+PixelFormat Camera::getCamPF() const
+{
+ return m_CamPF;
+}
+
+void Camera::setCamPF(PixelFormat pf)
+{
+ m_CamPF = pf;
+}
+
+PixelFormat Camera::getDestPF() const
+{
+ return m_DestPF;
+}
+
+static ProfilingZoneID CameraConvertProfilingZone("Camera format conversion");
+
+BitmapPtr Camera::convertCamFrameToDestPF(BitmapPtr pCamBmp)
+{
+ ScopeTimer Timer(CameraConvertProfilingZone);
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(pCamBmp->getSize(), m_DestPF));
+ pDestBmp->copyPixels(*pCamBmp);
+ if (m_CamPF == R8G8B8 && m_DestPF == B8G8R8X8) {
+ pDestBmp->setPixelFormat(R8G8B8X8);
+ FilterFlipRGB().applyInPlace(pDestBmp);
+ }
+
+ return pDestBmp;
+}
+
+PixelFormat Camera::fwBayerStringToPF(unsigned long reg)
+{
+ string sBayerFormat((char*)&reg, 4);
+ if (sBayerFormat == "RGGB") {
+ return BAYER8_RGGB;
+ } else if (sBayerFormat == "GBRG") {
+ return BAYER8_GBRG;
+ } else if (sBayerFormat == "GRBG") {
+ return BAYER8_GRBG;
+ } else if (sBayerFormat == "BGGR") {
+ return BAYER8_BGGR;
+ } else if (sBayerFormat == "YYYY") {
+ return I8;
+ } else {
+ AVG_ASSERT(false);
+ return I8;
+ }
+}
+
+string cameraFeatureToString(CameraFeature feature)
+{
+ switch (feature) {
+ case CAM_FEATURE_BRIGHTNESS:
+ return "brightness";
+ case CAM_FEATURE_EXPOSURE:
+ return "exposure";
+ case CAM_FEATURE_SHARPNESS:
+ return "sharpness";
+ case CAM_FEATURE_WHITE_BALANCE:
+ return "white balance";
+ case CAM_FEATURE_HUE:
+ return "hue";
+ case CAM_FEATURE_SATURATION:
+ return "saturation";
+ case CAM_FEATURE_GAMMA:
+ return "gamma";
+ case CAM_FEATURE_SHUTTER:
+ return "shutter";
+ case CAM_FEATURE_GAIN:
+ return "gain";
+ case CAM_FEATURE_IRIS:
+ return "iris";
+ case CAM_FEATURE_FOCUS:
+ return "focus";
+ case CAM_FEATURE_TEMPERATURE:
+ return "temperature";
+ case CAM_FEATURE_TRIGGER:
+ return "trigger";
+ case CAM_FEATURE_ZOOM:
+ return "zoom";
+ case CAM_FEATURE_PAN:
+ return "pan";
+ case CAM_FEATURE_TILT:
+ return "tilt";
+ case CAM_FEATURE_OPTICAL_FILTER:
+ return "optical filter";
+ case CAM_FEATURE_CAPTURE_SIZE:
+ return "capture size";
+ case CAM_FEATURE_CAPTURE_QUALITY:
+ return "capture quality";
+ case CAM_FEATURE_CONTRAST:
+ return "contrast";
+ case CAM_FEATURE_STROBE_DURATION:
+ return "strobe duration";
+ default:
+ return "unknown";
+ }
+}
+
+CameraPtr createCamera(const string& sDriver, const string& sDevice, int unit,
+ bool bFW800, const IntPoint& captureSize, PixelFormat camPF, PixelFormat destPF,
+ double frameRate)
+{
+ CameraPtr pCamera;
+ try {
+ if (sDriver == "firewire") {
+ char * pszErr;
+ long long guid = strtoll(sDevice.c_str(), &pszErr, 16);
+ if (strlen(pszErr)) {
+ throw Exception(AVG_ERR_INVALID_ARGS, "'"+sDevice
+ +"' is not a valid GUID.");
+ }
+#if defined(AVG_ENABLE_1394_2)
+ pCamera = CameraPtr(new FWCamera(guid, unit, bFW800, captureSize, camPF,
+ destPF, frameRate));
+#elif defined(AVG_ENABLE_CMU1394)
+ if (unit != -1) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "camera 'unit' attribute is not supported when using the cmu firewire driver.");
+ }
+ pCamera = CameraPtr(new CMUCamera(guid, bFW800, captureSize, camPF, destPF,
+ frameRate));
+#else
+ guid = 0; // Silence compiler warning
+ AVG_TRACE(Logger::WARNING, "Firewire camera specified, but firewire "
+ "support not compiled in.");
+#endif
+ } else if (sDriver == "video4linux") {
+#if defined(AVG_ENABLE_V4L2)
+ pCamera = CameraPtr(new V4LCamera(sDevice, unit, captureSize, camPF,
+ destPF, frameRate));
+#else
+ AVG_TRACE(Logger::WARNING, "Video4Linux camera specified, but "
+ "Video4Linux support not compiled in.");
+#endif
+ } else if (sDriver == "directshow") {
+#if defined(AVG_ENABLE_DSHOW)
+ if (unit != -1) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "camera 'unit' attribute is not supported when using the directshow driver.");
+ }
+ pCamera = CameraPtr(new DSCamera(sDevice, captureSize, camPF, destPF,
+ frameRate));
+#else
+ AVG_TRACE(Logger::WARNING, "DirectShow camera specified, but "
+ "DirectShow is only available under windows.");
+#endif
+ } else {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Unable to set up camera. Camera source '"+sDriver+"' unknown.");
+ }
+ } catch (const Exception& e) {
+ if (e.getCode() == AVG_ERR_CAMERA_NONFATAL) {
+ AVG_TRACE(Logger::WARNING, e.getStr());
+ } else {
+ throw;
+ }
+
+ }
+ if (!pCamera) {
+ pCamera = CameraPtr(new FakeCamera(camPF, destPF));
+ }
+ return pCamera;
+
+}
+
+void dumpCameras()
+{
+#ifdef AVG_ENABLE_1394_2
+ FWCamera::dumpCameras();
+#endif
+#ifdef AVG_ENABLE_CMU1394
+ CMUCamera::dumpCameras();
+#endif
+#ifdef AVG_ENABLE_V4L2
+ V4LCamera::dumpCameras();
+#endif
+#ifdef AVG_ENABLE_DSHOW
+ DSCamera::dumpCameras();
+#endif
+}
+
+}
diff --git a/src/imaging/Camera.h b/src/imaging/Camera.h
new file mode 100644
index 0000000..3a008e3
--- /dev/null
+++ b/src/imaging/Camera.h
@@ -0,0 +1,109 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Camera_H_
+#define _Camera_H_
+
+#include "../avgconfigwrapper.h"
+#include "../graphics/Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+enum CameraFeature {
+ CAM_FEATURE_BRIGHTNESS,
+ CAM_FEATURE_EXPOSURE,
+ CAM_FEATURE_SHARPNESS,
+ CAM_FEATURE_WHITE_BALANCE,
+ CAM_FEATURE_HUE,
+ CAM_FEATURE_SATURATION,
+ CAM_FEATURE_GAMMA,
+ CAM_FEATURE_SHUTTER,
+ CAM_FEATURE_GAIN,
+ CAM_FEATURE_IRIS,
+ CAM_FEATURE_FOCUS,
+ CAM_FEATURE_TEMPERATURE,
+ CAM_FEATURE_TRIGGER,
+ CAM_FEATURE_ZOOM,
+ CAM_FEATURE_PAN,
+ CAM_FEATURE_TILT,
+ CAM_FEATURE_OPTICAL_FILTER,
+ CAM_FEATURE_CAPTURE_SIZE,
+ CAM_FEATURE_CAPTURE_QUALITY,
+ CAM_FEATURE_CONTRAST,
+ CAM_FEATURE_STROBE_DURATION
+};
+
+class AVG_API Camera
+{
+public:
+ Camera(PixelFormat camPF, PixelFormat destPF);
+ virtual ~Camera() {};
+ virtual void startCapture() {};
+
+ PixelFormat getCamPF() const;
+ void setCamPF(PixelFormat pf);
+ PixelFormat getDestPF() const;
+ BitmapPtr convertCamFrameToDestPF(BitmapPtr pCamBmp);
+
+ virtual IntPoint getImgSize() = 0;
+ virtual BitmapPtr getImage(bool bWait) = 0;
+
+ virtual const std::string& getDevice() const = 0;
+ virtual const std::string& getDriverName() const = 0;
+ virtual double getFrameRate() const = 0;
+
+ virtual int getFeature(CameraFeature feature) const = 0;
+ virtual void setFeature(CameraFeature feature, int Value,
+ bool bIgnoreOldValue=false) = 0;
+ virtual void setFeatureOneShot(CameraFeature feature) = 0;
+ virtual int getWhitebalanceU() const = 0;
+ virtual int getWhitebalanceV() const = 0;
+ virtual void setWhitebalance(int u, int v, bool bIgnoreOldValue=false) = 0;
+
+protected:
+ PixelFormat fwBayerStringToPF(unsigned long reg);
+
+private:
+ Camera();
+ PixelFormat m_CamPF;
+ PixelFormat m_DestPF;
+};
+
+std::string cameraFeatureToString(CameraFeature feature);
+
+typedef boost::shared_ptr<Camera> CameraPtr;
+typedef std::map<CameraFeature, int> FeatureMap;
+
+AVG_API CameraPtr createCamera(const std::string& sDriver, const std::string& sDevice,
+ int unit, bool bFW800, const IntPoint& captureSize, PixelFormat camPF,
+ PixelFormat destPF, double frameRate);
+
+AVG_API void dumpCameras();
+
+}
+
+#endif
+
diff --git a/src/imaging/CoordTransformer.cpp b/src/imaging/CoordTransformer.cpp
new file mode 100644
index 0000000..1fdbadd
--- /dev/null
+++ b/src/imaging/CoordTransformer.cpp
@@ -0,0 +1,37 @@
+
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "CoordTransformer.h"
+
+namespace avg {
+
+CoordTransformer::CoordTransformer()
+{
+}
+
+CoordTransformer::~CoordTransformer()
+{
+}
+
+}
diff --git a/src/imaging/CoordTransformer.h b/src/imaging/CoordTransformer.h
new file mode 100644
index 0000000..795e9b2
--- /dev/null
+++ b/src/imaging/CoordTransformer.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CoordTransformer_H_
+#define _CoordTransformer_H_
+
+#include "../api.h"
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API CoordTransformer
+{
+public:
+ CoordTransformer();
+ virtual ~CoordTransformer();
+
+ virtual DPoint transform_point(const DPoint & pt) = 0; //(x,y) -> (x', y')
+ virtual DPoint inverse_transform_point(const DPoint & pt) = 0; //(x,y) -> (x', y')
+};
+
+typedef boost::shared_ptr<CoordTransformer> CoordTransformerPtr;
+
+}
+#endif
diff --git a/src/imaging/DSCamera.cpp b/src/imaging/DSCamera.cpp
new file mode 100644
index 0000000..2d0ae6e
--- /dev/null
+++ b/src/imaging/DSCamera.cpp
@@ -0,0 +1,571 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include <InitGuid.h>
+
+#include "DSHelper.h"
+#include "DSCamera.h"
+#include "DSSampleGrabber.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../graphics/FilterFlip.h"
+#include "../graphics/Filtergrayscale.h"
+
+#include <oleauto.h>
+
+#include <math.h>
+
+#include <sstream>
+
+namespace avg {
+
+using namespace std;
+
+DSCamera::DSCamera(std::string sDevice, IntPoint size, PixelFormat camPF,
+ PixelFormat destPF, double frameRate)
+ : Camera(camPF, destPF),
+ m_sDevice(sDevice),
+ m_Size(size),
+ m_FrameRate(frameRate),
+ m_pGraph(0),
+ m_pCapture(0),
+ m_pCameraPropControl(0)
+{
+ open();
+}
+
+DSCamera::~DSCamera()
+{
+ close();
+}
+
+void DSCamera::open()
+{
+ initGraphBuilder();
+ findCaptureDevice(&m_pSrcFilter);
+ if (m_pSrcFilter) {
+ HRESULT hr;
+ hr = m_pGraph->AddFilter(m_pSrcFilter, L"Video Capture");
+ checkForDShowError(hr, "DSCamera::open()::Add capture filter");
+
+ // Create and configure the sample grabber that delivers the frames to the app.
+ m_pGrabFilter = new CSampleGrabber(NULL, &hr);
+ m_pGrabFilter->AddRef();
+ checkForDShowError(hr, "DSCamera::open()::Create SampleGrabber");
+ hr = m_pGrabFilter->QueryInterface(IID_IlibavgGrabber,
+ (void **)&m_pSampleGrabber);
+ checkForDShowError(hr, "DSCamera::open()::Create SampleGrabber 2");
+
+ hr = m_pSrcFilter->QueryInterface(IID_IAMVideoProcAmp,
+ (void **)&m_pCameraPropControl);
+ checkForDShowError(hr, "DSCamera::open()::get IAMVideoProcAmp");
+ hr = m_pSrcFilter->QueryInterface(IID_IAMCameraControl,
+ (void **)&m_pAMCameraControl);
+ checkForDShowError(hr, "DSCamera::open()::get IAMCameraControl");
+
+ hr = m_pGraph->AddFilter(m_pGrabFilter, L"Sample Grabber");
+ checkForDShowError(hr, "DSCamera::open()::Add Grabber");
+ setCaptureFormat();
+
+ checkForDShowError(hr, "DSCamera::open()::SetMediaType");
+
+ m_pSampleGrabber->SetCallback(this);
+
+ IBaseFilter * pNull;
+ hr = CoCreateInstance(CLSID_NullRenderer, NULL, CLSCTX_INPROC_SERVER,
+ IID_IBaseFilter, (LPVOID*) &pNull);
+ checkForDShowError(hr, "DSCamera::open()::Create null filter");
+ m_pGraph->AddFilter(pNull, L"NullRender");
+ pNull->Release();
+
+ connectFilters(m_pGraph, m_pSrcFilter, m_pGrabFilter);
+ connectFilters(m_pGraph, m_pGrabFilter, pNull);
+
+ // Add our graph to the running object table, which will allow
+ // the GraphEdit application to "spy" on our graph.
+ hr = AddGraphToRot(m_pGraph, &m_GraphRegisterID);
+ checkForDShowError(hr, "DSCamera::open()::AddGraphToRot");
+
+ } else {
+ throw (Exception(AVG_ERR_CAMERA_NONFATAL, "DS Camera unavailable"));
+ }
+}
+
+void DSCamera::startCapture()
+{
+ HRESULT hr = m_pMediaControl->Run();
+ checkForDShowError(hr, "DSCamera::open()::Run");
+}
+
+void DSCamera::close()
+{
+ if (m_pAMCameraControl) {
+ m_pAMCameraControl->Release();
+ }
+ m_pMediaControl->Stop();
+ RemoveGraphFromRot(m_GraphRegisterID);
+ m_pGraph->Release();
+ m_pCapture->Release();
+ m_pMediaControl->Release();
+ if (m_pCameraPropControl) {
+ m_pCameraPropControl->Release();
+ }
+ m_pSrcFilter->Release();
+ m_pGrabFilter->Release();
+ m_pSampleGrabber->Release();
+}
+
+IntPoint DSCamera::getImgSize()
+{
+ return m_Size;
+}
+
+BitmapPtr DSCamera::getImage(bool bWait)
+{
+ BitmapPtr pBmp;
+ try {
+ pBmp = m_BitmapQ.pop(bWait);
+ } catch (Exception&) {
+ return BitmapPtr();
+ }
+
+ return pBmp;
+}
+
+void DSCamera::setCaptureFormat()
+{
+ IAMStreamConfig *pSC;
+ HRESULT hr = m_pCapture->FindInterface(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video,
+ m_pSrcFilter, IID_IAMStreamConfig, (void **)&pSC);
+ checkForDShowError(hr, "DSCamera::setCaptureFormat::FindInterface");
+
+ int numCaps = 0;
+ int capsSize = 0;
+ hr = pSC->GetNumberOfCapabilities(&numCaps, &capsSize);
+ checkForDShowError(hr, "DSCamera::dumpMediaTypes::GetNumberOfCapabilities");
+
+ AVG_ASSERT(capsSize == sizeof(VIDEO_STREAM_CONFIG_CAPS));
+ bool bFormatFound = false;
+ bool bCloseFormatFound = false;
+ AM_MEDIA_TYPE* pmtConfig;
+ AM_MEDIA_TYPE* pmtCloseConfig;
+ vector<string> sImageFormats;
+ VIDEOINFOHEADER* pvih;
+ BITMAPINFOHEADER bih;
+ PixelFormat capsPF;
+ for (int i = 0; i < numCaps; i++) {
+ VIDEO_STREAM_CONFIG_CAPS scc;
+ hr = pSC->GetStreamCaps(i, &pmtConfig, (BYTE*)&scc);
+ checkForDShowError(hr, "DSCamera::dumpMediaTypes::GetStreamCaps");
+ pvih = (VIDEOINFOHEADER*)(pmtConfig->pbFormat);
+ bih = pvih->bmiHeader;
+ double frameRate = double(10000000L/pvih->AvgTimePerFrame);
+ capsPF = mediaSubtypeToPixelFormat(pmtConfig->subtype);
+
+ if (capsPF != NO_PIXELFORMAT && bih.biWidth != 0) {
+ sImageFormats.push_back(camImageFormatToString(pmtConfig));
+ }
+
+ bool bFormatUsed = false;
+ int height = bih.biHeight;
+ if (height < 0) {
+ height = -height;
+ }
+ if (bih.biWidth == m_Size.x && height == m_Size.y &&
+ (getCamPF() == capsPF || (getCamPF() == BAYER8_GBRG && capsPF == I8)))
+ {
+ if (fabs(m_FrameRate-frameRate) < 0.001) {
+ bFormatFound = true;
+ break;
+ } else if (!bCloseFormatFound) {
+ // The current format fits everything but the framerate.
+ // Not all framerates are reported, so we're going to try this one as
+ // well.
+ bCloseFormatFound = true;
+ bFormatUsed = true;
+ pmtCloseConfig = pmtConfig;
+ }
+ }
+ if (!bFormatUsed) {
+ CoTaskMemFree((PVOID)pmtConfig->pbFormat);
+ CoTaskMemFree(pmtConfig);
+ }
+ }
+ if (bFormatFound) {
+ AVG_TRACE(Logger::CONFIG, "Camera image format: "
+ << camImageFormatToString(pmtConfig));
+ int height = ((VIDEOINFOHEADER*)(pmtConfig->pbFormat))->bmiHeader.biHeight;
+// m_bUpsideDown = (height < 0);
+ hr = pSC->SetFormat(pmtConfig);
+ checkForDShowError(hr, "DSCamera::dumpMediaTypes::SetFormat");
+ CoTaskMemFree((PVOID)pmtConfig->pbFormat);
+ CoTaskMemFree(pmtConfig);
+ } else {
+ if (bCloseFormatFound) {
+ // Set the framerate manually.
+ pvih = (VIDEOINFOHEADER*)(pmtCloseConfig->pbFormat);
+ pvih->AvgTimePerFrame = REFERENCE_TIME(10000000/m_FrameRate);
+ int height = pvih->bmiHeader.biHeight;
+// m_bUpsideDown = (height < 0);
+ hr = pSC->SetFormat(pmtCloseConfig);
+ checkForDShowError(hr, "DSCamera::dumpMediaTypes::SetFormat");
+ AVG_TRACE(Logger::CONFIG, "Camera image format: "
+ << camImageFormatToString(pmtCloseConfig));
+ CoTaskMemFree((PVOID)pmtCloseConfig->pbFormat);
+ CoTaskMemFree(pmtCloseConfig);
+
+ // TODO: Check if framerate is actually attained.
+ } else {
+ AVG_TRACE(Logger::WARNING,
+ "Possibly incomplete list of camera image formats: ");
+ for (unsigned i = 0; i < sImageFormats.size(); i++) {
+ AVG_TRACE(Logger::WARNING, " " << sImageFormats[i]);
+ }
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,
+ "Could not find requested camera image format.");
+ }
+ }
+ pSC->Release();
+}
+
+
+const string& DSCamera::getDevice() const
+{
+ return m_sDevice;
+}
+
+const std::string& DSCamera::getDriverName() const
+{
+ static string sDriverName = "directshow";
+ return sDriverName;
+}
+
+double DSCamera::getFrameRate() const
+{
+ return m_FrameRate;
+}
+
+int DSCamera::getFeature(CameraFeature feature) const
+{
+ long prop = getDSFeatureID(feature);
+ long val;
+ long flags;
+ HRESULT hr;
+ if (isDSFeatureCamControl(feature)) {
+ hr = m_pAMCameraControl->Get(prop, &val, &flags);
+ } else {
+ hr = m_pCameraPropControl->Get(prop, &val, &flags);
+ }
+ if (!SUCCEEDED(hr)) {
+ AVG_TRACE(Logger::WARNING, "DSCamera::getFeature "
+ + cameraFeatureToString(feature)+" failed.");
+ return 0;
+ }
+ return val;
+}
+
+void DSCamera::setFeature(CameraFeature feature, int value, bool bIgnoreOldValue)
+{
+ long prop = getDSFeatureID(feature);
+ if (!m_pCameraPropControl) {
+ return;
+ }
+ long flags;
+ if (value == -1) {
+ flags = VideoProcAmp_Flags_Auto;
+ } else {
+ flags = VideoProcAmp_Flags_Manual;
+ }
+ HRESULT hr;
+ if (isDSFeatureCamControl(feature)) {
+ hr = m_pAMCameraControl->Set(prop, value, flags);
+ } else {
+ hr = m_pCameraPropControl->Set(prop, value, flags);
+ }
+ switch (hr) {
+ case E_INVALIDARG:
+ // TODO: Throw exception
+ AVG_TRACE(Logger::ERROR, "DSCamera::setFeature("
+ << cameraFeatureToString(feature) << ", " << value << ") failed.");
+ break;
+ case E_PROP_ID_UNSUPPORTED:
+ case E_PROP_SET_UNSUPPORTED:
+ AVG_TRACE(Logger::ERROR, "DSCamera::setFeature("
+ << cameraFeatureToString(feature)
+ << ") failed: Feature not supported by camera.");
+ break;
+ default:
+ checkForDShowError(hr, "DSCamera::setFeature()::Set value");
+ }
+}
+
+void DSCamera::setFeatureOneShot(CameraFeature feature)
+{
+ AVG_TRACE(Logger::WARNING,
+ "OneShot feature setting not implemented for DirectShow camera driver.");
+}
+
+int DSCamera::getWhitebalanceU() const
+{
+ AVG_TRACE(Logger::WARNING,
+ "Whitebalance not implemented for DirectShow camera driver.");
+ return 0;
+}
+
+int DSCamera::getWhitebalanceV() const
+{
+ AVG_TRACE(Logger::WARNING,
+ "Whitebalance not implemented for DirectShow camera driver.");
+ return 0;
+}
+
+void DSCamera::setWhitebalance(int u, int v, bool bIgnoreOldValue)
+{
+ AVG_TRACE(Logger::WARNING,
+ "Whitebalance not implemented for DirectShow camera driver.");
+}
+
+void DSCamera::onSample(IMediaSample * pSample)
+{
+ unsigned char * pData;
+
+ // Get the current image.
+ pSample->GetPointer(&pData);
+
+ int stride = m_Size.x*getBytesPerPixel(getCamPF());
+ Bitmap camBmp(m_Size, getCamPF(), pData, stride, false, "CameraImage");
+ // Copy over to bitmap queue, doing pixel format conversion if necessary.
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(m_Size, getDestPF(),
+ "ConvertedCameraImage"));
+ pDestBmp->copyPixels(camBmp);
+/*
+ if (m_bUpsideDown) {
+ FilterFlip().applyInPlace(pDestBmp);
+ }
+*/
+ m_BitmapQ.push(pDestBmp);
+}
+
+void DSCamera::dumpCameras()
+{
+ HRESULT hr = S_OK;
+ // TODO: Check if the threading model is ok.
+ hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ checkForDShowError(hr, "DSCamera::dumpCameras()::CoInitializeEx");
+
+ // Create the system device enumerator
+ ICreateDevEnum *pDevEnum =NULL;
+ hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
+ IID_ICreateDevEnum, (void **) &pDevEnum);
+ checkForDShowError(hr, "DSCamera::dumpCameras()::CreateDevEnum");
+
+ // Create an enumerator for the video capture devices
+ IEnumMoniker *pClassEnum = NULL;
+ hr = pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pClassEnum, 0);
+ checkForDShowError(hr, "DSCamera::dumpCameras()::CreateClassEnumerator");
+
+ if (pClassEnum == NULL) {
+ return;
+ }
+
+ IMoniker* pMoniker = NULL;
+ bool bFirst = true;
+ while (pClassEnum->Next(1, &pMoniker, NULL) == S_OK) {
+ if (bFirst) {
+ cerr << endl;
+ cerr << "DirectShow cameras: " << endl;
+ bFirst = false;
+ }
+ IPropertyBag* pPropBag;
+ hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag));
+ checkForDShowError(hr, "DSCamera::dumpCameras()::BindToStorage");
+ cerr << " ----------------------------" << endl;
+ cerr << " Name: " << getStringProp(pPropBag, L"FriendlyName") << endl;
+ cerr << " Description: " << getStringProp(pPropBag, L"Description") << endl;
+ cerr << " Device Path: " << getStringProp(pPropBag, L"DevicePath") << endl;
+ pPropBag->Release();
+ }
+ pMoniker->Release();
+ pDevEnum->Release();
+ pClassEnum->Release();
+}
+
+void DSCamera::initGraphBuilder()
+{
+ HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ checkForDShowError(hr, "DSCamera::initGraphBuilder()::CoInitializeEx");
+
+ // Create the filter graph
+ hr = CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC, IID_IGraphBuilder,
+ (void **) &m_pGraph);
+ checkForDShowError(hr, "DSCamera::initGraphBuilder()::GraphBuilder");
+ // Create the capture graph builder
+ hr = CoCreateInstance (CLSID_CaptureGraphBuilder2 , NULL, CLSCTX_INPROC,
+ IID_ICaptureGraphBuilder2, (void **) &m_pCapture);
+ checkForDShowError(hr, "DSCamera::initGraphBuilder()::CaptureGraphBuilder2");
+
+ hr = m_pCapture->SetFiltergraph(m_pGraph);
+ checkForDShowError(hr, "DSCamera::initGraphBuilder()::SetFilterGraph");
+
+ m_pGraph->QueryInterface(IID_IMediaControl,(void**)&m_pMediaControl);
+}
+
+void DSCamera::findCaptureDevice(IBaseFilter ** ppSrcFilter)
+{
+ HRESULT hr = S_OK;
+ IBaseFilter * pSrc = NULL;
+ IMoniker* pMoniker = NULL;
+ ICreateDevEnum *pDevEnum = NULL;
+ IEnumMoniker *pClassEnum = NULL;
+
+ // Create the system device enumerator
+ hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC,
+ IID_ICreateDevEnum, (void **) &pDevEnum);
+ checkForDShowError(hr, "DSCamera::findCaptureDevice()::CreateDevEnum");
+
+ // Create an enumerator for the video capture devices
+ hr = pDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pClassEnum,
+ 0);
+ checkForDShowError(hr, "DSCamera::findCaptureDevice()::CreateClassEnumerator");
+
+ // If there are no enumerators for the requested type, then
+ // CreateClassEnumerator will succeed, but pClassEnum will be NULL.
+ if (pClassEnum == NULL) {
+ *ppSrcFilter = 0;
+ throw(Exception(AVG_ERR_CAMERA_NONFATAL, "No DirectShow Capture Device found"));
+ }
+
+ bool bFound = false;
+ while (!bFound && pClassEnum->Next(1, &pMoniker, NULL) == S_OK) {
+ IPropertyBag *pPropBag;
+ hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag));
+ checkForDShowError(hr, "DSCamera::findCaptureDevice()::BindToStorage");
+
+ string sDescription = getStringProp(pPropBag, L"Description");
+ string sFriendlyName = getStringProp(pPropBag, L"FriendlyName");
+ string sDevicePath = getStringProp(pPropBag, L"DevicePath");
+
+ if (m_sDevice == sDescription || m_sDevice == sFriendlyName ||
+ sDevicePath.find(m_sDevice) != -1 || m_sDevice == "")
+ {
+ bFound = true;
+ } else {
+ pMoniker->Release();
+ }
+ pPropBag->Release();
+ }
+ if (!bFound) {
+ pClassEnum->Reset();
+ if (pClassEnum->Next(1, &pMoniker, NULL) == S_OK) {
+ AVG_TRACE(Logger::WARNING, string("Camera ") + m_sDevice
+ + " not found. Using first camera.");
+ bFound = true;
+ IPropertyBag *pPropBag;
+ hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)(&pPropBag));
+ m_sDevice = getStringProp(pPropBag, L"FriendlyName");
+ checkForDShowError(hr, "DSCamera::findCaptureDevice()::BindToStorage");
+ pPropBag->Release();
+ } else {
+ throw(Exception(AVG_ERR_CAMERA_NONFATAL,
+ "No DirectShow Capture Device found"));
+ }
+ }
+
+ // Bind Moniker to a filter object
+ hr = pMoniker->BindToObject(0,0,IID_IBaseFilter, (void**)&pSrc);
+ checkForDShowError(hr, "DSCamera::findCaptureDevice()::BindToObject");
+
+ // Copy the found filter pointer to the output parameter.
+ *ppSrcFilter = pSrc;
+ (*ppSrcFilter)->AddRef();
+
+ pSrc->Release();
+ pMoniker->Release();
+ pDevEnum->Release();
+ pClassEnum->Release();
+}
+
+
+void DSCamera::connectFilters(IGraphBuilder *pGraph, IBaseFilter *pSrc,
+ IBaseFilter *pDest)
+{
+ IPin *pOut = 0;
+ getUnconnectedPin(pSrc, PINDIR_OUTPUT, &pOut);
+
+ IPin *pIn = 0;
+ getUnconnectedPin(pDest, PINDIR_INPUT, &pIn);
+
+ HRESULT hr = pGraph->ConnectDirect(pOut, pIn, 0);
+ checkForDShowError(hr, "DSCamera::ConnectFilters::Connect");
+ pOut->Release();
+ pIn->Release();
+}
+
+void DSCamera::getUnconnectedPin(IBaseFilter *pFilter, PIN_DIRECTION pinDir, IPin **ppPin)
+{
+ *ppPin = 0;
+ IEnumPins *pEnum = 0;
+ IPin *pPin = 0;
+ HRESULT hr = pFilter->EnumPins(&pEnum);
+ checkForDShowError(hr, "DSCamera::ConnectFilters::Connect");
+ while (pEnum->Next(1, &pPin, NULL) == S_OK)
+ {
+ PIN_DIRECTION thisPinDir;
+ pPin->QueryDirection(&thisPinDir);
+ if (thisPinDir == pinDir) {
+ IPin* pTmp = 0;
+ hr = pPin->ConnectedTo(&pTmp);
+ if (SUCCEEDED(hr)) { // Already connected, not the pin we want.
+ pTmp->Release();
+ } else { // Unconnected, this is the pin we want.
+ pEnum->Release();
+ *ppPin = pPin;
+ return;
+ }
+ }
+ pPin->Release();
+ }
+ pEnum->Release();
+ // Did not find a matching pin.
+ AVG_ASSERT(false);
+}
+
+#pragma warning(disable : 4995)
+void DSCamera::checkForDShowError(HRESULT hr, const string& sLocation)
+{
+ if (SUCCEEDED(hr)) {
+ return;
+ }
+ if (HRESULT_FACILITY(hr) == FACILITY_WINDOWS) {
+ hr = HRESULT_CODE(hr);
+ }
+ char szErr[MAX_ERROR_TEXT_LEN];
+ DWORD res = AMGetErrorText(hr, szErr, MAX_ERROR_TEXT_LEN);
+ if (res == 0) {
+ wsprintf(szErr, "Unknown Error: 0x%2x", hr);
+ }
+ cerr << sLocation << ": " << szErr << endl;
+}
+
+
+}
diff --git a/src/imaging/DSCamera.h b/src/imaging/DSCamera.h
new file mode 100644
index 0000000..bf562ac
--- /dev/null
+++ b/src/imaging/DSCamera.h
@@ -0,0 +1,106 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DSCamera_H_
+#define _DSCamera_H_
+
+#include "IDSSampleCallback.h"
+
+#include "../avgconfigwrapper.h"
+
+#include "Camera.h"
+
+#include "../graphics/Bitmap.h"
+#include "../graphics/Pixel24.h"
+
+#include "../base/Point.h"
+#include "../base/Queue.h"
+
+#include <string>
+#define _WIN32_DCOM
+#include <windows.h>
+#include <dshow.h>
+#include "Qedit.h"
+
+namespace avg {
+
+struct IlibavgGrabber;
+
+class DSCamera: public Camera, IDSSampleCallback
+{
+public:
+ DSCamera(std::string sDevice, IntPoint size, PixelFormat camPF, PixelFormat destPF,
+ double frameRate);
+ virtual ~DSCamera();
+ virtual void startCapture();
+
+ virtual IntPoint getImgSize();
+ virtual BitmapPtr getImage(bool bWait);
+
+ virtual const std::string& getDevice() const;
+ virtual const std::string& getDriverName() const;
+ virtual double getFrameRate() const;
+
+ virtual int getFeature(CameraFeature feature) const;
+ virtual void setFeature(CameraFeature feature, int value,
+ bool bIgnoreOldValue=false);
+ virtual void setFeatureOneShot(CameraFeature feature);
+ virtual int getWhitebalanceU() const;
+ virtual int getWhitebalanceV() const;
+ virtual void setWhitebalance(int u, int v, bool bIgnoreOldValue=false);
+
+ virtual void onSample(IMediaSample * pSample);
+
+ static void dumpCameras();
+
+private:
+ virtual void open();
+ virtual void close();
+ void initGraphBuilder();
+ void findCaptureDevice(IBaseFilter ** ppSrcFilter);
+
+ void setCaptureFormat();
+ void connectFilters(IGraphBuilder *pGraph, IBaseFilter *pSrc, IBaseFilter *pDest);
+ void getUnconnectedPin(IBaseFilter *pFilter, PIN_DIRECTION pinDir, IPin **ppPin);
+ static void checkForDShowError(HRESULT hr, const std::string & sAppMsg);
+
+ std::string m_sDevice;
+ IntPoint m_Size;
+ double m_FrameRate;
+
+ IGraphBuilder * m_pGraph;
+ ICaptureGraphBuilder2 * m_pCapture;
+ IMediaControl * m_pMediaControl;
+ IBaseFilter * m_pSrcFilter;
+ IBaseFilter * m_pGrabFilter;
+ IlibavgGrabber * m_pSampleGrabber;
+ IAMVideoProcAmp * m_pCameraPropControl;
+ IAMCameraControl * m_pAMCameraControl;
+
+ Queue<Bitmap> m_BitmapQ;
+
+ DWORD m_GraphRegisterID;
+// bool m_bUpsideDown;
+};
+
+}
+
+#endif
diff --git a/src/imaging/DSHelper.cpp b/src/imaging/DSHelper.cpp
new file mode 100644
index 0000000..6802ce9
--- /dev/null
+++ b/src/imaging/DSHelper.cpp
@@ -0,0 +1,269 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "DSHelper.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+#include <stdio.h>
+#include <oleauto.h>
+
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+#pragma warning(disable : 4995)
+HRESULT AddGraphToRot(IUnknown *pUnkGraph, DWORD *pdwRegister)
+{
+ IMoniker * pMoniker;
+ IRunningObjectTable *pROT;
+ WCHAR wsz[128];
+ HRESULT hr;
+
+ if (!pUnkGraph || !pdwRegister) {
+ return E_POINTER;
+ }
+
+ if (FAILED(GetRunningObjectTable(0, &pROT))) {
+ return E_FAIL;
+ }
+
+ hr = swprintf(wsz, NUMELMS(wsz), L"FilterGraph %08x pid %08x\0",
+ (DWORD_PTR)pUnkGraph, GetCurrentProcessId());
+
+ hr = CreateItemMoniker(L"!", wsz, &pMoniker);
+ if (SUCCEEDED(hr)) {
+ hr = pROT->Register(ROTFLAGS_REGISTRATIONKEEPSALIVE, pUnkGraph, pMoniker,
+ pdwRegister);
+ pMoniker->Release();
+ }
+
+ pROT->Release();
+ return hr;
+}
+
+void RemoveGraphFromRot(DWORD pdwRegister)
+{
+ IRunningObjectTable *pROT;
+
+ if (SUCCEEDED(GetRunningObjectTable(0, &pROT))) {
+ pROT->Revoke(pdwRegister);
+ pROT->Release();
+ }
+}
+
+string getStringProp(IPropertyBag *pPropBag, LPCOLESTR pszPropName)
+{
+ VARIANT varName;
+ VariantInit(&varName);
+ HRESULT hr = pPropBag->Read(pszPropName, &varName, 0);
+ if (FAILED(hr)) {
+ return "";
+ }
+// checkForDShowError(hr, string("DSHelper::getStringProp(")+pszPropName+")::Read PropBag");
+
+ string s;
+ int lenWStr = SysStringLen(varName.bstrVal);
+ int lenAStr = WideCharToMultiByte(CP_ACP, 0, varName.bstrVal, lenWStr, 0, 0, NULL, NULL);
+ if (lenAStr > 0) {
+ char* pAStr = new char[lenAStr + 1];
+ WideCharToMultiByte(CP_ACP, 0, varName.bstrVal, lenWStr, pAStr, lenAStr, NULL, NULL);
+ pAStr[lenAStr] = 0;
+ s = pAStr;
+ delete[] pAStr;
+ }
+
+ VariantClear(&varName);
+ return s;
+}
+
+PixelFormat mediaSubtypeToPixelFormat(const GUID& subtype)
+{
+ if (subtype == MEDIASUBTYPE_RGB24) {
+ return B8G8R8;
+ } else if (subtype == MEDIASUBTYPE_RGB32) {
+ return B8G8R8X8;
+ } else if (subtype == MEDIASUBTYPE_RGB8) {
+ return I8;
+ } else if (subtype == MEDIASUBTYPE_UYVY) {
+ return YCbCr422;
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ return YUYV422;
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
+ return B5G6R5;
+// } else if (Subtype == MEDIASUBTYPE_Y800 && DesiredPF == "BY8_GBRG") {
+// return BAYER8_GBRG;
+ } else if (subtype == MEDIASUBTYPE_Y800) {
+ return I8;
+ } else {
+ return NO_PIXELFORMAT;
+ }
+}
+
+std::string mediaTypeToString(const GUID& type)
+{
+ if (type == MEDIATYPE_Video) {
+ return "MEDIATYPE_Video";
+ } else if (type == GUID_NULL) {
+ return "GUID_NULL";
+ } else {
+ return "Unknown";
+ }
+}
+
+string mediaSubtypeToString(const GUID & subtype)
+{
+ if (subtype == MEDIASUBTYPE_RGB24) {
+ return "MEDIASUBTYPE_RGB24";
+ } else if (subtype == MEDIASUBTYPE_RGB32) {
+ return "MEDIASUBTYPE_RGB32";
+ } else if (subtype == MEDIASUBTYPE_RGB8) {
+ return "MEDIASUBTYPE_RGB8";
+ } else if (subtype == MEDIASUBTYPE_UYVY) {
+ return "MEDIASUBTYPE_UYVY";
+ } else if (subtype == MEDIASUBTYPE_YUY2) {
+ return "MEDIASUBTYPE_YUY2";
+ } else if (subtype == MEDIASUBTYPE_MJPG) {
+ return "MEDIASUBTYPE_MJPG";
+ } else if (subtype == MEDIASUBTYPE_RGB555) {
+ return "MEDIASUBTYPE_RGB555";
+ } else if (subtype == MEDIASUBTYPE_RGB565) {
+ return "MEDIASUBTYPE_RGB565";
+ } else if (subtype == MEDIASUBTYPE_Y800) {
+ return "MEDIASUBTYPE_Y800";
+ } else if (subtype == GUID_NULL) {
+ return "GUID_NULL";
+ } else {
+ return "Unknown";
+ }
+}
+
+string mediaFormattypeToString(const GUID& formattype)
+{
+ if (formattype == FORMAT_None) {
+ return "FORMAT_None";
+ } else if (formattype == FORMAT_VideoInfo) {
+ return "FORMAT_VideoInfo";
+ } else if (formattype == FORMAT_VideoInfo2) {
+ return "FORMAT_VideoInfo2";
+ } else if (formattype == GUID_NULL) {
+ return "GUID_NULL";
+ } else {
+ return "Unknown";
+ }
+}
+
+string camImageFormatToString(const AM_MEDIA_TYPE* pMediaType)
+{
+ stringstream ss;
+ VIDEOINFOHEADER* pVideoInfo = (VIDEOINFOHEADER*)(pMediaType->pbFormat);
+ BITMAPINFOHEADER* pBitmapInfo = &pVideoInfo->bmiHeader;
+ PixelFormat pf = mediaSubtypeToPixelFormat(pMediaType->subtype);
+ int height = abs(pBitmapInfo->biHeight);
+ ss << "(" << pBitmapInfo->biWidth << "x" << height << "), " << pf
+ << ", " << 10000000./pVideoInfo->AvgTimePerFrame << " fps.";
+ return ss.str();
+}
+
+bool isDSFeatureCamControl(CameraFeature feature)
+{
+ switch(feature) {
+ case CAM_FEATURE_BRIGHTNESS:
+ case CAM_FEATURE_SHARPNESS:
+ case CAM_FEATURE_WHITE_BALANCE:
+ case CAM_FEATURE_HUE:
+ case CAM_FEATURE_SATURATION:
+ case CAM_FEATURE_GAMMA:
+ case CAM_FEATURE_GAIN:
+ return false;
+ case CAM_FEATURE_EXPOSURE:
+ case CAM_FEATURE_IRIS:
+ case CAM_FEATURE_FOCUS:
+ case CAM_FEATURE_ZOOM:
+ case CAM_FEATURE_PAN:
+ case CAM_FEATURE_TILT:
+ return true;
+ case CAM_FEATURE_SHUTTER:
+ case CAM_FEATURE_TEMPERATURE:
+ case CAM_FEATURE_TRIGGER:
+ case CAM_FEATURE_OPTICAL_FILTER:
+ case CAM_FEATURE_CAPTURE_SIZE:
+ case CAM_FEATURE_CAPTURE_QUALITY:
+ case CAM_FEATURE_CONTRAST:
+ AVG_TRACE(Logger::WARNING, "isDSFeatureCamControl: "
+ + cameraFeatureToString(feature) + " not supported by DirectShow.");
+ return false;
+ default:
+ AVG_TRACE(Logger::WARNING, "isDSFeatureCamControl: "
+ + cameraFeatureToString(feature) + " unknown.");
+ return false;
+ }
+}
+
+long getDSFeatureID(CameraFeature feature)
+{
+ switch(feature) {
+ case CAM_FEATURE_BRIGHTNESS:
+ return VideoProcAmp_Brightness;
+ case CAM_FEATURE_SHARPNESS:
+ return VideoProcAmp_Sharpness;
+ case CAM_FEATURE_WHITE_BALANCE:
+ return VideoProcAmp_WhiteBalance;
+ case CAM_FEATURE_HUE:
+ return VideoProcAmp_Hue;
+ case CAM_FEATURE_SATURATION:
+ return VideoProcAmp_Saturation;
+ case CAM_FEATURE_GAMMA:
+ return VideoProcAmp_Gamma;
+ case CAM_FEATURE_GAIN:
+ return VideoProcAmp_Gain;
+ case CAM_FEATURE_EXPOSURE:
+ return CameraControl_Exposure;
+ case CAM_FEATURE_IRIS:
+ return CameraControl_Iris;
+ case CAM_FEATURE_FOCUS:
+ return CameraControl_Focus;
+ case CAM_FEATURE_ZOOM:
+ return CameraControl_Zoom;
+ case CAM_FEATURE_PAN:
+ return CameraControl_Pan;
+ case CAM_FEATURE_TILT:
+ return CameraControl_Tilt;
+ case CAM_FEATURE_SHUTTER:
+ case CAM_FEATURE_TEMPERATURE:
+ case CAM_FEATURE_TRIGGER:
+ case CAM_FEATURE_OPTICAL_FILTER:
+ case CAM_FEATURE_CAPTURE_SIZE:
+ case CAM_FEATURE_CAPTURE_QUALITY:
+ case CAM_FEATURE_CONTRAST:
+ AVG_TRACE(Logger::WARNING, "getDSFeatureID: "+cameraFeatureToString(feature)
+ +" not supported by DirectShow.");
+ return 0;
+ default:
+ AVG_TRACE(Logger::WARNING, "getDSFeatureID: "+cameraFeatureToString(feature)+" unknown.");
+ return -1;
+ }
+}
+
+}
diff --git a/src/imaging/DSHelper.h b/src/imaging/DSHelper.h
new file mode 100644
index 0000000..8904902
--- /dev/null
+++ b/src/imaging/DSHelper.h
@@ -0,0 +1,62 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DSHelper_H_
+#define _DSHelper_H_
+
+#include "Camera.h"
+
+#include "../graphics/Bitmap.h"
+
+#include <string>
+
+#define _WIN32_DCOM
+#include <windows.h>
+#include <dshow.h>
+#include "Qedit.h"
+
+
+static const GUID MEDIASUBTYPE_Y800 =
+ {0x30303859, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
+
+static const GUID MEDIASUBTYPE_Y160 =
+ {0x30363159, 0x0000, 0x0010, {0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71}};
+
+namespace avg {
+
+HRESULT AddGraphToRot(IUnknown* pUnkGraph, DWORD* pdwRegister);
+void RemoveGraphFromRot(DWORD pdwRegister);
+
+std::string getStringProp(IPropertyBag* pPropBag, LPCOLESTR pszPropName);
+
+PixelFormat mediaSubtypeToPixelFormat(const GUID& subtype);
+
+std::string mediaTypeToString(const GUID& type);
+std::string mediaSubtypeToString(const GUID& subtype);
+std::string mediaFormattypeToString(const GUID& formattype);
+std::string camImageFormatToString(const AM_MEDIA_TYPE* pMediaType);
+
+bool isDSFeatureCamControl(CameraFeature feature);
+long getDSFeatureID(CameraFeature feature);
+
+}
+
+#endif
diff --git a/src/imaging/DSSampleGrabber.cpp b/src/imaging/DSSampleGrabber.cpp
new file mode 100755
index 0000000..d38ad5f
--- /dev/null
+++ b/src/imaging/DSSampleGrabber.cpp
@@ -0,0 +1,220 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "DSSampleGrabber.h"
+
+#include <initguid.h>
+
+#pragma warning(disable: 4800)
+
+// {455A53B7-FC34-4960-94CE-A17A0B23F807}
+DEFINE_GUID(CLSID_libavgGrabber,
+0x455a53b7, 0xfc34, 0x4960, 0x94, 0xce, 0xa1, 0x7a, 0xb, 0x23, 0xf8, 0x7);
+
+namespace avg {
+
+class CSampleGrabberAllocator : public CMemAllocator
+{
+public:
+ CSampleGrabberAllocator(CSampleGrabberInPin* pParent, HRESULT* phr);
+ ~CSampleGrabberAllocator();
+
+ HRESULT Alloc();
+ void ReallyFree();
+ STDMETHODIMP SetProperties(ALLOCATOR_PROPERTIES* pRequest,
+ ALLOCATOR_PROPERTIES* pActual);
+
+protected:
+ CSampleGrabberInPin * m_pPin;
+
+private:
+ friend class CSampleGrabberInPin;
+ friend class CSampleGrabber;
+};
+
+class CSampleGrabberInPin : public CTransInPlaceInputPin
+{
+public:
+ CSampleGrabberInPin(CTransInPlaceFilter* pFilter, HRESULT* pHr);
+ ~CSampleGrabberInPin();
+
+ HRESULT GetMediaType(int iPosition, CMediaType* pMediaType);
+
+ // override this or GetMediaType is never called
+ STDMETHODIMP EnumMediaTypes(IEnumMediaTypes** ppEnum);
+
+ // we override this to tell whoever's upstream of us what kind of
+ // properties we're going to demand to have
+ STDMETHODIMP GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps);
+
+private:
+ friend class CSampleGrabberAllocator;
+ friend class CSampleGrabber;
+
+ CSampleGrabberAllocator* m_pPrivateAllocator;
+ ALLOCATOR_PROPERTIES m_allocprops;
+ BYTE* m_pBuffer;
+ BOOL m_bMediaTypeChanged;
+};
+
+CSampleGrabber::CSampleGrabber(IUnknown * pOuter, HRESULT * phr)
+ : CTransInPlaceFilter(TEXT("libavg sample grabber"), (IUnknown*) pOuter,
+ CLSID_libavgGrabber, phr, false),
+ m_pCallback(NULL)
+{
+ m_pInput = (CTransInPlaceInputPin*) new CSampleGrabberInPin(this, phr);
+
+ IPin *pOutput = GetPin(1);
+}
+
+STDMETHODIMP CSampleGrabber::NonDelegatingQueryInterface(REFIID riid, void** ppv)
+{
+ AVG_ASSERT(ppv);
+
+ if (riid == IID_IlibavgGrabber) {
+ return GetInterface((IlibavgGrabber *)this, ppv);
+ } else {
+ return CTransInPlaceFilter::NonDelegatingQueryInterface(riid, ppv);
+ }
+}
+
+HRESULT CSampleGrabber::CheckInputType(const CMediaType* pmt)
+{
+ AVG_ASSERT(pmt);
+ CAutoLock lock(&m_Lock);
+
+ if (MEDIATYPE_Video == *pmt->Type( )) {
+ return NOERROR;
+ } else {
+ return VFW_E_INVALID_MEDIA_TYPE;
+ }
+}
+
+HRESULT CSampleGrabber::Receive(IMediaSample * pms)
+{
+ AVG_ASSERT(pms);
+
+ HRESULT hr;
+ AM_SAMPLE2_PROPERTIES * const pProps = m_pInput->SampleProps();
+
+ if (pProps->dwStreamId != AM_STREAM_MEDIA) {
+ if (m_pOutput->IsConnected()) {
+ return m_pOutput->Deliver(pms);
+ } else {
+ return NOERROR;
+ }
+ }
+ if (UsingDifferentAllocators()) {
+ pms = Copy(pms);
+ AVG_ASSERT(pms);
+ }
+
+ hr = Transform(pms);
+ AVG_ASSERT(!FAILED(hr));
+ hr = m_pOutput->Deliver(pms);
+ if (UsingDifferentAllocators()) {
+ pms->Release();
+ }
+ return hr;
+}
+
+HRESULT CSampleGrabber::Transform(IMediaSample* pms)
+{
+ AVG_ASSERT(pms);
+ CAutoLock lock(&m_Lock);
+
+ if (m_pCallback) {
+ REFERENCE_TIME StartTime;
+ REFERENCE_TIME StopTime;
+ pms->GetTime( &StartTime, &StopTime);
+
+ StartTime += m_pInput->CurrentStartTime();
+ StopTime += m_pInput->CurrentStartTime();
+
+ m_pCallback->onSample(pms);
+ }
+ return NOERROR;
+}
+
+void STDMETHODCALLTYPE CSampleGrabber::SetCallback(IDSSampleCallback* pCallback)
+{
+ CAutoLock lock( &m_Lock );
+ m_pCallback = pCallback;
+}
+
+CSampleGrabberInPin::CSampleGrabberInPin(CTransInPlaceFilter* pFilter, HRESULT* pHr)
+ : CTransInPlaceInputPin(TEXT("SampleGrabberInputPin\0"), pFilter, pHr, L"Input\0"),
+ m_pPrivateAllocator(NULL),
+ m_pBuffer(NULL),
+ m_bMediaTypeChanged(FALSE)
+{
+ memset(&m_allocprops, 0, sizeof(m_allocprops));
+}
+
+CSampleGrabberInPin::~CSampleGrabberInPin()
+{
+ if (m_pPrivateAllocator) {
+ delete m_pPrivateAllocator;
+ }
+}
+
+HRESULT CSampleGrabberInPin::GetMediaType(int iPosition, CMediaType* pMediaType)
+{
+ AVG_ASSERT(pMediaType);
+ AVG_ASSERT(iPosition >= 0);
+ if (iPosition > 0) {
+ return VFW_S_NO_MORE_ITEMS;
+ }
+
+ *pMediaType = CMediaType();
+ pMediaType->SetType(&MEDIATYPE_Video);
+
+ return S_OK;
+}
+
+STDMETHODIMP CSampleGrabberInPin::EnumMediaTypes(IEnumMediaTypes** ppEnum)
+{
+ AVG_ASSERT(ppEnum);
+ ValidateReadWritePtr(ppEnum, sizeof(IEnumMediaTypes *));
+
+ if(!((CSampleGrabber*)m_pTIPFilter)->OutputPin()->IsConnected())
+ {
+ *ppEnum = new CEnumMediaTypes(this, NULL);
+ return NOERROR;
+ }
+
+ return ((CSampleGrabber*)m_pTIPFilter)->OutputPin()->GetConnected()
+ ->EnumMediaTypes(ppEnum);
+}
+
+HRESULT CSampleGrabberInPin::GetAllocatorRequirements(ALLOCATOR_PROPERTIES *pProps)
+{
+ AVG_ASSERT(pProps);
+
+ if (m_pPrivateAllocator) {
+ *pProps = m_allocprops;
+ return S_OK;
+ } else {
+ return CTransInPlaceInputPin::GetAllocatorRequirements(pProps);
+ }
+}
+
+} \ No newline at end of file
diff --git a/src/imaging/DSSampleGrabber.h b/src/imaging/DSSampleGrabber.h
new file mode 100755
index 0000000..100667c
--- /dev/null
+++ b/src/imaging/DSSampleGrabber.h
@@ -0,0 +1,91 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DSSampleGrabber_H_
+#define _DSSampleGrabber_H_
+
+#include "IDSSampleCallback.h"
+
+#include "../base/Exception.h"
+
+#include <Guiddef.h>
+#define _WIN32_DCOM
+#include <windows.h>
+#include <dshow.h>
+#include <dshowbase/mtype.h>
+#include <dshowbase/wxdebug.h>
+#include <dshowbase/combase.h>
+#include <dshowbase/reftime.h>
+#include <dshowbase/wxutil.h>
+#include <dshowbase/wxlist.h>
+#include <dshowbase/amfilter.h>
+#include <dshowbase/transfrm.h>
+#include <dshowbase/transip.h>
+
+// {87F09DC5-12BC-479d-A20F-21133C613037}
+DEFINE_GUID(IID_IlibavgGrabber,
+0x87f09dc5, 0x12bc, 0x479d, 0xa2, 0xf, 0x21, 0x13, 0x3c, 0x61, 0x30, 0x37);
+
+namespace avg {
+
+MIDL_INTERFACE("6B652FFF-11FE-4FCE-92AD-0266B5D7C78F")
+IlibavgGrabber : public IUnknown
+{
+public:
+ virtual void STDMETHODCALLTYPE SetCallback(IDSSampleCallback* pCallback) = 0;
+};
+
+class CSampleGrabberInPin;
+
+class CSampleGrabber : public CTransInPlaceFilter, IlibavgGrabber
+{
+public:
+ CSampleGrabber(IUnknown* pOuter, HRESULT* pHr);
+
+ STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void** ppv);
+ DECLARE_IUNKNOWN;
+
+ // IlibavgGrabber
+ void STDMETHODCALLTYPE SetCallback(IDSSampleCallback* pCallback);
+
+protected:
+ IDSSampleCallback* m_pCallback;
+ CCritSec m_Lock; // serialize access to our data
+
+ HRESULT CheckInputType(const CMediaType* pmt);
+ HRESULT Transform(IMediaSample* pms);
+
+ // override this so we can return S_FALSE directly.
+ // The base class CTransInPlace
+ // Transform( ) method is called by it's
+ // Receive( ) method. There is no way
+ // to get Transform( ) to return an S_FALSE value
+ // (which means "stop giving me data"),
+ // to Receive( ) and get Receive( ) to return S_FALSE as well.
+ HRESULT Receive(IMediaSample* pms);
+
+private:
+ friend class CSampleGrabberInPin;
+};
+
+};
+
+#endif \ No newline at end of file
diff --git a/src/imaging/DeDistort.cpp b/src/imaging/DeDistort.cpp
new file mode 100644
index 0000000..abed1c8
--- /dev/null
+++ b/src/imaging/DeDistort.cpp
@@ -0,0 +1,304 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "DeDistort.h"
+#include "TrackerConfig.h"
+
+#include "../base/StringHelper.h"
+
+#include <cstring>
+#include <iostream>
+#include <math.h>
+
+const double sqrt3 = sqrt(3.);
+
+using namespace std;
+
+namespace avg {
+
+// This transformation is based on the undistort code found at
+// http://www.math.rutgers.edu/~ojanen/undistort/index.html.
+// a lot of parameters enter here, some of which can be calculated/set manually,
+// some of which need to be determined via an optimization procedure
+//
+// * m_CamExtents is the size of the camera image. This is used to transform the
+// coordinates of the image so they fall in the range (-1,-1)-(1,1)
+// * m_pDistortionParams OPT see paper
+// * m_Angle corrects rotation of camera OPT
+// * m_DisplayScale convert back from standard coords to display
+// * m_DisplayOffset correct the offset of the display from the center of the table
+//
+
+DeDistort::DeDistort()
+ : m_CamExtents(1,1),
+ m_Angle(0.0),
+ m_TrapezoidFactor(0),
+ m_DisplayOffset(0,0),
+ m_DisplayScale(1,1)
+{
+ m_DistortionParams.push_back(0);
+ m_DistortionParams.push_back(0);
+ m_RescaleFactor = calc_rescale();
+}
+
+DeDistort::DeDistort(const DPoint& camExtents, const DPoint& displayExtents)
+ : m_Angle(0.0),
+ m_TrapezoidFactor(0),
+ m_DisplayOffset(0,0)
+{
+ m_CamExtents = camExtents;
+ m_DistortionParams.push_back(0);
+ m_DistortionParams.push_back(0);
+ m_DisplayScale.x = displayExtents.x/camExtents.x;
+ m_DisplayScale.y = displayExtents.y/camExtents.y;
+ m_RescaleFactor = calc_rescale();
+}
+
+DeDistort::DeDistort(const DPoint& camExtents, const vector<double>& distortionParams,
+ double angle, double trapezoidFactor, const DPoint& displayOffset,
+ const DPoint& displayScale)
+ : m_CamExtents(camExtents),
+ m_DistortionParams(distortionParams),
+ m_Angle(angle),
+ m_TrapezoidFactor(trapezoidFactor),
+ m_DisplayOffset(displayOffset),
+ m_DisplayScale(displayScale)
+{
+ m_RescaleFactor = calc_rescale();
+}
+
+DeDistort::~DeDistort()
+{
+}
+
+DRect DeDistort::getDisplayArea(const DPoint& displayExtents)
+{
+ return getActiveBlobArea(DRect(DPoint(0,0), displayExtents));
+}
+
+DRect DeDistort::getActiveBlobArea(const DRect& displayROI)
+{
+ DRect activeRect;
+ activeRect.tl = transformScreenToBlob(DPoint(displayROI.tl));
+ activeRect.br = transformScreenToBlob(DPoint(displayROI.br));
+ if (activeRect.height() < 1) {
+ double temp = activeRect.tl.y;
+ activeRect.tl.y = activeRect.br.y;
+ activeRect.br.y = temp;
+ }
+ if (activeRect.width() < 1) {
+ double temp = activeRect.tl.x;
+ activeRect.tl.x = activeRect.br.x;
+ activeRect.br.x = temp;
+ }
+ return activeRect;
+}
+
+void DeDistort::load(const DPoint& camExtents, const TrackerConfig& config)
+{
+ m_CamExtents = camExtents;
+ m_DistortionParams.clear();
+ m_DistortionParams.push_back(config.getDoubleParam
+ ("/transform/distortionparams/@p2"));
+ m_DistortionParams.push_back(config.getDoubleParam
+ ("/transform/distortionparams/@p3"));
+ m_TrapezoidFactor = config.getDoubleParam("/transform/trapezoid/@value");
+ m_Angle = config.getDoubleParam("/transform/angle/@value");
+ m_DisplayOffset = config.getPointParam("/transform/displaydisplacement/");
+ m_DisplayScale = config.getPointParam("/transform/displayscale/");
+
+ m_RescaleFactor = calc_rescale();
+}
+
+void DeDistort::save(TrackerConfig& config)
+{
+ config.setParam("/transform/distortionparams/@p2",
+ toString(m_DistortionParams[0]));
+ config.setParam("/transform/distortionparams/@p3",
+ toString(m_DistortionParams[1]));
+ config.setParam("/transform/trapezoid/@value",
+ toString(m_TrapezoidFactor));
+ config.setParam("/transform/angle/@value",
+ toString(m_Angle));
+ config.setParam("/transform/displaydisplacement/@x",
+ toString(m_DisplayOffset.x));
+ config.setParam("/transform/displaydisplacement/@y",
+ toString(m_DisplayOffset.y));
+ config.setParam("/transform/displayscale/@x",
+ toString(m_DisplayScale.x));
+ config.setParam("/transform/displayscale/@y",
+ toString(m_DisplayScale.y));
+}
+
+bool DeDistort::operator ==(const DeDistort& other) const
+{
+ return (m_CamExtents == other.m_CamExtents &&
+ m_DistortionParams == other.m_DistortionParams &&
+ m_Angle == other.m_Angle &&
+ m_TrapezoidFactor == other.m_TrapezoidFactor &&
+ m_DisplayOffset == other.m_DisplayOffset &&
+ m_DisplayScale == other.m_DisplayScale &&
+ m_RescaleFactor == other.m_RescaleFactor);
+}
+
+void DeDistort::dump() const
+{
+ cerr << " Transform:" << endl;
+ cerr << " CamExtents: " << m_CamExtents << endl;
+ cerr << " DistortionParams: " << m_DistortionParams[0] << ", "
+ << m_DistortionParams[1] << m_DistortionParams[2] << endl;
+ cerr << " Trapezoid: " << m_TrapezoidFactor << endl;
+ cerr << " Angle: " << m_Angle << endl;
+ cerr << " DisplayOffset: " << m_DisplayOffset << endl;
+ cerr << " DisplayScale: " << m_DisplayScale << endl;
+}
+
+DPoint DeDistort::transformScreenToBlob(const DPoint& pt)
+{
+ // scale to blob image resolution and translate 0,0 to upper left corner.
+ DPoint DestPt = pt-m_DisplayOffset;
+ DestPt = DPoint(DestPt.x/m_DisplayScale.x, DestPt.y/m_DisplayScale.y);
+ return DestPt;
+}
+
+DPoint DeDistort::inverse_transform_point(const DPoint& pt)
+{
+ DPoint destPt = pt-m_CamExtents/2;
+ destPt = DPoint(2*destPt.x/m_CamExtents.x, 2*destPt.y/m_CamExtents.y);
+ destPt = inv_trapezoid(m_TrapezoidFactor, destPt);
+ destPt = destPt.getRotated(-m_Angle);
+ destPt *= m_RescaleFactor;
+ destPt = inverse_undistort(m_DistortionParams, destPt);
+ destPt = DPoint(destPt.x*m_CamExtents.x/2, destPt.y*m_CamExtents.y/2);
+ destPt += m_CamExtents/2;
+ return destPt;
+}
+
+DPoint DeDistort::transformBlobToScreen(const DPoint& pt)
+{
+ DPoint destPt = DPoint(m_DisplayScale.x*pt.x, m_DisplayScale.y*pt.y);
+ destPt += m_DisplayOffset;
+ return destPt;
+}
+
+DPoint DeDistort::transform_point(const DPoint& pt)
+{
+ DPoint destPt = pt-m_CamExtents/2;
+ destPt = DPoint(2*destPt.x/m_CamExtents.x, 2*destPt.y/m_CamExtents.y);
+ destPt = undistort(m_DistortionParams, destPt);
+ destPt /= m_RescaleFactor;
+ destPt = destPt.getRotated(m_Angle);
+ destPt = trapezoid(m_TrapezoidFactor, destPt);
+ destPt = DPoint(destPt.x*m_CamExtents.x/2, destPt.y*m_CamExtents.y/2);
+ destPt += m_CamExtents/2;
+ return destPt;
+}
+
+DPoint DeDistort::inv_trapezoid(const double trapezoid_factor, const DPoint& pt)
+{
+ // stretch x coord
+ double yn = pt.y;
+ return DPoint(pt.x/(1+yn*trapezoid_factor), pt.y);
+}
+
+DPoint DeDistort::trapezoid(const double trapezoid_factor, const DPoint& pt)
+{
+ // stretch x coord
+ double yn = pt.y;
+ return DPoint(pt.x*(1+yn*trapezoid_factor), pt.y);
+}
+
+double distort_map(const vector<double>& params, double r)
+{
+ double S = 0;
+ int counter = 2;
+ std::vector<double>::const_iterator v;
+ for(v=params.begin(); v!=params.end(); ++v){
+ S += (*v) * pow(r, counter);
+ ++counter;
+ }
+ return r+S;
+}
+
+double DeDistort::calc_rescale()
+{
+ //make sure that the undistort transformation stays within the normalized box
+ double scale = distort_map(m_DistortionParams, sqrt(2.0));
+ return scale/sqrt(2.0);
+}
+
+double inv_distort_map(const vector<double>& params, double r)
+{
+ double r1,r2,r3,f1,f2;
+ r1 = r;
+ r2 = r+.001;
+ f1 = distort_map(params, r1)-r;
+ f2 = distort_map(params, r2)-r;
+ while (fabs(f2) > 0.0001) {
+ r3 = (r1*f2-r2*f1)/(f2-f1);
+ r1 = r2;
+ r2 = r3;
+ f1 = f2;
+ f2 = distort_map(params, r2)-r;
+ }
+ return r2;
+}
+
+#define EPSILON 0.00001
+DPoint DeDistort::inverse_undistort(const vector<double> &params, const DPoint &pt)
+{
+ if (params.empty()) {
+ return pt;
+ }
+ DPoint pt_norm = pt;
+ double r_d = sqrt(pt_norm.x*pt_norm.x + pt_norm.y*pt_norm.y);
+ double S;
+ if (r_d < EPSILON) {
+ S=0;
+ } else {
+ S = inv_distort_map(params, r_d)/r_d;
+ }
+ DPoint result = pt_norm*(S);
+ return result;
+}
+
+DPoint DeDistort::undistort(const vector<double>& params, const DPoint &pt)
+{
+ std::vector<double>::const_iterator v = params.begin();
+ if (v == params.end()) {
+ return pt;
+ }
+ DPoint pt_norm = pt;
+ double r_d = sqrt(pt_norm.x*pt_norm.x + pt_norm.y*pt_norm.y);
+ double S;
+ if (r_d < EPSILON) {
+ S=0;
+ } else {
+ S = distort_map(params, r_d)/r_d;
+ }
+
+ DPoint result = pt_norm*(S);
+ return result;
+}
+
+}
diff --git a/src/imaging/DeDistort.h b/src/imaging/DeDistort.h
new file mode 100644
index 0000000..ab804c6
--- /dev/null
+++ b/src/imaging/DeDistort.h
@@ -0,0 +1,86 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DeDistort_H_
+#define _DeDistort_H_
+
+#include "../api.h"
+#include "CoordTransformer.h"
+
+#include "../base/Point.h"
+#include "../base/Rect.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <libxml/parser.h>
+#include <libxml/xmlwriter.h>
+
+#include <vector>
+#include <string>
+
+namespace avg {
+
+class TrackerConfig;
+
+class AVG_API DeDistort: public CoordTransformer {
+ public:
+ DeDistort();
+ DeDistort(const DPoint& camExtents, const DPoint& displayExtents);
+ DeDistort(const DPoint& camExtents, const std::vector<double>& distortionParams,
+ double angle, double trapezoidFactor, const DPoint& displayOffset,
+ const DPoint& displayScale);
+ virtual ~DeDistort();
+
+ DPoint transformBlobToScreen(const DPoint& pt);
+ DPoint transformScreenToBlob(const DPoint& pt);
+ virtual DPoint transform_point(const DPoint& pt);
+ virtual DPoint inverse_transform_point(const DPoint& pt);
+ DRect getDisplayArea(const DPoint& displayExtents);
+ DRect getActiveBlobArea(const DRect& displayROI);
+
+ void load(const DPoint &CameraExtents, const TrackerConfig& config);
+ void save(TrackerConfig& config);
+
+ bool operator ==(const DeDistort& other) const;
+
+ void dump() const;
+
+ private:
+ double calc_rescale();
+ DPoint inverse_undistort(const std::vector<double>& params, const DPoint& pt);
+ DPoint undistort(const std::vector<double>& params, const DPoint& pt);
+ DPoint trapezoid(const double trapezoid_factor, const DPoint& pt);
+ DPoint inv_trapezoid(const double trapezoid_factor, const DPoint& pt);
+
+ DPoint m_CamExtents;
+ std::vector<double> m_DistortionParams;
+ double m_Angle;
+ double m_TrapezoidFactor;
+ DPoint m_DisplayOffset;
+ DPoint m_DisplayScale;
+
+ double m_RescaleFactor;
+};
+
+typedef boost::shared_ptr<DeDistort> DeDistortPtr;
+
+}
+#endif
diff --git a/src/imaging/FWCamera.cpp b/src/imaging/FWCamera.cpp
new file mode 100644
index 0000000..d009b97
--- /dev/null
+++ b/src/imaging/FWCamera.cpp
@@ -0,0 +1,576 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FWCamera.h"
+#ifdef AVG_ENABLE_1394_2
+#include "FWCameraUtils.h"
+#endif
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../base/StringHelper.h"
+
+#include <string.h>
+#include <sstream>
+#include <iomanip>
+
+namespace avg {
+
+using namespace std;
+
+FWCamera::FWCamera(uint64_t guid, int unit, bool bFW800, IntPoint size,
+ PixelFormat camPF, PixelFormat destPF, double frameRate)
+ : Camera(camPF, destPF),
+ m_Size(size),
+ m_FrameRate(frameRate),
+ m_WhitebalanceU(-1),
+ m_WhitebalanceV(-1)
+{
+#ifdef AVG_ENABLE_1394_2
+ m_FrameRateConstant = getFrameRateConst(m_FrameRate);
+ if (camPF == I16) {
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,
+ "I16 pixel format is not supported for firewire cameras.");
+ }
+ m_Mode = getCamMode(size, camPF);
+ dc1394camera_list_t * pCameraList;
+
+ m_pDC1394 = dc1394_new();
+ if (m_pDC1394 == 0) {
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,
+ "Failed to initialize firewire subsystem");
+ }
+ int err = dc1394_camera_enumerate(m_pDC1394, &pCameraList);
+
+ if (err != DC1394_SUCCESS) {
+ AVG_TRACE(Logger::ERROR, "Unable to look for cameras");
+#ifdef linux
+ AVG_TRACE(Logger::ERROR, "Please check");
+ AVG_TRACE(Logger::ERROR,
+ " - if the kernel modules `ieee1394',`raw1394' and `ohci1394' are loaded");
+ AVG_TRACE(Logger::ERROR,
+ " - if you have read/write access to /dev/raw1394.");
+#endif
+ dc1394_free(m_pDC1394);
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,"Firewire failure");
+ }
+
+ if (pCameraList->num == 0) {
+ dc1394_camera_free_list(pCameraList);
+ dc1394_free(m_pDC1394);
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,"No firewire cameras found.");
+ }
+ int id_to_use = -1;
+ if (guid != 0) {
+ for (unsigned i = 0; i < pCameraList->num; ++i) {
+ if (pCameraList->ids[i].guid == guid) {
+ id_to_use = i;
+ }
+ }
+ if (id_to_use == -1) {
+ AVG_TRACE(Logger::WARNING, "Firewire GUID=" << hex << guid << dec
+ << " requested but not found on bus. Using first camera");
+ id_to_use = 0;
+ }
+ } else {
+ id_to_use = 0;
+ }
+ if (unit != -1) {
+ m_pCamera = dc1394_camera_new_unit(m_pDC1394, pCameraList->ids[id_to_use].guid,
+ unit);
+ } else {
+ m_pCamera = dc1394_camera_new(m_pDC1394, pCameraList->ids[id_to_use].guid);
+ }
+ if (!m_pCamera) {
+ dc1394_camera_free_list(pCameraList);
+ dc1394_free(m_pDC1394);
+ throw Exception(AVG_ERR_CAMERA_FATAL,"Failed to initialize camera");
+ }
+
+ dc1394_camera_free_list(pCameraList);
+
+ if (bFW800) {
+ dc1394_video_set_operation_mode(m_pCamera, DC1394_OPERATION_MODE_1394B);
+ err = dc1394_video_set_iso_speed(m_pCamera, DC1394_ISO_SPEED_800);
+ } else {
+ err = dc1394_video_set_iso_speed(m_pCamera, DC1394_ISO_SPEED_400);
+ }
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ err = dc1394_video_set_mode(m_pCamera, m_Mode);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+
+ dc1394framerates_t frameRates;
+ err = dc1394_video_get_supported_framerates(m_pCamera, m_Mode, &frameRates);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ bool bFrameRateSupported = false;
+ for (unsigned int i = 0; i < frameRates.num; i++) {
+ if (frameRates.framerates[i] == m_FrameRateConstant) {
+ bFrameRateSupported = true;
+ break;
+ }
+ }
+ if (!bFrameRateSupported) {
+ AVG_TRACE(Logger::ERROR, "Camera does not support framerate " << m_FrameRate
+ << " in the current video mode.");
+ dc1394_capture_stop(m_pCamera);
+ dc1394_video_set_transmission(m_pCamera, DC1394_OFF);
+ dc1394_camera_free(m_pCamera);
+ dc1394_free(m_pDC1394);
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,
+ string("Camera does not support framerate ")+toString(m_FrameRate)+
+ " in the current video mode.");
+ }
+
+ err = dc1394_video_set_framerate(m_pCamera, m_FrameRateConstant);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+
+ err = dc1394_capture_setup(m_pCamera,8, DC1394_CAPTURE_FLAGS_DEFAULT);
+ if (err != DC1394_SUCCESS) {
+ AVG_TRACE(Logger::ERROR, "Unable to setup camera. Make sure that");
+ AVG_TRACE(Logger::ERROR, "video mode and framerate (" <<
+ m_FrameRate << ") are");
+ AVG_TRACE(Logger::ERROR, "supported by your camera.");
+ dc1394_capture_stop(m_pCamera);
+ dc1394_video_set_transmission(m_pCamera, DC1394_OFF);
+ dc1394_camera_free(m_pCamera);
+ dc1394_free(m_pDC1394);
+ throw Exception(AVG_ERR_CAMERA_NONFATAL, "Failed to initialize camera");
+ }
+#else
+ AVG_ASSERT(false);
+#endif
+}
+
+FWCamera::~FWCamera()
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394_video_set_transmission(m_pCamera, DC1394_OFF);
+ dc1394_capture_stop(m_pCamera);
+ dc1394_camera_free(m_pCamera);
+ dc1394_free(m_pDC1394);
+#endif
+ AVG_TRACE(Logger::CONFIG, "Firewire camera closed.");
+}
+
+void FWCamera::startCapture()
+{
+#ifdef AVG_ENABLE_1394_2
+ int err = dc1394_video_set_transmission(m_pCamera, DC1394_ON);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+
+ dc1394switch_t status = DC1394_OFF;
+
+ int i = 0;
+ while (status == DC1394_OFF && i++ < 5) {
+ usleep(50000);
+ err = dc1394_video_get_transmission(m_pCamera, &status);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ }
+
+ if (i == 5) {
+ AVG_ASSERT(false);
+ }
+ // Default to turning off any camera sharpness manipulation.
+ setFeature(CAM_FEATURE_SHARPNESS, 0);
+
+ // Turn off possible auto exposure.
+ dc1394_feature_set_mode(m_pCamera, DC1394_FEATURE_EXPOSURE,
+ DC1394_FEATURE_MODE_MANUAL);
+ dc1394_feature_set_power(m_pCamera, DC1394_FEATURE_EXPOSURE, DC1394_OFF);
+
+ AVG_TRACE(Logger::CONFIG, "Firewire camera opened.");
+ for (FeatureMap::iterator it=m_Features.begin(); it != m_Features.end(); it++) {
+ setFeature(it->first, it->second, true);
+ }
+ setWhitebalance(m_WhitebalanceU, m_WhitebalanceV, true);
+
+ if (getCamPF() == BAYER8) {
+ if (strcmp(m_pCamera->model, "DFx 31BF03") == 0) {
+ AVG_TRACE(Logger::CONFIG,
+ "Applying bayer pattern fixup for IS DFx31BF03 camera");
+ setCamPF(BAYER8_GRBG);
+ } else if (strcmp(m_pCamera->vendor, "Point Grey Research") == 0) {
+ AVG_TRACE(Logger::CONFIG,
+ "Applying bayer pattern fixup for PointGrey cameras");
+ enablePtGreyBayer();
+ }
+ }
+#endif
+}
+
+IntPoint FWCamera::getImgSize()
+{
+#ifdef AVG_ENABLE_1394_2
+ return m_Size;
+#else
+ return IntPoint(0, 0);
+#endif
+}
+
+
+static ProfilingZoneID CameraConvertProfilingZone("FW Camera format conversion");
+
+BitmapPtr FWCamera::getImage(bool bWait)
+{
+#ifdef AVG_ENABLE_1394_2
+ bool bGotFrame = false;
+ unsigned char * pCaptureBuffer = 0;
+ dc1394video_frame_t * pFrame;
+ dc1394error_t err;
+ if (bWait) {
+ err = dc1394_capture_dequeue(m_pCamera, DC1394_CAPTURE_POLICY_WAIT, &pFrame);
+ } else {
+ err = dc1394_capture_dequeue(m_pCamera, DC1394_CAPTURE_POLICY_POLL, &pFrame);
+ }
+ if (err == DC1394_SUCCESS && pFrame) {
+ bGotFrame = true;
+ pCaptureBuffer = pFrame->image;
+ }
+ if (bGotFrame) {
+ int lineLen;
+ if (getCamPF() == YCbCr411) {
+ lineLen = m_Size.x*1.5;
+ } else {
+ lineLen = m_Size.x*getBytesPerPixel(getCamPF());
+ }
+ BitmapPtr pCamBmp(new Bitmap(m_Size, getCamPF(), pCaptureBuffer, lineLen, false,
+ "TempCameraBmp"));
+ BitmapPtr pDestBmp = convertCamFrameToDestPF(pCamBmp);
+// cerr << "CamBmp: " << pCamBmp->getPixelFormat() << ", DestBmp: "
+// << pDestBmp->getPixelFormat() << endl;
+ dc1394_capture_enqueue(m_pCamera, pFrame);
+ return pDestBmp;
+ } else {
+ return BitmapPtr();
+ }
+#else
+ return BitmapPtr();
+#endif
+}
+
+
+const string& FWCamera::getDevice() const
+{
+ static string deviceInfo;
+ stringstream ss;
+#ifdef AVG_ENABLE_1394_2
+ ss << m_pCamera->vendor << " " << m_pCamera->model << " (guid=" << m_pCamera->guid
+ << ", unit=" << m_pCamera->unit << ")";
+#endif
+ deviceInfo = ss.str();
+ return deviceInfo;
+}
+
+const std::string& FWCamera::getDriverName() const
+{
+#ifdef AVG_ENABLE_1394_2
+ static string sDriverName = "libdc1394 v2";
+#else
+ static string sDriverName = "";
+#endif
+ return sDriverName;
+}
+
+double FWCamera::getFrameRate() const
+{
+ return m_FrameRate;
+}
+
+int FWCamera::getFeature(CameraFeature feature) const
+{
+#ifdef AVG_ENABLE_1394_2
+ FeatureMap::const_iterator it = m_Features.find(feature);
+ if (it == m_Features.end()) {
+ return 0;
+ } else {
+ return it->second;
+ }
+#else
+ return 0;
+#endif
+}
+
+bool FWCamera::hasFeature(CameraFeature feature)
+{
+#ifdef AVG_ENABLE_1394_2
+ if (feature == CAM_FEATURE_STROBE_DURATION) {
+ // FIXME
+ return true;
+ } else {
+ dc1394feature_t featureID = getFeatureID(feature);
+ dc1394bool_t bAvailable;
+ dc1394_feature_is_present(m_pCamera, featureID, &bAvailable);
+ return bAvailable;
+ }
+#else
+ return false;
+#endif
+}
+
+void FWCamera::setFeature(CameraFeature feature, int value, bool bIgnoreOldValue)
+{
+#ifdef AVG_ENABLE_1394_2
+ if (hasFeature(feature)) {
+ if (bIgnoreOldValue || m_Features[feature] != value) {
+ m_Features[feature] = value;
+ if (feature == CAM_FEATURE_STROBE_DURATION) {
+ try {
+ setStrobeDuration(value);
+ } catch (Exception& e) {
+ AVG_TRACE(Logger::WARNING,
+ string("Camera: Setting strobe duration failed. ") +
+ e.getStr());
+ }
+ } else {
+ dc1394feature_t featureID = getFeatureID(feature);
+ setFeature(featureID, value);
+ // dumpCameraInfo();
+ }
+ }
+ }
+#endif
+}
+
+void FWCamera::setFeatureOneShot(CameraFeature feature)
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394feature_t featureID = getFeatureID(feature);
+ dc1394error_t err = dc1394_feature_set_mode(m_pCamera, featureID,
+ DC1394_FEATURE_MODE_ONE_PUSH_AUTO);
+ if (err != DC1394_SUCCESS) {
+ AVG_TRACE(Logger::WARNING, "Camera: Unable to set one-shot for "
+ << cameraFeatureToString(feature) << ". Error was " << err);
+ }
+#endif
+}
+
+int FWCamera::getWhitebalanceU() const
+{
+ int u;
+ int v;
+ getWhitebalance(&u, &v);
+ return u;
+}
+
+int FWCamera::getWhitebalanceV() const
+{
+ int u;
+ int v;
+ getWhitebalance(&u, &v);
+ return v;
+}
+
+void FWCamera::setWhitebalance(int u, int v, bool bIgnoreOldValue)
+{
+#ifdef AVG_ENABLE_1394_2
+ if (hasFeature(CAM_FEATURE_WHITE_BALANCE)) {
+ if (bIgnoreOldValue || u != m_WhitebalanceU || v != m_WhitebalanceV) {
+ m_WhitebalanceU = u;
+ m_WhitebalanceV = v;
+ dc1394error_t err;
+ if (u == -1) {
+ err = dc1394_feature_set_mode(m_pCamera, DC1394_FEATURE_WHITE_BALANCE,
+ DC1394_FEATURE_MODE_AUTO);
+ } else {
+ err = dc1394_feature_set_mode(m_pCamera, DC1394_FEATURE_WHITE_BALANCE,
+ DC1394_FEATURE_MODE_MANUAL);
+ err = dc1394_feature_whitebalance_set_value(m_pCamera, u, v);
+ }
+ if (err != DC1394_SUCCESS) {
+ AVG_TRACE(Logger::WARNING,
+ "Camera: Unable to set whitebalance. Error was " << err);
+ }
+ }
+ }
+#endif
+}
+
+void FWCamera::setFeature(dc1394feature_t feature, int value)
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394error_t err;
+ if (value == -1) {
+ err = dc1394_feature_set_mode(m_pCamera, feature, DC1394_FEATURE_MODE_AUTO);
+ err = dc1394_feature_set_power(m_pCamera, feature, DC1394_OFF);
+ } else {
+ dc1394_feature_set_mode(m_pCamera, feature, DC1394_FEATURE_MODE_MANUAL);
+ err = dc1394_feature_set_power(m_pCamera, feature, DC1394_ON);
+ err = dc1394_feature_set_value(m_pCamera, feature, value);
+ }
+ if (err != DC1394_SUCCESS) {
+ AVG_TRACE(Logger::WARNING, "Camera: Unable to set " << feature <<
+ ". Error was " << err);
+ }
+/*
+ dc1394feature_info_t featureInfo;
+ featureInfo.id = feature;
+ err = dc1394_feature_get(m_pCamera, &featureInfo);
+ dc1394_feature_print(&featureInfo, stdout);
+*/
+#endif
+}
+
+void FWCamera::setStrobeDuration(int microsecs)
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394error_t err;
+ uint32_t durationRegValue;
+ if (microsecs >= 63930 || microsecs < -1) {
+ throw Exception(AVG_ERR_CAMERA_FATAL, string("Illegal value ")
+ +toString(microsecs)+" for strobe duration.");
+ }
+ if (microsecs == -1) {
+ // Turn off strobe. No error checking done here (if the camera doesn't support
+ // strobe, setting the register will fail. But there is really no error, because
+ // we're turning the feature off anyway.)
+ uint32_t strobeRegValue = 0x81000000;
+ err = dc1394_set_strobe_register(m_pCamera, 0x200, strobeRegValue);
+ } else {
+ if (microsecs < 0x400) {
+ durationRegValue = microsecs;
+ } else {
+ // Wierd calculations: IIDC register values for time are non-linear. Translate
+ // the method parameter in microseconds to appropriate register values.
+ double targetMillisecs = microsecs/1000.;
+ const double realTimes[] = {1,2,4,6,8,12,16,24,32,48,63.93};
+ const uint32_t regValues[] =
+ {0x400, 0x600, 0x800, 0x900, 0xA00, 0xB00, 0xC00, 0xD00,
+ 0xE00, 0xF00, 0xFFF};
+ int len = sizeof(regValues)/sizeof(*regValues);
+ AVG_ASSERT(len == sizeof(realTimes)/sizeof(*realTimes));
+ int i;
+ for (i = 1; realTimes[i] < targetMillisecs; ++i);
+ double ratio = (targetMillisecs-realTimes[i])/(realTimes[i-1]-realTimes[i]);
+ durationRegValue = ratio*regValues[i-1]+(1-ratio)*regValues[i];
+ }
+
+ err = dc1394_set_PIO_register(m_pCamera, 0x08, 0xC0000000);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+
+ uint32_t strobeRegValue = 0x83001000+durationRegValue;
+ err = dc1394_set_strobe_register(m_pCamera, 0x200, strobeRegValue);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ }
+#endif
+}
+
+void FWCamera::getWhitebalance(int* pU, int* pV) const
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394error_t err = dc1394_feature_whitebalance_get_value(m_pCamera,
+ (uint32_t*)pU, (uint32_t*)pV);
+ if (err != DC1394_SUCCESS) {
+ AVG_TRACE(Logger::WARNING,
+ "Camera: Unable to get whitebalance setting. Error was " << err);
+ }
+#endif
+}
+
+void FWCamera::enablePtGreyBayer()
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394error_t err;
+ uint32_t imageDataFormat;
+ err = dc1394_get_adv_control_register(m_pCamera, 0x48, &imageDataFormat);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ if (imageDataFormat & 0x80000000) {
+ err = dc1394_set_adv_control_register(m_pCamera, 0x48, 0x80000081);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ uint32_t bayerFormat;
+ err = dc1394_get_adv_control_register(m_pCamera, 0x40, &bayerFormat);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ PixelFormat exactPF = fwBayerStringToPF(bayerFormat);
+ if (exactPF == I8) {
+ throw(Exception(AVG_ERR_CAMERA_NONFATAL,
+ "Greyscale camera doesn't support bayer pattern."));
+ }
+ setCamPF(exactPF);
+ }
+#endif
+}
+
+void FWCamera::dumpCameras()
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394_t* pDC1394 = dc1394_new();
+ if (pDC1394 == 0) {
+ return;
+ }
+ dc1394camera_list_t * pCameraList;
+ int err=dc1394_camera_enumerate(pDC1394, &pCameraList);
+ if (err == DC1394_SUCCESS) {
+ if (pCameraList->num != 0) {
+ cerr << "Firewire cameras: " << endl;
+ for (unsigned i=0; i<pCameraList->num;++i) {
+ dc1394camera_id_t id = pCameraList->ids[i];
+ dc1394camera_t * pCamera = dc1394_camera_new_unit(pDC1394, id.guid,
+ id.unit);
+ if (pCamera) {
+ dc1394_camera_print_info(pCamera, stderr);
+ dumpCameraInfo(pCamera);
+ dc1394_camera_free(pCamera);
+ cerr << endl;
+ }
+ }
+ }
+ dc1394_camera_free_list(pCameraList);
+ }
+ dc1394_free(pDC1394);
+#endif
+}
+
+#ifdef AVG_ENABLE_1394_2
+void FWCamera::dumpCameraInfo(dc1394camera_t * pCamera)
+{
+ dc1394error_t err;
+ dc1394featureset_t FeatureSet;
+ err = dc1394_feature_get_all(pCamera, &FeatureSet);
+ AVG_ASSERT(err == DC1394_SUCCESS);
+ // TODO: do this using AVG_TRACE
+ dc1394_feature_print_all(&FeatureSet, stderr);
+}
+#endif
+
+void FWCamera::resetBus()
+{
+#ifdef AVG_ENABLE_1394_2
+ dc1394_t* pDC1394 = dc1394_new();
+ if (pDC1394 == 0) {
+ return;
+ }
+ dc1394camera_list_t * pCameraList;
+ int err=dc1394_camera_enumerate(pDC1394, &pCameraList);
+ if (err == DC1394_SUCCESS) {
+ if (pCameraList->num != 0) {
+ dc1394camera_t * pCam = dc1394_camera_new(pDC1394, pCameraList->ids[0].guid);
+ if (pCam) {
+ dc1394_reset_bus(pCam);
+ dc1394_camera_free(pCam);
+ }
+ }
+ dc1394_camera_free_list(pCameraList);
+ }
+ dc1394_free(pDC1394);
+#endif
+}
+
+}
diff --git a/src/imaging/FWCamera.h b/src/imaging/FWCamera.h
new file mode 100644
index 0000000..a5af3ad
--- /dev/null
+++ b/src/imaging/FWCamera.h
@@ -0,0 +1,99 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FWCamera_H_
+#define _FWCamera_H_
+
+#include "../avgconfigwrapper.h"
+
+#include "Camera.h"
+
+#include "../graphics/Bitmap.h"
+#include "../graphics/Pixel24.h"
+
+#include "../base/Point.h"
+
+#ifdef AVG_ENABLE_1394_2
+#include <dc1394/control.h>
+#include <dc1394/register.h>
+#endif
+#ifndef AVG_ENABLE_1394_2
+typedef unsigned int dc1394feature_t;
+#endif
+#ifndef uint64_t
+#define uint64_t unsigned long long
+#endif
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+class AVG_API FWCamera: public Camera {
+public:
+ FWCamera(uint64_t guid, int unit, bool bFW800, IntPoint size, PixelFormat camPF,
+ PixelFormat destPF, double frameRate);
+ virtual ~FWCamera();
+ virtual void startCapture();
+
+ virtual IntPoint getImgSize();
+ virtual BitmapPtr getImage(bool bWait);
+
+ virtual const std::string& getDevice() const;
+ virtual const std::string& getDriverName() const;
+ virtual double getFrameRate() const;
+
+ virtual int getFeature(CameraFeature feature) const;
+ bool hasFeature(CameraFeature feature);
+ virtual void setFeature(CameraFeature feature, int value, bool bIgnoreOldValue=false);
+ virtual void setFeatureOneShot(CameraFeature feature);
+ virtual int getWhitebalanceU() const;
+ virtual int getWhitebalanceV() const;
+ virtual void setWhitebalance(int u, int v, bool bIgnoreOldValue=false);
+
+ static void dumpCameras();
+ static void resetBus();
+
+private:
+ void setFeature(dc1394feature_t feature, int value);
+ void setStrobeDuration(int microsecs);
+ void getWhitebalance(int* pU, int* pV) const;
+ void enablePtGreyBayer();
+
+ IntPoint m_Size;
+ double m_FrameRate;
+
+#ifdef AVG_ENABLE_1394_2
+ dc1394_t * m_pDC1394;
+ dc1394camera_t * m_pCamera;
+ dc1394framerate_t m_FrameRateConstant;
+ dc1394video_mode_t m_Mode;
+ static void dumpCameraInfo(dc1394camera_t * pCamera);
+#endif
+
+ FeatureMap m_Features;
+ int m_WhitebalanceU;
+ int m_WhitebalanceV;
+};
+
+}
+
+#endif
diff --git a/src/imaging/FWCameraUtils.cpp b/src/imaging/FWCameraUtils.cpp
new file mode 100644
index 0000000..5e5a8e1
--- /dev/null
+++ b/src/imaging/FWCameraUtils.cpp
@@ -0,0 +1,185 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FWCameraUtils.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+
+namespace avg {
+
+using namespace std;
+
+dc1394video_mode_t getCamMode(IntPoint size, PixelFormat pf)
+{
+ if (size.x == 320 && size.y == 240 && pf == YCbCr422) {
+ return DC1394_VIDEO_MODE_320x240_YUV422;
+ } else if (size.x == 640 && size.y == 480) {
+ switch (pf) {
+ case I8:
+ case BAYER8:
+ return DC1394_VIDEO_MODE_640x480_MONO8;
+ case I16:
+ return DC1394_VIDEO_MODE_640x480_MONO16;
+ case YCbCr411:
+ return DC1394_VIDEO_MODE_640x480_YUV411;
+ case YCbCr422:
+ return DC1394_VIDEO_MODE_640x480_YUV422;
+ case R8G8B8:
+ return DC1394_VIDEO_MODE_640x480_RGB8;
+ default:
+ break;
+ }
+ } else if (size.x == 800 && size.y == 600) {
+ switch (pf) {
+ case I8:
+ case BAYER8:
+ return DC1394_VIDEO_MODE_800x600_MONO8;
+ case I16:
+ return DC1394_VIDEO_MODE_800x600_MONO16;
+ case YCbCr422:
+ return DC1394_VIDEO_MODE_800x600_YUV422;
+ case R8G8B8:
+ return DC1394_VIDEO_MODE_800x600_RGB8;
+ default:
+ break;
+ }
+ } else if (size.x == 1024 && size.y == 768) {
+ switch (pf) {
+ case I8:
+ case BAYER8:
+ return DC1394_VIDEO_MODE_1024x768_MONO8;
+ case I16:
+ return DC1394_VIDEO_MODE_1024x768_MONO16;
+ case YCbCr422:
+ return DC1394_VIDEO_MODE_1024x768_YUV422;
+ case R8G8B8:
+ return DC1394_VIDEO_MODE_1024x768_RGB8;
+ default:
+ break;
+ }
+ } else if (size.x == 1280 && size.y == 960) {
+ switch (pf) {
+ case I8:
+ case BAYER8:
+ return DC1394_VIDEO_MODE_1280x960_MONO8;
+ case I16:
+ return DC1394_VIDEO_MODE_1280x960_MONO16;
+ case YCbCr422:
+ return DC1394_VIDEO_MODE_1280x960_YUV422;
+ case R8G8B8:
+ return DC1394_VIDEO_MODE_1280x960_RGB8;
+ default:
+ break;
+ }
+ } else if (size.x == 1600 && size.y == 1200) {
+ switch (pf) {
+ case I8:
+ case BAYER8:
+ return DC1394_VIDEO_MODE_1600x1200_MONO8;
+ case I16:
+ return DC1394_VIDEO_MODE_1600x1200_MONO16;
+ case YCbCr422:
+ return DC1394_VIDEO_MODE_1600x1200_YUV422;
+ case R8G8B8:
+ return DC1394_VIDEO_MODE_1600x1200_RGB8;
+ default:
+ break;
+ }
+ }
+ throw Exception(AVG_ERR_CAMERA_FATAL,
+ "Unsupported or illegal value ("+toString(size.x)+", "+toString(size.y)+
+ "), "+getPixelFormatString(pf)+"\" for camera mode.");
+}
+
+dc1394framerate_t getFrameRateConst(double frameRate)
+{
+ if (frameRate == 1.875) {
+ return DC1394_FRAMERATE_1_875;
+ } else if (frameRate == 3.75) {
+ return DC1394_FRAMERATE_3_75;
+ } else if (frameRate == 7.5) {
+ return DC1394_FRAMERATE_7_5;
+ } else if (frameRate == 15) {
+ return DC1394_FRAMERATE_15;
+ } else if (frameRate == 30) {
+ return DC1394_FRAMERATE_30;
+ } else if (frameRate == 60) {
+ return DC1394_FRAMERATE_60;
+ } else if (frameRate == 120) {
+ return DC1394_FRAMERATE_120;
+ } else if (frameRate == 240) {
+ return DC1394_FRAMERATE_240;
+ } else {
+ throw Exception(AVG_ERR_CAMERA_FATAL, string("Illegal value ")
+ +toString(frameRate)+" for camera framerate.");
+ }
+}
+
+dc1394feature_t getFeatureID(CameraFeature feature)
+{
+ switch (feature) {
+ case CAM_FEATURE_BRIGHTNESS:
+ return DC1394_FEATURE_BRIGHTNESS;
+ case CAM_FEATURE_EXPOSURE:
+ return DC1394_FEATURE_EXPOSURE;
+ case CAM_FEATURE_SHARPNESS:
+ return DC1394_FEATURE_SHARPNESS;
+ case CAM_FEATURE_WHITE_BALANCE:
+ return DC1394_FEATURE_WHITE_BALANCE;
+ case CAM_FEATURE_HUE:
+ return DC1394_FEATURE_HUE;
+ case CAM_FEATURE_SATURATION:
+ return DC1394_FEATURE_SATURATION;
+ case CAM_FEATURE_GAMMA:
+ return DC1394_FEATURE_GAMMA;
+ case CAM_FEATURE_SHUTTER:
+ return DC1394_FEATURE_SHUTTER;
+ case CAM_FEATURE_GAIN:
+ return DC1394_FEATURE_GAIN;
+ case CAM_FEATURE_IRIS:
+ return DC1394_FEATURE_IRIS;
+ case CAM_FEATURE_FOCUS:
+ return DC1394_FEATURE_FOCUS;
+ case CAM_FEATURE_TEMPERATURE:
+ return DC1394_FEATURE_TEMPERATURE;
+ case CAM_FEATURE_TRIGGER:
+ return DC1394_FEATURE_TRIGGER;
+ case CAM_FEATURE_ZOOM:
+ return DC1394_FEATURE_ZOOM;
+ case CAM_FEATURE_PAN:
+ return DC1394_FEATURE_PAN;
+ case CAM_FEATURE_TILT:
+ return DC1394_FEATURE_TILT;
+ case CAM_FEATURE_OPTICAL_FILTER:
+ return DC1394_FEATURE_OPTICAL_FILTER;
+ case CAM_FEATURE_CAPTURE_SIZE:
+ return DC1394_FEATURE_CAPTURE_SIZE;
+ case CAM_FEATURE_CAPTURE_QUALITY:
+ return DC1394_FEATURE_CAPTURE_QUALITY;
+ default:
+ AVG_ASSERT(false);
+ return dc1394feature_t(0);
+ }
+}
+
+}
diff --git a/src/imaging/FWCameraUtils.h b/src/imaging/FWCameraUtils.h
new file mode 100644
index 0000000..634838d
--- /dev/null
+++ b/src/imaging/FWCameraUtils.h
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FWCameraUtils_H_
+#define _FWCameraUtils_H_
+
+#include "../api.h"
+#include "Camera.h"
+
+#include "../avgconfigwrapper.h"
+
+#include "../base/Point.h"
+
+#include <dc1394/control.h>
+
+#include <string>
+
+namespace avg {
+
+dc1394video_mode_t getCamMode(IntPoint size, PixelFormat pf);
+dc1394framerate_t getFrameRateConst(double frameRate);
+dc1394feature_t getFeatureID(CameraFeature feature);
+
+}
+
+#endif
diff --git a/src/imaging/FakeCamera.cpp b/src/imaging/FakeCamera.cpp
new file mode 100644
index 0000000..ae966f5
--- /dev/null
+++ b/src/imaging/FakeCamera.cpp
@@ -0,0 +1,160 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FakeCamera.h"
+
+#include "../graphics/Pixel8.h"
+#include "../graphics/Filterfill.h"
+#include "../graphics/Filterfillrect.h"
+#include "../graphics/Filtergrayscale.h"
+
+#include "../base/TimeSource.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+
+using namespace std;
+
+namespace avg {
+
+FakeCamera::FakeCamera(PixelFormat camPF, PixelFormat destPF)
+ : Camera(camPF, destPF),
+ m_pBmpQ(new std::queue<BitmapPtr>()),
+ m_bIsOpen(false)
+{
+ m_ImgSize = IntPoint(640, 480);
+}
+
+FakeCamera::FakeCamera(std::vector<std::string>& pictures)
+ : Camera(I8, I8),
+ m_pBmpQ(new std::queue<BitmapPtr>()),
+ m_bIsOpen(false)
+{
+ m_ImgSize = IntPoint(640, 480);
+ for (vector<string>::iterator it = pictures.begin(); it != pictures.end(); ++it) {
+ try {
+ BitmapPtr pBmp (new Bitmap(*it));
+ FilterGrayscale().applyInPlace(pBmp);
+ m_ImgSize = pBmp->getSize();
+ m_pBmpQ->push(pBmp);
+ } catch (Exception& ex) {
+ AVG_TRACE(Logger::ERROR, ex.getStr());
+ throw;
+ }
+ }
+}
+
+FakeCamera::~FakeCamera()
+{
+}
+
+void FakeCamera::open()
+{
+ m_bIsOpen = true;
+}
+
+void FakeCamera::close()
+{
+ m_bIsOpen = false;
+}
+
+
+IntPoint FakeCamera::getImgSize()
+{
+ return m_ImgSize;
+}
+
+BitmapPtr FakeCamera::getImage(bool bWait)
+{
+ if (bWait) {
+ msleep(100);
+ }
+ if (!m_bIsOpen || !bWait || m_pBmpQ->empty()) {
+ return BitmapPtr();
+ } else {
+ BitmapPtr pBmp = m_pBmpQ->front();
+ m_pBmpQ->pop();
+ return pBmp;
+ }
+}
+
+bool FakeCamera::isCameraAvailable()
+{
+ return true;
+}
+
+
+const string& FakeCamera::getDevice() const
+{
+ static string sDeviceName = "FakeCamera";
+ return sDeviceName;
+}
+
+const std::string& FakeCamera::getDriverName() const
+{
+ static string sDriverName = "FakeCameraDriver";
+ return sDriverName;
+}
+
+double FakeCamera::getFrameRate() const
+{
+ return 60;
+}
+
+const string& FakeCamera::getMode() const
+{
+ static string sMode = "FakeCamera";
+ return sMode;
+}
+
+
+int FakeCamera::getFeature(CameraFeature feature) const
+{
+ return 0;
+}
+
+void FakeCamera::setFeature(CameraFeature feature, int value, bool bIgnoreOldValue)
+{
+}
+
+void FakeCamera::setFeatureOneShot(CameraFeature feature)
+{
+}
+
+int FakeCamera::getWhitebalanceU() const
+{
+ return 0;
+}
+
+int FakeCamera::getWhitebalanceV() const
+{
+ return 0;
+}
+
+void FakeCamera::setWhitebalance(int u, int v, bool bIgnoreOldValue)
+{
+}
+
+}
+
+
+
+
diff --git a/src/imaging/FakeCamera.h b/src/imaging/FakeCamera.h
new file mode 100644
index 0000000..7f444cc
--- /dev/null
+++ b/src/imaging/FakeCamera.h
@@ -0,0 +1,72 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FakeCamera_H_
+#define _FakeCamera_H_
+
+#include "../api.h"
+#include "Camera.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <string>
+#include <queue>
+
+namespace avg {
+
+typedef boost::shared_ptr<std::queue<BitmapPtr> > BitmapQueuePtr;
+
+class AVG_API FakeCamera: public Camera
+{
+public:
+ FakeCamera(PixelFormat camPF, PixelFormat destPF);
+ FakeCamera(std::vector<std::string>& pictures);
+ virtual ~FakeCamera();
+ virtual void open();
+ virtual void close();
+
+ virtual IntPoint getImgSize();
+ virtual BitmapPtr getImage(bool bWait);
+ virtual bool isCameraAvailable();
+
+ virtual const std::string& getDevice() const;
+ virtual const std::string& getDriverName() const;
+ virtual double getFrameRate() const;
+ virtual const std::string& getMode() const;
+
+ virtual int getFeature(CameraFeature feature) const;
+ virtual void setFeature(CameraFeature feature, int Value, bool bIgnoreOldValue=false);
+ virtual void setFeatureOneShot(CameraFeature feature);
+ virtual int getWhitebalanceU() const;
+ virtual int getWhitebalanceV() const;
+ virtual void setWhitebalance(int u, int v, bool bIgnoreOldValue=false);
+
+private:
+ IntPoint m_ImgSize;
+ BitmapQueuePtr m_pBmpQ;
+ bool m_bIsOpen;
+};
+
+}
+
+#endif
+
+
diff --git a/src/imaging/FilterClearBorder.cpp b/src/imaging/FilterClearBorder.cpp
new file mode 100644
index 0000000..549a7bc
--- /dev/null
+++ b/src/imaging/FilterClearBorder.cpp
@@ -0,0 +1,67 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterClearBorder.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <math.h>
+#include <string.h>
+
+using namespace std;
+
+namespace avg {
+
+FilterClearBorder::FilterClearBorder(int numPixels)
+ : m_NumPixels(numPixels)
+{
+}
+
+FilterClearBorder::~FilterClearBorder()
+{
+}
+
+void FilterClearBorder::applyInPlace(BitmapPtr pBmp)
+{
+ AVG_ASSERT(pBmp->getPixelFormat() == I8);
+ AVG_ASSERT(m_NumPixels < pBmp->getSize().x);
+ AVG_ASSERT(m_NumPixels < pBmp->getSize().y);
+ if (m_NumPixels != 0) {
+ int stride = pBmp->getStride();
+ unsigned char * pPixels = pBmp->getPixels();
+ IntPoint size = pBmp->getSize();
+ IntPoint activeSize = pBmp->getSize()-IntPoint(2*m_NumPixels, 2*m_NumPixels);
+ for (int y=m_NumPixels-1; y >= 0; --y) {
+ memset(pPixels+stride*y+m_NumPixels, 0, activeSize.x);
+ }
+ for (int y=size.y-m_NumPixels; y < size.y; ++y) {
+ memset(pPixels+stride*y+m_NumPixels, 0, activeSize.x);
+ }
+
+ for (int y = 0; y < size.y; ++y) {
+ memset(pPixels+stride*y, 0, m_NumPixels);
+ memset(pPixels+stride*y+size.x-m_NumPixels, 0, m_NumPixels);
+ }
+ }
+}
+
+}
diff --git a/src/imaging/FilterClearBorder.h b/src/imaging/FilterClearBorder.h
new file mode 100644
index 0000000..869d784
--- /dev/null
+++ b/src/imaging/FilterClearBorder.h
@@ -0,0 +1,51 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterClearBorder_H_
+#define _FilterClearBorder_H_
+
+#include "../api.h"
+#include "CoordTransformer.h"
+
+#include "../graphics/Filter.h"
+
+#include "../base/Point.h"
+#include "../base/Rect.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API FilterClearBorder: public Filter
+{
+ public:
+ FilterClearBorder(int numPixels);
+ virtual ~FilterClearBorder();
+ virtual void applyInPlace(BitmapPtr pBmp);
+ private:
+ int m_NumPixels;
+};
+
+typedef boost::shared_ptr<FilterClearBorder> FilterClearBorderPtr;
+
+}
+
+#endif
diff --git a/src/imaging/FilterDistortion.cpp b/src/imaging/FilterDistortion.cpp
new file mode 100644
index 0000000..441dcd3
--- /dev/null
+++ b/src/imaging/FilterDistortion.cpp
@@ -0,0 +1,83 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org.
+//
+
+#include "FilterDistortion.h"
+
+#include <iostream>
+#include <math.h>
+
+using namespace std;
+
+namespace avg {
+
+FilterDistortion::FilterDistortion(const IntPoint& srcSize,
+ CoordTransformerPtr pTransformer)
+ : m_SrcSize(srcSize),
+ m_pTransformer(pTransformer)
+{
+ // We use the same dimensions for both of src and dest and just crop.
+ // for each pixel at (x,y) in the dest, m_pMap[x][y] contains an IntPoint that gives
+ // the coords in the src Bitmap.
+ m_pMap = new IntPoint[m_SrcSize.y*m_SrcSize.x];
+ for (int y = 0; y < m_SrcSize.y; ++y) {
+ for (int x = 0; x < m_SrcSize.x; ++x) {
+ DPoint tmp = m_pTransformer->inverse_transform_point(DPoint(int(x),int(y)));
+ IntPoint tmp2(int(tmp.x+0.5),int(tmp.y+0.5));
+ if (tmp2.x < m_SrcSize.x && tmp2.y < m_SrcSize.y &&
+ tmp2.x >= 0 && tmp2.y >= 0)
+ {
+ m_pMap[y*m_SrcSize.x+x] = tmp2;
+ } else {
+ m_pMap[y*m_SrcSize.x+x] = IntPoint(0,0);
+ }
+ }
+ }
+}
+
+FilterDistortion::~FilterDistortion()
+{
+ delete[] m_pMap;
+}
+
+BitmapPtr FilterDistortion::apply(BitmapPtr pBmpSource)
+{
+ BitmapPtr pDestBmp = BitmapPtr(new Bitmap(m_SrcSize, I8));
+ unsigned char* pDestLine = pDestBmp->getPixels();
+ unsigned char* pSrcPixels = pBmpSource->getPixels();
+ unsigned char* pDestPixel = pDestLine;
+ int destStride = pDestBmp->getStride();
+ int srcStride = pBmpSource->getStride();
+ IntPoint * pMapPos = m_pMap;
+ for (int y = 0; y < m_SrcSize.y; ++y) {
+ for(int x = 0; x < m_SrcSize.x; ++x) {
+ *pDestPixel = pSrcPixels[pMapPos->x + srcStride*pMapPos->y];
+ pDestPixel++;
+ pMapPos++;
+ }
+ pDestLine+=destStride;
+ pDestPixel = pDestLine;
+ }
+ return pDestBmp;
+}
+
+}
diff --git a/src/imaging/FilterDistortion.h b/src/imaging/FilterDistortion.h
new file mode 100644
index 0000000..a050796
--- /dev/null
+++ b/src/imaging/FilterDistortion.h
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#ifndef _FilterDistortion_H_
+#define _FilterDistortion_H_
+
+#include "../api.h"
+#include "CoordTransformer.h"
+
+#include "../graphics/Filter.h"
+
+#include "../base/Point.h"
+#include "../base/Rect.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+// TODO: This class doesn't have a unit test.
+class AVG_API FilterDistortion: public Filter
+{
+ public:
+ FilterDistortion(const IntPoint& srcSize, CoordTransformerPtr pTransformer);
+ virtual ~FilterDistortion();
+ BitmapPtr apply(BitmapPtr pBmpSource);
+ private:
+ IntPoint m_SrcSize;
+ CoordTransformerPtr m_pTransformer;
+ IntPoint* m_pMap;
+};
+
+typedef boost::shared_ptr<FilterDistortion> FilterDistortionPtr;
+
+}
+
+#endif
diff --git a/src/imaging/FilterWipeBorder.cpp b/src/imaging/FilterWipeBorder.cpp
new file mode 100644
index 0000000..cfdef40
--- /dev/null
+++ b/src/imaging/FilterWipeBorder.cpp
@@ -0,0 +1,70 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilterWipeBorder.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <math.h>
+#include <string.h>
+
+using namespace std;
+
+namespace avg {
+
+FilterWipeBorder::FilterWipeBorder(int numPixels)
+ : m_NumPixels(numPixels)
+{
+}
+
+FilterWipeBorder::~FilterWipeBorder()
+{
+}
+
+void FilterWipeBorder::applyInPlace(BitmapPtr pBmp)
+{
+ AVG_ASSERT(pBmp->getPixelFormat() == I8);
+ if (m_NumPixels != 0) {
+ int stride = pBmp->getStride();
+ unsigned char * pPixels = pBmp->getPixels();
+ IntPoint size = pBmp->getSize();
+ IntPoint activeSize = pBmp->getSize()-IntPoint(2*m_NumPixels, 2*m_NumPixels);
+
+ unsigned char * pSrcLine = pPixels+stride*m_NumPixels+m_NumPixels;
+ for (int y = m_NumPixels-1; y >= 0; --y) {
+ memcpy(pPixels+stride*y+m_NumPixels, pSrcLine, activeSize.x);
+ }
+ pSrcLine = pPixels+stride*(size.y-m_NumPixels-1)+m_NumPixels;
+ for (int y = size.y-m_NumPixels; y < size.y; ++y) {
+ memcpy(pPixels+stride*y+m_NumPixels, pSrcLine, activeSize.x);
+ }
+
+ for (int y = 0; y < size.y; ++y) {
+ unsigned char src = *(pPixels+stride*y+m_NumPixels);
+ memset(pPixels+stride*y, src, m_NumPixels);
+ src = *(pPixels+stride*y+size.x-m_NumPixels-1);
+ memset(pPixels+stride*y+size.x-m_NumPixels, src, m_NumPixels);
+ }
+ }
+}
+
+}
diff --git a/src/imaging/FilterWipeBorder.h b/src/imaging/FilterWipeBorder.h
new file mode 100644
index 0000000..91a0505
--- /dev/null
+++ b/src/imaging/FilterWipeBorder.h
@@ -0,0 +1,51 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilterWipeBorder_H_
+#define _FilterWipeBorder_H_
+
+#include "../api.h"
+#include "CoordTransformer.h"
+
+#include "../graphics/Filter.h"
+
+#include "../base/Point.h"
+#include "../base/Rect.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API FilterWipeBorder: public Filter
+{
+ public:
+ FilterWipeBorder(int numPixels);
+ virtual ~FilterWipeBorder();
+ virtual void applyInPlace(BitmapPtr pBmp);
+ private:
+ int m_NumPixels;
+};
+
+typedef boost::shared_ptr<FilterWipeBorder> FilterWipeBorderPtr;
+
+}
+
+#endif
diff --git a/src/imaging/Makefile.am b/src/imaging/Makefile.am
new file mode 100644
index 0000000..41b5f61
--- /dev/null
+++ b/src/imaging/Makefile.am
@@ -0,0 +1,45 @@
+INCLUDES = -I.. @PTHREAD_CFLAGS@ @XML2_CFLAGS@
+
+if ENABLE_V4L2
+ V4L2_SOURCES = V4LCamera.cpp
+ V4L2_INCLUDES = V4LCamera.h
+else
+ V4L2_SOURCES =
+ V4L2_INCLUDES =
+endif
+
+if ENABLE_1394_2
+ DC1394_SOURCES = FWCameraUtils.cpp
+ DC1394_INCLUDES = FWCameraUtils.h
+else
+
+ DC1394_SOURCES =
+ DC1394_INCLUDES =
+endif
+
+ALL_H = Camera.h TrackerThread.h TrackerConfig.h Blob.h FWCamera.h Run.h \
+ FakeCamera.h CoordTransformer.h FilterDistortion.h $(DC1394_INCLUDES) \
+ DeDistort.h trackerconfigdtd.h FilterWipeBorder.h FilterClearBorder.h \
+ $(V4L2_INCLUDES)
+ALL_CPP = Camera.cpp TrackerThread.cpp TrackerConfig.cpp Blob.cpp FWCamera.cpp Run.cpp \
+ FakeCamera.cpp CoordTransformer.cpp FilterDistortion.cpp $(DC1394_SOURCES) \
+ DeDistort.cpp trackerconfigdtd.cpp FilterWipeBorder.cpp FilterClearBorder.cpp \
+ $(V4L2_SOURCES)
+
+TESTS=testimaging
+
+EXTRA_DIST = avgtrackerrc.minimal $(wildcard baseline/*.png) $(wildcard testfiles/*.png) \
+ CMUCamera.h CMUCamera.cpp DSCamera.cpp DSCamera.h DSHelper.h DSHelper.cpp \
+ DSSampleGrabber.h DSSampleGrabber.cpp CMUCameraUtils.h CMUCameraUtils.cpp
+
+noinst_LTLIBRARIES = libimaging.la
+libimaging_la_SOURCES = $(ALL_CPP) $(ALL_H)
+noinst_PROGRAMS=testimaging checktracking
+
+testimaging_SOURCES=testimaging.cpp $(ALL_H)
+testimaging_LDADD = ./libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ @GDK_PIXBUF_LIBS@
+
+checktracking_SOURCES=checktracking.cpp $(ALL_H)
+checktracking_LDADD = ./libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ @GDK_PIXBUF_LIBS@
diff --git a/src/imaging/Makefile.in b/src/imaging/Makefile.in
new file mode 100644
index 0000000..3f65abd
--- /dev/null
+++ b/src/imaging/Makefile.in
@@ -0,0 +1,774 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+TESTS = testimaging$(EXEEXT)
+noinst_PROGRAMS = testimaging$(EXEEXT) checktracking$(EXEEXT)
+subdir = src/imaging
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libimaging_la_LIBADD =
+am__libimaging_la_SOURCES_DIST = Camera.cpp TrackerThread.cpp \
+ TrackerConfig.cpp Blob.cpp FWCamera.cpp Run.cpp FakeCamera.cpp \
+ CoordTransformer.cpp FilterDistortion.cpp FWCameraUtils.cpp \
+ DeDistort.cpp trackerconfigdtd.cpp FilterWipeBorder.cpp \
+ FilterClearBorder.cpp V4LCamera.cpp Camera.h TrackerThread.h \
+ TrackerConfig.h Blob.h FWCamera.h Run.h FakeCamera.h \
+ CoordTransformer.h FilterDistortion.h FWCameraUtils.h \
+ DeDistort.h trackerconfigdtd.h FilterWipeBorder.h \
+ FilterClearBorder.h V4LCamera.h
+@ENABLE_1394_2_TRUE@am__objects_1 = FWCameraUtils.lo
+@ENABLE_V4L2_TRUE@am__objects_2 = V4LCamera.lo
+am__objects_3 = Camera.lo TrackerThread.lo TrackerConfig.lo Blob.lo \
+ FWCamera.lo Run.lo FakeCamera.lo CoordTransformer.lo \
+ FilterDistortion.lo $(am__objects_1) DeDistort.lo \
+ trackerconfigdtd.lo FilterWipeBorder.lo FilterClearBorder.lo \
+ $(am__objects_2)
+am__objects_4 =
+am__objects_5 = $(am__objects_4) $(am__objects_4)
+am_libimaging_la_OBJECTS = $(am__objects_3) $(am__objects_5)
+libimaging_la_OBJECTS = $(am_libimaging_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+PROGRAMS = $(noinst_PROGRAMS)
+am__checktracking_SOURCES_DIST = checktracking.cpp Camera.h \
+ TrackerThread.h TrackerConfig.h Blob.h FWCamera.h Run.h \
+ FakeCamera.h CoordTransformer.h FilterDistortion.h \
+ FWCameraUtils.h DeDistort.h trackerconfigdtd.h \
+ FilterWipeBorder.h FilterClearBorder.h V4LCamera.h
+am_checktracking_OBJECTS = checktracking.$(OBJEXT) $(am__objects_5)
+checktracking_OBJECTS = $(am_checktracking_OBJECTS)
+checktracking_DEPENDENCIES = ./libimaging.la \
+ ../graphics/libgraphics.la ../base/libbase.la
+am__testimaging_SOURCES_DIST = testimaging.cpp Camera.h \
+ TrackerThread.h TrackerConfig.h Blob.h FWCamera.h Run.h \
+ FakeCamera.h CoordTransformer.h FilterDistortion.h \
+ FWCameraUtils.h DeDistort.h trackerconfigdtd.h \
+ FilterWipeBorder.h FilterClearBorder.h V4LCamera.h
+am_testimaging_OBJECTS = testimaging.$(OBJEXT) $(am__objects_5)
+testimaging_OBJECTS = $(am_testimaging_OBJECTS)
+testimaging_DEPENDENCIES = ./libimaging.la ../graphics/libgraphics.la \
+ ../base/libbase.la
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libimaging_la_SOURCES) $(checktracking_SOURCES) \
+ $(testimaging_SOURCES)
+DIST_SOURCES = $(am__libimaging_la_SOURCES_DIST) \
+ $(am__checktracking_SOURCES_DIST) \
+ $(am__testimaging_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.. @PTHREAD_CFLAGS@ @XML2_CFLAGS@
+@ENABLE_V4L2_FALSE@V4L2_SOURCES =
+@ENABLE_V4L2_TRUE@V4L2_SOURCES = V4LCamera.cpp
+@ENABLE_V4L2_FALSE@V4L2_INCLUDES =
+@ENABLE_V4L2_TRUE@V4L2_INCLUDES = V4LCamera.h
+@ENABLE_1394_2_FALSE@DC1394_SOURCES =
+@ENABLE_1394_2_TRUE@DC1394_SOURCES = FWCameraUtils.cpp
+@ENABLE_1394_2_FALSE@DC1394_INCLUDES =
+@ENABLE_1394_2_TRUE@DC1394_INCLUDES = FWCameraUtils.h
+ALL_H = Camera.h TrackerThread.h TrackerConfig.h Blob.h FWCamera.h Run.h \
+ FakeCamera.h CoordTransformer.h FilterDistortion.h $(DC1394_INCLUDES) \
+ DeDistort.h trackerconfigdtd.h FilterWipeBorder.h FilterClearBorder.h \
+ $(V4L2_INCLUDES)
+
+ALL_CPP = Camera.cpp TrackerThread.cpp TrackerConfig.cpp Blob.cpp FWCamera.cpp Run.cpp \
+ FakeCamera.cpp CoordTransformer.cpp FilterDistortion.cpp $(DC1394_SOURCES) \
+ DeDistort.cpp trackerconfigdtd.cpp FilterWipeBorder.cpp FilterClearBorder.cpp \
+ $(V4L2_SOURCES)
+
+EXTRA_DIST = avgtrackerrc.minimal $(wildcard baseline/*.png) $(wildcard testfiles/*.png) \
+ CMUCamera.h CMUCamera.cpp DSCamera.cpp DSCamera.h DSHelper.h DSHelper.cpp \
+ DSSampleGrabber.h DSSampleGrabber.cpp CMUCameraUtils.h CMUCameraUtils.cpp
+
+noinst_LTLIBRARIES = libimaging.la
+libimaging_la_SOURCES = $(ALL_CPP) $(ALL_H)
+testimaging_SOURCES = testimaging.cpp $(ALL_H)
+testimaging_LDADD = ./libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @GDK_PIXBUF_LIBS@
+
+checktracking_SOURCES = checktracking.cpp $(ALL_H)
+checktracking_LDADD = ./libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @GDK_PIXBUF_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/imaging/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/imaging/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libimaging.la: $(libimaging_la_OBJECTS) $(libimaging_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libimaging_la_OBJECTS) $(libimaging_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+checktracking$(EXEEXT): $(checktracking_OBJECTS) $(checktracking_DEPENDENCIES)
+ @rm -f checktracking$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(checktracking_OBJECTS) $(checktracking_LDADD) $(LIBS)
+testimaging$(EXEEXT): $(testimaging_OBJECTS) $(testimaging_DEPENDENCIES)
+ @rm -f testimaging$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(testimaging_OBJECTS) $(testimaging_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Blob.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Camera.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CoordTransformer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DeDistort.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FWCamera.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FWCameraUtils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FakeCamera.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterClearBorder.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterDistortion.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilterWipeBorder.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Run.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerConfig.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerThread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/V4LCamera.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/checktracking.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testimaging.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trackerconfigdtd.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/imaging/Run.cpp b/src/imaging/Run.cpp
new file mode 100644
index 0000000..e965338
--- /dev/null
+++ b/src/imaging/Run.cpp
@@ -0,0 +1,36 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "Run.h"
+
+namespace avg {
+
+Run::Run(int row, int startCol, int endCol)
+{
+ m_Row = row;
+ m_StartCol = startCol;
+ m_EndCol = endCol;
+ m_Center = DPoint((m_StartCol + m_EndCol-1)/2., m_Row);
+}
+
+}
diff --git a/src/imaging/Run.h b/src/imaging/Run.h
new file mode 100644
index 0000000..d751490
--- /dev/null
+++ b/src/imaging/Run.h
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#ifndef _Run_H_
+#define _Run_H_
+
+#include "../api.h"
+#include "../base/Point.h"
+
+#include <boost/weak_ptr.hpp>
+
+#include <vector>
+
+namespace avg {
+
+class Blob;
+typedef boost::weak_ptr<class Blob> BlobWeakPtr;
+
+struct Run
+{
+ Run(int row, int startCol, int end_col);
+ int m_Row;
+ int m_StartCol;
+ int m_EndCol;
+ DPoint m_Center;
+ int length() {
+ return m_EndCol-m_StartCol;
+ };
+ BlobWeakPtr m_pBlob;
+};
+
+typedef std::vector<Run> RunArray;
+
+}
+
+#endif
diff --git a/src/imaging/TrackerConfig.cpp b/src/imaging/TrackerConfig.cpp
new file mode 100644
index 0000000..1e86f8e
--- /dev/null
+++ b/src/imaging/TrackerConfig.cpp
@@ -0,0 +1,265 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+
+#include "TrackerConfig.h"
+#include "trackerconfigdtd.h"
+#include "DeDistort.h"
+
+#include "../base/XMLHelper.h"
+#include "../base/Logger.h"
+#include "../base/FileHelper.h"
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+#include "../base/ConfigMgr.h"
+
+#include <libxml/parser.h>
+#include <libxml/xmlwriter.h>
+#include <libxml/xmlstring.h>
+
+#include <cstring>
+#include <sstream>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+TrackerConfig::TrackerConfig()
+ : m_Doc(0)
+{
+}
+
+TrackerConfig::TrackerConfig(const TrackerConfig& other)
+{
+ m_Doc = 0;
+ if (other.m_Doc) {
+ m_Doc = xmlCopyDoc(other.m_Doc, true);
+ m_sFilename = other.m_sFilename;
+ m_pRoot = xmlDocGetRootElement(m_Doc);
+ }
+}
+
+TrackerConfig::~TrackerConfig()
+{
+ xmlFreeDoc(m_Doc);
+}
+
+void TrackerConfig::loadConfigFile(const string& sFilename)
+{
+ // TODO: There is duplicated code here and in Player::loadFile which belongs
+ // in a lower-level xml handling class.
+ registerDTDEntityLoader("trackerconfig.dtd", g_pTrackerConfigDTD);
+ xmlDtdPtr dtd;
+ string sDTDFName = "trackerconfig.dtd";
+ dtd = xmlParseDTD(NULL, (const xmlChar*) sDTDFName.c_str());
+ if (!dtd) {
+ AVG_TRACE(Logger::WARNING,
+ "DTD not found at " << sDTDFName
+ << ". Not validating trackerconfig files.");
+ }
+
+ m_Doc = xmlParseFile(sFilename.c_str());
+ if (!m_Doc) {
+ AVG_TRACE(Logger::ERROR, "Could not open tracker config file "
+ << sFilename << ". Using defaults which will probably not work.");
+ return;
+ }
+
+ xmlValidCtxtPtr cvp = xmlNewValidCtxt();
+ cvp->error = xmlParserValidityError;
+ cvp->warning = xmlParserValidityWarning;
+ int isValid = xmlValidateDtd(cvp, m_Doc, dtd);
+ xmlFreeValidCtxt(cvp);
+ if (!isValid) {
+ throw (Exception(AVG_ERR_XML_PARSE, sFilename + " does not validate."));
+ }
+
+ m_pRoot = xmlDocGetRootElement(m_Doc);
+ xmlFreeDtd(dtd);
+ m_sFilename = sFilename;
+
+ AVG_TRACE(Logger::CONFIG, "Reading Tracker config file from " << sFilename);
+}
+
+void TrackerConfig::load()
+{
+ // Give precedence to local configuration
+ string sFName = "avgtrackerrc";
+ if (fileExists(sFName) || !fileExists(getGlobalConfigDir() + sFName)) {
+ loadConfigFile(sFName);
+ } else {
+ loadConfigFile(getGlobalConfigDir() + sFName);
+ }
+}
+
+xmlXPathObjectPtr TrackerConfig::findConfigNodes(const string& sXPathExpr) const
+{
+ string sFullPath = string("/trackerconfig"+sXPathExpr);
+ xmlXPathContextPtr xpCtx;
+ xmlXPathObjectPtr xpElement;
+
+ xpCtx = xmlXPathNewContext(m_Doc);
+ if(!xpCtx) {
+ AVG_TRACE(Logger::ERROR, "Unable to create new XPath context");
+ return NULL;
+ }
+
+ xpElement = xmlXPathEvalExpression(BAD_CAST sFullPath.c_str(), xpCtx);
+ if(!xpElement) {
+ AVG_TRACE(Logger::ERROR, "Unable to evaluate XPath expression '"
+ << sFullPath << "'");
+ xmlXPathFreeContext(xpCtx);
+ return NULL;
+ }
+
+ xmlXPathFreeContext(xpCtx);
+
+ return xpElement;
+}
+
+void TrackerConfig::setParam(const string& sXPathExpr, const string& sValue)
+{
+ xmlXPathObjectPtr xpElement = findConfigNodes(sXPathExpr);
+ xmlNodeSetPtr nodes = xpElement->nodesetval;
+
+ if (!nodes || nodes->nodeNr == 0)
+ throw (Exception(AVG_ERR_OPTION_UNKNOWN,
+ string("setParam(): cannot find requested element ")+sXPathExpr));
+
+ for (int i = nodes->nodeNr-1; i >= 0; i--) {
+ AVG_ASSERT(nodes->nodeTab[i]);
+
+ xmlNodeSetContent(nodes->nodeTab[i], BAD_CAST sValue.c_str());
+ if (nodes->nodeTab[i]->type != XML_NAMESPACE_DECL)
+ nodes->nodeTab[i] = NULL;
+ }
+
+ xmlXPathFreeObject(xpElement);
+}
+
+string TrackerConfig::getParam(const string& sXPathExpr) const
+{
+ xmlXPathObjectPtr xpElement = findConfigNodes(sXPathExpr);
+ xmlNodeSetPtr nodes = xpElement->nodesetval;
+
+ if (!nodes || nodes->nodeNr == 0) {
+ throw (Exception(AVG_ERR_OPTION_UNKNOWN,
+ string("getParam(): cannot find requested element ")+sXPathExpr));
+ } else if (nodes->nodeNr > 1) {
+ AVG_TRACE(Logger::WARNING,
+ "getParam(): expression selects more than one node. Returning the first.");
+ }
+
+ xmlChar* xsRc = xmlNodeGetContent(nodes->nodeTab[0]);
+ string sValue((char *)xsRc);
+
+ xmlFree(xsRc);
+ xmlXPathFreeObject(xpElement);
+
+ return sValue;
+}
+
+bool TrackerConfig::getBoolParam(const std::string& sXPathExpr) const
+{
+ return stringToBool(getParam(sXPathExpr));
+}
+
+int TrackerConfig::getIntParam(const std::string& sXPathExpr) const
+{
+ return stringToInt(getParam(sXPathExpr));
+}
+
+double TrackerConfig::getDoubleParam(const std::string& sXPathExpr) const
+{
+ return stringToDouble(getParam(sXPathExpr));
+}
+
+DPoint TrackerConfig::getPointParam(const std::string& sXPathExpr) const
+{
+ return DPoint(getDoubleParam(sXPathExpr+"@x"), getDoubleParam(sXPathExpr+"@y"));
+}
+
+DRect TrackerConfig::getRectParam(const std::string& sXPathExpr) const
+{
+ DPoint pos1 = DPoint(getDoubleParam(sXPathExpr+"@x1"),
+ getDoubleParam(sXPathExpr+"@y1"));
+ DPoint pos2 = DPoint(getDoubleParam(sXPathExpr+"@x2"),
+ getDoubleParam(sXPathExpr+"@y2"));
+ return DRect(pos1, pos2);
+}
+
+xmlNodePtr TrackerConfig::getXmlNode(const std::string& sXPathExpr) const
+{
+ xmlXPathObjectPtr xpElement = findConfigNodes(sXPathExpr);
+ xmlNodeSetPtr nodes = xpElement->nodesetval;
+
+ if (!nodes || nodes->nodeNr == 0) {
+ throw (Exception(AVG_ERR_OPTION_UNKNOWN,
+ string("getParam(): cannot find requested element ")+sXPathExpr));
+ } else if (nodes->nodeNr > 1) {
+ AVG_TRACE(Logger::WARNING,
+ "getXmlNode(): expression selects more than one node. Returning the first.");
+ }
+ return nodes->nodeTab[0];
+}
+
+DeDistortPtr TrackerConfig::getTransform() const
+{
+ DPoint CameraExtents = getPointParam("/camera/size/");
+ DeDistortPtr pDD(new DeDistort);
+ pDD->load(CameraExtents, *this);
+ return pDD;
+}
+
+void TrackerConfig::setTransform(DeDistortPtr pDeDistort)
+{
+ pDeDistort->save(*this);
+}
+
+void TrackerConfig::dump() const
+{
+ string s;
+ xmlBufferPtr pBuffer = xmlBufferCreate();
+ xmlNodeDump(pBuffer, m_Doc, m_pRoot, 0, 0);
+ cerr << xmlBufferContent(pBuffer) << endl;
+}
+
+void TrackerConfig::save()
+{
+ AVG_TRACE(Logger::CONFIG, "Saving tracker configuration to "
+ << m_sFilename << ".");
+
+ if (m_Doc) {
+ if (fileExists(m_sFilename)) {
+ string sBakFile = m_sFilename + ".bak";
+ unlink(sBakFile.c_str());
+ if (rename(m_sFilename.c_str(), sBakFile.c_str())) {
+ AVG_TRACE(Logger::WARNING, "Cannot create tracker config backup. Backing "
+ "it up on current workdir.");
+ copyFile(m_sFilename, "avgtrackerrc.bak");
+ }
+ }
+ xmlSaveFileEnc(m_sFilename.c_str(), m_Doc, "utf-8");
+ } else
+ throw (Exception(AVG_ERR_FILEIO,
+ "save(): tracker configuration not initialized"));
+}
+
+}
diff --git a/src/imaging/TrackerConfig.h b/src/imaging/TrackerConfig.h
new file mode 100644
index 0000000..3eb10f7
--- /dev/null
+++ b/src/imaging/TrackerConfig.h
@@ -0,0 +1,72 @@
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org.
+//
+
+#ifndef _TrackerConfig_H_
+#define _TrackerConfig_H_
+
+#include "../api.h"
+#include "../base/Rect.h"
+
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+#include <libxml/xpath.h>
+
+namespace avg {
+
+class DeDistort;
+typedef boost::shared_ptr<DeDistort> DeDistortPtr;
+
+class AVG_API TrackerConfig
+{
+public:
+ TrackerConfig();
+ TrackerConfig(const TrackerConfig& other);
+ virtual ~TrackerConfig();
+
+ void load();
+ void save();
+ void setParam(const std::string& sXPathExpr, const std::string& sValue);
+ std::string getParam(const std::string& sXPathExpr) const;
+ bool getBoolParam(const std::string& sXPathExpr) const;
+ int getIntParam(const std::string& sXPathExpr) const;
+ double getDoubleParam(const std::string& sXPathExpr) const;
+ DPoint getPointParam(const std::string& sXPathExpr) const;
+ DRect getRectParam(const std::string& sXPathExpr) const;
+ xmlNodePtr getXmlNode(const std::string& sXPathExpr) const;
+
+ DeDistortPtr getTransform() const;
+ void setTransform(DeDistortPtr pDeDistort);
+
+ void dump() const;
+
+private:
+ xmlXPathObjectPtr findConfigNodes(const std::string& sXPathExpr) const;
+
+ xmlDocPtr m_Doc;
+ xmlNodePtr m_pRoot;
+
+ std::string m_sFilename;
+ void loadConfigFile(const std::string& sFilename);
+};
+typedef boost::shared_ptr<TrackerConfig> TrackerConfigPtr;
+
+}
+#endif
diff --git a/src/imaging/TrackerThread.cpp b/src/imaging/TrackerThread.cpp
new file mode 100644
index 0000000..16c30e4
--- /dev/null
+++ b/src/imaging/TrackerThread.cpp
@@ -0,0 +1,544 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+
+#include "TrackerThread.h"
+#include "FilterDistortion.h"
+#include "FilterWipeBorder.h"
+
+#include "../base/Logger.h"
+#include "../base/ProfilingZone.h"
+#include "../base/TimeSource.h"
+#include "../base/ScopeTimer.h"
+#include "../base/Exception.h"
+
+#include "../graphics/Filter.h"
+#include "../graphics/Filterfill.h"
+#include "../graphics/FilterHighpass.h"
+#include "../graphics/FilterFastBandpass.h"
+#include "../graphics/FilterFastDownscale.h"
+#include "../graphics/FilterNormalize.h"
+#include "../graphics/FilterBlur.h"
+#include "../graphics/FilterGauss.h"
+#include "../graphics/FilterMask.h"
+#include "../graphics/OGLImagingContext.h"
+#include "../graphics/GPUBandpassFilter.h"
+#include "../graphics/GPUBlurFilter.h"
+
+#include <iostream>
+#include <stdlib.h>
+
+using namespace std;
+
+namespace avg {
+
+static ProfilingZoneID ProfilingZoneCapture("Capture");
+static ProfilingZoneID ProfilingZoneMask("Mask");
+static ProfilingZoneID ProfilingZoneTracker("Tracker");
+static ProfilingZoneID ProfilingZoneHistory("History");
+static ProfilingZoneID ProfilingZoneDistort("Distort");
+static ProfilingZoneID ProfilingZoneHistogram("Histogram");
+static ProfilingZoneID ProfilingZoneDownscale("Downscale");
+static ProfilingZoneID ProfilingZoneBandpass("Bandpass");
+static ProfilingZoneID ProfilingZoneComps("ConnectedComps");
+static ProfilingZoneID ProfilingZoneUpdate("Update");
+static ProfilingZoneID ProfilingZoneDraw("Draw");
+
+TrackerThread::TrackerThread(IntRect roi, CameraPtr pCamera,
+ BitmapPtr ppBitmaps[NUM_TRACKER_IMAGES], MutexPtr pMutex, CQueue& cmdQ,
+ IBlobTarget *pTarget, bool bSubtractHistory, TrackerConfig& config)
+ : WorkerThread<TrackerThread>("Tracker", cmdQ),
+ m_TouchThreshold(0),
+ m_TrackThreshold(0),
+ m_HistoryDelay(-1),
+ m_StartTime(0),
+ m_pMutex(pMutex),
+ m_pCamera(pCamera),
+ m_pTarget(pTarget),
+ m_pTrafo(new DeDistort()),
+ m_bCreateDebugImages(false),
+ m_bCreateFingerImage(false),
+ m_NumFrames(0),
+ m_NumCamFramesDiscarded(0),
+ m_pImagingContext(0)
+{
+ m_bTrackBrighter = config.getBoolParam("/tracker/brighterregions/@value");
+ if (bSubtractHistory) {
+ m_pHistoryPreProcessor = HistoryPreProcessorPtr(
+ new HistoryPreProcessor(ppBitmaps[1]->getSize(), 1,
+ m_bTrackBrighter));
+ }
+ m_Prescale = config.getIntParam("/tracker/prescale/@value");
+ setBitmaps(roi, ppBitmaps);
+
+ DeDistortPtr pDeDistort = config.getTransform();
+ m_pDistorter = FilterDistortionPtr(new FilterDistortion(
+ m_pBitmaps[TRACKER_IMG_CAMERA]->getSize()/m_Prescale, pDeDistort));
+
+ m_pConfig = TrackerConfigPtr(new TrackerConfig(config));
+ m_pCamera->startCapture();
+}
+
+TrackerThread::~TrackerThread()
+{
+}
+
+bool TrackerThread::init()
+{
+ try {
+ m_pImagingContext = new OGLImagingContext();
+ createBandpassFilter();
+ AVG_TRACE(Logger::CONFIG, "Using fragment shaders for imaging operations.");
+ } catch (Exception& e) {
+ AVG_TRACE(Logger::WARNING, e.getStr());
+ AVG_TRACE(Logger::CONFIG,
+ "Using CPU for imaging operations (slow and inaccurate).");
+ m_pImagingContext = 0;
+ m_pBandpassFilter = FilterPtr(new FilterFastBandpass());
+ }
+ try {
+ m_StartTime = TimeSource::get()->getCurrentMillisecs();
+ m_HistoryDelay = m_pConfig->getIntParam("/tracker/historydelay/@value");
+ } catch (Exception& e) {
+ AVG_TRACE(Logger::WARNING, e.getStr());
+ }
+
+ // Done in TrackerInputDevice::ctor to work around Leopard/libdc1394 threading issue.
+ // m_pCamera->open();
+ return true;
+}
+
+bool TrackerThread::work()
+{
+ if ((m_HistoryDelay + m_StartTime) < TimeSource::get()->getCurrentMillisecs()
+ && m_HistoryDelay != -1)
+ {
+ resetHistory();
+ m_HistoryDelay = -1;
+ }
+
+ BitmapPtr pCamBmp;
+ {
+ ScopeTimer timer(ProfilingZoneCapture);
+ pCamBmp = m_pCamera->getImage(true);
+ BitmapPtr pTempBmp1;
+ while (pTempBmp1 = m_pCamera->getImage(false)) {
+ m_NumCamFramesDiscarded++;
+ m_NumFrames++;
+ pCamBmp = pTempBmp1;
+ }
+ }
+ long long time = TimeSource::get()->getCurrentMillisecs();
+ if (pCamBmp) {
+ m_NumFrames++;
+ ScopeTimer timer(ProfilingZoneTracker);
+ if (m_pCameraMaskBmp) {
+ ScopeTimer timer(ProfilingZoneMask);
+ FilterMask(m_pCameraMaskBmp).applyInPlace(pCamBmp);
+ }
+ if (m_bCreateDebugImages) {
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ *(m_pBitmaps[TRACKER_IMG_CAMERA]) = *pCamBmp;
+ ScopeTimer timer(ProfilingZoneHistogram);
+ drawHistogram(m_pBitmaps[TRACKER_IMG_HISTOGRAM], pCamBmp);
+ }
+ {
+ if (m_Prescale != 1) {
+ ScopeTimer timer(ProfilingZoneDownscale);
+ FilterFastDownscale(m_Prescale).applyInPlace(pCamBmp);
+ }
+ }
+ BitmapPtr pDistortedBmp;
+ {
+ ScopeTimer timer(ProfilingZoneDistort);
+ pDistortedBmp = m_pDistorter->apply(pCamBmp);
+ }
+ BitmapPtr pCroppedBmp(new Bitmap(*pDistortedBmp, m_ROI));
+ if (m_bCreateDebugImages) {
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ m_pBitmaps[TRACKER_IMG_DISTORTED]->copyPixels(*pCroppedBmp);
+ }
+ if (m_pHistoryPreProcessor) {
+ ScopeTimer timer(ProfilingZoneHistory);
+ m_pHistoryPreProcessor->applyInPlace(pCroppedBmp);
+ }
+ if (m_bCreateDebugImages) {
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ m_pBitmaps[TRACKER_IMG_NOHISTORY]->copyPixels(*pCroppedBmp);
+ FilterNormalize(2).applyInPlace(m_pBitmaps[TRACKER_IMG_NOHISTORY]);
+ }
+ {
+ BitmapPtr pBmpBandpass;
+ if (m_TouchThreshold != 0) {
+ {
+ ScopeTimer timer(ProfilingZoneBandpass);
+ pBmpBandpass = m_pBandpassFilter->apply(pCroppedBmp);
+ }
+ if (m_bCreateDebugImages) {
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ *(m_pBitmaps[TRACKER_IMG_HIGHPASS]) = *pBmpBandpass;
+ }
+ }
+ calcBlobs(pCroppedBmp, pBmpBandpass, time);
+ }
+ ThreadProfiler::get()->reset();
+ }
+ return true;
+}
+
+void TrackerThread::deinit()
+{
+ m_pCamera = CameraPtr();
+ AVG_TRACE(Logger::PROFILE, "Total camera frames: " << m_NumFrames);
+ AVG_TRACE(Logger::PROFILE, "Camera frames discarded: " << m_NumCamFramesDiscarded);
+ if (m_pBandpassFilter) {
+ m_pBandpassFilter.reset();
+ }
+ if (m_pImagingContext) {
+ delete m_pImagingContext;
+ }
+}
+
+void TrackerThread::setConfig(TrackerConfig config, IntRect roi,
+ BitmapPtr ppBitmaps[NUM_TRACKER_IMAGES])
+{
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ try {
+ m_TouchThreshold = config.getIntParam("/tracker/touch/threshold/@value");
+ } catch (Exception&) {
+ m_TouchThreshold = 0;
+ }
+ m_bTrackBrighter = config.getBoolParam("/tracker/brighterregions/@value");
+ try {
+ m_TrackThreshold = config.getIntParam("/tracker/track/threshold/@value");
+ } catch (Exception&) {
+ m_TrackThreshold = 0;
+ }
+ m_Prescale = config.getIntParam("/tracker/prescale/@value");
+ if(m_pHistoryPreProcessor) {
+ m_pHistoryPreProcessor->setInterval(config.getIntParam
+ ("/tracker/historyupdateinterval/@value"));
+ }
+ DeDistortPtr pDeDistort = config.getTransform();
+ if (!(*m_pTrafo == *pDeDistort)) {
+ m_pDistorter = FilterDistortionPtr(new FilterDistortion(
+ m_pBitmaps[TRACKER_IMG_CAMERA]->getSize()/m_Prescale, pDeDistort));
+ *m_pTrafo = *pDeDistort;
+ }
+ int brightness = config.getIntParam("/camera/brightness/@value");
+ int exposure = config.getIntParam("/camera/exposure/@value");
+ int gamma = config.getIntParam("/camera/gamma/@value");
+ int gain = config.getIntParam("/camera/gain/@value");
+ int shutter = config.getIntParam("/camera/shutter/@value");
+ int strobeDuration = config.getIntParam("/camera/strobeduration/@value");
+ string sCameraMaskFName = config.getParam("/tracker/mask/@value");
+ bool bNewCameraMask = ((m_pCameraMaskBmp == BitmapPtr() && sCameraMaskFName != "") ||
+ m_pConfig->getParam("/tracker/mask/@value") != sCameraMaskFName);
+ if (int(m_pCamera->getFeature(CAM_FEATURE_BRIGHTNESS)) != brightness ||
+ int(m_pCamera->getFeature(CAM_FEATURE_GAMMA)) != gamma ||
+ int(m_pCamera->getFeature(CAM_FEATURE_EXPOSURE)) != exposure ||
+ int(m_pCamera->getFeature(CAM_FEATURE_GAIN)) != gain ||
+ int(m_pCamera->getFeature(CAM_FEATURE_SHUTTER)) != shutter ||
+ int(m_pCamera->getFeature(CAM_FEATURE_STROBE_DURATION)) != strobeDuration ||
+ bNewCameraMask)
+ {
+ m_pHistoryPreProcessor->reset();
+ }
+
+ m_pCamera->setFeature(CAM_FEATURE_BRIGHTNESS, brightness);
+ m_pCamera->setFeature(CAM_FEATURE_GAMMA, gamma);
+// m_pCamera->setFeature(CAM_FEATURE_EXPOSURE, exposure);
+ m_pCamera->setFeature(CAM_FEATURE_GAIN, gain);
+ m_pCamera->setFeature(CAM_FEATURE_SHUTTER, shutter);
+ m_pCamera->setFeature(CAM_FEATURE_STROBE_DURATION, strobeDuration, true);
+
+ if (bNewCameraMask) {
+ if (sCameraMaskFName == "") {
+ m_pCameraMaskBmp = BitmapPtr();
+ } else {
+ BitmapPtr pRGBXCameraMaskBmp = BitmapPtr(new Bitmap(sCameraMaskFName));
+ m_pCameraMaskBmp = BitmapPtr(
+ new Bitmap(pRGBXCameraMaskBmp->getSize(), I8));
+ m_pCameraMaskBmp->copyPixels(*pRGBXCameraMaskBmp);
+ }
+ }
+ m_pConfig = TrackerConfigPtr(new TrackerConfig(config));
+
+ setBitmaps(roi, ppBitmaps);
+ createBandpassFilter();
+}
+
+void TrackerThread::setDebugImages(bool bImg, bool bFinger)
+{
+ m_bCreateDebugImages = bImg;
+ m_bCreateFingerImage = bFinger;
+}
+
+void TrackerThread::setBitmaps(IntRect roi, BitmapPtr ppBitmaps[NUM_TRACKER_IMAGES])
+{
+ m_ROI = roi;
+ for (int i=0; i<NUM_TRACKER_IMAGES; i++) {
+ m_pBitmaps[i] = ppBitmaps[i];
+ }
+ if (m_pHistoryPreProcessor) {
+ m_pHistoryPreProcessor = HistoryPreProcessorPtr(
+ new HistoryPreProcessor(roi.size(),
+ m_pHistoryPreProcessor->getInterval(), m_bTrackBrighter));
+ }
+ if (m_pBandpassFilter) {
+ createBandpassFilter();
+ }
+}
+
+void TrackerThread::createBandpassFilter()
+{
+ if (m_TouchThreshold != 0) {
+ double bandpassMin = m_pConfig->getDoubleParam("/tracker/touch/bandpass/@min");
+ double bandpassMax = m_pConfig->getDoubleParam("/tracker/touch/bandpass/@max");
+ double bandpassPostMult =
+ m_pConfig->getDoubleParam("/tracker/touch/bandpasspostmult/@value");
+ if (m_pImagingContext) {
+ m_pBandpassFilter = FilterPtr(new GPUBandpassFilter(m_ROI.size(), I8,
+ bandpassMin, bandpassMax, bandpassPostMult, m_bTrackBrighter));
+ }
+ }
+}
+
+void TrackerThread::resetHistory()
+{
+ if (m_pHistoryPreProcessor) {
+ m_pHistoryPreProcessor->reset();
+ }
+}
+
+void TrackerThread::drawHistogram(BitmapPtr pDestBmp, BitmapPtr pSrcBmp)
+{
+ HistogramPtr pHist = pSrcBmp->getHistogram(4);
+ AVG_ASSERT(pDestBmp->getPixelFormat() == I8);
+ // Normalize Histogram to 0..255
+ int max1 = 0;
+ int max2 = 0;
+ for (int i = 0; i < 256; ++i) {
+ if ((*pHist)[i] > max1) {
+ max2 = max1;
+ max1 = (*pHist)[i];
+ } else if ((*pHist)[i] > max2) {
+ max2 = (*pHist)[i];
+ }
+ }
+ if (max2 == 0) {
+ max2= 1;
+ }
+ for (int i = 0; i < 256; ++i) {
+ (*pHist)[i] = int((*pHist)[i]*256.0/max2)+1;
+ }
+
+ FilterFill<Pixel8>(0).applyInPlace(pDestBmp);
+ int stride = pDestBmp->getStride();
+ int endRow = 256;
+ if (pDestBmp->getSize().y < 256) {
+ endRow = pDestBmp->getSize().y;
+ }
+ int width = pDestBmp->getSize().x;
+ for (int i = 0; i < endRow; ++i) {
+ int endCol =(*pHist)[i];
+ if (endCol > width) {
+ endCol = width;
+ }
+ unsigned char * pDest = pDestBmp->getPixels()+stride*i;
+ memset(pDest, 255, endCol);
+ }
+}
+
+inline bool isInbetween(double x, double min, double max)
+{
+ return x >= min && x <= max;
+}
+
+bool TrackerThread::isRelevant(BlobPtr pBlob, int minArea, int maxArea,
+ double minEccentricity, double maxEccentricity)
+{
+ bool res;
+ res = isInbetween(pBlob->getArea(), minArea, maxArea) &&
+ isInbetween(pBlob->getEccentricity(), minEccentricity, maxEccentricity);
+ return res;
+}
+
+BlobVectorPtr TrackerThread::findRelevantBlobs(BlobVectorPtr pBlobs, bool bTouch)
+{
+ string sConfigPrefix;
+ if (bTouch) {
+ sConfigPrefix = "/tracker/touch/";
+ } else {
+ sConfigPrefix = "/tracker/track/";
+ }
+ int minArea = m_pConfig->getIntParam(sConfigPrefix+"areabounds/@min");
+ int maxArea = m_pConfig->getIntParam(sConfigPrefix+"areabounds/@max");
+ double minEccentricity = m_pConfig->getDoubleParam(sConfigPrefix+"eccentricitybounds/@min");
+ double maxEccentricity = m_pConfig->getDoubleParam(sConfigPrefix+"eccentricitybounds/@max");
+
+ BlobVectorPtr pRelevantBlobs(new BlobVector());
+ for(BlobVector::iterator it = pBlobs->begin(); it != pBlobs->end(); ++it) {
+ if (isRelevant(*it, minArea, maxArea, minEccentricity, maxEccentricity)) {
+ pRelevantBlobs->push_back(*it);
+ }
+ if (pRelevantBlobs->size() > 50) {
+ break;
+ }
+ }
+ return pRelevantBlobs;
+}
+
+void TrackerThread::drawBlobs(BlobVectorPtr pBlobs, BitmapPtr pSrcBmp,
+ BitmapPtr pDestBmp, int Offset, bool bTouch)
+{
+ if (!pDestBmp) {
+ return;
+ }
+ ScopeTimer timer(ProfilingZoneDraw);
+ string sConfigPrefix;
+ if (bTouch) {
+ sConfigPrefix = "/tracker/touch/";
+ } else {
+ sConfigPrefix = "/tracker/track/";
+ }
+ int minArea = m_pConfig->getIntParam(sConfigPrefix+"areabounds/@min");
+ int maxArea = m_pConfig->getIntParam(sConfigPrefix+"areabounds/@max");
+ double minEccentricity = m_pConfig->getDoubleParam(
+ sConfigPrefix+"eccentricitybounds/@min");
+ double maxEccentricity = m_pConfig->getDoubleParam(
+ sConfigPrefix+"eccentricitybounds/@max");
+
+ // Get max. pixel value in Bitmap
+ int max = 0;
+ HistogramPtr pHist = pSrcBmp->getHistogram(4);
+ int i;
+ for (i = 255; i >= 0; i--) {
+ if ((*pHist)[i] != 0) {
+ max = i;
+ i = 0;
+ }
+ }
+
+ for (BlobVector::iterator it2 = pBlobs->begin(); it2 != pBlobs->end(); ++it2) {
+ if (isRelevant(*it2, minArea, maxArea, minEccentricity, maxEccentricity)) {
+ if (bTouch) {
+ (*it2)->render(pSrcBmp, pDestBmp,
+ Pixel32(0xFF, 0xFF, 0xFF, 0xFF), Offset, max, bTouch, true,
+ Pixel32(0x00, 0x00, 0xFF, 0xFF));
+ } else {
+ (*it2)->render(pSrcBmp, pDestBmp,
+ Pixel32(0xFF, 0xFF, 0x00, 0x80), Offset, max, bTouch, true,
+ Pixel32(0x00, 0x00, 0xFF, 0xFF));
+ }
+ } else {
+ if (bTouch) {
+ (*it2)->render(pSrcBmp, pDestBmp,
+ Pixel32(0xFF, 0x00, 0x00, 0xFF), Offset, max, bTouch, false);
+ } else {
+ (*it2)->render(pSrcBmp, pDestBmp,
+ Pixel32(0x80, 0x80, 0x00, 0x80), Offset, max, bTouch, false);
+ }
+ }
+ }
+}
+
+void TrackerThread::calcContours(BlobVectorPtr pBlobs)
+{
+ ScopeTimer timer(ProfilingZoneDraw);
+ string sConfigPrefix;
+ sConfigPrefix = "/tracker/track/";
+ int minArea = m_pConfig->getIntParam(sConfigPrefix+"areabounds/@min");
+ int maxArea = m_pConfig->getIntParam(sConfigPrefix+"areabounds/@max");
+ double minEccentricity = m_pConfig->getDoubleParam(
+ sConfigPrefix+"eccentricitybounds/@min");
+ double maxEccentricity = m_pConfig->getDoubleParam(
+ sConfigPrefix+"eccentricitybounds/@max");
+
+ int ContourPrecision = m_pConfig->getIntParam("/tracker/contourprecision/@value");
+ if (ContourPrecision != 0) {
+ for (BlobVector::iterator it = pBlobs->begin(); it != pBlobs->end(); ++it) {
+ if (isRelevant(*it, minArea, maxArea, minEccentricity, maxEccentricity)) {
+ (*it)->calcContour(ContourPrecision);
+ }
+ }
+ }
+}
+
+void TrackerThread::correlateHands(BlobVectorPtr pTrackBlobs, BlobVectorPtr pTouchBlobs)
+{
+ if (!pTrackBlobs || !pTouchBlobs) {
+ return;
+ }
+ for (BlobVector::iterator it1 = pTouchBlobs->begin(); it1 != pTouchBlobs->end();
+ ++it1)
+ {
+ BlobPtr pTouchBlob = *it1;
+ IntPoint touchCenter = (IntPoint)(pTouchBlob->getCenter());
+ for (BlobVector::iterator it2 = pTrackBlobs->begin(); it2 != pTrackBlobs->end();
+ ++it2)
+ {
+ BlobPtr pTrackBlob = *it2;
+ if (pTrackBlob->contains(touchCenter)) {
+ pTouchBlob->addRelated(pTrackBlob);
+ pTrackBlob->addRelated(pTouchBlob);
+ break;
+ }
+ }
+ }
+}
+
+void TrackerThread::calcBlobs(BitmapPtr pTrackBmp, BitmapPtr pTouchBmp, long long time)
+{
+ BlobVectorPtr pTrackComps;
+ BlobVectorPtr pTouchComps;
+ {
+ ScopeTimer timer(ProfilingZoneComps);
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ BitmapPtr pDestBmp;
+ if (m_bCreateFingerImage) {
+ Pixel32 Black(0x00, 0x00, 0x00, 0x00);
+ FilterFill<Pixel32>(Black).applyInPlace(
+ m_pBitmaps[TRACKER_IMG_FINGERS]);
+ pDestBmp = m_pBitmaps[TRACKER_IMG_FINGERS];
+ }
+ {
+ if (m_TrackThreshold != 0) {
+ pTrackComps = findConnectedComponents(pTrackBmp, m_TrackThreshold);
+ calcContours(pTrackComps);
+ drawBlobs(pTrackComps, pTrackBmp, pDestBmp, m_TrackThreshold, false);
+ pTrackComps = findRelevantBlobs(pTrackComps, false);
+ }
+ if (m_TouchThreshold != 0) {
+ pTouchComps = findConnectedComponents(pTouchBmp, m_TouchThreshold);
+ pTouchComps = findRelevantBlobs(pTouchComps, true);
+ correlateHands(pTrackComps, pTouchComps);
+ drawBlobs(pTouchComps, pTouchBmp, pDestBmp, m_TouchThreshold, true);
+ }
+ }
+ // Send the blobs to the BlobTarget.
+ {
+ ScopeTimer timer(ProfilingZoneUpdate);
+ m_pTarget->update(pTrackComps, pTouchComps, time);
+ }
+ }
+
+}
+
+}
diff --git a/src/imaging/TrackerThread.h b/src/imaging/TrackerThread.h
new file mode 100644
index 0000000..5372828
--- /dev/null
+++ b/src/imaging/TrackerThread.h
@@ -0,0 +1,135 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+
+#ifndef _TrackerThread_H_
+#define _TrackerThread_H_
+
+#include "../api.h"
+#include "TrackerConfig.h"
+#include "Camera.h"
+#include "Blob.h"
+#include "FilterDistortion.h"
+#include "DeDistort.h"
+
+#include "../base/WorkerThread.h"
+#include "../base/Command.h"
+
+#include "../graphics/HistoryPreProcessor.h"
+#include "../graphics/Bitmap.h"
+#include "../graphics/Pixel8.h"
+#include "../graphics/Filter.h"
+
+#include <boost/thread.hpp>
+
+#include <string>
+#include <list>
+
+namespace avg {
+
+typedef enum {
+ TRACKER_IMG_CAMERA,
+ TRACKER_IMG_DISTORTED,
+ TRACKER_IMG_NOHISTORY,
+ TRACKER_IMG_HISTOGRAM,
+ TRACKER_IMG_HIGHPASS,
+ TRACKER_IMG_FINGERS,
+ NUM_TRACKER_IMAGES
+} TrackerImageID;
+
+typedef boost::shared_ptr<boost::mutex> MutexPtr;
+class OGLImagingContext;
+
+class AVG_API IBlobTarget {
+ public:
+ virtual ~IBlobTarget() {};
+ // Note that this function is called by TrackerThread in it's own thread!
+ virtual void update(BlobVectorPtr pTrackBlobs, BlobVectorPtr pTouchBlobs,
+ long long time) = 0;
+};
+
+
+class AVG_API TrackerThread: public WorkerThread<TrackerThread>
+{
+ public:
+ TrackerThread(IntRect roi, CameraPtr pCamera,
+ BitmapPtr ppBitmaps[NUM_TRACKER_IMAGES], MutexPtr pMutex, CQueue& cmdQ,
+ IBlobTarget* pTarget, bool bSubtractHistory, TrackerConfig& config);
+ virtual ~TrackerThread();
+
+ bool init();
+ bool work();
+ void deinit();
+
+ void setConfig(TrackerConfig config, IntRect roi,
+ BitmapPtr ppBitmaps[NUM_TRACKER_IMAGES]);
+ void setDebugImages(bool bImg, bool bFinger);
+ void resetHistory();
+
+ private:
+ void setBitmaps(IntRect roi, BitmapPtr ppBitmaps[NUM_TRACKER_IMAGES]);
+ void createBandpassFilter();
+ void checkMessages();
+ void calcHistory();
+ void drawHistogram(BitmapPtr pDestBmp, BitmapPtr pSrcBmp);
+ void calcBlobs(BitmapPtr pTrackBmp, BitmapPtr pTouchBmp, long long time);
+ bool isRelevant(BlobPtr pBlob, int minArea, int maxArea,
+ double minEccentricity, double maxEccentricity);
+ BlobVectorPtr findRelevantBlobs(BlobVectorPtr pBlobs, bool bTouch);
+ void drawBlobs(BlobVectorPtr pBlobs, BitmapPtr pSrcBmp, BitmapPtr pDestBmp,
+ int Offset, bool bTouch);
+ void calcContours(BlobVectorPtr pBlobs);
+ void correlateHands(BlobVectorPtr pTrackBlobs, BlobVectorPtr pTouchBlobs);
+
+ std::string m_sDevice;
+ std::string m_sMode;
+
+ TrackerConfigPtr m_pConfig;
+ BitmapPtr m_pCameraMaskBmp;
+
+ int m_TouchThreshold; // 0 => no touch events.
+ int m_TrackThreshold; // 0 => no generic tracking events.
+ int m_Prescale;
+ long long m_HistoryDelay;
+ long long m_StartTime;
+ bool m_bTrackBrighter;
+
+ BlobVectorPtr m_pBlobVector;
+ IntRect m_ROI;
+ BitmapPtr m_pBitmaps[NUM_TRACKER_IMAGES];
+ MutexPtr m_pMutex;
+
+ CameraPtr m_pCamera;
+ IBlobTarget *m_pTarget;
+ HistoryPreProcessorPtr m_pHistoryPreProcessor;
+ FilterDistortionPtr m_pDistorter;
+ DeDistortPtr m_pTrafo;
+ bool m_bCreateDebugImages;
+ bool m_bCreateFingerImage;
+ int m_NumFrames;
+ int m_NumCamFramesDiscarded;
+
+ OGLImagingContext* m_pImagingContext;
+ FilterPtr m_pBandpassFilter;
+};
+
+}
+
+#endif
+
diff --git a/src/imaging/V4LCamera.cpp b/src/imaging/V4LCamera.cpp
new file mode 100644
index 0000000..9452964
--- /dev/null
+++ b/src/imaging/V4LCamera.cpp
@@ -0,0 +1,708 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// V4L2/libavg compliance by 02L > Outside Standing Level
+
+#include "V4LCamera.h"
+
+#include "../base/ScopeTimer.h"
+#include "../base/TimeSource.h"
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+
+#include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include <linux/videodev2.h>
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <unistd.h>
+#include <iostream>
+#include <cstring>
+
+#define CLEAR(x) memset (&(x), 0, sizeof (x))
+
+using namespace avg;
+using namespace std;
+
+// anonymous namespace holding private (C-static-like) functions
+namespace {
+ int xioctl(int fd, int request, void * arg)
+ {
+ int rc;
+
+ do {
+ rc = ioctl(fd, request, arg);
+ } while (rc == -1 && EINTR == errno);
+
+ return rc;
+ }
+}
+
+
+V4LCamera::V4LCamera(std::string sDevice, int channel, IntPoint size, PixelFormat camPF,
+ PixelFormat destPF, double frameRate)
+ : Camera(camPF, destPF),
+ m_Fd(-1),
+ m_Channel(channel),
+ m_sDevice(sDevice),
+ m_ImgSize(size),
+ m_FrameRate(frameRate)
+{
+ m_v4lPF = getV4LPF(camPF);
+ if (m_sDevice == "") {
+ m_sDevice = "/dev/video0";
+ }
+ if (m_Channel == -1) {
+ m_Channel = 0;
+ }
+
+ m_FeaturesNames[V4L2_CID_BRIGHTNESS] = "brightness";
+ m_FeaturesNames[V4L2_CID_CONTRAST] = "contrast";
+ m_FeaturesNames[V4L2_CID_GAIN] = "gain";
+ m_FeaturesNames[V4L2_CID_EXPOSURE] = "exposure";
+ m_FeaturesNames[V4L2_CID_WHITENESS] = "whiteness";
+ m_FeaturesNames[V4L2_CID_GAMMA] = "gamma";
+ m_FeaturesNames[V4L2_CID_SATURATION] = "saturation";
+
+ struct stat st;
+ if (stat(m_sDevice.c_str(), &st) == -1) {
+ fatalError(string("Unable to access v4l2 device '")+m_sDevice+"'." );
+ }
+
+ if (!S_ISCHR (st.st_mode)) {
+ fatalError(string("'")+m_sDevice+" is not a v4l2 device.");
+ }
+
+ m_Fd = ::open(m_sDevice.c_str(), O_RDWR /* required */ | O_NONBLOCK, 0);
+
+ if (m_Fd == -1) {
+ fatalError(string("Unable to open v4l2 device '") + m_sDevice + "'.");
+ }
+
+ initDevice();
+ AVG_TRACE(Logger::CONFIG, "V4L2 Camera opened");
+}
+
+V4LCamera::~V4LCamera()
+{
+ close();
+}
+
+void V4LCamera::close()
+{
+ enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ int rc = xioctl(m_Fd, VIDIOC_STREAMOFF, &type);
+ if (rc == -1) {
+ AVG_TRACE(Logger::ERROR, "VIDIOC_STREAMOFF");
+ }
+ vector<Buffer>::iterator it;
+ for (it = m_vBuffers.begin(); it != m_vBuffers.end(); ++it) {
+ int err = munmap(it->start, it->length);
+ AVG_ASSERT (err != -1);
+ }
+ m_vBuffers.clear();
+
+ ::close(m_Fd);
+ AVG_TRACE(Logger::CONFIG, "V4L2 Camera closed");
+
+ m_Fd = -1;
+}
+
+IntPoint V4LCamera::getImgSize()
+{
+ return m_ImgSize;
+}
+
+int V4LCamera::getV4LPF(PixelFormat pf)
+{
+ switch (pf) {
+ case I8:
+ return V4L2_PIX_FMT_GREY;
+ case YCbCr411:
+ return V4L2_PIX_FMT_Y41P;
+ case YCbCr422:
+ return V4L2_PIX_FMT_UYVY;
+ case YUYV422:
+ return V4L2_PIX_FMT_YUYV;
+ case YCbCr420p:
+ return V4L2_PIX_FMT_YUV420;
+ case R8G8B8:
+ return V4L2_PIX_FMT_BGR24;
+ default:
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Unsupported or illegal value for camera pixel format '"
+ + getPixelFormatString(pf) + "'.");
+ }
+}
+
+BitmapPtr V4LCamera::getImage(bool bWait)
+{
+ struct v4l2_buffer buf;
+ CLEAR(buf);
+
+ // wait for incoming data blocking, timeout 2s
+ if (bWait) {
+ fd_set fds;
+ struct timeval tv;
+ int rc;
+
+ FD_ZERO(&fds);
+ FD_SET(m_Fd, &fds);
+
+ /* Timeout. */
+ tv.tv_sec = 2;
+ tv.tv_usec = 0;
+
+ rc = select (m_Fd+1, &fds, NULL, NULL, &tv);
+
+ // caught signal or something else
+ if (rc == -1) {
+ AVG_TRACE(Logger::WARNING, "V4L2: select failed.");
+ return BitmapPtr();
+ }
+ // timeout
+ if (rc == 0) {
+ AVG_TRACE(Logger::WARNING, "V4L2: Timeout while waiting for image data");
+ return BitmapPtr();
+ }
+ }
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+
+ // dequeue filled buffer
+ if (xioctl (m_Fd, VIDIOC_DQBUF, &buf) == -1) {
+ if (errno == EAGAIN) {
+ return BitmapPtr();
+ } else {
+ cerr << strerror(errno) << endl;
+ AVG_ASSERT(false);
+ }
+ }
+
+ unsigned char * pCaptureBuffer = (unsigned char*)m_vBuffers[buf.index].start;
+
+ double lineLen;
+ switch (getCamPF()) {
+ case YCbCr411:
+ lineLen = m_ImgSize.x*1.5;
+ break;
+ case YCbCr420p:
+ lineLen = m_ImgSize.x;
+ break;
+ default:
+ lineLen = m_ImgSize.x*getBytesPerPixel(getCamPF());
+ }
+ BitmapPtr pCamBmp(new Bitmap(m_ImgSize, getCamPF(), pCaptureBuffer, lineLen,
+ false, "TempCameraBmp"));
+
+ BitmapPtr pDestBmp = convertCamFrameToDestPF(pCamBmp);
+
+ // enqueues free buffer for mmap
+ if (-1 == xioctl (m_Fd, VIDIOC_QBUF, &buf)) {
+ throw(Exception(AVG_ERR_CAMERA_FATAL,
+ "V4L Camera: failed to enqueue image buffer."));
+ }
+
+ return pDestBmp;
+}
+
+bool V4LCamera::isCameraAvailable()
+{
+ return m_bCameraAvailable;
+}
+
+const std::string& V4LCamera::getDevice() const
+{
+ return m_sDevice;
+}
+
+const std::string& V4LCamera::getDriverName() const
+{
+ return m_sDriverName;
+}
+
+double V4LCamera::getFrameRate() const
+{
+ return m_FrameRate;
+}
+
+std::string V4LCamera::getFeatureName(V4LCID_t v4lFeature)
+{
+ std::string sName = m_FeaturesNames[v4lFeature];
+ if (sName == "") {
+ sName = "UNKNOWN";
+ }
+
+ return sName;
+}
+
+V4LCID_t V4LCamera::getFeatureID(CameraFeature feature) const
+{
+ V4LCID_t v4lFeature;
+ if (feature == CAM_FEATURE_BRIGHTNESS) {
+ v4lFeature = V4L2_CID_BRIGHTNESS;
+ } else if (feature == CAM_FEATURE_CONTRAST) {
+ v4lFeature = V4L2_CID_CONTRAST;
+ } else if (feature == CAM_FEATURE_GAIN) {
+ v4lFeature = V4L2_CID_GAIN;
+ } else if (feature == CAM_FEATURE_EXPOSURE) {
+ v4lFeature = V4L2_CID_EXPOSURE;
+ } else if (feature == CAM_FEATURE_GAMMA) {
+ v4lFeature = V4L2_CID_GAMMA;
+ } else if (feature == CAM_FEATURE_SATURATION) {
+ v4lFeature = V4L2_CID_SATURATION;
+ } else {
+ AVG_TRACE(Logger::WARNING, "feature " << cameraFeatureToString(feature)
+ << " not supported for V4L2.");
+ return -1;
+ }
+
+ return v4lFeature;
+}
+
+bool V4LCamera::isFeatureSupported(V4LCID_t v4lFeature) const
+{
+ struct v4l2_queryctrl queryCtrl;
+
+ CLEAR(queryCtrl);
+ queryCtrl.id = v4lFeature;
+
+ if (ioctl (m_Fd, VIDIOC_QUERYCTRL, &queryCtrl) == -1) {
+ if (errno != EINVAL) {
+ cerr << "Got " << strerror(errno) << endl;
+ AVG_ASSERT(false);
+ return false;
+ } else {
+ return false;
+ }
+ } else if (queryCtrl.flags & V4L2_CTRL_FLAG_DISABLED) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
+int V4LCamera::getFeature(CameraFeature feature) const
+{
+ V4LCID_t v4lFeature = getFeatureID(feature);
+
+ FeatureMap::const_iterator it = m_Features.find(v4lFeature);
+
+ if (it == m_Features.end()) {
+ return 0;
+ } else {
+ return it->second;
+ }
+}
+
+void V4LCamera::setFeature(V4LCID_t v4lFeature, int value)
+{
+ if (!m_bCameraAvailable) {
+ AVG_TRACE(Logger::WARNING, "setFeature() called before opening device: ignored");
+ return;
+ }
+
+ if (!isFeatureSupported(v4lFeature)) {
+ AVG_TRACE(Logger::WARNING, "Camera feature " << getFeatureName(v4lFeature) <<
+ " is not supported by hardware");
+ return;
+ }
+
+ struct v4l2_control control;
+
+ CLEAR(control);
+ control.id = v4lFeature;
+ control.value = value;
+
+// AVG_TRACE(Logger::APP, "Setting feature " << getFeatureName(v4lFeature) <<
+// " to "<< value);
+
+ if (ioctl(m_Fd, VIDIOC_S_CTRL, &control) == -1) {
+ AVG_TRACE(Logger::ERROR, "Cannot set feature " <<
+ m_FeaturesNames[v4lFeature]);
+ }
+}
+
+void V4LCamera::setFeatureOneShot(CameraFeature feature)
+{
+ AVG_TRACE(Logger::WARNING, "setFeatureOneShot is not supported by V4L cameras.");
+}
+
+int V4LCamera::getWhitebalanceU() const
+{
+ AVG_TRACE(Logger::WARNING, "getWhitebalance is not supported by V4L cameras.");
+ return 0;
+}
+
+int V4LCamera::getWhitebalanceV() const
+{
+ AVG_TRACE(Logger::WARNING, "getWhitebalance is not supported by V4L cameras.");
+ return 0;
+}
+
+void V4LCamera::setWhitebalance(int u, int v, bool bIgnoreOldValue)
+{
+ setFeature(V4L2_CID_RED_BALANCE, u);
+ setFeature(V4L2_CID_BLUE_BALANCE, v);
+}
+
+int dumpCameras_open(int j)
+{
+ stringstream minorDeviceNumber;
+ minorDeviceNumber << j;
+ string address = "/dev/video";
+ string result = address + minorDeviceNumber.str();
+ int fd = ::open(result.c_str(), O_RDWR /* required */ | O_NONBLOCK, 0);
+ return fd;
+}
+
+v4l2_capability dumpCameraCapabilities(int fd)
+{
+ v4l2_capability capability;
+ memset(&capability, 0, sizeof(capability));
+ int rc = ioctl(fd, VIDIOC_QUERYCAP, &capability);
+ if (rc != -1) {
+ cout << capability.card << ":" << endl;
+ cout << " Driver: " << capability.driver << endl;
+ cout << " Location: " << capability.bus_info;
+ cout << endl << endl;
+ }
+ return capability;
+}
+
+void dumpSupportedImgFormats(int fd)
+{
+ cout << "Suported Image Formats:" << endl;
+ for (int i = 0;; i++) {
+ v4l2_fmtdesc fmtDesc;
+ memset(&fmtDesc, 0, sizeof(fmtDesc));
+ fmtDesc.index = i;
+ fmtDesc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ int rc = ioctl(fd, VIDIOC_ENUM_FMT, &fmtDesc);
+ if (rc == -1) {
+ break;
+ }
+ v4l2_frmsizeenum frmSizeEnum;
+ memset(&frmSizeEnum, 0, sizeof (frmSizeEnum));
+ frmSizeEnum.index = 0;
+ frmSizeEnum.pixel_format = fmtDesc.pixelformat;
+ bool bSupported = false;
+ while (ioctl(fd, VIDIOC_ENUM_FRAMESIZES, &frmSizeEnum) == 0) {
+ string sAvgPixelformat;
+ switch (fmtDesc.pixelformat) {
+ case v4l2_fourcc('Y','U','Y','V'):
+ sAvgPixelformat = "YUYV422";
+ bSupported = true;
+ break;
+ case v4l2_fourcc('U','Y','V','Y'):
+ sAvgPixelformat = "YUV422";
+ bSupported = true;
+ break;
+ case v4l2_fourcc('G','R','E','Y'):
+ sAvgPixelformat = "I8";
+ bSupported = true;
+ break;
+ case v4l2_fourcc('Y','1','6',' '):
+ sAvgPixelformat = "I16";
+ bSupported = true;
+ break;
+ case v4l2_fourcc('R','G','B','3'):
+ sAvgPixelformat = "RGB";
+ bSupported = true;
+ break;
+ case v4l2_fourcc('B','G','R','3'):
+ sAvgPixelformat = "BGR";
+ bSupported = true;
+ break;
+ default:
+ break;
+ }
+
+ if (bSupported) {
+ v4l2_frmivalenum frmIvalEnum;
+ cout << " " << sAvgPixelformat << " ";
+ cout << " (" << frmSizeEnum.discrete.width << ", ";
+ cout << frmSizeEnum.discrete.height << ")";
+ cout << " fps: ";
+ memset (&frmIvalEnum, 0, sizeof (frmIvalEnum));
+ frmIvalEnum.index = 0;
+ frmIvalEnum.pixel_format = frmSizeEnum.pixel_format;
+ frmIvalEnum.width = frmSizeEnum.discrete.width;
+ frmIvalEnum.height = frmSizeEnum.discrete.height;
+ while (ioctl(fd, VIDIOC_ENUM_FRAMEINTERVALS, &frmIvalEnum) == 0) {
+ cout << frmIvalEnum.discrete.denominator << "/";
+ frmIvalEnum.index++;
+ }
+ cout << endl;
+ }
+ frmSizeEnum.index++;
+ }
+ }
+}
+
+void dumpCameraControls(int fd)
+{
+ cout << endl << "Camera Controls:" << endl;
+ v4l2_queryctrl queryCtrl;
+ for (queryCtrl.id = V4L2_CID_BASE; queryCtrl.id < V4L2_CID_LASTP1; queryCtrl.id++) {
+ int rc = ioctl (fd, VIDIOC_QUERYCTRL, &queryCtrl);
+ if (rc != -1) {
+ if (queryCtrl.flags & V4L2_CTRL_FLAG_DISABLED) {
+ continue;
+ }
+ cout << " " << queryCtrl.name << ":" << endl;
+ cout << " Min: " << queryCtrl.minimum << " | ";
+ cout << "Max: " << queryCtrl.maximum << " | ";
+ cout << "Default: "<< queryCtrl.default_value << endl;
+ } else {
+ if (errno != EINVAL) {
+ perror("VIDIOC_QUERYCTRL");
+ exit(EXIT_FAILURE);
+ }
+ }
+ }
+}
+
+void V4LCamera::dumpCameras()
+{
+ for(int j = 0; j < 256; j++){
+ int fd = dumpCameras_open(j);
+ if (fd != -1) {
+ cout << "------------------------Video4linux Camera-------------------------";
+ cout << endl;
+ cout << "/dev/video" << j << " ";
+ v4l2_capability capability = dumpCameraCapabilities(fd);
+ if (capability.capabilities & V4L2_CAP_VIDEO_CAPTURE) {
+ dumpSupportedImgFormats(fd);
+ dumpCameraControls(fd);
+ }
+ cout << "-------------------------------------------------------------------";
+ cout << endl;
+ }
+ }
+}
+
+
+void V4LCamera::setFeature(CameraFeature feature, int value, bool bIgnoreOldValue)
+{
+ // ignore -1 coming from default unbiased cameranode parameters
+ if (value < 0) {
+ return;
+ }
+
+ V4LCID_t v4lFeature = getFeatureID(feature);
+ m_Features[v4lFeature] = value;
+
+// AVG_TRACE(Logger::WARNING,"Setting feature " << sFeature <<
+// " to " << value);
+ if (m_bCameraAvailable) {
+ setFeature(v4lFeature, value);
+ }
+}
+
+void V4LCamera::startCapture()
+{
+// AVG_TRACE(Logger::APP, "Entering startCapture()...");
+
+ unsigned int i;
+ enum v4l2_buf_type type;
+
+ for (i = 0; i < m_vBuffers.size(); ++i) {
+ struct v4l2_buffer buf;
+
+ CLEAR(buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = i;
+
+ int err = xioctl(m_Fd, VIDIOC_QBUF, &buf);
+ AVG_ASSERT(err != -1);
+ }
+
+ type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ int err= xioctl (m_Fd, VIDIOC_STREAMON, &type);
+ AVG_ASSERT(err != -1);
+}
+
+void V4LCamera::initDevice()
+{
+// AVG_TRACE(Logger::APP, "Entering initDevice()...");
+
+ struct v4l2_capability cap;
+ struct v4l2_cropcap CropCap;
+ struct v4l2_crop Crop;
+ struct v4l2_format fmt;
+ struct v4l2_streamparm StreamParam;
+
+ if (xioctl(m_Fd, VIDIOC_QUERYCAP, &cap) == -1) {
+ close();
+ fatalError(m_sDevice + " is not a valid V4L2 device.");
+ }
+
+ if (!(cap.capabilities & V4L2_CAP_VIDEO_CAPTURE)) {
+ close();
+ fatalError(m_sDevice + " does not support capturing");
+ }
+
+ if (!(cap.capabilities & V4L2_CAP_STREAMING)) {
+ close();
+ fatalError(m_sDevice + " does not support streaming i/os");
+ }
+ m_sDriverName = (const char *)cap.driver;
+
+ /* Select video input, video standard and tune here. */
+ CLEAR(CropCap);
+ CropCap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ if (xioctl(m_Fd, VIDIOC_CROPCAP, &CropCap) == 0) {
+ Crop.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ Crop.c = CropCap.defrect; /* reset to default */
+
+ if (-1 == xioctl(m_Fd, VIDIOC_S_CROP, &Crop)) {
+ switch (errno) {
+ case EINVAL:
+ /* Cropping not supported. */
+ break;
+ default:
+ /* Errors ignored. */
+ break;
+ }
+ }
+ } else {
+ /* Errors ignored. */
+ }
+
+ CLEAR(fmt);
+
+ fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ fmt.fmt.pix.width = m_ImgSize.x;
+ fmt.fmt.pix.height = m_ImgSize.y;
+ fmt.fmt.pix.pixelformat = m_v4lPF;
+ fmt.fmt.pix.field = V4L2_FIELD_ANY;
+ int rc = xioctl(m_Fd, VIDIOC_S_FMT, &fmt);
+ if (int(fmt.fmt.pix.width) != m_ImgSize.x || int(fmt.fmt.pix.height) != m_ImgSize.y
+ || rc == -1)
+ {
+ throw(Exception(AVG_ERR_CAMERA_NONFATAL,
+ string("Unable to set V4L camera image format: '")
+ +strerror(errno)
+ +"'. Try using avg_showcamera.py --dump to find out what the device supports."));
+ }
+
+ CLEAR(StreamParam);
+
+ StreamParam.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ StreamParam.parm.capture.timeperframe.numerator = 1;
+ StreamParam.parm.capture.timeperframe.denominator = (int) m_FrameRate;
+ rc = xioctl(m_Fd, VIDIOC_S_PARM, &StreamParam);
+ if (m_FrameRate != StreamParam.parm.capture.timeperframe.denominator || rc == -1) {
+ throw(Exception(AVG_ERR_CAMERA_NONFATAL,
+ string("Unable to set V4L camera framerate: '")
+ +strerror(errno)
+ +"'. Try using avg_showcamera.py --dump to find out what the device supports."));
+ }
+ m_FrameRate = (double)StreamParam.parm.capture.timeperframe.denominator / \
+ (double)StreamParam.parm.capture.timeperframe.numerator;
+
+ initMMap ();
+
+ // TODO: string channel instead of numeric
+ // select channel
+ if (xioctl(m_Fd, VIDIOC_S_INPUT, &m_Channel) == -1) {
+ close();
+ fatalError(string("Cannot set MUX channel ")+toString(m_Channel));
+ }
+
+ m_bCameraAvailable = true;
+
+ for (FeatureMap::iterator it=m_Features.begin(); it != m_Features.end(); it++) {
+ setFeature(it->first, it->second);
+ }
+
+
+}
+
+void V4LCamera::initMMap()
+{
+ struct v4l2_requestbuffers req;
+ CLEAR(req);
+
+ req.count = 4;
+ req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ req.memory = V4L2_MEMORY_MMAP;
+
+ if (xioctl(m_Fd, VIDIOC_REQBUFS, &req) == -1) {
+ if (EINVAL == errno) {
+ close();
+ fatalError(m_sDevice+" does not support memory mapping");
+ } else {
+ cerr << "errno: " << strerror(errno);
+ AVG_ASSERT(false);
+ }
+ }
+
+ if (req.count < 2) {
+ cerr << "Insufficient buffer memory on " << m_sDevice;
+ AVG_ASSERT(false);
+ }
+
+ m_vBuffers.clear();
+
+ for (int i = 0; i < int(req.count); ++i) {
+ Buffer tmp;
+ struct v4l2_buffer buf;
+
+ CLEAR (buf);
+
+ buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+ buf.memory = V4L2_MEMORY_MMAP;
+ buf.index = i;
+
+ if (xioctl(m_Fd, VIDIOC_QUERYBUF, &buf) == -1) {
+ AVG_ASSERT(false);
+ }
+
+ tmp.length = buf.length;
+
+ tmp.start = mmap (NULL /* start anywhere */,
+ buf.length,
+ PROT_READ | PROT_WRITE /* required */,
+ MAP_SHARED /* recommended */,
+ m_Fd, buf.m.offset);
+
+ if (MAP_FAILED == tmp.start) {
+ AVG_ASSERT(false);
+ }
+
+ m_vBuffers.push_back(tmp);
+ }
+}
+
+
+
diff --git a/src/imaging/V4LCamera.h b/src/imaging/V4LCamera.h
new file mode 100644
index 0000000..6a8ebaa
--- /dev/null
+++ b/src/imaging/V4LCamera.h
@@ -0,0 +1,98 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _V4LCamera_H_
+#define _V4LCamera_H_
+
+#include "../api.h"
+#include "../avgconfigwrapper.h"
+
+#include "Camera.h"
+#include <string>
+#include <vector>
+
+namespace avg {
+
+typedef unsigned int V4LCID_t;
+
+class AVG_API V4LCamera: public Camera {
+
+ struct Buffer {
+ void * start;
+ size_t length;
+ };
+
+public:
+ V4LCamera(std::string sDevice, int channel, IntPoint size, PixelFormat camPF,
+ PixelFormat destPF, double frameRate);
+ virtual ~V4LCamera();
+
+ virtual IntPoint getImgSize();
+ virtual BitmapPtr getImage(bool bWait);
+ virtual bool isCameraAvailable();
+
+ virtual const std::string& getDevice() const;
+ virtual const std::string& getDriverName() const;
+ virtual double getFrameRate() const;
+
+ virtual int getFeature(CameraFeature feature) const;
+ virtual void setFeature(CameraFeature feature, int value,
+ bool bIgnoreOldValue=false);
+ virtual void setFeatureOneShot(CameraFeature feature);
+ virtual int getWhitebalanceU() const;
+ virtual int getWhitebalanceV() const;
+ virtual void setWhitebalance(int u, int v, bool bIgnoreOldValue=false);
+
+ static void dumpCameras();
+
+private:
+ void initDevice();
+ void startCapture();
+ void initMMap();
+ virtual void close();
+
+ int getV4LPF(PixelFormat pf);
+
+ int m_Fd;
+ int m_Channel;
+ std::string m_sDevice;
+ std::string m_sDriverName;
+ std::vector<Buffer> m_vBuffers;
+ bool m_bCameraAvailable;
+ int m_v4lPF;
+ IntPoint m_ImgSize;
+ double m_FrameRate;
+
+ void setFeature(V4LCID_t v4lFeature, int value);
+ V4LCID_t getFeatureID(CameraFeature feature) const;
+ std::string getFeatureName(V4LCID_t v4lFeature);
+ bool isFeatureSupported(V4LCID_t v4lFeature) const;
+ typedef std::map<V4LCID_t, unsigned int> FeatureMap;
+ typedef std::map<int, std::string> FeatureNamesMap;
+ FeatureMap m_Features;
+ // TODO: Feature strings should really be handled by
+ // Camera::cameraFeatureToString
+ FeatureNamesMap m_FeaturesNames;
+};
+
+}
+
+#endif
diff --git a/src/imaging/avgtrackerrc.minimal b/src/imaging/avgtrackerrc.minimal
new file mode 100644
index 0000000..f2bef02
--- /dev/null
+++ b/src/imaging/avgtrackerrc.minimal
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8"?>
+<trackerconfig>
+ <camera>
+ <driver value="firewire"/>
+ <device value=""/>
+ <fw800 value="false"/>
+ <format value="I8"/>
+ <size x="640" y="480"/>
+ <framerate value="60"/>
+ <brightness value="1"/>
+ <gamma value="0"/>
+ <exposure value="-1"/>
+ <gain value="16"/>
+ <shutter value="75"/>
+ <strobeduration value="-1"/>
+ </camera>
+ <tracker>
+ <prescale value="1"/>
+ <historyupdateinterval value="25"/>
+ <brighterregions value="true"/>
+ <contourprecision value="0"/>
+ <historydelay value="2200"/>
+ <mask value=""/>
+ <findfingertips value="true"/>
+ <track>
+ <threshold value="16"/>
+ <similarity value="100"/>
+ <areabounds min="700" max="1000000"/>
+ <eccentricitybounds min="1" max="80"/>
+ </track>
+ <touch>
+ <threshold value="148"/>
+ <similarity value="50"/>
+ <areabounds min="16" max="200000"/>
+ <eccentricitybounds min="1" max="800"/>
+ <bandpass min="1.6" max="2.4"/>
+ <bandpasspostmult value="30.0"/>
+ </touch>
+ </tracker>
+ <transform>
+ <distortionparams p2="0.697166" p3="0.0"/>
+ <trapezoid value="0.151537"/>
+ <angle value="0.00224421"/>
+ <displaydisplacement x="-174.966" y="-145.974"/>
+ <displayscale x="2.52439" y="2.55685"/>
+ <activedisplaysize x="1280" y="800"/>
+ <displayroi x1="0" y1="0" x2="1280" y2="800"/>
+ </transform>
+</trackerconfig>
diff --git a/src/imaging/baseline/FilterClearBorderResult1.png b/src/imaging/baseline/FilterClearBorderResult1.png
new file mode 100644
index 0000000..96d610a
--- /dev/null
+++ b/src/imaging/baseline/FilterClearBorderResult1.png
Binary files differ
diff --git a/src/imaging/baseline/FilterClearBorderResult3.png b/src/imaging/baseline/FilterClearBorderResult3.png
new file mode 100644
index 0000000..09943e3
--- /dev/null
+++ b/src/imaging/baseline/FilterClearBorderResult3.png
Binary files differ
diff --git a/src/imaging/baseline/FilterWipeBorderResult1.png b/src/imaging/baseline/FilterWipeBorderResult1.png
new file mode 100644
index 0000000..bf22671
--- /dev/null
+++ b/src/imaging/baseline/FilterWipeBorderResult1.png
Binary files differ
diff --git a/src/imaging/baseline/FilterWipeBorderResult3.png b/src/imaging/baseline/FilterWipeBorderResult3.png
new file mode 100644
index 0000000..4e8eb1d
--- /dev/null
+++ b/src/imaging/baseline/FilterWipeBorderResult3.png
Binary files differ
diff --git a/src/imaging/checktracking.cpp b/src/imaging/checktracking.cpp
new file mode 100644
index 0000000..86c3935
--- /dev/null
+++ b/src/imaging/checktracking.cpp
@@ -0,0 +1,101 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+
+#include "TrackerThread.h"
+#include "FWCamera.h"
+#include "FakeCamera.h"
+
+#include "../graphics/Filtergrayscale.h"
+#include "../graphics/FilterGauss.h"
+#include "../graphics/FilterHighpass.h"
+#include "../graphics/FilterBandpass.h"
+#include "../graphics/FilterFastBandpass.h"
+#include "../graphics/FilterBlur.h"
+
+#include <sstream>
+#include <iostream>
+#include <math.h>
+
+using namespace avg;
+using namespace std;
+
+class TestTracker: public IBlobTarget {
+
+public:
+
+TestTracker()
+{
+ m_FrameNum = 0;
+ std::vector<std::string> p = std::vector<std::string>();
+ for (int i=1; i<4; ++i) {
+ stringstream s;
+ s << "camimages/img" << i << "_nohistory.png";
+ p.push_back(s.str());
+ }
+ CameraPtr pCam = CameraPtr(new FakeCamera(p));
+ for (int i=0; i<NUM_TRACKER_IMAGES; i++) {
+ m_pBitmaps[i] = BitmapPtr(new Bitmap(pCam->getImgSize(), I8));
+ }
+ MutexPtr pMutex(new boost::mutex);
+ TrackerConfig Config;
+ Config.setParam("/tracker/touch/threshold/@value", "131");
+ m_pCmdQ = TrackerThread::CQueuePtr(new TrackerThread::CQueue);
+ IntRect ROI(0,0,pCam->getImgSize().x, pCam->getImgSize().y);
+ boost::thread Thread(
+ TrackerThread(ROI, pCam, m_pBitmaps, pMutex, *m_pCmdQ, this,
+ false, Config));
+ Thread.join();
+}
+
+virtual ~TestTracker()
+{
+}
+
+virtual void update(BlobVectorPtr pBlobs, BitmapPtr)
+{
+ m_FrameNum++;
+ cerr << "Frame " << m_FrameNum << endl;
+ for (int i=0; i<NUM_TRACKER_IMAGES; i++) {
+ stringstream s;
+ s << "camimages/img" << m_FrameNum << "_" << i << ".png";
+ m_pBitmaps[i]->save(s.str());
+ }
+}
+
+private:
+ int m_FrameNum;
+ TrackerThread::CQueuePtr m_pCmdQ;
+ BitmapPtr m_pBitmaps[NUM_TRACKER_IMAGES];
+
+};
+
+void testBlur()
+{
+ BitmapPtr pBitmap(new Bitmap("camimages/img1_nohistory.png"));
+ FilterGrayscale().applyInPlace(pBitmap);
+ BitmapPtr pBmpBandpass = FilterFastBandpass().apply(pBitmap);
+ pBmpBandpass->save("camimages/img1_bandpass_test.png");
+}
+
+int main(int argc, char **argv)
+{
+// TestTracker t;
+ testBlur();
+}
diff --git a/src/imaging/testfiles/filterwipeborder.png b/src/imaging/testfiles/filterwipeborder.png
new file mode 100644
index 0000000..58ac84d
--- /dev/null
+++ b/src/imaging/testfiles/filterwipeborder.png
Binary files differ
diff --git a/src/imaging/testimaging.cpp b/src/imaging/testimaging.cpp
new file mode 100644
index 0000000..85f7b07
--- /dev/null
+++ b/src/imaging/testimaging.cpp
@@ -0,0 +1,234 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FakeCamera.h"
+#include "TrackerThread.h"
+#include "TrackerConfig.h"
+#include "DeDistort.h"
+#include "FilterWipeBorder.h"
+#include "FilterClearBorder.h"
+
+#include "../graphics/GraphicsTest.h"
+#include "../graphics/Filtergrayscale.h"
+#include "../graphics/FilterId.h"
+
+#include "../base/TestSuite.h"
+#include "../base/Exception.h"
+#include "../base/FileHelper.h"
+#include "../base/MathHelper.h"
+
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sstream>
+
+using namespace avg;
+using namespace std;
+
+class FilterWipeBorderTest: public GraphicsTest
+{
+public:
+ FilterWipeBorderTest()
+ : GraphicsTest("FilterWipeBorderTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("filterwipeborder", I8);
+ BitmapPtr pDestBmp = FilterWipeBorder(0).apply(pBmp);
+ testEqual(*pDestBmp, *pBmp, "FilterWipeBorderResult0", 0, 0);
+ pDestBmp = FilterWipeBorder(1).apply(pBmp);
+ testEqual(*pDestBmp, "FilterWipeBorderResult1", I8);
+ pDestBmp = FilterWipeBorder(3).apply(pBmp);
+ testEqual(*pDestBmp, "FilterWipeBorderResult3", I8);
+ }
+};
+
+class FilterClearBorderTest: public GraphicsTest
+{
+public:
+ FilterClearBorderTest()
+ : GraphicsTest("FilterClearBorderTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ BitmapPtr pBmp = loadTestBmp("filterwipeborder", I8);
+ BitmapPtr pDestBmp = FilterClearBorder(0).apply(pBmp);
+ testEqual(*pDestBmp, *pBmp, "FilterClearBorderResult0", 0, 0);
+ pDestBmp = FilterClearBorder(1).apply(pBmp);
+ testEqual(*pDestBmp, "FilterClearBorderResult1", I8);
+ pDestBmp = FilterClearBorder(3).apply(pBmp);
+ testEqual(*pDestBmp, "FilterClearBorderResult3", I8);
+ }
+};
+
+class DeDistortTest: public Test
+{
+public:
+ DeDistortTest()
+ : Test("DeDistortTest", 2)
+ {}
+
+ void runTests()
+ {
+ vector<double> params;
+ params.push_back(0);
+ params.push_back(0);
+ DeDistort IdentityDistort = DeDistort(DPoint(1,1),
+ params, 0.0, 0.0,
+ DPoint(0,0), DPoint(1,1));
+ TEST(almostEqual(IdentityDistort.transform_point(DPoint(0,0)), DPoint(0,0)));
+ TEST(almostEqual(IdentityDistort.transform_point(DPoint(1,2)), DPoint(1,2)));
+ TEST(almostEqual(IdentityDistort.transformBlobToScreen(DPoint(0,0)),
+ DPoint(0,0)));
+ TEST(almostEqual(IdentityDistort.transformBlobToScreen(DPoint(1,2)),
+ DPoint(1,2)));
+ TEST(almostEqual(IdentityDistort.inverse_transform_point(DPoint(0,0)),
+ DPoint(0,0)));
+ TEST(almostEqual(IdentityDistort.inverse_transform_point(DPoint(1,2)),
+ DPoint(1,2)));
+ TEST(almostEqual(IdentityDistort.transformScreenToBlob(DPoint(0,0)),
+ DPoint(0,0)));
+ TEST(almostEqual(IdentityDistort.transformScreenToBlob(DPoint(1,2)),
+ DPoint(1,2)));
+ TEST(IdentityDistort.getDisplayArea(DPoint(1280,720)) == DRect(0,0,1280,720));
+
+ DeDistort scaler = DeDistort(DPoint(1,1), params, 0, 0.0, DPoint(0,0),
+ DPoint(2,2));
+ TEST(almostEqual(scaler.transform_point(DPoint(0,0)), DPoint(0,0)));
+ TEST(almostEqual(scaler.transformBlobToScreen(DPoint(1,2)), DPoint(2,4)));
+ TEST(almostEqual(scaler.inverse_transform_point(DPoint(0,0)), DPoint(0,0)));
+ TEST(almostEqual(scaler.transformScreenToBlob(DPoint(1,2)), DPoint(0.5,1)));
+
+ DeDistort shifter = DeDistort(DPoint(1,1), params, 0, 0.0, DPoint(1,1),
+ DPoint(1,1));
+ TEST(almostEqual(shifter.transformBlobToScreen(DPoint(0,0)), DPoint(1,1)));
+ TEST(almostEqual(shifter.transformBlobToScreen(DPoint(1,2)), DPoint(2,3)));
+ TEST(almostEqual(shifter.transformScreenToBlob(DPoint(0,0)), DPoint(-1,-1)));
+ TEST(almostEqual(shifter.transformScreenToBlob(DPoint(1,2)), DPoint(0,1)));
+ TEST(shifter.getDisplayArea(DPoint(1,1)) == DRect(-1, -1, 0, 0));
+
+ vector<double> cubed;
+ cubed.push_back(0);
+ cubed.push_back(1);
+ DeDistort barreler = DeDistort(DPoint(1,1), cubed, 0, 0.0, DPoint(0,0),
+ DPoint(1,1));
+ for (double xp = 0; xp < 10; xp++) {
+ for(double yp = 0; yp < 10; yp++) {
+ QUIET_TEST(almostEqual(barreler.inverse_transform_point(
+ barreler.transform_point(DPoint(xp,yp))), DPoint(xp,yp)));
+ }
+ }
+ TEST(almostEqual(barreler.transform_point(DPoint(1,1)), DPoint(1,1)));
+
+ DeDistort rotator = DeDistort(DPoint(1,1), params, 0, M_PI/2, DPoint(0,0),
+ DPoint(1,1));
+ for (double xp = 0; xp < 10; xp++) {
+ for(double yp = 0; yp < 10; yp++) {
+ QUIET_TEST(almostEqual(rotator.inverse_transform_point(
+ rotator.transform_point(DPoint(xp,yp))), DPoint(xp,yp)));
+ }
+ }
+
+ DeDistort shifterScaler = DeDistort(DPoint(1,1), params, 0, 0.0, DPoint(1,1),
+ DPoint(2,2));
+ for (double xp = 0; xp < 10; xp++) {
+ for(double yp = 0; yp < 10; yp++) {
+ QUIET_TEST(almostEqual(shifterScaler.inverse_transform_point(
+ shifterScaler.transform_point(DPoint(xp,yp))), DPoint(xp,yp)));
+ }
+ }
+ }
+};
+
+#ifdef _WIN32
+#pragma warning(disable: 4996)
+#endif
+class SerializeTest: public Test
+{
+public:
+ SerializeTest()
+ : Test("SerializeTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ TrackerConfig Config;
+ copyFile(getSrcDirName()+"avgtrackerrc.minimal", "avgtrackerrc");
+ Config.load();
+
+ Config.setParam("/transform/distortionparams/@p2", "0");
+ Config.setParam("/transform/distortionparams/@p3", "0");
+ Config.setParam("/transform/trapezoid/@value", "0");
+ Config.setParam("/transform/angle/@value", "0");
+ Config.setParam("/transform/displaydisplacement/@x", "0");
+ Config.setParam("/transform/displaydisplacement/@y", "0");
+ Config.setParam("/transform/displayscale/@x", "2");
+ Config.setParam("/transform/displayscale/@y", "2");
+
+ if (getSrcDirName() == "./") {
+ Config.save();
+
+ TrackerConfig loadedConfig;
+ loadedConfig.load();
+ DPoint scale = loadedConfig.getPointParam("/transform/displayscale/");
+ TEST(almostEqual(scale, DPoint(2,2)));
+ unlink("avgtrackerrc.bak");
+ }
+ unlink("avgtrackerrc");
+ }
+};
+
+class ImagingTestSuite: public TestSuite
+{
+public:
+ ImagingTestSuite()
+ : TestSuite("ImagingTestSuite")
+ {
+ addTest(TestPtr(new FilterWipeBorderTest));
+ addTest(TestPtr(new FilterClearBorderTest));
+ addTest(TestPtr(new DeDistortTest));
+ addTest(TestPtr(new SerializeTest));
+ }
+};
+
+
+int main(int nargs, char** args)
+{
+ ImagingTestSuite Suite;
+ Suite.runTests();
+ bool bOK = Suite.isOk();
+
+ if (bOK) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
diff --git a/src/imaging/trackerconfigdtd.cpp b/src/imaging/trackerconfigdtd.cpp
new file mode 100644
index 0000000..2d12406
--- /dev/null
+++ b/src/imaging/trackerconfigdtd.cpp
@@ -0,0 +1,175 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+const char * g_pTrackerConfigDTD =
+"<!ENTITY % minmaxAttrs\n"
+" \"min CDATA #REQUIRED\n"
+" max CDATA #REQUIRED\" >\n"
+
+"<!ENTITY % posAttrs\n"
+" \"x CDATA #REQUIRED\n"
+" y CDATA #REQUIRED\" >\n"
+
+"<!ELEMENT trackerconfig (camera|tracker|transform)* >\n"
+"<!ELEMENT camera (driver|device|fw800|format|size|framerate|brightness|gamma|exposure|"
+" gain|shutter|strobeduration)* >\n"
+"<!ELEMENT tracker (mask|prescale|historyupdateinterval|brighterregions|"
+" contourprecision|historydelay|touch|track|findfingertips)* >\n"
+"<!ELEMENT touch (threshold|similarity|areabounds|eccentricitybounds|bandpass|"
+" bandpasspostmult)* >\n"
+"<!ELEMENT track (threshold|similarity|areabounds|eccentricitybounds)* >\n"
+"<!ELEMENT transform (cameradisplacement|camerascale|distortionparams|trapezoid|"
+" angle|displaydisplacement|displayscale|activedisplaysize|displayroi)* >\n"
+
+"<!ELEMENT driver EMPTY>\n"
+"<!ATTLIST driver\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT device EMPTY>\n"
+"<!ATTLIST device\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT fw800 EMPTY>\n"
+"<!ATTLIST fw800\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT format EMPTY>\n"
+"<!ATTLIST format\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT size EMPTY>\n"
+"<!ATTLIST size\n"
+" %posAttrs; >\n"
+
+"<!ELEMENT framerate EMPTY>\n"
+"<!ATTLIST framerate\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT brightness EMPTY>\n"
+"<!ATTLIST brightness\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT gamma EMPTY>\n"
+"<!ATTLIST gamma\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT exposure EMPTY>\n"
+"<!ATTLIST exposure\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT gain EMPTY>\n"
+"<!ATTLIST gain\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT shutter EMPTY>\n"
+"<!ATTLIST shutter\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT strobeduration EMPTY>\n"
+"<!ATTLIST strobeduration\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT brighterregions EMPTY>\n"
+"<!ATTLIST brighterregions\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT threshold EMPTY>\n"
+"<!ATTLIST threshold\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT mask EMPTY>\n"
+"<!ATTLIST mask\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT findfingertips EMPTY>\n"
+"<!ATTLIST findfingertips\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT prescale EMPTY>\n"
+"<!ATTLIST prescale\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT historyupdateinterval EMPTY>\n"
+"<!ATTLIST historyupdateinterval\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT contourprecision EMPTY>\n"
+"<!ATTLIST contourprecision\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT historydelay EMPTY>\n"
+"<!ATTLIST historydelay\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT similarity EMPTY>\n"
+"<!ATTLIST similarity\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT areabounds EMPTY>\n"
+"<!ATTLIST areabounds\n"
+" %minmaxAttrs; >\n"
+
+"<!ELEMENT eccentricitybounds EMPTY>\n"
+"<!ATTLIST eccentricitybounds\n"
+" %minmaxAttrs; >\n"
+
+"<!ELEMENT bandpass EMPTY>\n"
+"<!ATTLIST bandpass\n"
+" %minmaxAttrs; >\n"
+
+"<!ELEMENT bandpasspostmult EMPTY>\n"
+"<!ATTLIST bandpasspostmult\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT distortionparams EMPTY>\n"
+"<!ATTLIST distortionparams\n"
+" p2 CDATA #REQUIRED\n"
+" p3 CDATA #REQUIRED >\n"
+
+"<!ELEMENT trapezoid EMPTY>\n"
+"<!ATTLIST trapezoid\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT angle EMPTY>\n"
+"<!ATTLIST angle\n"
+" value CDATA #REQUIRED >\n"
+
+"<!ELEMENT displaydisplacement EMPTY>\n"
+"<!ATTLIST displaydisplacement\n"
+" %posAttrs; >\n"
+
+"<!ELEMENT displayscale EMPTY>\n"
+"<!ATTLIST displayscale\n"
+" %posAttrs; >\n"
+
+"<!ELEMENT activedisplaysize EMPTY>\n"
+"<!ATTLIST activedisplaysize\n"
+" %posAttrs; >\n"
+
+"<!ELEMENT displayroi EMPTY>\n"
+"<!ATTLIST displayroi\n"
+" x1 CDATA #REQUIRED\n"
+" y1 CDATA #REQUIRED\n"
+" x2 CDATA #REQUIRED\n"
+" y2 CDATA #REQUIRED >\n"
+
+;
+
diff --git a/src/imaging/trackerconfigdtd.h b/src/imaging/trackerconfigdtd.h
new file mode 100644
index 0000000..20293b2
--- /dev/null
+++ b/src/imaging/trackerconfigdtd.h
@@ -0,0 +1,27 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _avgdtd_H_
+
+extern const char * g_pTrackerConfigDTD;
+
+#endif
+
diff --git a/src/lmfit/Makefile.am b/src/lmfit/Makefile.am
new file mode 100644
index 0000000..5a66da2
--- /dev/null
+++ b/src/lmfit/Makefile.am
@@ -0,0 +1,8 @@
+
+INCLUDES = -I.
+CPPFLAGS=-DBUG
+ALL_H = lmmin.h lm_eval.h
+noinst_LTLIBRARIES = liblmfit.la
+liblmfit_la_SOURCES = lmmin.c lm_eval.c $(ALL_H)
+liblmfit_a_CXXFLAGS = -Wno-format-y2k
+
diff --git a/src/lmfit/Makefile.in b/src/lmfit/Makefile.in
new file mode 100644
index 0000000..111f999
--- /dev/null
+++ b/src/lmfit/Makefile.in
@@ -0,0 +1,562 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/lmfit
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+liblmfit_la_LIBADD =
+am__objects_1 =
+am_liblmfit_la_OBJECTS = lmmin.lo lm_eval.lo $(am__objects_1)
+liblmfit_la_OBJECTS = $(am_liblmfit_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(liblmfit_la_SOURCES)
+DIST_SOURCES = $(liblmfit_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = -DBUG
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.
+ALL_H = lmmin.h lm_eval.h
+noinst_LTLIBRARIES = liblmfit.la
+liblmfit_la_SOURCES = lmmin.c lm_eval.c $(ALL_H)
+liblmfit_a_CXXFLAGS = -Wno-format-y2k
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/lmfit/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/lmfit/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+liblmfit.la: $(liblmfit_la_OBJECTS) $(liblmfit_la_DEPENDENCIES)
+ $(AM_V_CCLD)$(LINK) $(liblmfit_la_OBJECTS) $(liblmfit_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lm_eval.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lmmin.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/lmfit/lm_eval.c b/src/lmfit/lm_eval.c
new file mode 100644
index 0000000..7a1b971
--- /dev/null
+++ b/src/lmfit/lm_eval.c
@@ -0,0 +1,81 @@
+#include "lmmin.h"
+#include "lm_eval.h"
+#include <stdio.h>
+
+/*
+ * This file contains default implementation of the evaluate and printout
+ * routines. In most cases, customization of lmfit can be done by modifying
+ * these two routines. Either modify them here, or copy and rename them.
+ */
+
+void lm_evaluate_default( double* par, int m_dat, double* fvec,
+ void *data, int *info )
+/*
+ * par is an input array. At the end of the minimization, it contains
+ * the approximate solution vector.
+ *
+ * m_dat is a positive integer input variable set to the number
+ * of functions.
+ *
+ * fvec is an output array of length m_dat which contains the function
+ * values the square sum of which ought to be minimized.
+ *
+ * data is a read-only pointer to lm_data_type, as specified by lmuse.h.
+ *
+ * info is an integer output variable. If set to a negative value, the
+ * minimization procedure will stop.
+ */
+{
+ int i;
+ lm_data_type *mydata;
+ mydata = (lm_data_type*)data;
+
+ for (i=0; i<m_dat; i++)
+ fvec[i] = mydata->user_y[i]
+ - mydata->user_func( mydata->user_t[i], par);
+
+ *info = *info; /* to prevent a 'unused variable' warning */
+ /* if <parameters drifted away> { *info = -1; } */
+}
+
+void lm_print_default( int n_par, double* par, int m_dat, double* fvec,
+ void *data, int iflag, int iter, int nfev )
+/*
+ * data : for soft control of printout behaviour, add control
+ * variables to the data struct
+ * iflag : 0 (init) 1 (outer loop) 2(inner loop) -1(terminated)
+ * iter : outer loop counter
+ * nfev : number of calls to *evaluate
+ */
+{
+ double f, y, t;
+ int i;
+ lm_data_type *mydata;
+ mydata = (lm_data_type*)data;
+
+ if (iflag==2) {
+ printf ("trying step in gradient direction\n");
+ } else if (iflag==1) {
+ printf ("determining gradient (iteration %d)\n", iter);
+ } else if (iflag==0) {
+ printf ("starting minimization\n");
+ } else if (iflag==-1) {
+ printf ("terminated after %d evaluations\n", nfev);
+ }
+
+ printf( " par: " );
+ for( i=0; i<n_par; ++i )
+ printf( " %12g", par[i] );
+ printf ( " => norm: %12g\n", lm_enorm( m_dat, fvec ) );
+
+ if ( iflag == -1 ) {
+ printf( " fitting data as follows:\n" );
+ for( i=0; i<m_dat; ++i ) {
+ t = (mydata->user_t)[i];
+ y = (mydata->user_y)[i];
+ f = mydata->user_func( t, par );
+ printf( " t[%2d]=%12g y=%12g fit=%12g residue=%12g\n",
+ i, t, y, f, y-f );
+ }
+ }
+}
diff --git a/src/lmfit/lm_eval.h b/src/lmfit/lm_eval.h
new file mode 100644
index 0000000..331a8f2
--- /dev/null
+++ b/src/lmfit/lm_eval.h
@@ -0,0 +1,11 @@
+typedef struct {
+ double* user_t;
+ double* user_y;
+ double (*user_func)( double user_t_point, double* par );
+} lm_data_type;
+
+void lm_evaluate_default( double* par, int m_dat, double* fvec,
+ void *data, int *info );
+
+void lm_print_default( int n_par, double* par, int m_dat, double* fvec,
+ void *data, int iflag, int iter, int nfev );
diff --git a/src/lmfit/lmmin.c b/src/lmfit/lmmin.c
new file mode 100644
index 0000000..fdf634e
--- /dev/null
+++ b/src/lmfit/lmmin.c
@@ -0,0 +1,1320 @@
+/*
+ * lmfit
+ *
+ * Solves or minimizes the sum of squares of m nonlinear
+ * functions of n variables.
+ *
+ * From public domain Fortran version
+ * of Argonne National Laboratories MINPACK
+ * argonne national laboratory. minpack project. march 1980.
+ * burton s. garbow, kenneth e. hillstrom, jorge j. more
+ * C translation by Steve Moshier
+ * Joachim Wuttke converted the source into C++ compatible ANSI style
+ * and provided a simplified interface
+ */
+
+
+#include <stdlib.h>
+#include <math.h>
+#include "lmmin.h"
+#define _LMDIF
+
+/* *********************** high-level interface **************************** */
+
+
+void lm_initialize_control( lm_control_type *control )
+{
+ control->maxcall = 100;
+ control->epsilon = 1.e-14;
+ control->stepbound = 100.;
+ control->ftol = 1.e-14;
+ control->xtol = 1.e-14;
+ control->gtol = 1.e-14;
+}
+
+void lm_minimize( int m_dat, int n_par, double* par,
+ lm_evaluate_ftype *evaluate, lm_print_ftype *printout,
+ void *data, lm_control_type *control )
+{
+
+// *** allocate work space.
+
+ double *fvec, *diag, *fjac, *qtf, *wa1, *wa2, *wa3, *wa4;
+ int *ipvt;
+
+ int n = n_par;
+ int m = m_dat;
+
+ if (!(fvec = (double*) malloc( m*sizeof(double))) ||
+ !(diag = (double*) malloc(n* sizeof(double))) ||
+ !(qtf = (double*) malloc(n* sizeof(double))) ||
+ !(fjac = (double*) malloc(n*m*sizeof(double))) ||
+ !(wa1 = (double*) malloc(n* sizeof(double))) ||
+ !(wa2 = (double*) malloc(n* sizeof(double))) ||
+ !(wa3 = (double*) malloc(n* sizeof(double))) ||
+ !(wa4 = (double*) malloc( m*sizeof(double))) ||
+ !(ipvt = (int*) malloc(n* sizeof(int)))) {
+ control->info = 9;
+ return;
+ }
+
+// *** perform fit.
+
+ control->info = 0;
+ control->nfev = 0;
+
+ // this goes through the modified legacy interface:
+ lm_lmdif( m, n, par, fvec, control->ftol, control->xtol, control->gtol,
+ control->maxcall*(n+1), control->epsilon, diag, 1,
+ control->stepbound, &(control->info),
+ &(control->nfev), fjac, ipvt, qtf, wa1, wa2, wa3, wa4,
+ evaluate, printout, data );
+
+ (*printout)( n, par, m, fvec, data, -1, 0, control->nfev );
+ control->fnorm = lm_enorm(m, fvec);
+ if (control->info < 0 ) control->info = 10;
+
+// *** clean up.
+
+ free(fvec);
+ free(diag);
+ free(qtf);
+ free(fjac);
+ free(wa1);
+ free(wa2);
+ free(wa3 );
+ free(wa4);
+ free(ipvt);
+}
+
+
+// ***** the following messages are referenced by the variable info.
+
+char *lm_infmsg[] = {
+ "improper input parameters",
+ "the relative error in the sum of squares is at most tol",
+ "the relative error between x and the solution is at most tol",
+ "both errors are at most tol",
+ "fvec is orthogonal to the columns of the jacobian to machine precision",
+ "number of calls to fcn has reached or exceeded 200*(n+1)",
+ "ftol is too small. no further reduction in the sum of squares is possible",
+ "xtol too small. no further improvement in approximate solution x possible",
+ "gtol too small. no further improvement in approximate solution x possible",
+ "not enough memory",
+ "break requested within function evaluation"
+};
+
+char *lm_shortmsg[] = {
+ "invalid input",
+ "success (f)",
+ "success (p)",
+ "success (f,p)",
+ "degenerate",
+ "call limit",
+ "failed (f)",
+ "failed (p)",
+ "failed (o)",
+ "no memory",
+ "user break"
+};
+
+
+/* ************************** implementation ******************************* */
+
+
+#undef BUG
+#if BUG
+#include <stdio.h>
+#endif
+
+// the following values seem good for an x86:
+#define LM_MACHEP .555e-16 /* resolution of arithmetic */
+#define LM_DWARF 9.9e-324 /* smallest nonzero number */
+// the follwoing values should work on any machine:
+// #define LM_MACHEP 1.2e-16
+// #define LM_DWARF 1.0e-38
+
+// the squares of the following constants shall not under/overflow:
+// these values seem good for an x86:
+#define LM_SQRT_DWARF 1.e-160
+#define LM_SQRT_GIANT 1.e150
+// the following values should work on any machine:
+// #define LM_SQRT_DWARF 3.834e-20
+// #define LM_SQRT_GIANT 1.304e19
+
+
+void lm_qrfac( int m, int n, double* a, int pivot, int* ipvt,
+ double* rdiag, double* acnorm, double* wa);
+void lm_qrsolv(int n, double* r, int ldr, int* ipvt, double* diag,
+ double* qtb, double* x, double* sdiag, double* wa);
+void lm_lmpar( int n, double* r, int ldr, int* ipvt, double* diag, double* qtb,
+ double delta, double* par, double* x, double* sdiag,
+ double* wa1, double* wa2);
+
+#define MIN(a,b) (((a)<=(b)) ? (a) : (b))
+#define MAX(a,b) (((a)>=(b)) ? (a) : (b))
+#define SQR(x) (x)*(x)
+
+
+// ***** the low-level legacy interface for full control.
+
+void lm_lmdif( int m, int n, double* x, double* fvec, double ftol, double xtol,
+ double gtol, int maxfev, double epsfcn, double* diag, int mode,
+ double factor, int *info, int *nfev,
+ double* fjac, int* ipvt, double* qtf,
+ double* wa1, double* wa2, double* wa3, double* wa4,
+ lm_evaluate_ftype *evaluate, lm_print_ftype *printout,
+ void *data )
+{
+/*
+ * the purpose of lmdif is to minimize the sum of the squares of
+ * m nonlinear functions in n variables by a modification of
+ * the levenberg-marquardt algorithm. the user must provide a
+ * subroutine evaluate which calculates the functions. the jacobian
+ * is then calculated by a forward-difference approximation.
+ *
+ * the multi-parameter interface lm_lmdif is for users who want
+ * full control and flexibility. most users will be better off using
+ * the simpler interface lmfit provided above.
+ *
+ * the parameters are the same as in the legacy FORTRAN implementation,
+ * with the following exceptions:
+ * the old parameter ldfjac which gave leading dimension of fjac has
+ * been deleted because this C translation makes no use of two-
+ * dimensional arrays;
+ * the old parameter nprint has been deleted; printout is now controlled
+ * by the user-supplied routine *printout;
+ * the parameter field *data and the function parameters *evaluate and
+ * *printout have been added; they help avoiding global variables.
+ *
+ * parameters:
+ *
+ * m is a positive integer input variable set to the number
+ * of functions.
+ *
+ * n is a positive integer input variable set to the number
+ * of variables. n must not exceed m.
+ *
+ * x is an array of length n. on input x must contain
+ * an initial estimate of the solution vector. on output x
+ * contains the final estimate of the solution vector.
+ *
+ * fvec is an output array of length m which contains
+ * the functions evaluated at the output x.
+ *
+ * ftol is a nonnegative input variable. termination
+ * occurs when both the actual and predicted relative
+ * reductions in the sum of squares are at most ftol.
+ * therefore, ftol measures the relative error desired
+ * in the sum of squares.
+ *
+ * xtol is a nonnegative input variable. termination
+ * occurs when the relative error between two consecutive
+ * iterates is at most xtol. therefore, xtol measures the
+ * relative error desired in the approximate solution.
+ *
+ * gtol is a nonnegative input variable. termination
+ * occurs when the cosine of the angle between fvec and
+ * any column of the jacobian is at most gtol in absolute
+ * value. therefore, gtol measures the orthogonality
+ * desired between the function vector and the columns
+ * of the jacobian.
+ *
+ * maxfev is a positive integer input variable. termination
+ * occurs when the number of calls to lm_fcn is at least
+ * maxfev by the end of an iteration.
+ *
+ * epsfcn is an input variable used in determining a suitable
+ * step length for the forward-difference approximation. this
+ * approximation assumes that the relative errors in the
+ * functions are of the order of epsfcn. if epsfcn is less
+ * than the machine precision, it is assumed that the relative
+ * errors in the functions are of the order of the machine
+ * precision.
+ *
+ * diag is an array of length n. if mode = 1 (see below), diag is
+ * internally set. if mode = 2, diag must contain positive entries
+ * that serve as multiplicative scale factors for the variables.
+ *
+ * mode is an integer input variable. if mode = 1, the
+ * variables will be scaled internally. if mode = 2,
+ * the scaling is specified by the input diag. other
+ * values of mode are equivalent to mode = 1.
+ *
+ * factor is a positive input variable used in determining the
+ * initial step bound. this bound is set to the product of
+ * factor and the euclidean norm of diag*x if nonzero, or else
+ * to factor itself. in most cases factor should lie in the
+ * interval (.1,100.). 100. is a generally recommended value.
+ *
+ * info is an integer output variable that indicates the termination
+ * status of lm_lmdif as follows:
+ *
+ * info < 0 termination requested by user-supplied routine *evaluate;
+ *
+ * info = 0 improper input parameters;
+ *
+ * info = 1 both actual and predicted relative reductions
+ * in the sum of squares are at most ftol;
+ *
+ * info = 2 relative error between two consecutive iterates
+ * is at most xtol;
+ *
+ * info = 3 conditions for info = 1 and info = 2 both hold;
+ *
+ * info = 4 the cosine of the angle between fvec and any
+ * column of the jacobian is at most gtol in
+ * absolute value;
+ *
+ * info = 5 number of calls to lm_fcn has reached or
+ * exceeded maxfev;
+ *
+ * info = 6 ftol is too small. no further reduction in
+ * the sum of squares is possible;
+ *
+ * info = 7 xtol is too small. no further improvement in
+ * the approximate solution x is possible;
+ *
+ * info = 8 gtol is too small. fvec is orthogonal to the
+ * columns of the jacobian to machine precision;
+ *
+ * nfev is an output variable set to the number of calls to the
+ * user-supplied routine *evaluate.
+ *
+ * fjac is an output m by n array. the upper n by n submatrix
+ * of fjac contains an upper triangular matrix r with
+ * diagonal elements of nonincreasing magnitude such that
+ *
+ * t t t
+ * p *(jac *jac)*p = r *r,
+ *
+ * where p is a permutation matrix and jac is the final
+ * calculated jacobian. column j of p is column ipvt(j)
+ * (see below) of the identity matrix. the lower trapezoidal
+ * part of fjac contains information generated during
+ * the computation of r.
+ *
+ * ipvt is an integer output array of length n. ipvt
+ * defines a permutation matrix p such that jac*p = q*r,
+ * where jac is the final calculated jacobian, q is
+ * orthogonal (not stored), and r is upper triangular
+ * with diagonal elements of nonincreasing magnitude.
+ * column j of p is column ipvt(j) of the identity matrix.
+ *
+ * qtf is an output array of length n which contains
+ * the first n elements of the vector (q transpose)*fvec.
+ *
+ * wa1, wa2, and wa3 are work arrays of length n.
+ *
+ * wa4 is a work array of length m.
+ *
+ * the following parameters are newly introduced in this C translation:
+ *
+ * evaluate is the name of the subroutine which calculates the functions.
+ * a default implementation lm_evaluate_default is provided in lm_eval.c;
+ * alternatively, evaluate can be provided by a user calling program.
+ * it should be written as follows:
+ *
+ * void evaluate ( double* par, int m_dat, double* fvec,
+ * void *data, int *info )
+ * {
+ * // for ( i=0; i<m_dat; ++i )
+ * // calculate fvec[i] for given parameters par;
+ * // to stop the minimization,
+ * // set *info to a negative integer.
+ * }
+ *
+ * printout is the name of the subroutine which nforms about fit progress.
+ * a default implementation lm_print_default is provided in lm_eval.c;
+ * alternatively, printout can be provided by a user calling program.
+ * it should be written as follows:
+ *
+ * void printout ( int n_par, double* par, int m_dat, double* fvec,
+ * void *data, int iflag, int iter, int nfev )
+ * {
+ * // iflag : 0 (init) 1 (outer loop) 2(inner loop) -1(terminated)
+ * // iter : outer loop counter
+ * // nfev : number of calls to *evaluate
+ * }
+ *
+ * data is an input pointer to an arbitrary structure that is passed to
+ * evaluate. typically, it contains experimental data to be fitted.
+ *
+ */
+ int i, iter, j;
+ double actred, delta, dirder, eps, fnorm, fnorm1, gnorm, par, pnorm,
+ prered, ratio, step, sum, temp, temp1, temp2, temp3, xnorm;
+ static double p1 = 0.1;
+ static double p5 = 0.5;
+ static double p25 = 0.25;
+ static double p75 = 0.75;
+ static double p0001 = 1.0e-4;
+
+ *nfev = 0; // function evaluation counter
+ iter = 1; // outer loop counter
+ par = 0; // levenberg-marquardt parameter
+ delta = 0; // just to prevent a warning (initialization within if-clause)
+ xnorm = 0; // dito
+
+ temp = MAX(epsfcn,LM_MACHEP);
+ eps = sqrt(temp); // used in calculating the Jacobian by forward differences
+
+// *** check the input parameters for errors.
+
+ if ( (n <= 0) || (m < n) || (ftol < 0.)
+ || (xtol < 0.) || (gtol < 0.) || (maxfev <= 0) || (factor <= 0.) )
+ {
+ *info = 0; // invalid parameter
+ return;
+ }
+ if ( mode == 2 ) /* scaling by diag[] */
+ {
+ for ( j=0; j<n; j++ ) /* check for nonpositive elements */
+ {
+ if ( diag[j] <= 0.0 )
+ {
+ *info = 0; // invalid parameter
+ return;
+ }
+ }
+ }
+#if BUG
+ printf( "lmdif\n" );
+#endif
+
+// *** evaluate the function at the starting point and calculate its norm.
+
+ *info = 0;
+ (*evaluate)( x, m, fvec, data, info );
+ (*printout)( n, x, m, fvec, data, 0, 0, ++(*nfev) );
+ if ( *info < 0 ) return;
+ fnorm = lm_enorm(m,fvec);
+
+// *** the outer loop.
+
+ do {
+#if BUG
+ printf( "lmdif/ outer loop iter=%d nfev=%d fnorm=%.10e\n",
+ iter, *nfev, fnorm );
+#endif
+
+// O** calculate the jacobian matrix.
+
+ for ( j=0; j<n; j++ )
+ {
+ temp = x[j];
+ step = eps * fabs(temp);
+ if (step == 0.) step = eps;
+ x[j] = temp + step;
+ *info = 0;
+ (*evaluate)( x, m, wa4, data, info );
+ (*printout)( n, x, m, wa4, data, 1, iter, ++(*nfev) );
+ if ( *info < 0 ) return; // user requested break
+ x[j] = temp;
+ for ( i=0; i<m; i++ )
+ fjac[j*m+i] = (wa4[i] - fvec[i]) / step;
+ }
+#if BUG>1
+ // DEBUG: print the entire matrix
+ for ( i=0; i<m; i++ )
+ {
+ for ( j=0; j<n; j++ )
+ printf( "%.5e ", y[j*m+i] );
+ printf( "\n" );
+ }
+#endif
+
+// O** compute the qr factorization of the jacobian.
+
+ lm_qrfac( m, n, fjac, 1, ipvt, wa1, wa2, wa3);
+
+// O** on the first iteration ...
+
+ if (iter == 1)
+ {
+ if (mode != 2)
+// ... scale according to the norms of the columns of the initial jacobian.
+ {
+ for ( j=0; j<n; j++ )
+ {
+ diag[j] = wa2[j];
+ if ( wa2[j] == 0. )
+ diag[j] = 1.;
+ }
+ }
+
+// ... calculate the norm of the scaled x and
+// initialize the step bound delta.
+
+ for ( j=0; j<n; j++ )
+ wa3[j] = diag[j] * x[j];
+
+ xnorm = lm_enorm( n, wa3 );
+ delta = factor*xnorm;
+ if (delta == 0.)
+ delta = factor;
+ }
+
+// O** form (q transpose)*fvec and store the first n components in qtf.
+
+ for ( i=0; i<m; i++ )
+ wa4[i] = fvec[i];
+
+ for ( j=0; j<n; j++ )
+ {
+ temp3 = fjac[j*m+j];
+ if (temp3 != 0.)
+ {
+ sum = 0;
+ for ( i=j; i<m; i++ )
+ sum += fjac[j*m+i] * wa4[i];
+ temp = -sum / temp3;
+ for ( i=j; i<m; i++ )
+ wa4[i] += fjac[j*m+i] * temp;
+ }
+ fjac[j*m+j] = wa1[j];
+ qtf[j] = wa4[j];
+ }
+
+// O** compute the norm of the scaled gradient and test for convergence.
+
+ gnorm = 0;
+ if ( fnorm != 0 )
+ {
+ for ( j=0; j<n; j++ )
+ {
+ if ( wa2[ ipvt[j] ] == 0 ) continue;
+
+ sum = 0.;
+ for ( i=0; i<=j; i++ )
+ sum += fjac[j*m+i] * qtf[i] / fnorm;
+ gnorm = MAX( gnorm, fabs(sum/wa2[ ipvt[j] ]) );
+ }
+ }
+
+ if ( gnorm <= gtol )
+ {
+ *info = 4;
+ return;
+ }
+
+// O** rescale if necessary.
+
+ if ( mode != 2 )
+ {
+ for ( j=0; j<n; j++ )
+ diag[j] = MAX(diag[j],wa2[j]);
+ }
+
+// O** the inner loop.
+
+ do {
+#if BUG
+ printf( "lmdif/ inner loop iter=%d nfev=%d\n", iter, *nfev );
+#endif
+
+// OI* determine the levenberg-marquardt parameter.
+
+ lm_lmpar( n,fjac,m,ipvt,diag,qtf,delta,&par,wa1,wa2,wa3,wa4 );
+
+// OI* store the direction p and x + p. calculate the norm of p.
+
+ for ( j=0; j<n; j++ )
+ {
+ wa1[j] = -wa1[j];
+ wa2[j] = x[j] + wa1[j];
+ wa3[j] = diag[j]*wa1[j];
+ }
+ pnorm = lm_enorm(n,wa3);
+
+// OI* on the first iteration, adjust the initial step bound.
+
+ if ( *nfev<= 1+n ) // bug corrected by J. Wuttke in 2004
+ delta = MIN(delta,pnorm);
+
+// OI* evaluate the function at x + p and calculate its norm.
+
+ *info = 0;
+ (*evaluate)( wa2, m, wa4, data, info );
+ (*printout)( n, x, m, wa4, data, 2, iter, ++(*nfev) );
+ if ( *info < 0 ) return; // user requested break
+
+ fnorm1 = lm_enorm(m,wa4);
+#if BUG
+ printf( "lmdif/ pnorm %.10e fnorm1 %.10e fnorm %.10e"
+ " delta=%.10e par=%.10e\n",
+ pnorm, fnorm1, fnorm, delta, par );
+#endif
+
+// OI* compute the scaled actual reduction.
+
+ if ( p1*fnorm1 < fnorm )
+ actred = 1 - SQR( fnorm1/fnorm );
+ else
+ actred = -1;
+
+// OI* compute the scaled predicted reduction and
+// the scaled directional derivative.
+
+ for ( j=0; j<n; j++ )
+ {
+ wa3[j] = 0;
+ for ( i=0; i<=j; i++ )
+ wa3[i] += fjac[j*m+i]*wa1[ ipvt[j] ];
+ }
+ temp1 = lm_enorm(n,wa3) / fnorm;
+ temp2 = sqrt(par) * pnorm / fnorm;
+ prered = SQR(temp1) + 2 * SQR(temp2);
+ dirder = - ( SQR(temp1) + SQR(temp2) );
+
+// OI* compute the ratio of the actual to the predicted reduction.
+
+ ratio = prered!=0 ? actred/prered : 0;
+#if BUG
+ printf( "lmdif/ actred=%.10e prered=%.10e ratio=%.10e"
+ " sq(1)=%.10e sq(2)=%.10e dd=%.10e\n",
+ actred, prered, prered!=0 ? ratio : 0.,
+ SQR(temp1), SQR(temp2), dirder );
+#endif
+
+// OI* update the step bound.
+
+ if (ratio <= p25)
+ {
+ if (actred >= 0.)
+ temp = p5;
+ else
+ temp = p5*dirder/(dirder + p5*actred);
+ if ( p1*fnorm1 >= fnorm || temp < p1 )
+ temp = p1;
+ delta = temp * MIN(delta,pnorm/p1);
+ par /= temp;
+ }
+ else if ( par == 0. || ratio >= p75 )
+ {
+ delta = pnorm/p5;
+ par *= p5;
+ }
+
+// OI* test for successful iteration...
+
+ if (ratio >= p0001)
+ {
+
+// ... successful iteration. update x, fvec, and their norms.
+
+ for ( j=0; j<n; j++ )
+ {
+ x[j] = wa2[j];
+ wa2[j] = diag[j]*x[j];
+ }
+ for ( i=0; i<m; i++ )
+ fvec[i] = wa4[i];
+ xnorm = lm_enorm(n,wa2);
+ fnorm = fnorm1;
+ iter++;
+ }
+#if BUG
+ else {
+ printf( "ATTN: iteration considered unsuccessful\n" );
+ }
+#endif
+
+// OI* tests for convergence ( otherwise *info = 1, 2, or 3 )
+
+ *info = 0; // do not terminate (unless overwritten by nonzero value)
+ if ( fabs(actred) <= ftol && prered <= ftol && p5*ratio <= 1 )
+ *info = 1;
+ if (delta <= xtol*xnorm)
+ *info += 2;
+ if ( *info != 0)
+ return;
+
+// OI* tests for termination and stringent tolerances.
+
+ if ( *nfev >= maxfev)
+ *info = 5;
+ if ( fabs(actred) <= LM_MACHEP &&
+ prered <= LM_MACHEP && p5*ratio <= 1 )
+ *info = 6;
+ if (delta <= LM_MACHEP*xnorm)
+ *info = 7;
+ if (gnorm <= LM_MACHEP)
+ *info = 8;
+ if ( *info != 0)
+ return;
+
+// OI* end of the inner loop. repeat if iteration unsuccessful.
+
+ } while (ratio < p0001);
+
+// O** end of the outer loop.
+
+ } while (1);
+
+}
+
+
+
+void lm_lmpar(int n, double* r, int ldr, int* ipvt, double* diag, double* qtb,
+ double delta, double* par, double* x, double* sdiag,
+ double* wa1, double* wa2)
+{
+/* given an m by n matrix a, an n by n nonsingular diagonal
+ * matrix d, an m-vector b, and a positive number delta,
+ * the problem is to determine a value for the parameter
+ * par such that if x solves the system
+ *
+ * a*x = b , sqrt(par)*d*x = 0 ,
+ *
+ * in the least squares sense, and dxnorm is the euclidean
+ * norm of d*x, then either par is 0. and
+ *
+ * (dxnorm-delta) .le. 0.1*delta ,
+ *
+ * or par is positive and
+ *
+ * abs(dxnorm-delta) .le. 0.1*delta .
+ *
+ * this subroutine completes the solution of the problem
+ * if it is provided with the necessary information from the
+ * qr factorization, with column pivoting, of a. that is, if
+ * a*p = q*r, where p is a permutation matrix, q has orthogonal
+ * columns, and r is an upper triangular matrix with diagonal
+ * elements of nonincreasing magnitude, then lmpar expects
+ * the full upper triangle of r, the permutation matrix p,
+ * and the first n components of (q transpose)*b. on output
+ * lmpar also provides an upper triangular matrix s such that
+ *
+ * t t t
+ * p *(a *a + par*d*d)*p = s *s .
+ *
+ * s is employed within lmpar and may be of separate interest.
+ *
+ * only a few iterations are generally needed for convergence
+ * of the algorithm. if, however, the limit of 10 iterations
+ * is reached, then the output par will contain the best
+ * value obtained so far.
+ *
+ * parameters:
+ *
+ * n is a positive integer input variable set to the order of r.
+ *
+ * r is an n by n array. on input the full upper triangle
+ * must contain the full upper triangle of the matrix r.
+ * on output the full upper triangle is unaltered, and the
+ * strict lower triangle contains the strict upper triangle
+ * (transposed) of the upper triangular matrix s.
+ *
+ * ldr is a positive integer input variable not less than n
+ * which specifies the leading dimension of the array r.
+ *
+ * ipvt is an integer input array of length n which defines the
+ * permutation matrix p such that a*p = q*r. column j of p
+ * is column ipvt(j) of the identity matrix.
+ *
+ * diag is an input array of length n which must contain the
+ * diagonal elements of the matrix d.
+ *
+ * qtb is an input array of length n which must contain the first
+ * n elements of the vector (q transpose)*b.
+ *
+ * delta is a positive input variable which specifies an upper
+ * bound on the euclidean norm of d*x.
+ *
+ * par is a nonnegative variable. on input par contains an
+ * initial estimate of the levenberg-marquardt parameter.
+ * on output par contains the final estimate.
+ *
+ * x is an output array of length n which contains the least
+ * squares solution of the system a*x = b, sqrt(par)*d*x = 0,
+ * for the output par.
+ *
+ * sdiag is an output array of length n which contains the
+ * diagonal elements of the upper triangular matrix s.
+ *
+ * wa1 and wa2 are work arrays of length n.
+ *
+ */
+ int i, iter, j, nsing;
+ double dxnorm, fp, fp_old, gnorm, parc, parl, paru;
+ double sum, temp;
+ static double p1 = 0.1;
+ static double p001 = 0.001;
+
+#if BUG
+ printf( "lmpar\n" );
+#endif
+
+// *** compute and store in x the gauss-newton direction. if the
+// jacobian is rank-deficient, obtain a least squares solution.
+
+ nsing = n;
+ for ( j=0; j<n; j++ )
+ {
+ wa1[j] = qtb[j];
+ if ( r[j*ldr+j] == 0 && nsing == n )
+ nsing = j;
+ if (nsing < n)
+ wa1[j] = 0;
+ }
+#if BUG
+ printf( "nsing %d ", nsing );
+#endif
+ for ( j=nsing-1; j>=0; j-- )
+ {
+ wa1[j] = wa1[j]/r[j+ldr*j];
+ temp = wa1[j];
+ for ( i=0; i<j; i++ )
+ wa1[i] -= r[j*ldr+i]*temp;
+ }
+
+ for ( j=0; j<n; j++ )
+ x[ ipvt[j] ] = wa1[j];
+
+// *** initialize the iteration counter.
+// evaluate the function at the origin, and test
+// for acceptance of the gauss-newton direction.
+
+ iter = 0;
+ for ( j=0; j<n; j++ )
+ wa2[j] = diag[j]*x[j];
+ dxnorm = lm_enorm(n,wa2);
+ fp = dxnorm - delta;
+ if (fp <= p1*delta)
+ {
+#if BUG
+ printf( "lmpar/ terminate (fp<delta/10\n" );
+#endif
+ *par = 0;
+ return;
+ }
+
+// *** if the jacobian is not rank deficient, the newton
+// step provides a lower bound, parl, for the 0. of
+// the function. otherwise set this bound to 0..
+
+ parl = 0;
+ if (nsing >= n)
+ {
+ for ( j=0; j<n; j++ )
+ wa1[j] = diag[ ipvt[j] ] * wa2[ ipvt[j] ] / dxnorm;
+
+ for ( j=0; j<n; j++ )
+ {
+ sum = 0.;
+ for ( i=0; i<j; i++ )
+ sum += r[j*ldr+i]*wa1[i];
+ wa1[j] = (wa1[j] - sum)/r[j+ldr*j];
+ }
+ temp = lm_enorm(n,wa1);
+ parl = fp/delta/temp/temp;
+ }
+
+// *** calculate an upper bound, paru, for the 0. of the function.
+
+ for ( j=0; j<n; j++ )
+ {
+ sum = 0;
+ for ( i=0; i<=j; i++ )
+ sum += r[j*ldr+i]*qtb[i];
+ wa1[j] = sum/diag[ ipvt[j] ];
+ }
+ gnorm = lm_enorm(n,wa1);
+ paru = gnorm/delta;
+ if (paru == 0.)
+ paru = LM_DWARF/MIN(delta,p1);
+
+// *** if the input par lies outside of the interval (parl,paru),
+// set par to the closer endpoint.
+
+ *par = MAX( *par,parl);
+ *par = MIN( *par,paru);
+ if ( *par == 0.)
+ *par = gnorm/dxnorm;
+#if BUG
+ printf( "lmpar/ parl %.4e par %.4e paru %.4e\n", parl, *par, paru );
+#endif
+
+// *** iterate.
+
+ for ( ; ; iter++ ) {
+
+// *** evaluate the function at the current value of par.
+
+ if ( *par == 0.)
+ *par = MAX(LM_DWARF,p001*paru);
+ temp = sqrt( *par );
+ for ( j=0; j<n; j++ )
+ wa1[j] = temp*diag[j];
+ lm_qrsolv( n, r, ldr, ipvt, wa1, qtb, x, sdiag, wa2);
+ for ( j=0; j<n; j++ )
+ wa2[j] = diag[j]*x[j];
+ dxnorm = lm_enorm(n,wa2);
+ fp_old = fp;
+ fp = dxnorm - delta;
+
+// *** if the function is small enough, accept the current value
+// of par. also test for the exceptional cases where parl
+// is 0. or the number of iterations has reached 10.
+
+ if ( fabs(fp) <= p1*delta
+ || (parl == 0. && fp <= fp_old && fp_old < 0.)
+ || iter == 10 )
+ break; // the only exit from this loop
+
+// *** compute the Newton correction.
+
+ for ( j=0; j<n; j++ )
+ wa1[j] = diag[ ipvt[j] ] * wa2[ ipvt[j] ] / dxnorm;
+
+ for ( j=0; j<n; j++ )
+ {
+ wa1[j] = wa1[j]/sdiag[j];
+ for ( i=j+1; i<n; i++ )
+ wa1[i] -= r[j*ldr+i]*wa1[j];
+ }
+ temp = lm_enorm( n, wa1);
+ parc = fp/delta/temp/temp;
+
+// *** depending on the sign of the function, update parl or paru.
+
+ if (fp > 0)
+ parl = MAX(parl, *par);
+ else if (fp < 0)
+ paru = MIN(paru, *par);
+ // the case fp==0 is precluded by the break condition
+
+// *** compute an improved estimate for par.
+
+ *par = MAX(parl, *par + parc);
+
+ }
+
+}
+
+
+
+void lm_qrfac(int m, int n, double* a, int pivot, int* ipvt,
+ double* rdiag, double* acnorm, double* wa)
+{
+/*
+ * this subroutine uses householder transformations with column
+ * pivoting (optional) to compute a qr factorization of the
+ * m by n matrix a. that is, qrfac determines an orthogonal
+ * matrix q, a permutation matrix p, and an upper trapezoidal
+ * matrix r with diagonal elements of nonincreasing magnitude,
+ * such that a*p = q*r. the householder transformation for
+ * column k, k = 1,2,...,min(m,n), is of the form
+ *
+ * t
+ * i - (1/u(k))*u*u
+ *
+ * where u has 0.s in the first k-1 positions. the form of
+ * this transformation and the method of pivoting first
+ * appeared in the corresponding linpack subroutine.
+ *
+ * parameters:
+ *
+ * m is a positive integer input variable set to the number
+ * of rows of a.
+ *
+ * n is a positive integer input variable set to the number
+ * of columns of a.
+ *
+ * a is an m by n array. on input a contains the matrix for
+ * which the qr factorization is to be computed. on output
+ * the strict upper trapezoidal part of a contains the strict
+ * upper trapezoidal part of r, and the lower trapezoidal
+ * part of a contains a factored form of q (the non-trivial
+ * elements of the u vectors described above).
+ *
+ * pivot is a logical input variable. if pivot is set true,
+ * then column pivoting is enforced. if pivot is set false,
+ * then no column pivoting is done.
+ *
+ * ipvt is an integer output array of length lipvt. ipvt
+ * defines the permutation matrix p such that a*p = q*r.
+ * column j of p is column ipvt(j) of the identity matrix.
+ * if pivot is false, ipvt is not referenced.
+ *
+ * rdiag is an output array of length n which contains the
+ * diagonal elements of r.
+ *
+ * acnorm is an output array of length n which contains the
+ * norms of the corresponding columns of the input matrix a.
+ * if this information is not needed, then acnorm can coincide
+ * with rdiag.
+ *
+ * wa is a work array of length n. if pivot is false, then wa
+ * can coincide with rdiag.
+ *
+ */
+ int i, j, k, kmax, minmn;
+ double ajnorm, sum, temp;
+ static double p05 = 0.05;
+
+// *** compute the initial column norms and initialize several arrays.
+
+ for ( j=0; j<n; j++ )
+ {
+ acnorm[j] = lm_enorm(m, &a[j*m]);
+ rdiag[j] = acnorm[j];
+ wa[j] = rdiag[j];
+ if ( pivot )
+ ipvt[j] = j;
+ }
+#if BUG
+ printf( "qrfac\n" );
+#endif
+
+// *** reduce a to r with householder transformations.
+
+ minmn = MIN(m,n);
+ for ( j=0; j<minmn; j++ )
+ {
+ if ( !pivot ) goto pivot_ok;
+
+// *** bring the column of largest norm into the pivot position.
+
+ kmax = j;
+ for ( k=j+1; k<n; k++ )
+ if (rdiag[k] > rdiag[kmax])
+ kmax = k;
+ if (kmax == j) goto pivot_ok; // bug fixed in rel 2.1
+
+ for ( i=0; i<m; i++ )
+ {
+ temp = a[j*m+i];
+ a[j*m+i] = a[kmax*m+i];
+ a[kmax*m+i] = temp;
+ }
+ rdiag[kmax] = rdiag[j];
+ wa[kmax] = wa[j];
+ k = ipvt[j];
+ ipvt[j] = ipvt[kmax];
+ ipvt[kmax] = k;
+
+ pivot_ok:
+
+// *** compute the Householder transformation to reduce the
+// j-th column of a to a multiple of the j-th unit vector.
+
+ ajnorm = lm_enorm( m-j, &a[j*m+j] );
+ if (ajnorm == 0.)
+ {
+ rdiag[j] = 0;
+ continue;
+ }
+
+ if (a[j*m+j] < 0.)
+ ajnorm = -ajnorm;
+ for ( i=j; i<m; i++ )
+ a[j*m+i] /= ajnorm;
+ a[j*m+j] += 1;
+
+// *** apply the transformation to the remaining columns
+// and update the norms.
+
+ for ( k=j+1; k<n; k++ )
+ {
+ sum = 0;
+
+ for ( i=j; i<m; i++ )
+ sum += a[j*m+i]*a[k*m+i];
+
+ temp = sum/a[j+m*j];
+
+ for ( i=j; i<m; i++ )
+ a[k*m+i] -= temp * a[j*m+i];
+
+ if ( pivot && rdiag[k] != 0. )
+ {
+ temp = a[m*k+j]/rdiag[k];
+ temp = MAX( 0., 1-temp*temp );
+ rdiag[k] *= sqrt(temp);
+ temp = rdiag[k]/wa[k];
+ if ( p05*SQR(temp) <= LM_MACHEP )
+ {
+ rdiag[k] = lm_enorm( m-j-1, &a[m*k+j+1]);
+ wa[k] = rdiag[k];
+ }
+ }
+ }
+
+ rdiag[j] = -ajnorm;
+ }
+}
+
+
+
+void lm_qrsolv(int n, double* r, int ldr, int* ipvt, double* diag,
+ double* qtb, double* x, double* sdiag, double* wa)
+{
+/*
+ * given an m by n matrix a, an n by n diagonal matrix d,
+ * and an m-vector b, the problem is to determine an x which
+ * solves the system
+ *
+ * a*x = b , d*x = 0 ,
+ *
+ * in the least squares sense.
+ *
+ * this subroutine completes the solution of the problem
+ * if it is provided with the necessary information from the
+ * qr factorization, with column pivoting, of a. that is, if
+ * a*p = q*r, where p is a permutation matrix, q has orthogonal
+ * columns, and r is an upper triangular matrix with diagonal
+ * elements of nonincreasing magnitude, then qrsolv expects
+ * the full upper triangle of r, the permutation matrix p,
+ * and the first n components of (q transpose)*b. the system
+ * a*x = b, d*x = 0, is then equivalent to
+ *
+ * t t
+ * r*z = q *b , p *d*p*z = 0 ,
+ *
+ * where x = p*z. if this system does not have full rank,
+ * then a least squares solution is obtained. on output qrsolv
+ * also provides an upper triangular matrix s such that
+ *
+ * t t t
+ * p *(a *a + d*d)*p = s *s .
+ *
+ * s is computed within qrsolv and may be of separate interest.
+ *
+ * parameters
+ *
+ * n is a positive integer input variable set to the order of r.
+ *
+ * r is an n by n array. on input the full upper triangle
+ * must contain the full upper triangle of the matrix r.
+ * on output the full upper triangle is unaltered, and the
+ * strict lower triangle contains the strict upper triangle
+ * (transposed) of the upper triangular matrix s.
+ *
+ * ldr is a positive integer input variable not less than n
+ * which specifies the leading dimension of the array r.
+ *
+ * ipvt is an integer input array of length n which defines the
+ * permutation matrix p such that a*p = q*r. column j of p
+ * is column ipvt(j) of the identity matrix.
+ *
+ * diag is an input array of length n which must contain the
+ * diagonal elements of the matrix d.
+ *
+ * qtb is an input array of length n which must contain the first
+ * n elements of the vector (q transpose)*b.
+ *
+ * x is an output array of length n which contains the least
+ * squares solution of the system a*x = b, d*x = 0.
+ *
+ * sdiag is an output array of length n which contains the
+ * diagonal elements of the upper triangular matrix s.
+ *
+ * wa is a work array of length n.
+ *
+ */
+ int i, kk, j, k, nsing;
+ double qtbpj, sum, temp;
+ double sin, cos, tan, cotan; // these are local variables, not functions
+ static double p25 = 0.25;
+ static double p5 = 0.5;
+
+// *** copy r and (q transpose)*b to preserve input and initialize s.
+// in particular, save the diagonal elements of r in x.
+
+ for ( j=0; j<n; j++ )
+ {
+ for ( i=j; i<n; i++ )
+ r[j*ldr+i] = r[i*ldr+j];
+ x[j] = r[j*ldr+j];
+ wa[j] = qtb[j];
+ }
+#if BUG
+ printf( "qrsolv\n" );
+#endif
+
+// *** eliminate the diagonal matrix d using a givens rotation.
+
+ for ( j=0; j<n; j++ )
+ {
+
+// *** prepare the row of d to be eliminated, locating the
+// diagonal element using p from the qr factorization.
+
+ if (diag[ ipvt[j] ] == 0.)
+ goto L90;
+ for ( k=j; k<n; k++ )
+ sdiag[k] = 0.;
+ sdiag[j] = diag[ ipvt[j] ];
+
+// *** the transformations to eliminate the row of d
+// modify only a single element of (q transpose)*b
+// beyond the first n, which is initially 0..
+
+ qtbpj = 0.;
+ for ( k=j; k<n; k++ )
+ {
+
+// determine a givens rotation which eliminates the
+// appropriate element in the current row of d.
+
+ if (sdiag[k] == 0.)
+ continue;
+ kk = k + ldr * k; // <! keep this shorthand !>
+ if ( fabs(r[kk]) < fabs(sdiag[k]) )
+ {
+ cotan = r[kk]/sdiag[k];
+ sin = p5/sqrt(p25+p25*SQR(cotan));
+ cos = sin*cotan;
+ }
+ else
+ {
+ tan = sdiag[k]/r[kk];
+ cos = p5/sqrt(p25+p25*SQR(tan));
+ sin = cos*tan;
+ }
+
+// *** compute the modified diagonal element of r and
+// the modified element of ((q transpose)*b,0).
+
+ r[kk] = cos*r[kk] + sin*sdiag[k];
+ temp = cos*wa[k] + sin*qtbpj;
+ qtbpj = -sin*wa[k] + cos*qtbpj;
+ wa[k] = temp;
+
+// *** accumulate the tranformation in the row of s.
+
+ for ( i=k+1; i<n; i++ )
+ {
+ temp = cos*r[k*ldr+i] + sin*sdiag[i];
+ sdiag[i] = -sin*r[k*ldr+i] + cos*sdiag[i];
+ r[k*ldr+i] = temp;
+ }
+ }
+ L90:
+
+// *** store the diagonal element of s and restore
+// the corresponding diagonal element of r.
+
+ sdiag[j] = r[j*ldr+j];
+ r[j*ldr+j] = x[j];
+ }
+
+// *** solve the triangular system for z. if the system is
+// singular, then obtain a least squares solution.
+
+ nsing = n;
+ for ( j=0; j<n; j++ )
+ {
+ if ( sdiag[j] == 0. && nsing == n )
+ nsing = j;
+ if (nsing < n)
+ wa[j] = 0;
+ }
+
+ for ( j=nsing-1; j>=0; j-- )
+ {
+ sum = 0;
+ for ( i=j+1; i<nsing; i++ )
+ sum += r[j*ldr+i]*wa[i];
+ wa[j] = (wa[j] - sum)/sdiag[j];
+ }
+
+// *** permute the components of z back to components of x.
+
+ for ( j=0; j<n; j++ )
+ x[ ipvt[j] ] = wa[j];
+}
+
+
+
+double lm_enorm( int n, double *x )
+{
+/* given an n-vector x, this function calculates the
+ * euclidean norm of x.
+ *
+ * the euclidean norm is computed by accumulating the sum of
+ * squares in three different sums. the sums of squares for the
+ * small and large components are scaled so that no overflows
+ * occur. non-destructive underflows are permitted. underflows
+ * and overflows do not occur in the computation of the unscaled
+ * sum of squares for the intermediate components.
+ * the definitions of small, intermediate and large components
+ * depend on two constants, LM_SQRT_DWARF and LM_SQRT_GIANT. the main
+ * restrictions on these constants are that LM_SQRT_DWARF**2 not
+ * underflow and LM_SQRT_GIANT**2 not overflow.
+ *
+ * parameters
+ *
+ * n is a positive integer input variable.
+ *
+ * x is an input array of length n.
+ */
+ int i;
+ double agiant, s1, s2, s3, xabs, x1max, x3max, temp;
+
+ s1 = 0;
+ s2 = 0;
+ s3 = 0;
+ x1max = 0;
+ x3max = 0;
+ agiant = LM_SQRT_GIANT/( (double) n);
+
+ for ( i=0; i<n; i++ )
+ {
+ xabs = fabs(x[i]);
+ if ( xabs > LM_SQRT_DWARF && xabs < agiant )
+ {
+// ** sum for intermediate components.
+ s2 += xabs*xabs;
+ continue;
+ }
+
+ if ( xabs > LM_SQRT_DWARF )
+ {
+// ** sum for large components.
+ if (xabs > x1max)
+ {
+ temp = x1max/xabs;
+ s1 = 1 + s1*SQR(temp);
+ x1max = xabs;
+ }
+ else
+ {
+ temp = xabs/x1max;
+ s1 += SQR(temp);
+ }
+ continue;
+ }
+// ** sum for small components.
+ if (xabs > x3max)
+ {
+ temp = x3max/xabs;
+ s3 = 1 + s3*SQR(temp);
+ x3max = xabs;
+ }
+ else
+ {
+ if (xabs != 0.)
+ {
+ temp = xabs/x3max;
+ s3 += SQR(temp);
+ }
+ }
+ }
+
+// *** calculation of norm.
+
+ if (s1 != 0)
+ return x1max*sqrt(s1 + (s2/x1max)/x1max);
+ if (s2 != 0)
+ {
+ if (s2 >= x3max)
+ return sqrt( s2*(1+(x3max/s2)*(x3max*s3)) );
+ else
+ return sqrt( x3max*((s2/x3max)+(x3max*s3)) );
+ }
+
+ return x3max*sqrt(s3);
+}
diff --git a/src/lmfit/lmmin.h b/src/lmfit/lmmin.h
new file mode 100644
index 0000000..1a90f13
--- /dev/null
+++ b/src/lmfit/lmmin.h
@@ -0,0 +1,52 @@
+// parameters for calling the high-level interface lmfit
+// ( lmfit.c provides lm_initialize_control which sets default values ):
+typedef struct {
+ double ftol; // relative error desired in the sum of squares.
+ double xtol; // relative error between last two approximations.
+ double gtol; // orthogonality desired between fvec and its derivs.
+ double epsilon; // step used to calculate the jacobian.
+ double stepbound; // initial bound to steps in the outer loop.
+ double fnorm; // norm of the residue vector fvec.
+ int maxcall; // maximum number of iterations.
+ int nfev; // actual number of iterations.
+ int info; // status of minimization.
+} lm_control_type;
+
+
+// the subroutine that calculates fvec:
+typedef void (lm_evaluate_ftype) (
+ double* par, int m_dat, double* fvec, void *data, int *info );
+// default implementation therof, provided by lm_eval.c:
+void lm_evaluate_default (
+ double* par, int m_dat, double* fvec, void *data, int *info );
+
+// the subroutine that informs about fit progress:
+typedef void (lm_print_ftype) (
+ int n_par, double* par, int m_dat, double* fvec, void *data,
+ int iflag, int iter, int nfev );
+// default implementation therof, provided by lm_eval.c:
+void lm_print_default (
+ int n_par, double* par, int m_dat, double* fvec, void *data,
+ int iflag, int iter, int nfev );
+
+// compact high-level interface:
+void lm_initialize_control( lm_control_type *control );
+void lm_minimize ( int m_dat, int n_par, double* par,
+ lm_evaluate_ftype *evaluate, lm_print_ftype *printout,
+ void *data, lm_control_type *control );
+double lm_enorm( int, double* );
+
+// low-level interface for full control:
+void lm_lmdif( int m, int n, double* x, double* fvec, double ftol, double xtol,
+ double gtol, int maxfev, double epsfcn, double* diag, int mode,
+ double factor, int *info, int *nfev,
+ double* fjac, int* ipvt, double* qtf,
+ double* wa1, double* wa2, double* wa3, double* wa4,
+ lm_evaluate_ftype *evaluate, lm_print_ftype *printout,
+ void *data );
+
+
+#ifndef _LMDIF
+extern char *lm_infmsg[];
+extern char *lm_shortmsg[];
+#endif
diff --git a/src/oscpack/CHANGES b/src/oscpack/CHANGES
new file mode 100644
index 0000000..804df95
--- /dev/null
+++ b/src/oscpack/CHANGES
@@ -0,0 +1,68 @@
+September 28, 2005
+------------------
+
+Compared to the previous official snapshot (November 2004) the
+current version of oscpack includes a re-written set of network
+classes and some changes to the syntax of the networking code. It no
+longer uses threads, which means that you don't need to use sleep()
+if you are writing a simple single-threaded server, or you need to
+spawn your own threads in a more complex application.
+
+The list below summarises the changes if you are porting code from
+the previous release.
+
+ - there are no longer any threads in oscpack. if you need to
+ set up an asynchronous listener you can create your own thread
+ and call Run on an instance of SocketReceiveMultiplexer or
+ UdpListeningReceiveSocket (see ip/UdpSocket.h) yourself.
+
+ - host byte order is now used for network (IP) addresses
+
+ - functions which used to take two parameters <address, port>
+ now take an instance of IpEndpointName (see
+ ip/IpEndpointName.h) this class has a number of convenient
+ constructors for converting numbers and strings to internet
+ addresses. For example there is one which takes a string and
+ another that take the dotted address components as separate
+ parameters.
+
+ - The UdpTransmitPort class, formerly in UdpTransmitPort.h, is
+ now called UdpTransmitSocket, which is simply a convenience
+ class derived from UdpSocket (see ip/UdpSocket.h). Where you
+ used to use the constructor UdpTransmitPort( address, port) now
+ you can use UdpTransmitSocket( IpEndpointName( address, port )
+ ) or you can any of the other possible ctors to IpEndpointName
+ () (see above). The Send() method is unchanged.
+
+ - The packet listener base class is now located in
+ ip/PacketListener.h instead of PacketListenerPort.h. The
+ ProcessPacket method now has an additional parameter indicating
+ the remote endpoint
+
+ - The preferred way to set up listeners is with
+ SocketReceiveMultiplexer (in ip/UdpSocket.h), this also allows
+ attaching periodic timers. For simple applications which only
+ listen to a single socket with no timers you can use
+ UdpListeningReceiveSocket (also in UdpSocket.h) See
+ osc/OscReceiveTest.cpp or osc/OscDump.cpp for examples of this.
+ This is more or less equivalent to the UdpPacketListenerPort
+ object in the old oscpack versions except that you need to
+ explicitly call Run() before it will start receiving packets
+ and it runs in the same thread, not a separate thread so Run()
+ won't usually return.
+
+ - Explicit calls to InitializeNetworking() and
+ TerminateNetworking() are no longer required for simple
+ applications (more complex windows applications should
+ instantiate NetworkInitializer in main() or WinMain (see
+ ip/NetworkingUtils.h/.cpp)
+
+ - The OscPacketListener base class (OscPacketListener.h) was
+ added to make traversing OSC packets easier, it handles bundle
+ traversal automatically so you only need to process messages in
+ your derived classes.
+
+ - On Windows be sure to link with ws2_32.lib or you will see
+ a linker error about WSAEventSelect not being found. Also you
+ will need to link with winmm.lib for timeGetTime()
+
diff --git a/src/oscpack/IpEndpointName.cpp b/src/oscpack/IpEndpointName.cpp
new file mode 100644
index 0000000..77740d0
--- /dev/null
+++ b/src/oscpack/IpEndpointName.cpp
@@ -0,0 +1,81 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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 "IpEndpointName.h"
+
+#include <stdio.h>
+
+#include "NetworkingUtils.h"
+
+
+unsigned long IpEndpointName::GetHostByName( const char *s )
+{
+ return ::GetHostByName(s);
+}
+
+
+void IpEndpointName::AddressAsString( char *s ) const
+{
+ if( address == ANY_ADDRESS ){
+ sprintf( s, "<any>" );
+ }else{
+ sprintf( s, "%d.%d.%d.%d",
+ (int)((address >> 24) & 0xFF),
+ (int)((address >> 16) & 0xFF),
+ (int)((address >> 8) & 0xFF),
+ (int)(address & 0xFF) );
+ }
+}
+
+
+void IpEndpointName::AddressAndPortAsString( char *s ) const
+{
+ if( port == ANY_PORT ){
+ if( address == ANY_ADDRESS ){
+ sprintf( s, "<any>:<any>" );
+ }else{
+ sprintf( s, "%d.%d.%d.%d:<any>",
+ (int)((address >> 24) & 0xFF),
+ (int)((address >> 16) & 0xFF),
+ (int)((address >> 8) & 0xFF),
+ (int)(address & 0xFF) );
+ }
+ }else{
+ if( address == ANY_ADDRESS ){
+ sprintf( s, "<any>:%d", port );
+ }else{
+ sprintf( s, "%d.%d.%d.%d:%d",
+ (int)((address >> 24) & 0xFF),
+ (int)((address >> 16) & 0xFF),
+ (int)((address >> 8) & 0xFF),
+ (int)(address & 0xFF),
+ (int)port );
+ }
+ }
+}
diff --git a/src/oscpack/IpEndpointName.h b/src/oscpack/IpEndpointName.h
new file mode 100644
index 0000000..af10e72
--- /dev/null
+++ b/src/oscpack/IpEndpointName.h
@@ -0,0 +1,74 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_IPENDPOINTNAME_H
+#define INCLUDED_IPENDPOINTNAME_H
+
+
+class IpEndpointName{
+ static unsigned long GetHostByName( const char *s );
+public:
+ static const unsigned long ANY_ADDRESS = 0xFFFFFFFF;
+ static const int ANY_PORT = -1;
+
+ IpEndpointName()
+ : address( ANY_ADDRESS ), port( ANY_PORT ) {}
+ IpEndpointName( int port_ )
+ : address( ANY_ADDRESS ), port( port_ ) {}
+ IpEndpointName( unsigned long ipAddress_, int port_ )
+ : address( ipAddress_ ), port( port_ ) {}
+ IpEndpointName( const char *addressName, int port_=ANY_PORT )
+ : address( GetHostByName( addressName ) )
+ , port( port_ ) {}
+ IpEndpointName( int addressA, int addressB, int addressC, int addressD, int port_=ANY_PORT )
+ : address( ( (addressA << 24) | (addressB << 16) | (addressC << 8) | addressD ) )
+ , port( port_ ) {}
+
+ // address and port are maintained in host byte order here
+ unsigned long address;
+ int port;
+
+ enum { ADDRESS_STRING_LENGTH=17 };
+ void AddressAsString( char *s ) const;
+
+ enum { ADDRESS_AND_PORT_STRING_LENGTH=23};
+ void AddressAndPortAsString( char *s ) const;
+};
+
+inline bool operator==( const IpEndpointName& lhs, const IpEndpointName& rhs )
+{
+ return (lhs.address == rhs.address && lhs.port == rhs.port );
+}
+
+inline bool operator!=( const IpEndpointName& lhs, const IpEndpointName& rhs )
+{
+ return !(lhs == rhs);
+}
+
+#endif /* INCLUDED_IPENDPOINTNAME_H */
diff --git a/src/oscpack/LICENSE b/src/oscpack/LICENSE
new file mode 100644
index 0000000..23c9609
--- /dev/null
+++ b/src/oscpack/LICENSE
@@ -0,0 +1,28 @@
+oscpack -- Open Sound Control packet manipulation library
+http://www.audiomulch.com/~rossb/code/oscpack
+
+Copyright (c) 2004 Ross Bencina <rossb@audiomulch.com>
+
+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.
+
+Any person wishing to distribute modifications to the Software is
+requested to send the modifications to the original developer so that
+they can be incorporated into the canonical version.
+
+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.
+
diff --git a/src/oscpack/Makefile.am b/src/oscpack/Makefile.am
new file mode 100644
index 0000000..891aebb
--- /dev/null
+++ b/src/oscpack/Makefile.am
@@ -0,0 +1,13 @@
+ALL_H = IpEndpointName.h NetworkingUtils.h PacketListener.h TimerListener.h UdpSocket.h \
+ MessageMappingOscPacketListener.h OscPacketListener.h OscException.h \
+ OscPrintReceivedElements.h OscHostEndianness.h OscReceivedElements.h \
+ OscOutboundPacketStream.h OscTypes.h
+ALL_CPP = IpEndpointName.cpp NetworkingUtils.cpp UdpSocket.cpp \
+ OscOutboundPacketStream.cpp OscReceivedElements.cpp \
+ OscPrintReceivedElements.cpp OscTypes.cpp
+
+EXTRA_DIST = CHANGES LICENSE README TODO
+
+noinst_LTLIBRARIES = liboscpack.la
+liboscpack_la_SOURCES = $(ALL_CPP) $(ALL_H)
+
diff --git a/src/oscpack/Makefile.in b/src/oscpack/Makefile.in
new file mode 100644
index 0000000..ed2eb7d
--- /dev/null
+++ b/src/oscpack/Makefile.in
@@ -0,0 +1,593 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/oscpack
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in TODO
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+liboscpack_la_LIBADD =
+am__objects_1 = IpEndpointName.lo NetworkingUtils.lo UdpSocket.lo \
+ OscOutboundPacketStream.lo OscReceivedElements.lo \
+ OscPrintReceivedElements.lo OscTypes.lo
+am__objects_2 =
+am_liboscpack_la_OBJECTS = $(am__objects_1) $(am__objects_2)
+liboscpack_la_OBJECTS = $(am_liboscpack_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(liboscpack_la_SOURCES)
+DIST_SOURCES = $(liboscpack_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ALL_H = IpEndpointName.h NetworkingUtils.h PacketListener.h TimerListener.h UdpSocket.h \
+ MessageMappingOscPacketListener.h OscPacketListener.h OscException.h \
+ OscPrintReceivedElements.h OscHostEndianness.h OscReceivedElements.h \
+ OscOutboundPacketStream.h OscTypes.h
+
+ALL_CPP = IpEndpointName.cpp NetworkingUtils.cpp UdpSocket.cpp \
+ OscOutboundPacketStream.cpp OscReceivedElements.cpp \
+ OscPrintReceivedElements.cpp OscTypes.cpp
+
+EXTRA_DIST = CHANGES LICENSE README TODO
+noinst_LTLIBRARIES = liboscpack.la
+liboscpack_la_SOURCES = $(ALL_CPP) $(ALL_H)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/oscpack/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/oscpack/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+liboscpack.la: $(liboscpack_la_OBJECTS) $(liboscpack_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(liboscpack_la_OBJECTS) $(liboscpack_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/IpEndpointName.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NetworkingUtils.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OscOutboundPacketStream.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OscPrintReceivedElements.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OscReceivedElements.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OscTypes.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/UdpSocket.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/oscpack/MessageMappingOscPacketListener.h b/src/oscpack/MessageMappingOscPacketListener.h
new file mode 100644
index 0000000..0df0a4d
--- /dev/null
+++ b/src/oscpack/MessageMappingOscPacketListener.h
@@ -0,0 +1,73 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_MESSAGEMAPPINGOSCPACKETLISTENER_H
+#define INCLUDED_MESSAGEMAPPINGOSCPACKETLISTENER_H
+
+#include <string.h>
+#include <map>
+
+#include "OscPacketListener.h"
+
+
+
+namespace osc{
+
+template< class T >
+class MessageMappingOscPacketListener : public OscPacketListener{
+public:
+ typedef void (T::*function_type)(const osc::ReceivedMessage&, const IpEndpointName&);
+
+protected:
+ void RegisterMessageFunction( const char *addressPattern, function_type f )
+ {
+ functions_.insert( std::make_pair( addressPattern, f ) );
+ }
+
+ virtual void ProcessMessage( const osc::ReceivedMessage& m,
+ const IpEndpointName& remoteEndpoint )
+ {
+ typename function_map_type::iterator i = functions_.find( m.AddressPattern() );
+ if( i != functions_.end() )
+ (dynamic_cast<T*>(this)->*(i->second))( m, remoteEndpoint );
+ }
+
+private:
+ struct cstr_compare{
+ bool operator()( const char *lhs, const char *rhs ) const
+ { return strcmp( lhs, rhs ) < 0; }
+ };
+
+ typedef std::map<const char*, function_type, cstr_compare> function_map_type;
+ function_map_type functions_;
+};
+
+} // namespace osc
+
+#endif /* INCLUDED_MESSAGEMAPPINGOSCPACKETLISTENER_H */
diff --git a/src/oscpack/NetworkingUtils.cpp b/src/oscpack/NetworkingUtils.cpp
new file mode 100644
index 0000000..e6a7a54
--- /dev/null
+++ b/src/oscpack/NetworkingUtils.cpp
@@ -0,0 +1,98 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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 "NetworkingUtils.h"
+
+#ifdef WIN32
+#include <winsock2.h> // this must come first to prevent errors with MSVC7
+#include <windows.h>
+#include <stdlib.h>
+
+static LONG initCount_ = 0;
+static bool winsockInitialized_ = false;
+#else
+#include <netdb.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <string.h>
+#endif
+
+#include <stdio.h>
+
+NetworkInitializer::NetworkInitializer()
+{
+#ifdef WIN32
+ if( InterlockedIncrement( &initCount_ ) == 1 ){
+ // there is a race condition here if one thread tries to access
+ // the library while another is still initializing it.
+ // i can't think of an easy way to fix it so i'm telling you here
+ // incase you need to init the library from two threads at once.
+ // this is why the header file advises to instantiate one of these
+ // in main() so that the initialization happens globally
+
+ // initialize winsock
+ WSAData wsaData;
+ int nCode = WSAStartup(MAKEWORD(1, 1), &wsaData);
+ if( nCode != 0 ){
+ //std::cout << "WSAStartup() failed with error code " << nCode << "\n";
+ }else{
+ winsockInitialized_ = true;
+ }
+ }
+#endif
+}
+
+NetworkInitializer::~NetworkInitializer()
+{
+#ifdef WIN32
+ if( InterlockedDecrement( &initCount_ ) == 0 ){
+ if( winsockInitialized_ ){
+ WSACleanup();
+ winsockInitialized_ = false;
+ }
+ }
+#endif
+}
+
+
+unsigned long GetHostByName( const char *name )
+{
+ NetworkInitializer networkInitializer;
+
+ unsigned long result = 0;
+
+ struct hostent *h = gethostbyname( name );
+ if( h ){
+ struct in_addr a;
+ memcpy( &a, h->h_addr_list[0], h->h_length );
+ result = ntohl(a.s_addr);
+ }
+
+ return result;
+}
diff --git a/src/oscpack/NetworkingUtils.h b/src/oscpack/NetworkingUtils.h
new file mode 100644
index 0000000..d76807b
--- /dev/null
+++ b/src/oscpack/NetworkingUtils.h
@@ -0,0 +1,49 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_NETWORKINGUTILS_H
+#define INCLUDED_NETWORKINGUTILS_H
+
+
+// in general NetworkInitializer is only used internally, but if you're
+// application creates multiple sockets from different threads at runtime you
+// should instantiate one of these in main just to make sure the networking
+// layer is initialized.
+class NetworkInitializer{
+public:
+ NetworkInitializer();
+ ~NetworkInitializer();
+};
+
+
+// return ip address of host name in host byte order
+unsigned long GetHostByName( const char *name );
+
+
+#endif /* INCLUDED_NETWORKINGUTILS_H */
diff --git a/src/oscpack/OscException.h b/src/oscpack/OscException.h
new file mode 100644
index 0000000..78cc2db
--- /dev/null
+++ b/src/oscpack/OscException.h
@@ -0,0 +1,54 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_OSC_EXCEPTION_H
+#define INCLUDED_OSC_EXCEPTION_H
+
+#include <exception>
+
+namespace osc{
+
+class Exception : public std::exception {
+ const char *what_;
+
+public:
+ Exception() throw() {}
+ Exception( const Exception& src ) throw()
+ : what_( src.what_ ) {}
+ Exception( const char *w ) throw()
+ : what_( w ) {}
+ Exception& operator=( const Exception& src ) throw()
+ { what_ = src.what_; return *this; }
+ virtual ~Exception() throw() {}
+ virtual const char* what() const throw() { return what_; }
+};
+
+} // namespace osc
+
+#endif /* INCLUDED_OSC_EXCEPTION_H */
diff --git a/src/oscpack/OscHostEndianness.h b/src/oscpack/OscHostEndianness.h
new file mode 100644
index 0000000..bb811c2
--- /dev/null
+++ b/src/oscpack/OscHostEndianness.h
@@ -0,0 +1,70 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef OSC_HOSTENDIANNESS_H
+#define OSC_HOSTENDIANNESS_H
+
+/*
+ Make sure either OSC_HOST_LITTLE_ENDIAN or OSC_HOST_BIG_ENDIAN is defined
+
+ If you know a way to enhance the detection below for Linux and/or MacOSX
+ please let me know! I've tried a few things which don't work.
+*/
+
+#if defined(OSC_HOST_LITTLE_ENDIAN) || defined(OSC_HOST_BIG_ENDIAN)
+
+// you can define one of the above symbols from the command line
+// then you don't have to edit this file.
+
+#elif defined(__WIN32__) || defined(WIN32)
+
+// assume that __WIN32__ is only defined on little endian systems
+
+#define OSC_HOST_LITTLE_ENDIAN 1
+#undef OSC_HOST_BIG_ENDIAN
+
+#elif defined(__APPLE__)
+
+#if defined(__LITTLE_ENDIAN__)
+#define OSC_HOST_LITTLE_ENDIAN 1
+#undef OSC_HOST_BIG_ENDIAN
+#else
+#define OSC_HOST_BIG_ENDIAN 1
+#undef OSC_HOST_LITTLE_ENDIAN
+#endif
+
+#else
+
+#define OSC_HOST_LITTLE_ENDIAN 1
+#undef OSC_HOST_BIG_ENDIAN
+
+#endif
+
+#endif /* OSC_HOSTENDIANNESS_H */
+
diff --git a/src/oscpack/OscOutboundPacketStream.cpp b/src/oscpack/OscOutboundPacketStream.cpp
new file mode 100644
index 0000000..a91d10a
--- /dev/null
+++ b/src/oscpack/OscOutboundPacketStream.cpp
@@ -0,0 +1,639 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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 "OscOutboundPacketStream.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <assert.h>
+
+#if defined(__WIN32__) || defined(WIN32)
+#include <malloc.h> // for alloca
+#endif
+
+#include "OscHostEndianness.h"
+
+
+namespace osc{
+
+static void FromInt32( char *p, int32 x )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::int32 i;
+ char c[4];
+ } u;
+
+ u.i = x;
+
+ p[3] = u.c[0];
+ p[2] = u.c[1];
+ p[1] = u.c[2];
+ p[0] = u.c[3];
+#else
+ *reinterpret_cast<int32*>(p) = x;
+#endif
+}
+
+
+static void FromUInt32( char *p, uint32 x )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::uint32 i;
+ char c[4];
+ } u;
+
+ u.i = x;
+
+ p[3] = u.c[0];
+ p[2] = u.c[1];
+ p[1] = u.c[2];
+ p[0] = u.c[3];
+#else
+ *reinterpret_cast<uint32*>(p) = x;
+#endif
+}
+
+
+static void FromInt64( char *p, int64 x )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::int64 i;
+ char c[8];
+ } u;
+
+ u.i = x;
+
+ p[7] = u.c[0];
+ p[6] = u.c[1];
+ p[5] = u.c[2];
+ p[4] = u.c[3];
+ p[3] = u.c[4];
+ p[2] = u.c[5];
+ p[1] = u.c[6];
+ p[0] = u.c[7];
+#else
+ *reinterpret_cast<int64*>(p) = x;
+#endif
+}
+
+
+static void FromUInt64( char *p, uint64 x )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::uint64 i;
+ char c[8];
+ } u;
+
+ u.i = x;
+
+ p[7] = u.c[0];
+ p[6] = u.c[1];
+ p[5] = u.c[2];
+ p[4] = u.c[3];
+ p[3] = u.c[4];
+ p[2] = u.c[5];
+ p[1] = u.c[6];
+ p[0] = u.c[7];
+#else
+ *reinterpret_cast<uint64*>(p) = x;
+#endif
+}
+
+
+static inline long RoundUp4( long x )
+{
+ return ((x-1) & (~0x03L)) + 4;
+}
+
+
+OutboundPacketStream::OutboundPacketStream( char *buffer, unsigned long capacity )
+ : data_( buffer )
+ , end_( data_ + capacity )
+ , typeTagsCurrent_( end_ )
+ , messageCursor_( data_ )
+ , argumentCurrent_( data_ )
+ , elementSizePtr_( 0 )
+ , messageIsInProgress_( false )
+{
+
+}
+
+
+OutboundPacketStream::~OutboundPacketStream()
+{
+
+}
+
+
+char *OutboundPacketStream::BeginElement( char *beginPtr )
+{
+ if( elementSizePtr_ == 0 ){
+
+ elementSizePtr_ = reinterpret_cast<uint32*>(data_);
+
+ return beginPtr;
+
+ }else{
+ // store an offset to the old element size ptr in the element size slot
+ // we store an offset rather than the actual pointer to be 64 bit clean.
+ *reinterpret_cast<uint32*>(beginPtr) =
+ (uint32)(reinterpret_cast<char*>(elementSizePtr_) - data_);
+
+ elementSizePtr_ = reinterpret_cast<uint32*>(beginPtr);
+
+ return beginPtr + 4;
+ }
+}
+
+
+void OutboundPacketStream::EndElement( char *endPtr )
+{
+ assert( elementSizePtr_ != 0 );
+
+ if( elementSizePtr_ == reinterpret_cast<uint32*>(data_) ){
+
+ elementSizePtr_ = 0;
+
+ }else{
+ // while building an element, an offset to the containing element's
+ // size slot is stored in the elements size slot (or a ptr to data_
+ // if there is no containing element). We retrieve that here
+ uint32 *previousElementSizePtr =
+ (uint32*)(data_ + *reinterpret_cast<uint32*>(elementSizePtr_));
+
+ // then we store the element size in the slot, note that the element
+ // size does not include the size slot, hence the - 4 below.
+ uint32 elementSize =
+ (endPtr - reinterpret_cast<char*>(elementSizePtr_)) - 4;
+ FromUInt32( reinterpret_cast<char*>(elementSizePtr_), elementSize );
+
+ // finally, we reset the element size ptr to the containing element
+ elementSizePtr_ = previousElementSizePtr;
+ }
+}
+
+
+bool OutboundPacketStream::ElementSizeSlotRequired() const
+{
+ return (elementSizePtr_ != 0);
+}
+
+
+void OutboundPacketStream::CheckForAvailableBundleSpace()
+{
+ unsigned long required = Size() + ((ElementSizeSlotRequired())?4:0) + 16;
+
+ if( required > Capacity() )
+ throw OutOfBufferMemoryException();
+}
+
+
+void OutboundPacketStream::CheckForAvailableMessageSpace( const char *addressPattern )
+{
+ // plus 4 for at least four bytes of type tag
+ unsigned long required = Size() + ((ElementSizeSlotRequired())?4:0)
+ + RoundUp4(strlen(addressPattern) + 1) + 4;
+
+ if( required > Capacity() )
+ throw OutOfBufferMemoryException();
+}
+
+
+void OutboundPacketStream::CheckForAvailableArgumentSpace( long argumentLength )
+{
+ // plus three for extra type tag, comma and null terminator
+ unsigned long required = (argumentCurrent_ - data_) + argumentLength
+ + RoundUp4( (end_ - typeTagsCurrent_) + 3 );
+
+ if( required > Capacity() )
+ throw OutOfBufferMemoryException();
+}
+
+
+void OutboundPacketStream::Clear()
+{
+ typeTagsCurrent_ = end_;
+ messageCursor_ = data_;
+ argumentCurrent_ = data_;
+ elementSizePtr_ = 0;
+ messageIsInProgress_ = false;
+}
+
+
+unsigned int OutboundPacketStream::Capacity() const
+{
+ return end_ - data_;
+}
+
+
+unsigned int OutboundPacketStream::Size() const
+{
+ unsigned int result = argumentCurrent_ - data_;
+ if( IsMessageInProgress() ){
+ // account for the length of the type tag string. the total type tag
+ // includes an initial comma, plus at least one terminating \0
+ result += RoundUp4( (end_ - typeTagsCurrent_) + 2 );
+ }
+
+ return result;
+}
+
+
+const char *OutboundPacketStream::Data() const
+{
+ return data_;
+}
+
+
+bool OutboundPacketStream::IsReady() const
+{
+ return (!IsMessageInProgress() && !IsBundleInProgress());
+}
+
+
+bool OutboundPacketStream::IsMessageInProgress() const
+{
+ return messageIsInProgress_;
+}
+
+
+bool OutboundPacketStream::IsBundleInProgress() const
+{
+ return (elementSizePtr_ != 0);
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const BundleInitiator& rhs )
+{
+ if( IsMessageInProgress() )
+ throw MessageInProgressException();
+
+ CheckForAvailableBundleSpace();
+
+ messageCursor_ = BeginElement( messageCursor_ );
+
+ memcpy( messageCursor_, "#bundle\0", 8 );
+ FromUInt64( messageCursor_ + 8, rhs.timeTag );
+
+ messageCursor_ += 16;
+ argumentCurrent_ = messageCursor_;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const BundleTerminator& rhs )
+{
+ (void) rhs;
+
+ if( !IsBundleInProgress() )
+ throw BundleNotInProgressException();
+ if( IsMessageInProgress() )
+ throw MessageInProgressException();
+
+ EndElement( messageCursor_ );
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const BeginMessage& rhs )
+{
+ if( IsMessageInProgress() )
+ throw MessageInProgressException();
+
+ CheckForAvailableMessageSpace( rhs.addressPattern );
+
+ messageCursor_ = BeginElement( messageCursor_ );
+
+ strcpy( messageCursor_, rhs.addressPattern );
+ unsigned long rhsLength = strlen(rhs.addressPattern);
+ messageCursor_ += rhsLength + 1;
+
+ // zero pad to 4-byte boundary
+ unsigned long i = rhsLength + 1;
+ while( i & 0x3 ){
+ *messageCursor_++ = '\0';
+ ++i;
+ }
+
+ argumentCurrent_ = messageCursor_;
+ typeTagsCurrent_ = end_;
+
+ messageIsInProgress_ = true;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const MessageTerminator& rhs )
+{
+ (void) rhs;
+
+ if( !IsMessageInProgress() )
+ throw MessageNotInProgressException();
+
+ int typeTagsCount = end_ - typeTagsCurrent_;
+
+ if( typeTagsCount ){
+
+ char *tempTypeTags = (char*)alloca(typeTagsCount);
+ memcpy( tempTypeTags, typeTagsCurrent_, typeTagsCount );
+
+ // slot size includes comma and null terminator
+ int typeTagSlotSize = RoundUp4( typeTagsCount + 2 );
+
+ uint32 argumentsSize = argumentCurrent_ - messageCursor_;
+
+ memmove( messageCursor_ + typeTagSlotSize, messageCursor_, argumentsSize );
+
+ messageCursor_[0] = ',';
+ // copy type tags in reverse (really forward) order
+ for( int i=0; i < typeTagsCount; ++i )
+ messageCursor_[i+1] = tempTypeTags[ (typeTagsCount-1) - i ];
+
+ char *p = messageCursor_ + 1 + typeTagsCount;
+ for( int i=0; i < (typeTagSlotSize - (typeTagsCount + 1)); ++i )
+ *p++ = '\0';
+
+ typeTagsCurrent_ = end_;
+
+ // advance messageCursor_ for next message
+ messageCursor_ += typeTagSlotSize + argumentsSize;
+
+ }else{
+ // send an empty type tags string
+ memcpy( messageCursor_, ",\0\0\0", 4 );
+
+ // advance messageCursor_ for next message
+ messageCursor_ += 4;
+ }
+
+ argumentCurrent_ = messageCursor_;
+
+ EndElement( messageCursor_ );
+
+ messageIsInProgress_ = false;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( bool rhs )
+{
+ CheckForAvailableArgumentSpace(0);
+
+ *(--typeTagsCurrent_) = (char)((rhs) ? TRUE_TYPE_TAG : FALSE_TYPE_TAG);
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const NilType& rhs )
+{
+ (void) rhs;
+ CheckForAvailableArgumentSpace(0);
+
+ *(--typeTagsCurrent_) = NIL_TYPE_TAG;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const InfinitumType& rhs )
+{
+ (void) rhs;
+ CheckForAvailableArgumentSpace(0);
+
+ *(--typeTagsCurrent_) = INFINITUM_TYPE_TAG;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( int32 rhs )
+{
+ CheckForAvailableArgumentSpace(4);
+
+ *(--typeTagsCurrent_) = INT32_TYPE_TAG;
+ FromInt32( argumentCurrent_, rhs );
+ argumentCurrent_ += 4;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( float rhs )
+{
+ CheckForAvailableArgumentSpace(4);
+
+ *(--typeTagsCurrent_) = FLOAT_TYPE_TAG;
+
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ float f;
+ char c[4];
+ } u;
+
+ u.f = rhs;
+
+ argumentCurrent_[3] = u.c[0];
+ argumentCurrent_[2] = u.c[1];
+ argumentCurrent_[1] = u.c[2];
+ argumentCurrent_[0] = u.c[3];
+#else
+ *reinterpret_cast<float*>(argumentCurrent_) = rhs;
+#endif
+
+ argumentCurrent_ += 4;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( char rhs )
+{
+ CheckForAvailableArgumentSpace(4);
+
+ *(--typeTagsCurrent_) = CHAR_TYPE_TAG;
+ FromInt32( argumentCurrent_, rhs );
+ argumentCurrent_ += 4;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const RgbaColor& rhs )
+{
+ CheckForAvailableArgumentSpace(4);
+
+ *(--typeTagsCurrent_) = RGBA_COLOR_TYPE_TAG;
+ FromUInt32( argumentCurrent_, rhs );
+ argumentCurrent_ += 4;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const MidiMessage& rhs )
+{
+ CheckForAvailableArgumentSpace(4);
+
+ *(--typeTagsCurrent_) = MIDI_MESSAGE_TYPE_TAG;
+ FromUInt32( argumentCurrent_, rhs );
+ argumentCurrent_ += 4;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( int64 rhs )
+{
+ CheckForAvailableArgumentSpace(8);
+
+ *(--typeTagsCurrent_) = INT64_TYPE_TAG;
+ FromInt64( argumentCurrent_, rhs );
+ argumentCurrent_ += 8;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const TimeTag& rhs )
+{
+ CheckForAvailableArgumentSpace(8);
+
+ *(--typeTagsCurrent_) = TIME_TAG_TYPE_TAG;
+ FromUInt64( argumentCurrent_, rhs );
+ argumentCurrent_ += 8;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( double rhs )
+{
+ CheckForAvailableArgumentSpace(8);
+
+ *(--typeTagsCurrent_) = DOUBLE_TYPE_TAG;
+
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ double f;
+ char c[8];
+ } u;
+
+ u.f = rhs;
+
+ argumentCurrent_[7] = u.c[0];
+ argumentCurrent_[6] = u.c[1];
+ argumentCurrent_[5] = u.c[2];
+ argumentCurrent_[4] = u.c[3];
+ argumentCurrent_[3] = u.c[4];
+ argumentCurrent_[2] = u.c[5];
+ argumentCurrent_[1] = u.c[6];
+ argumentCurrent_[0] = u.c[7];
+#else
+ *reinterpret_cast<double*>(argumentCurrent_) = rhs;
+#endif
+
+ argumentCurrent_ += 8;
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const char *rhs )
+{
+ CheckForAvailableArgumentSpace( RoundUp4(strlen(rhs) + 1) );
+
+ *(--typeTagsCurrent_) = STRING_TYPE_TAG;
+ strcpy( argumentCurrent_, rhs );
+ unsigned long rhsLength = strlen(rhs);
+ argumentCurrent_ += rhsLength + 1;
+
+ // zero pad to 4-byte boundary
+ unsigned long i = rhsLength + 1;
+ while( i & 0x3 ){
+ *argumentCurrent_++ = '\0';
+ ++i;
+ }
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const Symbol& rhs )
+{
+ CheckForAvailableArgumentSpace( RoundUp4(strlen(rhs) + 1) );
+
+ *(--typeTagsCurrent_) = SYMBOL_TYPE_TAG;
+ strcpy( argumentCurrent_, rhs );
+ unsigned long rhsLength = strlen(rhs);
+ argumentCurrent_ += rhsLength + 1;
+
+ // zero pad to 4-byte boundary
+ unsigned long i = rhsLength + 1;
+ while( i & 0x3 ){
+ *argumentCurrent_++ = '\0';
+ ++i;
+ }
+
+ return *this;
+}
+
+
+OutboundPacketStream& OutboundPacketStream::operator<<( const Blob& rhs )
+{
+ CheckForAvailableArgumentSpace( 4 + RoundUp4(rhs.size) );
+
+ *(--typeTagsCurrent_) = BLOB_TYPE_TAG;
+ FromUInt32( argumentCurrent_, rhs.size );
+ argumentCurrent_ += 4;
+
+ memcpy( argumentCurrent_, rhs.data, rhs.size );
+ argumentCurrent_ += rhs.size;
+
+ // zero pad to 4-byte boundary
+ unsigned long i = rhs.size;
+ while( i & 0x3 ){
+ *argumentCurrent_++ = '\0';
+ ++i;
+ }
+
+ return *this;
+}
+
+} // namespace osc
+
+
diff --git a/src/oscpack/OscOutboundPacketStream.h b/src/oscpack/OscOutboundPacketStream.h
new file mode 100644
index 0000000..5afbaa6
--- /dev/null
+++ b/src/oscpack/OscOutboundPacketStream.h
@@ -0,0 +1,142 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_OSCOUTBOUNDPACKET_H
+#define INCLUDED_OSCOUTBOUNDPACKET_H
+
+#include "OscTypes.h"
+#include "OscException.h"
+
+
+namespace osc{
+
+class OutOfBufferMemoryException : public Exception{
+public:
+ OutOfBufferMemoryException( const char *w="out of buffer memory" )
+ : Exception( w ) {}
+};
+
+class BundleNotInProgressException : public Exception{
+public:
+ BundleNotInProgressException(
+ const char *w="call to EndBundle when bundle is not in progress" )
+ : Exception( w ) {}
+};
+
+class MessageInProgressException : public Exception{
+public:
+ MessageInProgressException(
+ const char *w="opening or closing bundle or message while message is in progress" )
+ : Exception( w ) {}
+};
+
+class MessageNotInProgressException : public Exception{
+public:
+ MessageNotInProgressException(
+ const char *w="call to EndMessage when message is not in progress" )
+ : Exception( w ) {}
+};
+
+
+class OutboundPacketStream{
+public:
+ OutboundPacketStream( char *buffer, unsigned long capacity );
+ ~OutboundPacketStream();
+
+ void Clear();
+
+ unsigned int Capacity() const;
+
+ // invariant: size() is valid even while building a message.
+ unsigned int Size() const;
+
+ const char *Data() const;
+
+ // indicates that all messages have been closed with a matching EndMessage
+ // and all bundles have been closed with a matching EndBundle
+ bool IsReady() const;
+
+ bool IsMessageInProgress() const;
+ bool IsBundleInProgress() const;
+
+ OutboundPacketStream& operator<<( const BundleInitiator& rhs );
+ OutboundPacketStream& operator<<( const BundleTerminator& rhs );
+
+ OutboundPacketStream& operator<<( const BeginMessage& rhs );
+ OutboundPacketStream& operator<<( const MessageTerminator& rhs );
+
+ OutboundPacketStream& operator<<( bool rhs );
+ OutboundPacketStream& operator<<( const NilType& rhs );
+ OutboundPacketStream& operator<<( const InfinitumType& rhs );
+ OutboundPacketStream& operator<<( int32 rhs );
+
+#if !(defined(__x86_64__)) && !(defined(__APPLE__))
+ OutboundPacketStream& operator<<( int rhs )
+ { *this << (int32)rhs; return *this; }
+#endif
+
+ OutboundPacketStream& operator<<( float rhs );
+ OutboundPacketStream& operator<<( char rhs );
+ OutboundPacketStream& operator<<( const RgbaColor& rhs );
+ OutboundPacketStream& operator<<( const MidiMessage& rhs );
+ OutboundPacketStream& operator<<( int64 rhs );
+ OutboundPacketStream& operator<<( const TimeTag& rhs );
+ OutboundPacketStream& operator<<( double rhs );
+ OutboundPacketStream& operator<<( const char* rhs );
+ OutboundPacketStream& operator<<( const Symbol& rhs );
+ OutboundPacketStream& operator<<( const Blob& rhs );
+
+private:
+
+ char *BeginElement( char *beginPtr );
+ void EndElement( char *endPtr );
+
+ bool ElementSizeSlotRequired() const;
+ void CheckForAvailableBundleSpace();
+ void CheckForAvailableMessageSpace( const char *addressPattern );
+ void CheckForAvailableArgumentSpace( long argumentLength );
+
+ char *data_;
+ char *end_;
+
+ char *typeTagsCurrent_; // stored in reverse order
+ char *messageCursor_;
+ char *argumentCurrent_;
+
+ // elementSizePtr_ has two special values: 0 indicates that a bundle
+ // isn't open, and elementSizePtr_==data_ indicates that a bundle is
+ // open but that it doesn't have a size slot (ie the outermost bundle)
+ uint32 *elementSizePtr_;
+
+ bool messageIsInProgress_;
+};
+
+} // namespace osc
+
+#endif /* INCLUDED_OSC_OUTBOUND_PACKET_H */
diff --git a/src/oscpack/OscPacketListener.h b/src/oscpack/OscPacketListener.h
new file mode 100644
index 0000000..7ffbc0e
--- /dev/null
+++ b/src/oscpack/OscPacketListener.h
@@ -0,0 +1,72 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_OSCPACKETLISTENER_H
+#define INCLUDED_OSCPACKETLISTENER_H
+
+#include "OscReceivedElements.h"
+#include "PacketListener.h"
+
+
+namespace osc{
+
+class OscPacketListener : public PacketListener{
+protected:
+ virtual void ProcessBundle( const osc::ReceivedBundle& b,
+ const IpEndpointName& remoteEndpoint )
+ {
+ // ignore bundle time tag for now
+
+ for( ReceivedBundle::const_iterator i = b.ElementsBegin();
+ i != b.ElementsEnd(); ++i ){
+ if( i->IsBundle() )
+ ProcessBundle( ReceivedBundle(*i), remoteEndpoint );
+ else
+ ProcessMessage( ReceivedMessage(*i), remoteEndpoint );
+ }
+ }
+
+ virtual void ProcessMessage( const osc::ReceivedMessage& m,
+ const IpEndpointName& remoteEndpoint ) = 0;
+
+public:
+ virtual void ProcessPacket( const char *data, int size,
+ const IpEndpointName& remoteEndpoint )
+ {
+ osc::ReceivedPacket p( data, size );
+ if( p.IsBundle() )
+ ProcessBundle( ReceivedBundle(p), remoteEndpoint );
+ else
+ ProcessMessage( ReceivedMessage(p), remoteEndpoint );
+ }
+};
+
+} // namespace osc
+
+#endif /* INCLUDED_OSCPACKETLISTENER_H */
diff --git a/src/oscpack/OscPrintReceivedElements.cpp b/src/oscpack/OscPrintReceivedElements.cpp
new file mode 100644
index 0000000..8c3722d
--- /dev/null
+++ b/src/oscpack/OscPrintReceivedElements.cpp
@@ -0,0 +1,240 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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 "OscPrintReceivedElements.h"
+
+#include <iostream>
+#include <iomanip>
+#include <ctime>
+#include <string.h>
+
+namespace osc{
+
+
+std::ostream& operator<<( std::ostream & os,
+ const ReceivedMessageArgument& arg )
+{
+ switch( arg.TypeTag() ){
+ case TRUE_TYPE_TAG:
+ os << "bool:true";
+ break;
+
+ case FALSE_TYPE_TAG:
+ os << "bool:false";
+ break;
+
+ case NIL_TYPE_TAG:
+ os << "(Nil)";
+ break;
+
+ case INFINITUM_TYPE_TAG:
+ os << "(Infinitum)";
+ break;
+
+ case INT32_TYPE_TAG:
+ os << "int32:" << arg.AsInt32Unchecked();
+ break;
+
+ case FLOAT_TYPE_TAG:
+ os << "float32:" << arg.AsFloatUnchecked();
+ break;
+
+ case CHAR_TYPE_TAG:
+ {
+ char s[2] = {0};
+ s[0] = arg.AsCharUnchecked();
+ os << "char:'" << s << "'";
+ }
+ break;
+
+ case RGBA_COLOR_TYPE_TAG:
+ {
+ uint32 color = arg.AsRgbaColorUnchecked();
+
+ os << "RGBA:0x"
+ << std::hex << std::setfill('0')
+ << std::setw(2) << (int)((color>>24) & 0xFF)
+ << std::setw(2) << (int)((color>>16) & 0xFF)
+ << std::setw(2) << (int)((color>>8) & 0xFF)
+ << std::setw(2) << (int)(color & 0xFF)
+ << std::setfill(' ');
+ os.unsetf(std::ios::basefield);
+ }
+ break;
+
+ case MIDI_MESSAGE_TYPE_TAG:
+ {
+ uint32 m = arg.AsMidiMessageUnchecked();
+ os << "midi (port, status, data1, data2):<<"
+ << std::hex << std::setfill('0')
+ << "0x" << std::setw(2) << (int)((m>>24) & 0xFF)
+ << " 0x" << std::setw(2) << (int)((m>>16) & 0xFF)
+ << " 0x" << std::setw(2) << (int)((m>>8) & 0xFF)
+ << " 0x" << std::setw(2) << (int)(m & 0xFF)
+ << std::setfill(' ') << ">>";
+ os.unsetf(std::ios::basefield);
+ }
+ break;
+
+ case INT64_TYPE_TAG:
+ os << "int64:" << arg.AsInt64Unchecked();
+ break;
+
+ case TIME_TAG_TYPE_TAG:
+ {
+ os << "OSC-timetag:" << arg.AsTimeTagUnchecked();
+
+ std::time_t t =
+ (unsigned long)( arg.AsTimeTagUnchecked() >> 32 );
+
+ // strip trailing newline from string returned by ctime
+ const char *timeString = std::ctime( &t );
+ size_t len = strlen( timeString );
+ char *s = new char[ len + 1 ];
+ strcpy( s, timeString );
+ if( len )
+ s[ len - 1 ] = '\0';
+
+ os << " " << s;
+ }
+ break;
+
+ case DOUBLE_TYPE_TAG:
+ os << "double:" << arg.AsDoubleUnchecked();
+ break;
+
+ case STRING_TYPE_TAG:
+ os << "OSC-string:`" << arg.AsStringUnchecked() << "'";
+ break;
+
+ case SYMBOL_TYPE_TAG:
+ os << "OSC-string (symbol):`" << arg.AsSymbolUnchecked() << "'";
+ break;
+
+ case BLOB_TYPE_TAG:
+ {
+ unsigned long size;
+ const void *data;
+ arg.AsBlobUnchecked( data, size );
+ os << "OSC-blob:<<" << std::hex << std::setfill('0');
+ unsigned char *p = (unsigned char*)data;
+ for( unsigned long i = 0; i < size; ++i ){
+ os << "0x" << std::setw(2) << int(p[i]);
+ if( i != size-1 )
+ os << ' ';
+ }
+ os.unsetf(std::ios::basefield);
+ os << ">>" << std::setfill(' ');
+ }
+ break;
+
+ default:
+ os << "unknown";
+ }
+
+ return os;
+}
+
+
+std::ostream& operator<<( std::ostream & os, const ReceivedMessage& m )
+{
+
+ os << "[" << m.AddressPattern();
+ bool first = true;
+
+ for( ReceivedMessage::const_iterator i = m.ArgumentsBegin();
+ i != m.ArgumentsEnd(); ++i ){
+ if( first ){
+ os << " ";
+ first = false;
+ }else{
+ os << ", ";
+ }
+
+ os << *i;
+ }
+
+ os << "]";
+
+ return os;
+}
+
+
+std::ostream& operator<<( std::ostream & os, const ReceivedBundle& b )
+{
+ static int indent = 0;
+
+ for( int j=0; j < indent; ++j )
+ os << " ";
+ os << "{ ( ";
+ if( b.TimeTag() == 1 )
+ os << "immediate";
+ else
+ os << b.TimeTag();
+ os << " )\n";
+
+ ++indent;
+
+ for( ReceivedBundle::const_iterator i = b.ElementsBegin();
+ i != b.ElementsEnd(); ++i ){
+ if( i->IsBundle() ){
+ ReceivedBundle b(*i);
+ os << b << "\n";
+ }else{
+ ReceivedMessage m(*i);
+ for( int j=0; j < indent; ++j )
+ os << " ";
+ os << m << "\n";
+ }
+ }
+
+ --indent;
+
+ for( int j=0; j < indent; ++j )
+ os << " ";
+ os << "}";
+
+ return os;
+}
+
+
+std::ostream& operator<<( std::ostream & os, const ReceivedPacket& p )
+{
+ if( p.IsBundle() ){
+ ReceivedBundle b(p);
+ os << b << "\n";
+ }else{
+ ReceivedMessage m(p);
+ os << m << "\n";
+ }
+
+ return os;
+}
+
+} // namespace osc
diff --git a/src/oscpack/OscPrintReceivedElements.h b/src/oscpack/OscPrintReceivedElements.h
new file mode 100644
index 0000000..956524d
--- /dev/null
+++ b/src/oscpack/OscPrintReceivedElements.h
@@ -0,0 +1,49 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_OSCPRINTRECEIVEDELEMENTS_H
+#define INCLUDED_OSCPRINTRECEIVEDELEMENTS_H
+
+#include <iosfwd>
+
+#ifndef INCLUDED_OSCRECEIVEDELEMENTS_H
+#include "OscReceivedElements.h"
+#endif /* INCLUDED_OSCRECEIVEDELEMENTS_H */
+
+
+namespace osc{
+
+std::ostream& operator<<( std::ostream & os, const ReceivedPacket& p );
+std::ostream& operator<<( std::ostream & os, const ReceivedMessageArgument& arg );
+std::ostream& operator<<( std::ostream & os, const ReceivedMessage& m );
+std::ostream& operator<<( std::ostream & os, const ReceivedBundle& b );
+
+} // namespace osc
+
+#endif /* INCLUDED_OSCPRINTRECEIVEDELEMENTS_H */
diff --git a/src/oscpack/OscReceivedElements.cpp b/src/oscpack/OscReceivedElements.cpp
new file mode 100644
index 0000000..e28eb55
--- /dev/null
+++ b/src/oscpack/OscReceivedElements.cpp
@@ -0,0 +1,722 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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 "OscReceivedElements.h"
+
+#include <cassert>
+
+#include "OscHostEndianness.h"
+
+
+namespace osc{
+
+
+// return the first 4 byte boundary after the end of a str4
+// be careful about calling this version if you don't know whether
+// the string is terminated correctly.
+static inline const char* FindStr4End( const char *p )
+{
+ if( p[0] == '\0' ) // special case for SuperCollider integer address pattern
+ return p + 4;
+
+ p += 3;
+
+ while( *p )
+ p += 4;
+
+ return p + 1;
+}
+
+
+// return the first 4 byte boundary after the end of a str4
+// returns 0 if p == end or if the string is unterminated
+static inline const char* FindStr4End( const char *p, const char *end )
+{
+ if( p >= end )
+ return 0;
+
+ if( p[0] == '\0' ) // special case for SuperCollider integer address pattern
+ return p + 4;
+
+ p += 3;
+ end -= 1;
+
+ while( p < end && *p )
+ p += 4;
+
+ if( *p )
+ return 0;
+ else
+ return p + 1;
+}
+
+
+static inline unsigned long RoundUp4( unsigned long x )
+{
+ unsigned long remainder = x & 0x3UL;
+ if( remainder )
+ return x + (4 - remainder);
+ else
+ return x;
+}
+
+
+static inline int32 ToInt32( const char *p )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::int32 i;
+ char c[4];
+ } u;
+
+ u.c[0] = p[3];
+ u.c[1] = p[2];
+ u.c[2] = p[1];
+ u.c[3] = p[0];
+
+ return u.i;
+#else
+ return *(int32*)p;
+#endif
+}
+
+
+static inline uint32 ToUInt32( const char *p )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::uint32 i;
+ char c[4];
+ } u;
+
+ u.c[0] = p[3];
+ u.c[1] = p[2];
+ u.c[2] = p[1];
+ u.c[3] = p[0];
+
+ return u.i;
+#else
+ return *(uint32*)p;
+#endif
+}
+
+
+int64 ToInt64( const char *p )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::int64 i;
+ char c[8];
+ } u;
+
+ u.c[0] = p[7];
+ u.c[1] = p[6];
+ u.c[2] = p[5];
+ u.c[3] = p[4];
+ u.c[4] = p[3];
+ u.c[5] = p[2];
+ u.c[6] = p[1];
+ u.c[7] = p[0];
+
+ return u.i;
+#else
+ return *(int64*)p;
+#endif
+}
+
+
+uint64 ToUInt64( const char *p )
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::uint64 i;
+ char c[8];
+ } u;
+
+ u.c[0] = p[7];
+ u.c[1] = p[6];
+ u.c[2] = p[5];
+ u.c[3] = p[4];
+ u.c[4] = p[3];
+ u.c[5] = p[2];
+ u.c[6] = p[1];
+ u.c[7] = p[0];
+
+ return u.i;
+#else
+ return *(uint64*)p;
+#endif
+}
+
+//------------------------------------------------------------------------------
+
+bool ReceivedPacket::IsBundle() const
+{
+ return (Size() > 0 && Contents()[0] == '#');
+}
+
+//------------------------------------------------------------------------------
+
+bool ReceivedBundleElement::IsBundle() const
+{
+ return (Size() > 0 && Contents()[0] == '#');
+}
+
+
+int32 ReceivedBundleElement::Size() const
+{
+ return ToUInt32( size_ );
+}
+
+//------------------------------------------------------------------------------
+
+bool ReceivedMessageArgument::AsBool() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == TRUE_TYPE_TAG )
+ return true;
+ else if( *typeTag_ == FALSE_TYPE_TAG )
+ return false;
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+bool ReceivedMessageArgument::AsBoolUnchecked() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == TRUE_TYPE_TAG )
+ return true;
+ else
+ return false;
+}
+
+
+int32 ReceivedMessageArgument::AsInt32() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == INT32_TYPE_TAG )
+ return AsInt32Unchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+int32 ReceivedMessageArgument::AsInt32Unchecked() const
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ osc::int32 i;
+ char c[4];
+ } u;
+
+ u.c[0] = argument_[3];
+ u.c[1] = argument_[2];
+ u.c[2] = argument_[1];
+ u.c[3] = argument_[0];
+
+ return u.i;
+#else
+ return *(int32*)argument_;
+#endif
+}
+
+
+float ReceivedMessageArgument::AsFloat() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == FLOAT_TYPE_TAG )
+ return AsFloatUnchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+float ReceivedMessageArgument::AsFloatUnchecked() const
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ float f;
+ char c[4];
+ } u;
+
+ u.c[0] = argument_[3];
+ u.c[1] = argument_[2];
+ u.c[2] = argument_[1];
+ u.c[3] = argument_[0];
+
+ return u.f;
+#else
+ return *(float*)argument_;
+#endif
+}
+
+
+char ReceivedMessageArgument::AsChar() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == CHAR_TYPE_TAG )
+ return AsCharUnchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+char ReceivedMessageArgument::AsCharUnchecked() const
+{
+ return (char)ToInt32( argument_ );
+}
+
+
+uint32 ReceivedMessageArgument::AsRgbaColor() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == RGBA_COLOR_TYPE_TAG )
+ return AsRgbaColorUnchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+uint32 ReceivedMessageArgument::AsRgbaColorUnchecked() const
+{
+ return ToUInt32( argument_ );
+}
+
+
+uint32 ReceivedMessageArgument::AsMidiMessage() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == MIDI_MESSAGE_TYPE_TAG )
+ return AsMidiMessageUnchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+uint32 ReceivedMessageArgument::AsMidiMessageUnchecked() const
+{
+ return ToUInt32( argument_ );
+}
+
+
+int64 ReceivedMessageArgument::AsInt64() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == INT64_TYPE_TAG )
+ return AsInt64Unchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+int64 ReceivedMessageArgument::AsInt64Unchecked() const
+{
+ return ToInt64( argument_ );
+}
+
+
+uint64 ReceivedMessageArgument::AsTimeTag() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == TIME_TAG_TYPE_TAG )
+ return AsTimeTagUnchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+uint64 ReceivedMessageArgument::AsTimeTagUnchecked() const
+{
+ return ToUInt64( argument_ );
+}
+
+
+double ReceivedMessageArgument::AsDouble() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == DOUBLE_TYPE_TAG )
+ return AsDoubleUnchecked();
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+double ReceivedMessageArgument::AsDoubleUnchecked() const
+{
+#ifdef OSC_HOST_LITTLE_ENDIAN
+ union{
+ double d;
+ char c[8];
+ } u;
+
+ u.c[0] = argument_[7];
+ u.c[1] = argument_[6];
+ u.c[2] = argument_[5];
+ u.c[3] = argument_[4];
+ u.c[4] = argument_[3];
+ u.c[5] = argument_[2];
+ u.c[6] = argument_[1];
+ u.c[7] = argument_[0];
+
+ return u.d;
+#else
+ return *(double*)argument_;
+#endif
+}
+
+
+const char* ReceivedMessageArgument::AsString() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == STRING_TYPE_TAG )
+ return argument_;
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+const char* ReceivedMessageArgument::AsSymbol() const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == SYMBOL_TYPE_TAG )
+ return argument_;
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+void ReceivedMessageArgument::AsBlob( const void*& data, unsigned long& size ) const
+{
+ if( !typeTag_ )
+ throw MissingArgumentException();
+ else if( *typeTag_ == BLOB_TYPE_TAG )
+ AsBlobUnchecked( data, size );
+ else
+ throw WrongArgumentTypeException();
+}
+
+
+void ReceivedMessageArgument::AsBlobUnchecked( const void*& data, unsigned long& size ) const
+{
+ size = ToUInt32( argument_ );
+ data = (void*)(argument_+4);
+}
+
+//------------------------------------------------------------------------------
+
+void ReceivedMessageArgumentIterator::Advance()
+{
+ if( !value_.typeTag_ )
+ return;
+
+ switch( *value_.typeTag_++ ){
+ case '\0':
+ // don't advance past end
+ --value_.typeTag_;
+ break;
+
+ case TRUE_TYPE_TAG:
+ case FALSE_TYPE_TAG:
+ case NIL_TYPE_TAG:
+ case INFINITUM_TYPE_TAG:
+
+ // zero length
+ break;
+
+ case INT32_TYPE_TAG:
+ case FLOAT_TYPE_TAG:
+ case CHAR_TYPE_TAG:
+ case RGBA_COLOR_TYPE_TAG:
+ case MIDI_MESSAGE_TYPE_TAG:
+
+ value_.argument_ += 4;
+ break;
+
+ case INT64_TYPE_TAG:
+ case TIME_TAG_TYPE_TAG:
+ case DOUBLE_TYPE_TAG:
+
+ value_.argument_ += 8;
+ break;
+
+ case STRING_TYPE_TAG:
+ case SYMBOL_TYPE_TAG:
+
+ // we use the unsafe function FindStr4End(char*) here because all of
+ // the arguments have already been validated in
+ // ReceivedMessage::Init() below.
+
+ value_.argument_ = FindStr4End( value_.argument_ );
+ break;
+
+ case BLOB_TYPE_TAG:
+ {
+ uint32 blobSize = ToUInt32( value_.argument_ );
+ value_.argument_ = value_.argument_ + 4 + RoundUp4( blobSize );
+ }
+ break;
+
+ default: // unknown type tag
+ // don't advance
+ --value_.typeTag_;
+ break;
+
+
+ // not handled:
+ // [ Indicates the beginning of an array. The tags following are for
+ // data in the Array until a close brace tag is reached.
+ // ] Indicates the end of an array.
+ }
+}
+
+//------------------------------------------------------------------------------
+
+ReceivedMessage::ReceivedMessage( const ReceivedPacket& packet )
+ : addressPattern_( packet.Contents() )
+{
+ Init( packet.Contents(), packet.Size() );
+}
+
+
+ReceivedMessage::ReceivedMessage( const ReceivedBundleElement& bundleElement )
+ : addressPattern_( bundleElement.Contents() )
+{
+ Init( bundleElement.Contents(), bundleElement.Size() );
+}
+
+
+bool ReceivedMessage::AddressPatternIsUInt32() const
+{
+ return (addressPattern_[0] == '\0');
+}
+
+
+uint32 ReceivedMessage::AddressPatternAsUInt32() const
+{
+ return ToUInt32( addressPattern_ );
+}
+
+
+void ReceivedMessage::Init( const char *message, unsigned long size )
+{
+ if( size == 0 )
+ throw MalformedMessageException( "zero length messages not permitted" );
+
+ if( (size & 0x03L) != 0 )
+ throw MalformedMessageException( "message size must be multiple of four" );
+
+ const char *end = message + size;
+
+ typeTagsBegin_ = FindStr4End( addressPattern_, end );
+ if( typeTagsBegin_ == 0 ){
+ // address pattern was not terminated before end
+ throw MalformedMessageException( "unterminated address pattern" );
+ }
+
+ if( typeTagsBegin_ == end ){
+ // message consists of only the address pattern - no arguments or type tags.
+ typeTagsBegin_ = 0;
+ typeTagsEnd_ = 0;
+ arguments_ = 0;
+
+ }else{
+ if( *typeTagsBegin_ != ',' )
+ throw MalformedMessageException( "type tags not present" );
+
+ if( *(typeTagsBegin_ + 1) == '\0' ){
+ // zero length type tags
+ typeTagsBegin_ = 0;
+ typeTagsEnd_ = 0;
+ arguments_ = 0;
+
+ }else{
+ // check that all arguments are present and well formed
+
+ arguments_ = FindStr4End( typeTagsBegin_, end );
+ if( arguments_ == 0 ){
+ throw MalformedMessageException( "type tags were not terminated before end of message" );
+ }
+
+ ++typeTagsBegin_; // advance past initial ','
+
+ const char *typeTag = typeTagsBegin_;
+ const char *argument = arguments_;
+
+ do{
+ switch( *typeTag ){
+ case TRUE_TYPE_TAG:
+ case FALSE_TYPE_TAG:
+ case NIL_TYPE_TAG:
+ case INFINITUM_TYPE_TAG:
+
+ // zero length
+ break;
+
+ case INT32_TYPE_TAG:
+ case FLOAT_TYPE_TAG:
+ case CHAR_TYPE_TAG:
+ case RGBA_COLOR_TYPE_TAG:
+ case MIDI_MESSAGE_TYPE_TAG:
+
+ if( argument == end )
+ throw MalformedMessageException( "arguments exceed message size" );
+ argument += 4;
+ if( argument > end )
+ throw MalformedMessageException( "arguments exceed message size" );
+ break;
+
+ case INT64_TYPE_TAG:
+ case TIME_TAG_TYPE_TAG:
+ case DOUBLE_TYPE_TAG:
+
+ if( argument == end )
+ throw MalformedMessageException( "arguments exceed message size" );
+ argument += 8;
+ if( argument > end )
+ throw MalformedMessageException( "arguments exceed message size" );
+ break;
+
+ case STRING_TYPE_TAG:
+ case SYMBOL_TYPE_TAG:
+
+ if( argument == end )
+ throw MalformedMessageException( "arguments exceed message size" );
+ argument = FindStr4End( argument, end );
+ if( argument == 0 )
+ throw MalformedMessageException( "unterminated string argument" );
+ break;
+
+ case BLOB_TYPE_TAG:
+ {
+ if( argument + 4 > end )
+ MalformedMessageException( "arguments exceed message size" );
+
+ uint32 blobSize = ToUInt32( argument );
+ argument = argument + 4 + RoundUp4( blobSize );
+ if( argument > end )
+ MalformedMessageException( "arguments exceed message size" );
+ }
+ break;
+
+ default:
+ throw MalformedMessageException( "unknown type tag" );
+
+ // not handled:
+ // [ Indicates the beginning of an array. The tags following are for
+ // data in the Array until a close brace tag is reached.
+ // ] Indicates the end of an array.
+ }
+
+ }while( *++typeTag != '\0' );
+ typeTagsEnd_ = typeTag;
+ }
+ }
+}
+
+//------------------------------------------------------------------------------
+
+ReceivedBundle::ReceivedBundle( const ReceivedPacket& packet )
+ : elementCount_( 0 )
+{
+ Init( packet.Contents(), packet.Size() );
+}
+
+
+ReceivedBundle::ReceivedBundle( const ReceivedBundleElement& bundleElement )
+ : elementCount_( 0 )
+{
+ Init( bundleElement.Contents(), bundleElement.Size() );
+}
+
+
+void ReceivedBundle::Init( const char *bundle, unsigned long size )
+{
+ if( size < 16 )
+ throw MalformedBundleException( "packet too short for bundle" );
+
+ if( (size & 0x03L) != 0 )
+ throw MalformedBundleException( "bundle size must be multiple of four" );
+
+ if( bundle[0] != '#'
+ || bundle[1] != 'b'
+ || bundle[2] != 'u'
+ || bundle[3] != 'n'
+ || bundle[4] != 'd'
+ || bundle[5] != 'l'
+ || bundle[6] != 'e'
+ || bundle[7] != '\0' )
+ throw MalformedBundleException( "bad bundle address pattern" );
+
+ end_ = bundle + size;
+
+ timeTag_ = bundle + 8;
+
+ const char *p = timeTag_ + 8;
+
+ while( p < end_ ){
+ if( p + 4 > end_ )
+ throw MalformedBundleException( "packet too short for elementSize" );
+
+ uint32 elementSize = ToUInt32( p );
+ if( (elementSize & 0x03L) != 0 )
+ throw MalformedBundleException( "bundle element size must be multiple of four" );
+
+ p += 4 + elementSize;
+ if( p > end_ )
+ throw MalformedBundleException( "packet too short for bundle element" );
+
+ ++elementCount_;
+ }
+
+ if( p != end_ )
+ throw MalformedBundleException( "bundle contents " );
+}
+
+
+uint64 ReceivedBundle::TimeTag() const
+{
+ return ToUInt64( timeTag_ );
+}
+
+
+} // namespace osc
+
diff --git a/src/oscpack/OscReceivedElements.h b/src/oscpack/OscReceivedElements.h
new file mode 100644
index 0000000..1a81f6d
--- /dev/null
+++ b/src/oscpack/OscReceivedElements.h
@@ -0,0 +1,486 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_OSCRECEIVEDELEMENTS_H
+#define INCLUDED_OSCRECEIVEDELEMENTS_H
+
+#include "OscTypes.h"
+#include "OscException.h"
+
+
+namespace osc{
+
+
+class MalformedMessageException : public Exception{
+public:
+ MalformedMessageException( const char *w="malformed message" )
+ : Exception( w ) {}
+};
+
+class MalformedBundleException : public Exception{
+public:
+ MalformedBundleException( const char *w="malformed bundle" )
+ : Exception( w ) {}
+};
+
+class WrongArgumentTypeException : public Exception{
+public:
+ WrongArgumentTypeException( const char *w="wrong argument type" )
+ : Exception( w ) {}
+};
+
+class MissingArgumentException : public Exception{
+public:
+ MissingArgumentException( const char *w="missing argument" )
+ : Exception( w ) {}
+};
+
+class ExcessArgumentException : public Exception{
+public:
+ ExcessArgumentException( const char *w="too many arguments" )
+ : Exception( w ) {}
+};
+
+
+class ReceivedPacket{
+public:
+ ReceivedPacket( const char *contents, int32 size )
+ : contents_( contents )
+ , size_( size ) {}
+
+ bool IsMessage() const { return !IsBundle(); }
+ bool IsBundle() const;
+
+ int32 Size() const { return size_; }
+ const char *Contents() const { return contents_; }
+
+private:
+ const char *contents_;
+ int32 size_;
+};
+
+
+class ReceivedBundleElement{
+public:
+ ReceivedBundleElement( const char *size )
+ : size_( size ) {}
+
+ friend class ReceivedBundleElementIterator;
+
+ bool IsMessage() const { return !IsBundle(); }
+ bool IsBundle() const;
+
+ int32 Size() const;
+ const char *Contents() const { return size_ + 4; }
+
+private:
+ const char *size_;
+};
+
+
+class ReceivedBundleElementIterator{
+public:
+ ReceivedBundleElementIterator( const char *sizePtr )
+ : value_( sizePtr ) {}
+
+ ReceivedBundleElementIterator operator++()
+ {
+ Advance();
+ return *this;
+ }
+
+ ReceivedBundleElementIterator operator++(int)
+ {
+ ReceivedBundleElementIterator old( *this );
+ Advance();
+ return old;
+ }
+
+ const ReceivedBundleElement& operator*() const { return value_; }
+
+ const ReceivedBundleElement* operator->() const { return &value_; }
+
+ friend bool operator==(const ReceivedBundleElementIterator& lhs,
+ const ReceivedBundleElementIterator& rhs );
+
+private:
+ ReceivedBundleElement value_;
+
+ void Advance() { value_.size_ = value_.Contents() + value_.Size(); }
+
+ bool IsEqualTo( const ReceivedBundleElementIterator& rhs ) const
+ {
+ return value_.size_ == rhs.value_.size_;
+ }
+};
+
+inline bool operator==(const ReceivedBundleElementIterator& lhs,
+ const ReceivedBundleElementIterator& rhs )
+{
+ return lhs.IsEqualTo( rhs );
+}
+
+inline bool operator!=(const ReceivedBundleElementIterator& lhs,
+ const ReceivedBundleElementIterator& rhs )
+{
+ return !( lhs == rhs );
+}
+
+
+class ReceivedMessageArgument{
+public:
+ ReceivedMessageArgument( const char *typeTag, const char *argument )
+ : typeTag_( typeTag )
+ , argument_( argument ) {}
+
+ friend class ReceivedMessageArgumentIterator;
+
+ const char TypeTag() const { return *typeTag_; }
+
+ // the unchecked methods below don't check whether the argument actually
+ // is of the specified type. they should only be used if you've already
+ // checked the type tag or the associated IsType() method.
+
+ bool IsBool() const
+ { return *typeTag_ == TRUE_TYPE_TAG || *typeTag_ == FALSE_TYPE_TAG; }
+ bool AsBool() const;
+ bool AsBoolUnchecked() const;
+
+ bool IsNil() const { return *typeTag_ == NIL_TYPE_TAG; }
+ bool IsInfinitum() const { return *typeTag_ == INFINITUM_TYPE_TAG; }
+
+ bool IsInt32() const { return *typeTag_ == INT32_TYPE_TAG; }
+ int32 AsInt32() const;
+ int32 AsInt32Unchecked() const;
+
+ bool IsFloat() const { return *typeTag_ == FLOAT_TYPE_TAG; }
+ float AsFloat() const;
+ float AsFloatUnchecked() const;
+
+ bool IsChar() const { return *typeTag_ == CHAR_TYPE_TAG; }
+ char AsChar() const;
+ char AsCharUnchecked() const;
+
+ bool IsRgbaColor() const { return *typeTag_ == RGBA_COLOR_TYPE_TAG; }
+ uint32 AsRgbaColor() const;
+ uint32 AsRgbaColorUnchecked() const;
+
+ bool IsMidiMessage() const { return *typeTag_ == MIDI_MESSAGE_TYPE_TAG; }
+ uint32 AsMidiMessage() const;
+ uint32 AsMidiMessageUnchecked() const;
+
+ bool IsInt64() const { return *typeTag_ == INT64_TYPE_TAG; }
+ int64 AsInt64() const;
+ int64 AsInt64Unchecked() const;
+
+ bool IsTimeTag() const { return *typeTag_ == TIME_TAG_TYPE_TAG; }
+ uint64 AsTimeTag() const;
+ uint64 AsTimeTagUnchecked() const;
+
+ bool IsDouble() const { return *typeTag_ == DOUBLE_TYPE_TAG; }
+ double AsDouble() const;
+ double AsDoubleUnchecked() const;
+
+ bool IsString() const { return *typeTag_ == STRING_TYPE_TAG; }
+ const char* AsString() const;
+ const char* AsStringUnchecked() const { return argument_; }
+
+ bool IsSymbol() const { return *typeTag_ == SYMBOL_TYPE_TAG; }
+ const char* AsSymbol() const;
+ const char* AsSymbolUnchecked() const { return argument_; }
+
+ bool IsBlob() const { return *typeTag_ == BLOB_TYPE_TAG; }
+ void AsBlob( const void*& data, unsigned long& size ) const;
+ void AsBlobUnchecked( const void*& data, unsigned long& size ) const;
+
+private:
+ const char *typeTag_;
+ const char *argument_;
+};
+
+
+class ReceivedMessageArgumentIterator{
+public:
+ ReceivedMessageArgumentIterator( const char *typeTags, const char *arguments )
+ : value_( typeTags, arguments ) {}
+
+ ReceivedMessageArgumentIterator operator++()
+ {
+ Advance();
+ return *this;
+ }
+
+ ReceivedMessageArgumentIterator operator++(int)
+ {
+ ReceivedMessageArgumentIterator old( *this );
+ Advance();
+ return old;
+ }
+
+ const ReceivedMessageArgument& operator*() const { return value_; }
+
+ const ReceivedMessageArgument* operator->() const { return &value_; }
+
+ friend bool operator==(const ReceivedMessageArgumentIterator& lhs,
+ const ReceivedMessageArgumentIterator& rhs );
+
+private:
+ ReceivedMessageArgument value_;
+
+ void Advance();
+
+ bool IsEqualTo( const ReceivedMessageArgumentIterator& rhs ) const
+ {
+ return value_.typeTag_ == rhs.value_.typeTag_;
+ }
+};
+
+inline bool operator==(const ReceivedMessageArgumentIterator& lhs,
+ const ReceivedMessageArgumentIterator& rhs )
+{
+ return lhs.IsEqualTo( rhs );
+}
+
+inline bool operator!=(const ReceivedMessageArgumentIterator& lhs,
+ const ReceivedMessageArgumentIterator& rhs )
+{
+ return !( lhs == rhs );
+}
+
+
+class ReceivedMessageArgumentStream{
+ friend class ReceivedMessage;
+ ReceivedMessageArgumentStream( const ReceivedMessageArgumentIterator& begin,
+ const ReceivedMessageArgumentIterator& end )
+ : p_( begin )
+ , end_( end ) {}
+
+ ReceivedMessageArgumentIterator p_, end_;
+
+public:
+
+ // end of stream
+ bool Eos() const { return p_ == end_; }
+
+ ReceivedMessageArgumentStream& operator>>( bool& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs = (*p_++).AsBool();
+ return *this;
+ }
+
+ // not sure if it would be useful to stream Nil and Infinitum
+ // for now it's not possible
+
+ ReceivedMessageArgumentStream& operator>>( int32& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs = (*p_++).AsInt32();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( float& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs = (*p_++).AsFloat();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( char& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs = (*p_++).AsChar();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( RgbaColor& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs.value = (*p_++).AsRgbaColor();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( MidiMessage& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs.value = (*p_++).AsMidiMessage();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( int64& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs = (*p_++).AsInt64();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( TimeTag& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs.value = (*p_++).AsTimeTag();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( double& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs = (*p_++).AsDouble();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( Blob& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ (*p_++).AsBlob( rhs.data, rhs.size );
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( const char*& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs = (*p_++).AsString();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( Symbol& rhs )
+ {
+ if( Eos() )
+ throw MissingArgumentException();
+
+ rhs.value = (*p_++).AsSymbol();
+ return *this;
+ }
+
+ ReceivedMessageArgumentStream& operator>>( MessageTerminator& rhs )
+ {
+ if( !Eos() )
+ throw ExcessArgumentException();
+
+ return *this;
+ }
+};
+
+
+class ReceivedMessage{
+ void Init( const char *bundle, unsigned long size );
+public:
+ explicit ReceivedMessage( const ReceivedPacket& packet );
+ explicit ReceivedMessage( const ReceivedBundleElement& bundleElement );
+
+ const char *AddressPattern() const { return addressPattern_; }
+
+ // Support for non-standad SuperCollider integer address patterns:
+ bool AddressPatternIsUInt32() const;
+ uint32 AddressPatternAsUInt32() const;
+
+ unsigned long ArgumentCount() const { return static_cast<unsigned long>(typeTagsEnd_ - typeTagsBegin_); }
+
+ const char *TypeTags() const { return typeTagsBegin_; }
+
+
+ typedef ReceivedMessageArgumentIterator const_iterator;
+
+ ReceivedMessageArgumentIterator ArgumentsBegin() const
+ {
+ return ReceivedMessageArgumentIterator( typeTagsBegin_, arguments_ );
+ }
+
+ ReceivedMessageArgumentIterator ArgumentsEnd() const
+ {
+ return ReceivedMessageArgumentIterator( typeTagsEnd_, 0 );
+ }
+
+ ReceivedMessageArgumentStream ArgumentStream() const
+ {
+ return ReceivedMessageArgumentStream( ArgumentsBegin(), ArgumentsEnd() );
+ }
+
+private:
+ const char *addressPattern_;
+ const char *typeTagsBegin_;
+ const char *typeTagsEnd_;
+ const char *arguments_;
+};
+
+
+class ReceivedBundle{
+ void Init( const char *message, unsigned long size );
+public:
+ explicit ReceivedBundle( const ReceivedPacket& packet );
+ explicit ReceivedBundle( const ReceivedBundleElement& bundleElement );
+
+ uint64 TimeTag() const;
+
+ unsigned long ElementCount() const { return elementCount_; }
+
+ typedef ReceivedBundleElementIterator const_iterator;
+
+ ReceivedBundleElementIterator ElementsBegin() const
+ {
+ return ReceivedBundleElementIterator( timeTag_ + 8 );
+ }
+
+ ReceivedBundleElementIterator ElementsEnd() const
+ {
+ return ReceivedBundleElementIterator( end_ );
+ }
+
+private:
+ const char *timeTag_;
+ const char *end_;
+ unsigned long elementCount_;
+};
+
+
+} // namespace osc
+
+
+#endif /* INCLUDED_OSCRECEIVEDELEMENTS_H */
diff --git a/src/oscpack/OscTypes.cpp b/src/oscpack/OscTypes.cpp
new file mode 100644
index 0000000..bb3159d
--- /dev/null
+++ b/src/oscpack/OscTypes.cpp
@@ -0,0 +1,40 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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 "OscTypes.h"
+
+namespace osc{
+
+BundleInitiator BeginBundleImmediate(1);
+BundleTerminator EndBundle;
+MessageTerminator EndMessage;
+NilType Nil;
+InfinitumType Infinitum;
+
+} // namespace osc
diff --git a/src/oscpack/OscTypes.h b/src/oscpack/OscTypes.h
new file mode 100644
index 0000000..0aeebb7
--- /dev/null
+++ b/src/oscpack/OscTypes.h
@@ -0,0 +1,178 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_OSCTYPES_H
+#define INCLUDED_OSCTYPES_H
+
+
+namespace osc{
+
+// basic types
+
+#if defined(__BORLANDC__) || defined(_MSC_VER)
+
+typedef __int64 int64;
+typedef unsigned __int64 uint64;
+
+#else
+
+typedef long long int64;
+typedef unsigned long long uint64;
+
+#endif
+
+
+
+#if defined(__x86_64__) || defined(__APPLE__)
+
+typedef signed int int32;
+typedef unsigned int uint32;
+
+#else
+
+typedef signed long int32;
+typedef unsigned long uint32;
+
+#endif
+
+
+
+enum TypeTagValues {
+ TRUE_TYPE_TAG = 'T',
+ FALSE_TYPE_TAG = 'F',
+ NIL_TYPE_TAG = 'N',
+ INFINITUM_TYPE_TAG = 'I',
+ INT32_TYPE_TAG = 'i',
+ FLOAT_TYPE_TAG = 'f',
+ CHAR_TYPE_TAG = 'c',
+ RGBA_COLOR_TYPE_TAG = 'r',
+ MIDI_MESSAGE_TYPE_TAG = 'm',
+ INT64_TYPE_TAG = 'h',
+ TIME_TAG_TYPE_TAG = 't',
+ DOUBLE_TYPE_TAG = 'd',
+ STRING_TYPE_TAG = 's',
+ SYMBOL_TYPE_TAG = 'S',
+ BLOB_TYPE_TAG = 'b'
+};
+
+
+
+// i/o manipulators used for streaming interfaces
+
+struct BundleInitiator{
+ explicit BundleInitiator( uint64 timeTag_ ) : timeTag( timeTag_ ) {}
+ uint64 timeTag;
+};
+
+extern BundleInitiator BeginBundleImmediate;
+
+inline BundleInitiator BeginBundle( uint64 timeTag=1 )
+{
+ return BundleInitiator(timeTag);
+}
+
+
+struct BundleTerminator{
+};
+
+extern BundleTerminator EndBundle;
+
+struct BeginMessage{
+ explicit BeginMessage( const char *addressPattern_ ) : addressPattern( addressPattern_ ) {}
+ const char *addressPattern;
+};
+
+struct MessageTerminator{
+};
+
+extern MessageTerminator EndMessage;
+
+
+// osc specific types. they are defined as structs so they can be used
+// as separately identifiable types with the streaming operators.
+
+struct NilType{
+};
+
+extern NilType Nil;
+
+
+struct InfinitumType{
+};
+
+extern InfinitumType Infinitum;
+
+struct RgbaColor{
+ RgbaColor() {}
+ explicit RgbaColor( uint32 value_ ) : value( value_ ) {}
+ uint32 value;
+
+ operator uint32() const { return value; }
+};
+
+
+struct MidiMessage{
+ MidiMessage() {}
+ explicit MidiMessage( uint32 value_ ) : value( value_ ) {}
+ uint32 value;
+
+ operator uint32() const { return value; }
+};
+
+
+struct TimeTag{
+ TimeTag() {}
+ explicit TimeTag( uint64 value_ ) : value( value_ ) {}
+ uint64 value;
+
+ operator uint64() const { return value; }
+};
+
+
+struct Symbol{
+ Symbol() {}
+ explicit Symbol( const char* value_ ) : value( value_ ) {}
+ const char* value;
+
+ operator const char *() const { return value; }
+};
+
+
+struct Blob{
+ Blob() {}
+ explicit Blob( const void* data_, unsigned long size_ )
+ : data( data_ ), size( size_ ) {}
+ const void* data;
+ unsigned long size;
+};
+
+} // namespace osc
+
+
+#endif /* INCLUDED_OSCTYPES_H */
diff --git a/src/oscpack/PacketListener.h b/src/oscpack/PacketListener.h
new file mode 100644
index 0000000..5c210f3
--- /dev/null
+++ b/src/oscpack/PacketListener.h
@@ -0,0 +1,44 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_PACKETLISTENER_H
+#define INCLUDED_PACKETLISTENER_H
+
+#include "../api.h"
+
+class IpEndpointName;
+
+class AVG_API PacketListener{
+public:
+ virtual ~PacketListener() {}
+ virtual void ProcessPacket( const char *data, int size,
+ const IpEndpointName& remoteEndpoint ) = 0;
+};
+
+#endif /* INCLUDED_PACKETLISTENER_H */
diff --git a/src/oscpack/README b/src/oscpack/README
new file mode 100644
index 0000000..61964ce
--- /dev/null
+++ b/src/oscpack/README
@@ -0,0 +1,80 @@
+oscpack -- Open Sound Control packet manipulation library
+http://www.audiomulch.com/~rossb/code/oscpack
+
+Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+A simple C++ library for packing and unpacking OSC packets.
+
+
+Oscpack is simply a set of C++ classes for packing and unpacking OSC packets.
+Oscpack includes a minimal set of UDP networking classes for windows and posix
+which are sufficient for writing many OSC applications and servers, but you are
+encouraged to use another networking framework if it better suits your needs.
+Oscpack is not an OSC application framework, it doesn't include infrastructure for
+constructing or routing OSC namespaces, just classes for easily constructing,
+sending, receiving and parsing OSC packets. The library should also be easy to use
+for other transport methods (eg serial).
+
+The key goals of the oscpack library are:
+
+ - to be a simple and complete implementation of OSC
+ - to be portable to a wide variety of platforms
+ - to allow easy development of robust OSC applications
+ (for example it should be impossible to crash a server
+ by sending it malformed packets, and difficult to
+ create malformed packets.)
+
+Here's a summary of the key files:
+
+osc/OscReceivedElements -- classes for parsing a packet
+osc/OscPrintRecievedElements -- iostream << operators for printing packet elements
+osc/OscOutboundPacket -- a class for packing messages into a packet
+osc/OscPacketListener -- base class for listening to OSC packets on a UdpSocket
+tests/OscUnitTests -- unit test program for the OSC modules
+tests/OscSendTests -- examples of how to send messages
+tests/OscReceiveTest -- example of how to receive the messages sent by OSCSendTests
+examples/OscDump -- a program that prints received OSC packets
+
+
+
+Building
+--------
+
+In general the idea is that you will embed this source code in your projects as you
+see fit. The Makefile has an install rule for building a shared library and
+installing headers in usr/local.
+
+The Makefile works for Linux and MaxOS X except that if you are on a big endian
+machine such as PowerPC Macintosh you need to edit the line which sets the
+endianness to OSC_HOST_BIG_ENDIAN (see the makefile comment for details) or it won't
+work. If you want to build and install liboscpack as a library on OS X you also need
+to edit the $(LIBFILENAME) rule by commenting out the Linux case and uncommenting
+the OS X case since OS X uses different gcc flags for shared libraries.
+
+On Windows there is a batch file for doing a simple test build with MinGW gcc called
+make.MinGW32.bat. This will build the test executables and oscdump in ./bin and run
+the unit tests.
+
+--
+
+
+If you fix anything or write a set of TCP send/recieve classes
+please consider sending me a patch. Thanks :)
+
+For more information about Open Sound Control, see:
+http://www.cnmat.berkeley.edu/OpenSoundControl/
+
+
+Thanks to Till Bovermann for helping with POSIX networking code and
+Mac compatibility, and to Martin Kaltenbrunner and the rest of the
+reacTable team for giving me a reason to finish this library. Thanks
+to Merlijn Blaauw for reviewing the interfaces. Thanks to Xavier Oliver
+for additional help with Linux builds and POSIX implementation details.
+
+Portions developed at the Music Technology Group, Audiovisual Institute,
+University Pompeu Fabra, Barcelona, during my stay as a visiting
+researcher, November 2004 - September 2005.
+
+See the file LICENSE for information about distributing and using this code.
+
+
diff --git a/src/oscpack/TODO b/src/oscpack/TODO
new file mode 100644
index 0000000..309ae68
--- /dev/null
+++ b/src/oscpack/TODO
@@ -0,0 +1,55 @@
+TODO:
+
+ - consider adding the local endpoint name to PacketListener::PacketReceived() params
+
+ - consider adding ListenerThread class to support old seperate thread listener functionality, something like:
+
+ class UdpSocketListenerThread{
+ public:
+ UdpSocketListenerThread( UdpSocket& socket, Listener *listener );
+ UdpSocketListenerThread( UdpSocketReceiveMultiplexer *mux );
+ ~UdpSocketListenerThread();
+
+ void Run();
+ void Stop();
+ };
+
+ - provide some kind of automatic endianness configuration (hopefully there
+ are gcc symbols for this)
+
+ - work out a way to make the parsing classes totally safe. at a minimum this
+ means adding functions to test for invalid float/doublevalues,
+ making sure the iterators never pass the end of the message, ...
+ (passing end of message can happen if:
+ - too many args in type tags
+ a. typetags overflow message size
+ b. args fulfilling typetags overflow message size
+ - strings too long or not terminated correctly
+ - blobs too long or not terminated correctly
+
+ if the message was fully checked during construction, the end() iterator
+ could be moved back until only arguments which fit withing size() may
+ be interated (this could be none). A flag could be set to indicate that
+ something was wrong.
+
+ - other packet badness could include:
+ - time tags too far into the future (the scheduler should deal with
+ that i guess).
+ - message address patterns which aren't correctly terminated
+
+ - improve the ability to parse messages without tags (SC uses methods which
+ get the data and advance the iterator in one step.)
+ - Check* could be modified to do this - ie if typetags are not present
+ it could check that reading the field won't escape the message size
+ and return the data, or return false if some consistency
+ constraint is violated.
+ (or alternately drop support for messages without type tags)
+
+
+ - add a method to discard an inprogress message if it gets half
+ constructed and the buffer is full in OutboundPacket
+
+ - write a stress testing app which can send garbage packets to try to flush out other bugs in the parsing code.
+
+
+
diff --git a/src/oscpack/TimerListener.h b/src/oscpack/TimerListener.h
new file mode 100644
index 0000000..502b321
--- /dev/null
+++ b/src/oscpack/TimerListener.h
@@ -0,0 +1,40 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_TIMERLISTENER_H
+#define INCLUDED_TIMERLISTENER_H
+
+
+class TimerListener{
+public:
+ virtual ~TimerListener() {}
+ virtual void TimerExpired() = 0;
+};
+
+#endif /* INCLUDED_TIMERLISTENER_H */
diff --git a/src/oscpack/UdpSocket.cpp b/src/oscpack/UdpSocket.cpp
new file mode 100644
index 0000000..44f266e
--- /dev/null
+++ b/src/oscpack/UdpSocket.cpp
@@ -0,0 +1,1039 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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 "UdpSocket.h"
+
+#ifdef WIN32
+#include <winsock2.h> // this must come first to prevent errors with MSVC7
+#include <windows.h>
+#include <mmsystem.h> // for timeGetTime()
+
+#include <vector>
+#include <algorithm>
+#include <stdexcept>
+#include <assert.h>
+#include <signal.h>
+
+#include "NetworkingUtils.h"
+#include "PacketListener.h"
+#include "TimerListener.h"
+
+
+typedef int socklen_t;
+
+
+static void SockaddrFromIpEndpointName( struct sockaddr_in& sockAddr, const IpEndpointName& endpoint )
+{
+ memset( (char *)&sockAddr, 0, sizeof(sockAddr ) );
+ sockAddr.sin_family = AF_INET;
+
+ sockAddr.sin_addr.s_addr =
+ (endpoint.address == IpEndpointName::ANY_ADDRESS)
+ ? INADDR_ANY
+ : htonl( endpoint.address );
+
+ sockAddr.sin_port =
+ (endpoint.port == IpEndpointName::ANY_PORT)
+ ? (short)0
+ : htons( (short)endpoint.port );
+}
+
+
+static IpEndpointName IpEndpointNameFromSockaddr( const struct sockaddr_in& sockAddr )
+{
+ return IpEndpointName(
+ (sockAddr.sin_addr.s_addr == INADDR_ANY)
+ ? IpEndpointName::ANY_ADDRESS
+ : ntohl( sockAddr.sin_addr.s_addr ),
+ (sockAddr.sin_port == 0)
+ ? IpEndpointName::ANY_PORT
+ : ntohs( sockAddr.sin_port )
+ );
+}
+
+
+class UdpSocket::Implementation{
+ NetworkInitializer networkInitializer_;
+
+ bool isBound_;
+ bool isConnected_;
+
+ SOCKET socket_;
+ struct sockaddr_in connectedAddr_;
+ struct sockaddr_in sendToAddr_;
+
+public:
+
+ Implementation()
+ : isBound_( false )
+ , isConnected_( false )
+ , socket_( INVALID_SOCKET )
+ {
+ if( (socket_ = socket( AF_INET, SOCK_DGRAM, 0 )) == INVALID_SOCKET ){
+ throw std::runtime_error("unable to create udp socket\n");
+ }
+
+ memset( &sendToAddr_, 0, sizeof(sendToAddr_) );
+ sendToAddr_.sin_family = AF_INET;
+ }
+
+ ~Implementation()
+ {
+ if (socket_ != INVALID_SOCKET) closesocket(socket_);
+ }
+
+ IpEndpointName LocalEndpointFor( const IpEndpointName& remoteEndpoint ) const
+ {
+ assert( isBound_ );
+
+ // first connect the socket to the remote server
+
+ struct sockaddr_in connectSockAddr;
+ SockaddrFromIpEndpointName( connectSockAddr, remoteEndpoint );
+
+ if (connect(socket_, (struct sockaddr *)&connectSockAddr, sizeof(connectSockAddr)) < 0) {
+ throw std::runtime_error("unable to connect udp socket\n");
+ }
+
+ // get the address
+
+ struct sockaddr_in sockAddr;
+ memset( (char *)&sockAddr, 0, sizeof(sockAddr ) );
+ socklen_t length = sizeof(sockAddr);
+ if (getsockname(socket_, (struct sockaddr *)&sockAddr, &length) < 0) {
+ throw std::runtime_error("unable to getsockname\n");
+ }
+
+ if( isConnected_ ){
+ // reconnect to the connected address
+
+ if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) {
+ throw std::runtime_error("unable to connect udp socket\n");
+ }
+
+ }else{
+ // unconnect from the remote address
+
+ struct sockaddr_in unconnectSockAddr;
+ SockaddrFromIpEndpointName( unconnectSockAddr, IpEndpointName() );
+
+ if( connect(socket_, (struct sockaddr *)&unconnectSockAddr, sizeof(unconnectSockAddr)) < 0
+ && WSAGetLastError() != WSAEADDRNOTAVAIL ){
+ throw std::runtime_error("unable to un-connect udp socket\n");
+ }
+ }
+
+ return IpEndpointNameFromSockaddr( sockAddr );
+ }
+
+ void Connect( const IpEndpointName& remoteEndpoint )
+ {
+ SockaddrFromIpEndpointName( connectedAddr_, remoteEndpoint );
+
+ if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) {
+ throw std::runtime_error("unable to connect udp socket\n");
+ }
+
+ isConnected_ = true;
+ }
+
+ void Send( const char *data, int size )
+ {
+ assert( isConnected_ );
+
+ send( socket_, data, size, 0 );
+ }
+
+ void SendTo( const IpEndpointName& remoteEndpoint, const char *data, int size )
+ {
+ sendToAddr_.sin_addr.s_addr = htonl( remoteEndpoint.address );
+ sendToAddr_.sin_port = htons( (short)remoteEndpoint.port );
+
+ sendto( socket_, data, size, 0, (sockaddr*)&sendToAddr_, sizeof(sendToAddr_) );
+ }
+
+ void Bind( const IpEndpointName& localEndpoint )
+ {
+ struct sockaddr_in bindSockAddr;
+ SockaddrFromIpEndpointName( bindSockAddr, localEndpoint );
+
+ if (bind(socket_, (struct sockaddr *)&bindSockAddr, sizeof(bindSockAddr)) < 0) {
+ throw std::runtime_error("unable to bind udp socket\n");
+ }
+
+ isBound_ = true;
+ }
+
+ bool IsBound() const { return isBound_; }
+
+ int ReceiveFrom( IpEndpointName& remoteEndpoint, char *data, int size )
+ {
+ assert( isBound_ );
+
+ struct sockaddr_in fromAddr;
+ socklen_t fromAddrLen = sizeof(fromAddr);
+
+ int result = recvfrom(socket_, data, size, 0,
+ (struct sockaddr *) &fromAddr, (socklen_t*)&fromAddrLen);
+ if( result < 0 )
+ return 0;
+
+ remoteEndpoint.address = ntohl(fromAddr.sin_addr.s_addr);
+ remoteEndpoint.port = ntohs(fromAddr.sin_port);
+
+ return result;
+ }
+
+ SOCKET& Socket() { return socket_; }
+};
+
+UdpSocket::UdpSocket()
+{
+ impl_ = new Implementation();
+}
+
+UdpSocket::~UdpSocket()
+{
+ delete impl_;
+}
+
+IpEndpointName UdpSocket::LocalEndpointFor( const IpEndpointName& remoteEndpoint ) const
+{
+ return impl_->LocalEndpointFor( remoteEndpoint );
+}
+
+void UdpSocket::Connect( const IpEndpointName& remoteEndpoint )
+{
+ impl_->Connect( remoteEndpoint );
+}
+
+void UdpSocket::Send( const char *data, int size )
+{
+ impl_->Send( data, size );
+}
+
+void UdpSocket::SendTo( const IpEndpointName& remoteEndpoint, const char *data, int size )
+{
+ impl_->SendTo( remoteEndpoint, data, size );
+}
+
+void UdpSocket::Bind( const IpEndpointName& localEndpoint )
+{
+ impl_->Bind( localEndpoint );
+}
+
+bool UdpSocket::IsBound() const
+{
+ return impl_->IsBound();
+}
+
+int UdpSocket::ReceiveFrom( IpEndpointName& remoteEndpoint, char *data, int size )
+{
+ return impl_->ReceiveFrom( remoteEndpoint, data, size );
+}
+
+
+struct AttachedTimerListener{
+ AttachedTimerListener( int id, int p, TimerListener *tl )
+ : initialDelayMs( id )
+ , periodMs( p )
+ , listener( tl ) {}
+ int initialDelayMs;
+ int periodMs;
+ TimerListener *listener;
+};
+
+
+static bool CompareScheduledTimerCalls(
+ const std::pair< double, AttachedTimerListener > & lhs, const std::pair< double, AttachedTimerListener > & rhs )
+{
+ return lhs.first < rhs.first;
+}
+
+
+SocketReceiveMultiplexer *multiplexerInstanceToAbortWithSigInt_ = 0;
+
+extern "C" /*static*/ void InterruptSignalHandler( int );
+/*static*/ void InterruptSignalHandler( int )
+{
+ multiplexerInstanceToAbortWithSigInt_->AsynchronousBreak();
+ signal( SIGINT, SIG_DFL );
+}
+
+
+class SocketReceiveMultiplexer::Implementation{
+ NetworkInitializer networkInitializer_;
+
+ std::vector< std::pair< PacketListener*, UdpSocket* > > socketListeners_;
+ std::vector< AttachedTimerListener > timerListeners_;
+
+ volatile bool break_;
+ HANDLE breakEvent_;
+
+ double GetCurrentTimeMs() const
+ {
+ return timeGetTime(); // FIXME: bad choice if you want to run for more than 40 days
+ }
+
+public:
+ Implementation()
+ {
+ breakEvent_ = CreateEvent( NULL, FALSE, FALSE, NULL );
+ }
+
+ ~Implementation()
+ {
+ CloseHandle( breakEvent_ );
+ }
+
+ void AttachSocketListener( UdpSocket *socket, PacketListener *listener )
+ {
+ assert( std::find( socketListeners_.begin(), socketListeners_.end(), std::make_pair(listener, socket) ) == socketListeners_.end() );
+ // we don't check that the same socket has been added multiple times, even though this is an error
+ socketListeners_.push_back( std::make_pair( listener, socket ) );
+ }
+
+ void DetachSocketListener( UdpSocket *socket, PacketListener *listener )
+ {
+ std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i =
+ std::find( socketListeners_.begin(), socketListeners_.end(), std::make_pair(listener, socket) );
+ assert( i != socketListeners_.end() );
+
+ socketListeners_.erase( i );
+ }
+
+ void AttachPeriodicTimerListener( int periodMilliseconds, TimerListener *listener )
+ {
+ timerListeners_.push_back( AttachedTimerListener( periodMilliseconds, periodMilliseconds, listener ) );
+ }
+
+ void AttachPeriodicTimerListener( int initialDelayMilliseconds, int periodMilliseconds, TimerListener *listener )
+ {
+ timerListeners_.push_back( AttachedTimerListener( initialDelayMilliseconds, periodMilliseconds, listener ) );
+ }
+
+ void DetachPeriodicTimerListener( TimerListener *listener )
+ {
+ std::vector< AttachedTimerListener >::iterator i = timerListeners_.begin();
+ while( i != timerListeners_.end() ){
+ if( i->listener == listener )
+ break;
+ ++i;
+ }
+
+ assert( i != timerListeners_.end() );
+
+ timerListeners_.erase( i );
+ }
+
+ void Run()
+ {
+ break_ = false;
+
+ // prepare the window events which we use to wake up on incoming data
+ // we use this instead of select() primarily to support the AsyncBreak()
+ // mechanism.
+
+ std::vector<HANDLE> events( socketListeners_.size() + 1, 0 );
+ int j=0;
+ for( std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i = socketListeners_.begin();
+ i != socketListeners_.end(); ++i, ++j ){
+
+ HANDLE event = CreateEvent( NULL, FALSE, FALSE, NULL );
+ WSAEventSelect( i->second->impl_->Socket(), event, FD_READ ); // note that this makes the socket non-blocking which is why we can safely call RecieveFrom() on all sockets below
+ events[j] = event;
+ }
+
+
+ events[ socketListeners_.size() ] = breakEvent_; // last event in the collection is the break event
+
+
+ // configure the timer queue
+ double currentTimeMs = GetCurrentTimeMs();
+
+ // expiry time ms, listener
+ std::vector< std::pair< double, AttachedTimerListener > > timerQueue_;
+ for( std::vector< AttachedTimerListener >::iterator i = timerListeners_.begin();
+ i != timerListeners_.end(); ++i )
+ timerQueue_.push_back( std::make_pair( currentTimeMs + i->initialDelayMs, *i ) );
+ std::sort( timerQueue_.begin(), timerQueue_.end(), CompareScheduledTimerCalls );
+
+ const int MAX_BUFFER_SIZE = 4098;
+ char *data = new char[ MAX_BUFFER_SIZE ];
+ IpEndpointName remoteEndpoint;
+
+ while( !break_ ){
+
+ double currentTimeMs = GetCurrentTimeMs();
+
+ DWORD waitTime = INFINITE;
+ if( !timerQueue_.empty() ){
+
+ waitTime = (DWORD)( timerQueue_.front().first >= currentTimeMs
+ ? timerQueue_.front().first - currentTimeMs
+ : 0 );
+ }
+
+ DWORD waitResult = WaitForMultipleObjects( (DWORD)socketListeners_.size() + 1, &events[0], FALSE, waitTime );
+ if( break_ )
+ break;
+
+ if( waitResult != WAIT_TIMEOUT ){
+ for( int i = waitResult - WAIT_OBJECT_0; i < (int)socketListeners_.size(); ++i ){
+ int size = socketListeners_[i].second->ReceiveFrom( remoteEndpoint, data, MAX_BUFFER_SIZE );
+ if( size > 0 ){
+ socketListeners_[i].first->ProcessPacket( data, size, remoteEndpoint );
+ if( break_ )
+ break;
+ }
+ }
+ }
+
+ // execute any expired timers
+ currentTimeMs = GetCurrentTimeMs();
+ bool resort = false;
+ for( std::vector< std::pair< double, AttachedTimerListener > >::iterator i = timerQueue_.begin();
+ i != timerQueue_.end() && i->first <= currentTimeMs; ++i ){
+
+ i->second.listener->TimerExpired();
+ if( break_ )
+ break;
+
+ i->first += i->second.periodMs;
+ resort = true;
+ }
+ if( resort )
+ std::sort( timerQueue_.begin(), timerQueue_.end(), CompareScheduledTimerCalls );
+ }
+
+ delete [] data;
+
+ // free events
+ j = 0;
+ for( std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i = socketListeners_.begin();
+ i != socketListeners_.end(); ++i, ++j ){
+
+ WSAEventSelect( i->second->impl_->Socket(), events[j], 0 ); // remove association between socket and event
+ CloseHandle( events[j] );
+ unsigned long enableNonblocking = 0;
+ ioctlsocket( i->second->impl_->Socket(), FIONBIO, &enableNonblocking ); // make the socket blocking again
+ }
+ }
+
+ void Break()
+ {
+ break_ = true;
+ }
+
+ void AsynchronousBreak()
+ {
+ break_ = true;
+ SetEvent( breakEvent_ );
+ }
+};
+
+
+
+SocketReceiveMultiplexer::SocketReceiveMultiplexer()
+{
+ impl_ = new Implementation();
+}
+
+SocketReceiveMultiplexer::~SocketReceiveMultiplexer()
+{
+ delete impl_;
+}
+
+void SocketReceiveMultiplexer::AttachSocketListener( UdpSocket *socket, PacketListener *listener )
+{
+ impl_->AttachSocketListener( socket, listener );
+}
+
+void SocketReceiveMultiplexer::DetachSocketListener( UdpSocket *socket, PacketListener *listener )
+{
+ impl_->DetachSocketListener( socket, listener );
+}
+
+void SocketReceiveMultiplexer::AttachPeriodicTimerListener( int periodMilliseconds, TimerListener *listener )
+{
+ impl_->AttachPeriodicTimerListener( periodMilliseconds, listener );
+}
+
+void SocketReceiveMultiplexer::AttachPeriodicTimerListener( int initialDelayMilliseconds, int periodMilliseconds, TimerListener *listener )
+{
+ impl_->AttachPeriodicTimerListener( initialDelayMilliseconds, periodMilliseconds, listener );
+}
+
+void SocketReceiveMultiplexer::DetachPeriodicTimerListener( TimerListener *listener )
+{
+ impl_->DetachPeriodicTimerListener( listener );
+}
+
+void SocketReceiveMultiplexer::Run()
+{
+ impl_->Run();
+}
+
+void SocketReceiveMultiplexer::RunUntilSigInt()
+{
+ assert( multiplexerInstanceToAbortWithSigInt_ == 0 ); /* at present we support only one multiplexer instance running until sig int */
+ multiplexerInstanceToAbortWithSigInt_ = this;
+ signal( SIGINT, InterruptSignalHandler );
+ impl_->Run();
+ signal( SIGINT, SIG_DFL );
+ multiplexerInstanceToAbortWithSigInt_ = 0;
+}
+
+void SocketReceiveMultiplexer::Break()
+{
+ impl_->Break();
+}
+
+void SocketReceiveMultiplexer::AsynchronousBreak()
+{
+ impl_->AsynchronousBreak();
+}
+
+#else
+
+#include <vector>
+#include <algorithm>
+#include <stdexcept>
+#include <assert.h>
+#include <signal.h>
+#include <math.h>
+#include <errno.h>
+#include <string.h> // for memset
+
+#include <pthread.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <netdb.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <netinet/in.h> // for sockaddr_in
+
+#include "PacketListener.h"
+#include "TimerListener.h"
+
+
+#if defined(__APPLE__) && !defined(_SOCKLEN_T)
+// pre system 10.3 didn have socklen_t
+typedef ssize_t socklen_t;
+#endif
+
+
+static void SockaddrFromIpEndpointName( struct sockaddr_in& sockAddr, const IpEndpointName& endpoint )
+{
+ memset( (char *)&sockAddr, 0, sizeof(sockAddr ) );
+ sockAddr.sin_family = AF_INET;
+
+ sockAddr.sin_addr.s_addr =
+ (endpoint.address == IpEndpointName::ANY_ADDRESS)
+ ? INADDR_ANY
+ : htonl( endpoint.address );
+
+ sockAddr.sin_port =
+ (endpoint.port == IpEndpointName::ANY_PORT)
+ ? 0
+ : htons( endpoint.port );
+}
+
+
+static IpEndpointName IpEndpointNameFromSockaddr( const struct sockaddr_in& sockAddr )
+{
+ return IpEndpointName(
+ (sockAddr.sin_addr.s_addr == INADDR_ANY)
+ ? IpEndpointName::ANY_ADDRESS
+ : ntohl( sockAddr.sin_addr.s_addr ),
+ (sockAddr.sin_port == 0)
+ ? IpEndpointName::ANY_PORT
+ : ntohs( sockAddr.sin_port )
+ );
+}
+
+
+class UdpSocket::Implementation{
+ bool isBound_;
+ bool isConnected_;
+
+ int socket_;
+ struct sockaddr_in connectedAddr_;
+ struct sockaddr_in sendToAddr_;
+
+public:
+
+ Implementation()
+ : isBound_( false )
+ , isConnected_( false )
+ , socket_( -1 )
+ {
+ if( (socket_ = socket( AF_INET, SOCK_DGRAM, 0 )) == -1 ){
+ throw std::runtime_error("unable to create udp socket\n");
+ }
+
+ memset( &sendToAddr_, 0, sizeof(sendToAddr_) );
+ sendToAddr_.sin_family = AF_INET;
+ }
+
+ ~Implementation()
+ {
+ if (socket_ != -1) close(socket_);
+ }
+
+ IpEndpointName LocalEndpointFor( const IpEndpointName& remoteEndpoint ) const
+ {
+ assert( isBound_ );
+
+ // first connect the socket to the remote server
+
+ struct sockaddr_in connectSockAddr;
+ SockaddrFromIpEndpointName( connectSockAddr, remoteEndpoint );
+
+ if (connect(socket_, (struct sockaddr *)&connectSockAddr, sizeof(connectSockAddr)) < 0) {
+ throw std::runtime_error("unable to connect udp socket\n");
+ }
+
+ // get the address
+
+ struct sockaddr_in sockAddr;
+ memset( (char *)&sockAddr, 0, sizeof(sockAddr ) );
+ socklen_t length = sizeof(sockAddr);
+ if (getsockname(socket_, (struct sockaddr *)&sockAddr, &length) < 0) {
+ throw std::runtime_error("unable to getsockname\n");
+ }
+
+ if( isConnected_ ){
+ // reconnect to the connected address
+
+ if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) {
+ throw std::runtime_error("unable to connect udp socket\n");
+ }
+
+ }else{
+ // unconnect from the remote address
+
+ struct sockaddr_in unconnectSockAddr;
+ memset( (char *)&unconnectSockAddr, 0, sizeof(unconnectSockAddr ) );
+ unconnectSockAddr.sin_family = AF_UNSPEC;
+ // address fields are zero
+ int connectResult = connect(socket_, (struct sockaddr *)&unconnectSockAddr, sizeof(unconnectSockAddr));
+ if ( connectResult < 0 && errno != EAFNOSUPPORT ) {
+ throw std::runtime_error("unable to un-connect udp socket\n");
+ }
+ }
+
+ return IpEndpointNameFromSockaddr( sockAddr );
+ }
+
+ void Connect( const IpEndpointName& remoteEndpoint )
+ {
+ SockaddrFromIpEndpointName( connectedAddr_, remoteEndpoint );
+
+ if (connect(socket_, (struct sockaddr *)&connectedAddr_, sizeof(connectedAddr_)) < 0) {
+ throw std::runtime_error("unable to connect udp socket\n");
+ }
+
+ isConnected_ = true;
+ }
+
+ void Send( const char *data, int size )
+ {
+ assert( isConnected_ );
+
+ send( socket_, data, size, 0 );
+ }
+
+ void SendTo( const IpEndpointName& remoteEndpoint, const char *data, int size )
+ {
+ sendToAddr_.sin_addr.s_addr = htonl( remoteEndpoint.address );
+ sendToAddr_.sin_port = htons( remoteEndpoint.port );
+
+ sendto( socket_, data, size, 0, (sockaddr*)&sendToAddr_, sizeof(sendToAddr_) );
+ }
+
+ void Bind( const IpEndpointName& localEndpoint )
+ {
+ struct sockaddr_in bindSockAddr;
+ SockaddrFromIpEndpointName( bindSockAddr, localEndpoint );
+
+ if (bind(socket_, (struct sockaddr *)&bindSockAddr, sizeof(bindSockAddr)) < 0) {
+ throw std::runtime_error("unable to bind udp socket\n");
+ }
+
+ isBound_ = true;
+ }
+
+ bool IsBound() const { return isBound_; }
+
+ int ReceiveFrom( IpEndpointName& remoteEndpoint, char *data, int size )
+ {
+ assert( isBound_ );
+
+ struct sockaddr_in fromAddr;
+ socklen_t fromAddrLen = sizeof(fromAddr);
+
+ int result = recvfrom(socket_, data, size, 0,
+ (struct sockaddr *) &fromAddr, (socklen_t*)&fromAddrLen);
+ if( result < 0 )
+ return 0;
+
+ remoteEndpoint.address = ntohl(fromAddr.sin_addr.s_addr);
+ remoteEndpoint.port = ntohs(fromAddr.sin_port);
+
+ return result;
+ }
+
+ int Socket() { return socket_; }
+};
+
+UdpSocket::UdpSocket()
+{
+ impl_ = new Implementation();
+}
+
+UdpSocket::~UdpSocket()
+{
+ delete impl_;
+}
+
+IpEndpointName UdpSocket::LocalEndpointFor( const IpEndpointName& remoteEndpoint ) const
+{
+ return impl_->LocalEndpointFor( remoteEndpoint );
+}
+
+void UdpSocket::Connect( const IpEndpointName& remoteEndpoint )
+{
+ impl_->Connect( remoteEndpoint );
+}
+
+void UdpSocket::Send( const char *data, int size )
+{
+ impl_->Send( data, size );
+}
+
+void UdpSocket::SendTo( const IpEndpointName& remoteEndpoint, const char *data, int size )
+{
+ impl_->SendTo( remoteEndpoint, data, size );
+}
+
+void UdpSocket::Bind( const IpEndpointName& localEndpoint )
+{
+ impl_->Bind( localEndpoint );
+}
+
+bool UdpSocket::IsBound() const
+{
+ return impl_->IsBound();
+}
+
+int UdpSocket::ReceiveFrom( IpEndpointName& remoteEndpoint, char *data, int size )
+{
+ return impl_->ReceiveFrom( remoteEndpoint, data, size );
+}
+
+
+struct AttachedTimerListener{
+ AttachedTimerListener( int id, int p, TimerListener *tl )
+ : initialDelayMs( id )
+ , periodMs( p )
+ , listener( tl ) {}
+ int initialDelayMs;
+ int periodMs;
+ TimerListener *listener;
+};
+
+
+static bool CompareScheduledTimerCalls(
+ const std::pair< double, AttachedTimerListener > & lhs, const std::pair< double, AttachedTimerListener > & rhs )
+{
+ return lhs.first < rhs.first;
+}
+
+
+SocketReceiveMultiplexer *multiplexerInstanceToAbortWithSigInt_ = 0;
+
+extern "C" /*static*/ void InterruptSignalHandler( int );
+/*static*/ void InterruptSignalHandler( int )
+{
+ multiplexerInstanceToAbortWithSigInt_->AsynchronousBreak();
+ signal( SIGINT, SIG_DFL );
+}
+
+
+class SocketReceiveMultiplexer::Implementation{
+ std::vector< std::pair< PacketListener*, UdpSocket* > > socketListeners_;
+ std::vector< AttachedTimerListener > timerListeners_;
+
+ volatile bool break_;
+ int breakPipe_[2]; // [0] is the reader descriptor and [1] the writer
+
+ double GetCurrentTimeMs() const
+ {
+ struct timeval t;
+
+ gettimeofday( &t, 0 );
+
+ return ((double)t.tv_sec*1000.) + ((double)t.tv_usec / 1000.);
+ }
+
+public:
+ Implementation()
+ {
+ if( pipe(breakPipe_) != 0 )
+ throw std::runtime_error( "creation of asynchronous break pipes failed\n" );
+ }
+
+ ~Implementation()
+ {
+ close( breakPipe_[0] );
+ close( breakPipe_[1] );
+ }
+
+ void AttachSocketListener( UdpSocket *socket, PacketListener *listener )
+ {
+ assert( std::find( socketListeners_.begin(), socketListeners_.end(), std::make_pair(listener, socket) ) == socketListeners_.end() );
+ // we don't check that the same socket has been added multiple times, even though this is an error
+ socketListeners_.push_back( std::make_pair( listener, socket ) );
+ }
+
+ void DetachSocketListener( UdpSocket *socket, PacketListener *listener )
+ {
+ std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i =
+ std::find( socketListeners_.begin(), socketListeners_.end(), std::make_pair(listener, socket) );
+ assert( i != socketListeners_.end() );
+
+ socketListeners_.erase( i );
+ }
+
+ void AttachPeriodicTimerListener( int periodMilliseconds, TimerListener *listener )
+ {
+ timerListeners_.push_back( AttachedTimerListener( periodMilliseconds, periodMilliseconds, listener ) );
+ }
+
+ void AttachPeriodicTimerListener( int initialDelayMilliseconds, int periodMilliseconds, TimerListener *listener )
+ {
+ timerListeners_.push_back( AttachedTimerListener( initialDelayMilliseconds, periodMilliseconds, listener ) );
+ }
+
+ void DetachPeriodicTimerListener( TimerListener *listener )
+ {
+ std::vector< AttachedTimerListener >::iterator i = timerListeners_.begin();
+ while( i != timerListeners_.end() ){
+ if( i->listener == listener )
+ break;
+ ++i;
+ }
+
+ assert( i != timerListeners_.end() );
+
+ timerListeners_.erase( i );
+ }
+
+ void Run()
+ {
+ break_ = false;
+
+ // configure the master fd_set for select()
+
+ fd_set masterfds, tempfds;
+ FD_ZERO( &masterfds );
+ FD_ZERO( &tempfds );
+
+ // in addition to listening to the inbound sockets we
+ // also listen to the asynchronous break pipe, so that AsynchronousBreak()
+ // can break us out of select() from another thread.
+ FD_SET( breakPipe_[0], &masterfds );
+ int fdmax = breakPipe_[0];
+
+ for( std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i = socketListeners_.begin();
+ i != socketListeners_.end(); ++i ){
+
+ if( fdmax < i->second->impl_->Socket() )
+ fdmax = i->second->impl_->Socket();
+ FD_SET( i->second->impl_->Socket(), &masterfds );
+ }
+
+
+ // configure the timer queue
+ double currentTimeMs = GetCurrentTimeMs();
+
+ // expiry time ms, listener
+ std::vector< std::pair< double, AttachedTimerListener > > timerQueue_;
+ for( std::vector< AttachedTimerListener >::iterator i = timerListeners_.begin();
+ i != timerListeners_.end(); ++i )
+ timerQueue_.push_back( std::make_pair( currentTimeMs + i->initialDelayMs, *i ) );
+ std::sort( timerQueue_.begin(), timerQueue_.end(), CompareScheduledTimerCalls );
+
+ const int MAX_BUFFER_SIZE = 4098;
+ char *data = new char[ MAX_BUFFER_SIZE ];
+ IpEndpointName remoteEndpoint;
+
+ struct timeval timeout;
+
+ while( !break_ ){
+ tempfds = masterfds;
+
+ struct timeval *timeoutPtr = 0;
+ if( !timerQueue_.empty() ){
+ double timeoutMs = timerQueue_.front().first - GetCurrentTimeMs();
+ if( timeoutMs < 0 )
+ timeoutMs = 0;
+
+ // 1000000 microseconds in a second
+ timeout.tv_sec = (long)(timeoutMs * .001);
+ timeout.tv_usec = (long)((timeoutMs - (timeout.tv_sec * 1000)) * 1000);
+ timeoutPtr = &timeout;
+ }
+
+ if( select( fdmax + 1, &tempfds, 0, 0, timeoutPtr ) < 0 && errno != EINTR ){
+ throw std::runtime_error("select failed\n");
+ }
+
+ if ( FD_ISSET( breakPipe_[0], &tempfds ) ){
+ // clear pending data from the asynchronous break pipe
+ char c;
+ if (read( breakPipe_[0], &c, 1 )) {};
+ }
+
+ if( break_ )
+ break;
+
+ for( std::vector< std::pair< PacketListener*, UdpSocket* > >::iterator i = socketListeners_.begin();
+ i != socketListeners_.end(); ++i ){
+
+ if( FD_ISSET( i->second->impl_->Socket(), &tempfds ) ){
+
+ int size = i->second->ReceiveFrom( remoteEndpoint, data, MAX_BUFFER_SIZE );
+ if( size > 0 ){
+ i->first->ProcessPacket( data, size, remoteEndpoint );
+ if( break_ )
+ break;
+ }
+ }
+ }
+
+ // execute any expired timers
+ currentTimeMs = GetCurrentTimeMs();
+ bool resort = false;
+ for( std::vector< std::pair< double, AttachedTimerListener > >::iterator i = timerQueue_.begin();
+ i != timerQueue_.end() && i->first <= currentTimeMs; ++i ){
+
+ i->second.listener->TimerExpired();
+ if( break_ )
+ break;
+
+ i->first += i->second.periodMs;
+ resort = true;
+ }
+ if( resort )
+ std::sort( timerQueue_.begin(), timerQueue_.end(), CompareScheduledTimerCalls );
+ }
+
+ delete [] data;
+ }
+
+ void Break()
+ {
+ break_ = true;
+ }
+
+ void AsynchronousBreak()
+ {
+ break_ = true;
+
+ // Send a termination message to the asynchronous break pipe, so select() will return
+ if (write( breakPipe_[1], "!", 1 )) {};
+ }
+};
+
+
+
+SocketReceiveMultiplexer::SocketReceiveMultiplexer()
+{
+ impl_ = new Implementation();
+}
+
+SocketReceiveMultiplexer::~SocketReceiveMultiplexer()
+{
+ delete impl_;
+}
+
+void SocketReceiveMultiplexer::AttachSocketListener( UdpSocket *socket, PacketListener *listener )
+{
+ impl_->AttachSocketListener( socket, listener );
+}
+
+void SocketReceiveMultiplexer::DetachSocketListener( UdpSocket *socket, PacketListener *listener )
+{
+ impl_->DetachSocketListener( socket, listener );
+}
+
+void SocketReceiveMultiplexer::AttachPeriodicTimerListener( int periodMilliseconds, TimerListener *listener )
+{
+ impl_->AttachPeriodicTimerListener( periodMilliseconds, listener );
+}
+
+void SocketReceiveMultiplexer::AttachPeriodicTimerListener( int initialDelayMilliseconds, int periodMilliseconds, TimerListener *listener )
+{
+ impl_->AttachPeriodicTimerListener( initialDelayMilliseconds, periodMilliseconds, listener );
+}
+
+void SocketReceiveMultiplexer::DetachPeriodicTimerListener( TimerListener *listener )
+{
+ impl_->DetachPeriodicTimerListener( listener );
+}
+
+void SocketReceiveMultiplexer::Run()
+{
+ impl_->Run();
+}
+
+void SocketReceiveMultiplexer::RunUntilSigInt()
+{
+ assert( multiplexerInstanceToAbortWithSigInt_ == 0 ); /* at present we support only one multiplexer instance running until sig int */
+ multiplexerInstanceToAbortWithSigInt_ = this;
+ signal( SIGINT, InterruptSignalHandler );
+ impl_->Run();
+ signal( SIGINT, SIG_DFL );
+ multiplexerInstanceToAbortWithSigInt_ = 0;
+}
+
+void SocketReceiveMultiplexer::Break()
+{
+ impl_->Break();
+}
+
+void SocketReceiveMultiplexer::AsynchronousBreak()
+{
+ impl_->AsynchronousBreak();
+}
+#endif
diff --git a/src/oscpack/UdpSocket.h b/src/oscpack/UdpSocket.h
new file mode 100644
index 0000000..b9ec5db
--- /dev/null
+++ b/src/oscpack/UdpSocket.h
@@ -0,0 +1,158 @@
+/*
+ oscpack -- Open Sound Control packet manipulation library
+ http://www.audiomulch.com/~rossb/oscpack
+
+ Copyright (c) 2004-2005 Ross Bencina <rossb@audiomulch.com>
+
+ 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.
+
+ Any person wishing to distribute modifications to the Software is
+ requested to send the modifications to the original developer so that
+ they can be incorporated into the canonical version.
+
+ 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.
+*/
+#ifndef INCLUDED_UDPSOCKET_H
+#define INCLUDED_UDPSOCKET_H
+
+#ifndef INCLUDED_NETWORKINGUTILITIES_H
+#include "NetworkingUtils.h"
+#endif /* INCLUDED_NETWORKINGUTILITIES_H */
+
+#ifndef INCLUDED_IPENDPOINTNAME_H
+#include "IpEndpointName.h"
+#endif /* INCLUDED_IPENDPOINTNAME_H */
+
+
+class PacketListener;
+class TimerListener;
+
+class UdpSocket;
+
+class SocketReceiveMultiplexer{
+ class Implementation;
+ Implementation *impl_;
+
+ friend class UdpSocket;
+
+public:
+ SocketReceiveMultiplexer();
+ ~SocketReceiveMultiplexer();
+
+ // only call the attach/detach methods _before_ calling Run
+
+ // only one listener per socket, each socket at most once
+ void AttachSocketListener( UdpSocket *socket, PacketListener *listener );
+ void DetachSocketListener( UdpSocket *socket, PacketListener *listener );
+
+ void AttachPeriodicTimerListener( int periodMilliseconds, TimerListener *listener );
+ void AttachPeriodicTimerListener(
+ int initialDelayMilliseconds, int periodMilliseconds, TimerListener *listener );
+ void DetachPeriodicTimerListener( TimerListener *listener );
+
+ void Run(); // loop and block processing messages indefinitely
+ void RunUntilSigInt();
+ void Break(); // call this from a listener to exit once the listener returns
+ void AsynchronousBreak(); // call this from another thread or signal handler to exit the Run() state
+};
+
+
+class UdpSocket{
+ class Implementation;
+ Implementation *impl_;
+
+ friend class SocketReceiveMultiplexer::Implementation;
+
+public:
+
+ // ctor throws std::runtime_error if there's a problem
+ // initializing the socket.
+ UdpSocket();
+ virtual ~UdpSocket();
+
+ // the socket is created in an unbound, unconnected state
+ // such a socket can only be used to send to an arbitrary
+ // address using SendTo(). To use Send() you need to first
+ // connect to a remote endpoint using Connect(). To use
+ // ReceiveFrom you need to first bind to a local endpoint
+ // using Bind().
+
+ // retrieve the local endpoint name when sending to 'to'
+ IpEndpointName LocalEndpointFor( const IpEndpointName& remoteEndpoint ) const;
+
+ // Connect to a remote endpoint which is used as the target
+ // for calls to Send()
+ void Connect( const IpEndpointName& remoteEndpoint );
+ void Send( const char *data, int size );
+ void SendTo( const IpEndpointName& remoteEndpoint, const char *data, int size );
+
+
+ // Bind a local endpoint to receive incoming data. Endpoint
+ // can be 'any' for the system to choose an endpoint
+ void Bind( const IpEndpointName& localEndpoint );
+ bool IsBound() const;
+
+ int ReceiveFrom( IpEndpointName& remoteEndpoint, char *data, int size );
+};
+
+
+// convenience classes for transmitting and receiving
+// they just call Connect and/or Bind in the ctor.
+// note that you can still use a receive socket
+// for transmitting etc
+
+class UdpTransmitSocket : public UdpSocket{
+public:
+ UdpTransmitSocket( const IpEndpointName& remoteEndpoint )
+ { Connect( remoteEndpoint ); }
+};
+
+
+class UdpReceiveSocket : public UdpSocket{
+public:
+ UdpReceiveSocket( const IpEndpointName& localEndpoint )
+ { Bind( localEndpoint ); }
+};
+
+
+// UdpListeningReceiveSocket provides a simple way to bind one listener
+// to a single socket without having to manually set up a SocketReceiveMultiplexer
+
+class UdpListeningReceiveSocket : public UdpSocket{
+ SocketReceiveMultiplexer mux_;
+ PacketListener *listener_;
+public:
+ UdpListeningReceiveSocket( const IpEndpointName& localEndpoint, PacketListener *listener )
+ : listener_( listener )
+ {
+ Bind( localEndpoint );
+ mux_.AttachSocketListener( this, listener_ );
+ }
+
+ ~UdpListeningReceiveSocket()
+ { mux_.DetachSocketListener( this, listener_ ); }
+
+ // see SocketReceiveMultiplexer above for the behaviour of these methods...
+ void Run() { mux_.Run(); }
+ void RunUntilSigInt() { mux_.RunUntilSigInt(); }
+ void Break() { mux_.Break(); }
+ void AsynchronousBreak() { mux_.AsynchronousBreak(); }
+};
+
+
+#endif /* INCLUDED_UDPSOCKET_H */
diff --git a/src/parport/Makefile.am b/src/parport/Makefile.am
new file mode 100644
index 0000000..eaff53e
--- /dev/null
+++ b/src/parport/Makefile.am
@@ -0,0 +1,6 @@
+
+INCLUDES = -I.
+
+ALL_H = ParPort.h
+noinst_LTLIBRARIES = libparport.la
+libparport_la_SOURCES = ParPort.cpp $(ALL_H)
diff --git a/src/parport/Makefile.in b/src/parport/Makefile.in
new file mode 100644
index 0000000..bf5a31f
--- /dev/null
+++ b/src/parport/Makefile.in
@@ -0,0 +1,576 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/parport
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libparport_la_LIBADD =
+am__objects_1 =
+am_libparport_la_OBJECTS = ParPort.lo $(am__objects_1)
+libparport_la_OBJECTS = $(am_libparport_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libparport_la_SOURCES)
+DIST_SOURCES = $(libparport_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.
+ALL_H = ParPort.h
+noinst_LTLIBRARIES = libparport.la
+libparport_la_SOURCES = ParPort.cpp $(ALL_H)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/parport/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/parport/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libparport.la: $(libparport_la_OBJECTS) $(libparport_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libparport_la_OBJECTS) $(libparport_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ParPort.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+ pdf pdf-am ps ps-am tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/parport/ParPort.cpp b/src/parport/ParPort.cpp
new file mode 100644
index 0000000..3b926bb
--- /dev/null
+++ b/src/parport/ParPort.cpp
@@ -0,0 +1,234 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ParPort.h"
+
+#include "../avgconfigwrapper.h"
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/MathHelper.h"
+
+#ifdef AVG_ENABLE_PARPORT
+#include <linux/ppdev.h>
+#include <linux/parport.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <unistd.h>
+
+#include <cstring>
+#include <iostream>
+#include <sstream>
+#include <cerrno>
+
+using namespace std;
+
+namespace avg {
+
+ParPort::ParPort()
+ : _myFileDescriptor(-1),
+ _myDeviceName(""),
+ _isOpen(false),
+ _myDataLines(0)
+{
+}
+
+ParPort::~ParPort() {
+ deinit();
+}
+
+void
+ParPort::init(const string& theDevice) {
+ string myDevice = theDevice;
+#ifdef AVG_ENABLE_PARPORT
+ if (myDevice.empty()) {
+ myDevice = "/dev/parport0";
+ }
+ _myFileDescriptor = open(myDevice.c_str(), O_RDONLY);
+ if (_myFileDescriptor == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Failed to open parallel port '"
+ << myDevice << "': " << strerror(errno));
+ return;
+ } else {
+ AVG_TRACE(Logger::CONFIG, "Parallel port opened.");
+ }
+
+ if (ioctl(_myFileDescriptor, PPCLAIM) == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Failed to claim parallel port: "
+ << strerror(errno));
+ _myFileDescriptor = -1;
+ return;
+ }
+ _isOpen = true;
+#else
+ AVG_TRACE(Logger::ERROR,
+ "Failed to open parallel port. Support not compiled in.");
+ _myFileDescriptor = -1;
+#endif
+ _myDeviceName = myDevice;
+}
+
+bool ParPort::setControlLine(int theLine, bool theValue) {
+ int theStatus;
+ if (theValue) {
+ theStatus = theLine;
+ } else {
+ theStatus = 0;
+ }
+ return frob(theLine, theStatus);
+}
+
+bool ParPort::getStatusLine(int theLine) {
+#ifdef AVG_ENABLE_PARPORT
+ if (_myFileDescriptor == -1) {
+ return false;
+ }
+ unsigned char myStatus;
+ int myOk = ioctl(_myFileDescriptor, PPRSTATUS, &myStatus);
+ if (myOk == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Could not get parallel port status.");
+ return false;
+ }
+ return (myStatus & theLine) == theLine;
+#else
+ return false;
+#endif
+}
+
+bool ParPort::setDataLines(unsigned char theData)
+{
+#ifdef AVG_ENABLE_PARPORT
+ if (_myFileDescriptor == -1) {
+ return false;
+ }
+ _myDataLines |= theData;
+ int myOk = ioctl(_myFileDescriptor, PPWDATA, &_myDataLines);
+ if (myOk == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Could not write parallel port data.");
+ return false;
+ }
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ParPort::clearDataLines(unsigned char theData)
+{
+#ifdef AVG_ENABLE_PARPORT
+ if (_myFileDescriptor == -1) {
+ return false;
+ }
+ _myDataLines &= ~theData;
+ int myOk = ioctl(_myFileDescriptor, PPWDATA, &_myDataLines);
+ if (myOk == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Could not write parallel port data.");
+ return false;
+ }
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ParPort::setAllDataLines(unsigned char theData)
+{
+#ifdef AVG_ENABLE_PARPORT
+ if (_myFileDescriptor == -1) {
+ return false;
+ }
+ _myDataLines = theData;
+ int myOk = ioctl(_myFileDescriptor, PPWDATA, &_myDataLines);
+ if (myOk == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Could not write parallel port data.");
+ return false;
+ }
+ return true;
+#else
+ return false;
+#endif
+}
+
+bool ParPort::isAvailable()
+{
+ return (_myFileDescriptor != -1);
+}
+
+bool ParPort::frob(int theLines, int theStatus)
+{
+#ifdef AVG_ENABLE_PARPORT
+ if (_myFileDescriptor == -1) {
+ return false;
+ }
+ ppdev_frob_struct myFrob;
+ myFrob.mask = theLines;
+ myFrob.val = theStatus;
+ int myOk = ioctl(_myFileDescriptor, PPFCONTROL, &myFrob);
+ if (myOk == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Could not set parallel port control line.");
+ return false;
+ }
+ return true;
+#else
+ return false;
+#endif
+}
+
+void ParPort::deinit() {
+ if (_isOpen) {
+ if (::close(_myFileDescriptor) == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "Can't close parallel port '"
+ << _myDeviceName << "':" << strerror(errno));
+ } else {
+ AVG_TRACE(Logger::CONFIG, "Parallel port closed.");
+ }
+ }
+}
+
+bool
+ParPort::writeControlRegister(unsigned char theStatus) {
+#ifdef AVG_ENABLE_PARPORT
+ if (_isOpen) {
+ if (ioctl(_myFileDescriptor, PPWCONTROL, & theStatus) == -1) {
+ AVG_TRACE(Logger::ERROR,
+ "ERROR: Failed to write control register: "
+ << strerror(errno));
+ return false;
+ }
+ return true;
+ }
+#endif
+ return false;
+}
+
+}
+
diff --git a/src/parport/ParPort.h b/src/parport/ParPort.h
new file mode 100644
index 0000000..fe7882f
--- /dev/null
+++ b/src/parport/ParPort.h
@@ -0,0 +1,80 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ParPort_H_
+#define _ParPort_H_
+
+#include "../api.h"
+#include <string>
+
+// Copied from linux/parport.h so we have a plattform-independent interface.
+#define PARPORT_CONTROL_STROBE 0x1
+#define PARPORT_CONTROL_AUTOFD 0x2
+#define PARPORT_CONTROL_INIT 0x4
+#define PARPORT_CONTROL_SELECT 0x8
+
+#define PARPORT_STATUS_ERROR 0x8
+#define PARPORT_STATUS_SELECT 0x10
+#define PARPORT_STATUS_PAPEROUT 0x20
+#define PARPORT_STATUS_ACK 0x40
+#define PARPORT_STATUS_BUSY 0x80
+
+namespace avg {
+
+enum ParPortData {
+ BIT0 = 1,
+ BIT1 = 2,
+ BIT2 = 4,
+ BIT3 = 8,
+ BIT4 = 16,
+ BIT5 = 32,
+ BIT6 = 64,
+ BIT7 = 128
+};
+
+class AVG_API ParPort
+{
+ public:
+ ParPort();
+ virtual ~ParPort();
+ void init(const std::string& theDevice);
+ bool setControlLine(int theLine, bool theValue);
+ bool getStatusLine(int theLine);
+ bool setDataLines(unsigned char theData);
+ bool clearDataLines(unsigned char theData);
+ bool setAllDataLines(unsigned char theData);
+ bool isAvailable();
+
+ private:
+ bool frob(int theLines, int theStatus);
+ void deinit();
+ bool writeControlRegister(unsigned char theStatus);
+
+ int _myFileDescriptor;
+ std::string _myDeviceName;
+ bool _isOpen;
+
+ unsigned char _myDataLines;
+};
+
+}
+
+#endif
diff --git a/src/player/AVGNode.cpp b/src/player/AVGNode.cpp
new file mode 100644
index 0000000..524bab5
--- /dev/null
+++ b/src/player/AVGNode.cpp
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "AVGNode.h"
+#include "Player.h"
+
+#include "NodeDefinition.h"
+#include "KeyEvent.h"
+
+#include "../base/FileHelper.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition AVGNode::createDefinition()
+{
+ return NodeDefinition("avg", Node::buildNode<AVGNode>)
+ .extendDefinition(CanvasNode::createDefinition())
+ .addArg(Arg<string>("onkeyup", ""))
+ .addArg(Arg<string>("onkeydown", ""));
+}
+
+AVGNode::AVGNode(const ArgList& args)
+ : CanvasNode(args)
+{
+ args.setMembers(this);
+ addArgEventHandler(Event::KEYUP, Event::NONE, args.getArgVal<string>("onkeyup"));
+ addArgEventHandler(Event::KEYDOWN, Event::NONE, args.getArgVal<string>("onkeydown"));
+}
+
+AVGNode::~AVGNode()
+{
+}
+
+}
diff --git a/src/player/AVGNode.h b/src/player/AVGNode.h
new file mode 100644
index 0000000..ade1f79
--- /dev/null
+++ b/src/player/AVGNode.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _AVGNode_H_
+#define _AVGNode_H_
+
+#include "../api.h"
+#include "CanvasNode.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API AVGNode : public CanvasNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ AVGNode(const ArgList& args);
+ virtual ~AVGNode();
+};
+
+typedef boost::shared_ptr<AVGNode> AVGNodePtr;
+
+}
+
+#endif
diff --git a/src/player/AppleTrackpadInputDevice.cpp b/src/player/AppleTrackpadInputDevice.cpp
new file mode 100644
index 0000000..d78e946
--- /dev/null
+++ b/src/player/AppleTrackpadInputDevice.cpp
@@ -0,0 +1,114 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "AppleTrackpadInputDevice.h"
+#include "TouchEvent.h"
+#include "Player.h"
+#include "AVGNode.h"
+#include "TouchStatus.h"
+
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include <CoreFoundation/CoreFoundation.h>
+
+using namespace std;
+
+namespace avg {
+
+AppleTrackpadInputDevice* AppleTrackpadInputDevice::s_pInstance(0);
+
+AppleTrackpadInputDevice::AppleTrackpadInputDevice()
+ : m_LastID(0)
+{
+ s_pInstance = this;
+}
+
+AppleTrackpadInputDevice::~AppleTrackpadInputDevice()
+{
+ MTDeviceStop(m_Device);
+ MTUnregisterContactFrameCallback(m_Device, callback);
+ MTDeviceRelease(m_Device);
+ s_pInstance = 0;
+}
+
+void AppleTrackpadInputDevice::start()
+{
+ MultitouchInputDevice::start();
+ m_Device = MTDeviceCreateDefault();
+ MTRegisterContactFrameCallback(m_Device, callback);
+ MTDeviceStart(m_Device, 0);
+ AVG_TRACE(Logger::CONFIG, "Apple Trackpad Multitouch event source created.");
+}
+
+void AppleTrackpadInputDevice::onData(int device, Finger* pFingers, int numFingers,
+ double timestamp, int frame)
+{
+ boost::mutex::scoped_lock lock(getMutex());
+ for (int i = 0; i < numFingers; i++) {
+ Finger* pFinger = &pFingers[i];
+ TouchStatusPtr pTouchStatus = getTouchStatus(pFinger->identifier);
+ if (!pTouchStatus) {
+ m_LastID++;
+ TouchEventPtr pEvent = createEvent(m_LastID, pFinger, Event::CURSORDOWN);
+ addTouchStatus(pFinger->identifier, pEvent);
+ } else {
+ Event::Type eventType;
+ if (pFinger->state == 7) {
+ eventType = Event::CURSORUP;
+ removeTouchStatus(pFinger->identifier);
+ } else {
+ eventType = Event::CURSORMOTION;
+ }
+ TouchEventPtr pEvent = createEvent(0, pFinger, eventType);
+ pTouchStatus->pushEvent(pEvent);
+ }
+ }
+}
+
+int AppleTrackpadInputDevice::callback(int device, Finger *data, int nFingers,
+ double timestamp, int frame)
+{
+ AVG_ASSERT(s_pInstance != 0);
+ s_pInstance->onData(device, data, nFingers, timestamp, frame);
+ return 0;
+}
+
+TouchEventPtr AppleTrackpadInputDevice::createEvent(int avgID, Finger* pFinger,
+ Event::Type eventType)
+{
+ DPoint size = getWindowSize();
+ IntPoint pos(pFinger->normalized.pos.x*size.x, (1-pFinger->normalized.pos.y)*size.y);
+ DPoint speed(pFinger->normalized.vel.x*size.x, pFinger->normalized.vel.y*size.y);
+ double eccentricity = pFinger->majorAxis/pFinger->minorAxis;
+ DPoint majorAxis = DPoint::fromPolar(pFinger->angle, pFinger->majorAxis);
+ majorAxis.y = -majorAxis.y;
+ DPoint minorAxis = DPoint::fromPolar(pFinger->angle+1.57, pFinger->minorAxis);
+ minorAxis.y = -minorAxis.y;
+
+ TouchEventPtr pEvent(new TouchEvent(avgID, eventType, pos, Event::TOUCH,
+ speed, pFinger->angle, pFinger->size, eccentricity, majorAxis,
+ minorAxis));
+ return pEvent;
+}
+
+}
diff --git a/src/player/AreaNode.cpp b/src/player/AreaNode.cpp
new file mode 100644
index 0000000..64e2ae8
--- /dev/null
+++ b/src/player/AreaNode.cpp
@@ -0,0 +1,283 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "AreaNode.h"
+
+#include "Event.h"
+#include "CursorEvent.h"
+#include "MouseEvent.h"
+#include "DivNode.h"
+#include "ArgList.h"
+#include "NodeDefinition.h"
+#include "BoostPython.h"
+
+#include "../base/MathHelper.h"
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/GLContext.h"
+
+#include <object.h>
+#include <compile.h>
+#include <eval.h>
+
+#include <iostream>
+
+using namespace boost;
+using namespace boost::python;
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition AreaNode::createDefinition()
+{
+ return NodeDefinition("areanode")
+ .extendDefinition(Node::createDefinition())
+ .addArg(Arg<double>("x", 0.0, false, offsetof(AreaNode, m_RelViewport.tl.x)))
+ .addArg(Arg<double>("y", 0.0, false, offsetof(AreaNode, m_RelViewport.tl.y)))
+ .addArg(Arg<DPoint>("pos", DPoint(0.0, 0.0)))
+ .addArg(Arg<double>("width", 0.0, false, offsetof(AreaNode, m_UserSize.x)))
+ .addArg(Arg<double>("height", 0.0, false, offsetof(AreaNode, m_UserSize.y)))
+ .addArg(Arg<DPoint>("size", DPoint(0.0, 0.0)))
+ .addArg(Arg<double>("angle", 0.0, false, offsetof(AreaNode, m_Angle)))
+ .addArg(Arg<DPoint>("pivot", DPoint(-32767, -32767), false,
+ offsetof(AreaNode, m_Pivot)));
+}
+
+AreaNode::AreaNode()
+ : m_RelViewport(0,0,0,0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+AreaNode::~AreaNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void AreaNode::setArgs(const ArgList& args)
+{
+ Node::setArgs(args);
+ args.getOverlayedArgVal(&m_RelViewport.tl, "pos", "x", "y", getID());
+ args.getOverlayedArgVal(&m_UserSize, "size", "width", "height", getID());
+ m_RelViewport.setWidth(m_UserSize.x);
+ m_RelViewport.setHeight(m_UserSize.y);
+ m_bHasCustomPivot = ((m_Pivot.x != -32767) && (m_Pivot.y != -32767));
+}
+
+void AreaNode::connectDisplay()
+{
+ IntPoint MediaSize = getMediaSize();
+ if (m_UserSize.x == 0.0) {
+ m_RelViewport.setWidth(MediaSize.x);
+ } else {
+ m_RelViewport.setWidth(m_UserSize.x);
+ }
+ if (m_UserSize.y == 0.0) {
+ m_RelViewport.setHeight(MediaSize.y);
+ } else {
+ m_RelViewport.setHeight(m_UserSize.y);
+ }
+ Node::connectDisplay();
+}
+
+double AreaNode::getX() const
+{
+ return m_RelViewport.tl.x;
+}
+
+void AreaNode::setX(double x)
+{
+ setViewport(x, -32767, -32767, -32767);
+}
+
+double AreaNode::getY() const
+{
+ return m_RelViewport.tl.y;
+}
+
+void AreaNode::setY(double y)
+{
+ setViewport(-32767, y, -32767, -32767);
+}
+
+const DPoint& AreaNode::getPos() const
+{
+ return m_RelViewport.tl;
+}
+
+void AreaNode::setPos(const DPoint& pt)
+{
+ setViewport(pt.x, pt.y, -32767, -32767);
+}
+
+double AreaNode::getWidth() const
+{
+ return getRelViewport().width();
+}
+
+void AreaNode::setWidth(double width)
+{
+ m_UserSize.x = width;
+ setViewport(-32767, -32767, -32767, -32767);
+}
+
+double AreaNode::getHeight() const
+{
+ return getRelViewport().height();
+}
+
+void AreaNode::setHeight(double height)
+{
+ m_UserSize.y = height;
+ setViewport(-32767, -32767, -32767, -32767);
+}
+
+DPoint AreaNode::getSize() const
+{
+ return getRelViewport().size();
+}
+
+void AreaNode::setSize(const DPoint& pt)
+{
+ m_UserSize = pt;
+ setViewport(-32767, -32767, -32767, -32767);
+}
+
+double AreaNode::getAngle() const
+{
+ return m_Angle;
+}
+
+void AreaNode::setAngle(double angle)
+{
+ m_Angle = fmod(angle, 2*M_PI);
+}
+
+DPoint AreaNode::getPivot() const
+{
+ if (m_bHasCustomPivot) {
+ return m_Pivot;
+ } else {
+ return getSize()/2;
+ }
+}
+
+void AreaNode::setPivot(const DPoint& pt)
+{
+ m_Pivot.x = pt.x;
+ m_Pivot.y = pt.y;
+ m_bHasCustomPivot = true;
+}
+
+DPoint AreaNode::toLocal(const DPoint& globalPos) const
+{
+ DPoint localPos = globalPos-m_RelViewport.tl;
+ return localPos.getRotatedPivot(-getAngle(), getPivot());
+}
+
+DPoint AreaNode::toGlobal(const DPoint& localPos) const
+{
+ DPoint globalPos = localPos.getRotatedPivot(getAngle(), getPivot());
+ return globalPos+m_RelViewport.tl;
+}
+
+void AreaNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ if (pos.x >= 0 && pos.y >= 0 && pos.x < getSize().x && pos.y < getSize().y &&
+ reactsToMouseEvents())
+ {
+ pElements.push_back(shared_from_this());
+ }
+}
+
+void AreaNode::maybeRender(const DRect& rect)
+{
+ AVG_ASSERT(getState() == NS_CANRENDER);
+ if (isVisible()) {
+ if (getID() != "") {
+ AVG_TRACE(Logger::BLTS, "Rendering " << getTypeStr() <<
+ " with ID " << getID());
+ } else {
+ AVG_TRACE(Logger::BLTS, "Rendering " << getTypeStr());
+ }
+ GLContext * pContext = GLContext::getCurrent();
+ pContext->pushTransform(getRelViewport().tl, getAngle(), getPivot());
+ render(rect);
+ pContext->popTransform();
+ }
+}
+
+void AreaNode::setViewport(double x, double y, double width, double height)
+{
+ if (x == -32767) {
+ x = getRelViewport().tl.x;
+ }
+ if (y == -32767) {
+ y = getRelViewport().tl.y;
+ }
+ IntPoint MediaSize = getMediaSize();
+ if (width == -32767) {
+ if (m_UserSize.x == 0.0) {
+ width = MediaSize.x;
+ } else {
+ width = m_UserSize.x;
+ }
+ }
+ if (height == -32767) {
+ if (m_UserSize.y == 0.0) {
+ height = MediaSize.y;
+ } else {
+ height = m_UserSize.y;
+ }
+ }
+ if (width < 0 || height < 0) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE, "Negative size for a node.");
+ }
+ m_RelViewport = DRect (x, y, x+width, y+height);
+}
+
+const DRect& AreaNode::getRelViewport() const
+{
+// cerr << "Node " << getID() << ": " << m_RelViewport << endl;
+ return m_RelViewport;
+}
+
+string AreaNode::dump(int indent)
+{
+ string dumpStr = Node::dump(indent);
+ char sz[256];
+ sprintf (sz, ", x=%.1f, y=%.1f, width=%.1f, height=%.1f\n",
+ m_RelViewport.tl.x, m_RelViewport.tl.y,
+ m_RelViewport.width(), m_RelViewport.height());
+ dumpStr += sz;
+
+ return dumpStr;
+}
+
+DPoint AreaNode::getUserSize() const
+{
+ return m_UserSize;
+}
+
+}
diff --git a/src/player/AreaNode.h b/src/player/AreaNode.h
new file mode 100644
index 0000000..65bb3bf
--- /dev/null
+++ b/src/player/AreaNode.h
@@ -0,0 +1,122 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _AreaNode_H_
+#define _AreaNode_H_
+
+#include "../api.h"
+
+#include "Node.h"
+
+#include "../base/Point.h"
+#include "../base/Rect.h"
+
+#include "../graphics/OGLShader.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+class AreaNode;
+class DivNode;
+class ArgList;
+
+typedef boost::shared_ptr<AreaNode> AreaNodePtr;
+typedef boost::weak_ptr<AreaNode> AreaNodeWeakPtr;
+typedef boost::shared_ptr<DivNode> DivNodePtr;
+typedef boost::weak_ptr<DivNode> DivNodeWeakPtr;
+
+class AVG_API AreaNode: public Node
+{
+ public:
+ template<class NodeType>
+ static NodePtr buildNode(const ArgList& args)
+ {
+ return NodePtr(new NodeType(args));
+ }
+ static NodeDefinition createDefinition();
+
+ virtual ~AreaNode() = 0;
+ virtual void setArgs(const ArgList& args);
+ virtual void connectDisplay();
+
+ double getX() const;
+ void setX(double x);
+
+ double getY() const;
+ void setY(double Y);
+
+ const DPoint& getPos() const;
+ void setPos(const DPoint& pt);
+
+ virtual double getWidth() const;
+ virtual void setWidth(double width);
+
+ virtual double getHeight() const;
+ virtual void setHeight(double height);
+
+ virtual DPoint getSize() const;
+ virtual void setSize(const DPoint& pt);
+
+ double getAngle() const;
+ void setAngle(double angle);
+
+ virtual DPoint getPivot() const;
+ void setPivot(const DPoint& pt);
+
+ virtual DPoint toLocal(const DPoint& globalPos) const;
+ virtual DPoint toGlobal(const DPoint& localPos) const;
+
+ virtual void getElementsByPos(const DPoint& pos,
+ std::vector<NodeWeakPtr>& pElements);
+
+ virtual void maybeRender(const DRect& rect);
+ virtual void setViewport(double x, double y, double width, double height);
+ virtual const DRect& getRelViewport() const;
+
+ virtual std::string dump(int indent = 0);
+
+ virtual void checkReload() {};
+
+ virtual IntPoint getMediaSize()
+ { return IntPoint(0,0); };
+
+ protected:
+ AreaNode();
+ DPoint getUserSize() const;
+
+ private:
+ DRect m_RelViewport; // In coordinates relative to the parent.
+ double m_Angle;
+ DPoint m_Pivot;
+ bool m_bHasCustomPivot;
+
+ DPoint m_UserSize;
+};
+
+}
+
+#endif
+
diff --git a/src/player/Arg.cpp b/src/player/Arg.cpp
new file mode 100644
index 0000000..6bb7fbb
--- /dev/null
+++ b/src/player/Arg.cpp
@@ -0,0 +1,44 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Jan Boelsche (regular.gonzales@googlemail.com).
+//
+
+#include "Arg.h"
+#include <string>
+
+using namespace std;
+
+namespace avg {
+// Explicit template instantiation. See Arg.h for comments.
+#ifndef _WIN32
+template class Arg<int>;
+template class Arg<bool>;
+template class Arg<double>;
+template class Arg<float>;
+template class Arg<string>;
+template class Arg<DPoint>;
+template class Arg<IntTriple>;
+template class Arg<DTriple>;
+template class Arg<vector<double> >;
+template class Arg<vector<DPoint> >;
+template class Arg<vector<IntTriple> >;
+#endif
+}
diff --git a/src/player/Arg.h b/src/player/Arg.h
new file mode 100644
index 0000000..a48e86f
--- /dev/null
+++ b/src/player/Arg.h
@@ -0,0 +1,120 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _Arg_H_
+#define _Arg_H_
+
+#include "../api.h"
+#include "../base/Point.h"
+#include "../base/Triple.h"
+
+#include "ArgBase.h"
+
+#include <string>
+#include <vector>
+
+namespace avg {
+
+class Node;
+
+template<class T>
+class AVG_TEMPLATE_API Arg: public ArgBase
+{
+public:
+ Arg(std::string sName, const T& Value, bool bRequired = false,
+ ptrdiff_t MemberOffset = -1);
+ virtual ~Arg();
+
+ void setValue(const T& Value);
+ const T& getValue() const;
+ virtual void setMember(Node * pNode) const;
+ virtual ArgBase* createCopy() const;
+
+private:
+ T m_Value;
+};
+
+template<class T>
+Arg<T>::Arg(std::string sName, const T& Value, bool bRequired,
+ ptrdiff_t MemberOffset)
+ : ArgBase(sName, bRequired, MemberOffset),
+ m_Value(Value)
+{
+}
+
+template<class T>
+Arg<T>::~Arg()
+{
+}
+
+template<class T>
+const T& Arg<T>::getValue() const
+{
+ return m_Value;
+}
+
+template<class T>
+void Arg<T>::setValue(const T& Value)
+{
+ m_Value = Value;
+ m_bDefault = false;
+}
+
+template<class T>
+void Arg<T>::setMember(Node * pNode) const
+{
+ if (getMemberOffset() != -1) {
+ T* pMember = (T*)((char*)pNode+getMemberOffset());
+ *pMember = m_Value;
+ }
+}
+
+template<class T>
+ArgBase* Arg<T>::createCopy() const
+{
+ return new Arg<T>(*this);
+}
+
+#ifdef AVG_PLUGIN
+#ifndef _WIN32
+// Under Linux, templates used by plugins need to be instantiated explicitly if
+// RTTI is needed. Templates instantiated implicitly get instantiated again in the
+// plugin with a different typeid.
+extern template class Arg<int>;
+extern template class Arg<bool>;
+extern template class Arg<float>;
+extern template class Arg<double>;
+extern template class Arg<std::string>;
+extern template class Arg<DPoint>;
+extern template class Arg<IntTriple>;
+extern template class Arg<DTriple>;
+extern template class Arg<std::vector<double> >;
+extern template class Arg<std::vector<DPoint> >;
+extern template class Arg<std::vector<IntTriple> >;
+#endif
+#endif
+
+}
+
+#endif
+
diff --git a/src/player/ArgBase.cpp b/src/player/ArgBase.cpp
new file mode 100644
index 0000000..1c4882d
--- /dev/null
+++ b/src/player/ArgBase.cpp
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "ArgBase.h"
+
+#include "../base/Exception.h"
+
+#include <stdlib.h>
+
+using namespace std;
+
+namespace avg {
+
+ArgBase::ArgBase(string sName, bool bRequired, ptrdiff_t memberOffset)
+ : m_sName(sName),
+ m_bRequired(bRequired),
+ m_MemberOffset(memberOffset)
+{
+ m_bDefault = true;
+}
+
+ArgBase::~ArgBase()
+{
+}
+
+string ArgBase::getName() const
+{
+ return m_sName;
+}
+
+bool ArgBase::isDefault() const
+{
+ return m_bDefault;
+}
+
+bool ArgBase::isRequired() const
+{
+ return m_bRequired;
+}
+
+ptrdiff_t ArgBase::getMemberOffset() const
+{
+ return m_MemberOffset;
+}
+
+}
diff --git a/src/player/ArgBase.h b/src/player/ArgBase.h
new file mode 100644
index 0000000..c6017f2
--- /dev/null
+++ b/src/player/ArgBase.h
@@ -0,0 +1,65 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _ArgBase_H_
+#define _ArgBase_H_
+
+#include "../api.h"
+
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class Node;
+
+class AVG_API ArgBase
+{
+public:
+ ArgBase(std::string sName, bool bRequired, ptrdiff_t memberOffset);
+ virtual ~ArgBase();
+
+ std::string getName() const;
+ bool isDefault() const;
+ bool isRequired() const;
+
+ virtual void setMember(Node * pNode) const = 0;
+
+ virtual ArgBase* createCopy() const = 0;
+
+protected:
+ ptrdiff_t getMemberOffset() const;
+ bool m_bDefault;
+
+private:
+ std::string m_sName;
+ bool m_bRequired;
+ ptrdiff_t m_MemberOffset;
+};
+
+typedef boost::shared_ptr<ArgBase> ArgBasePtr;
+
+}
+
+#endif
diff --git a/src/player/ArgList.cpp b/src/player/ArgList.cpp
new file mode 100644
index 0000000..15b5ce3
--- /dev/null
+++ b/src/player/ArgList.cpp
@@ -0,0 +1,256 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "ArgList.h"
+
+#include "Node.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+#include "../base/UTF8String.h"
+
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+ArgList::ArgList()
+{
+}
+
+ArgList::ArgList(const ArgList& argTemplates, const xmlNodePtr xmlNode)
+{
+ copyArgsFrom(argTemplates);
+
+ for (xmlAttrPtr prop = xmlNode->properties; prop; prop = prop->next)
+ {
+ string name = (char*)prop->name;
+ string value = (char*)prop->children->content;
+ setArgValue(name, value);
+ }
+}
+
+ArgList::ArgList(const ArgList& argTemplates, const boost::python::dict& PyDict)
+{
+ // TODO: Check if all required args are being set.
+ copyArgsFrom(argTemplates);
+ boost::python::list keys = PyDict.keys();
+ int nKeys = boost::python::len(keys);
+ for (int i = 0; i < nKeys; i++)
+ {
+ boost::python::object keyObj = keys[i];
+ boost::python::object valObj = PyDict[keyObj];
+
+ boost::python::extract<string> keyStrProxy(keyObj);
+ if (!keyStrProxy.check()) {
+ throw Exception(AVG_ERR_INVALID_ARGS, "Argument name must be a string.");
+ }
+ string keyStr = keyStrProxy();
+
+ setArgValue(keyStr, valObj);
+ }
+}
+
+ArgList::~ArgList()
+{
+}
+
+bool ArgList::hasArg(const std::string& sName) const
+{
+ ArgMap::const_iterator it = m_Args.find(sName);
+ return (it != m_Args.end() && !(it->second->isDefault()));
+}
+
+const ArgBasePtr ArgList::getArg(const string& sName) const
+{
+ ArgMap::const_iterator valIt = m_Args.find(sName);
+ if (valIt == m_Args.end()) {
+ // TODO: The error message should mention line number and node type.
+ throw Exception(AVG_ERR_INVALID_ARGS, string("Argument ")+sName+" is not valid.");
+ }
+ return valIt->second;
+}
+
+void ArgList::getOverlayedArgVal(DPoint* pResult, const string& sName,
+ const string& sOverlay1, const string& sOverlay2, const string& sID) const
+{
+ if (hasArg(sName)) {
+ if (hasArg(sOverlay1) || hasArg(sOverlay2)) {
+ throw (Exception(AVG_ERR_INVALID_ARGS,
+ string("Duplicate node arguments (")+sName+" and "+
+ sOverlay1+","+sOverlay2+") for node '"+sID+"'"));
+ }
+ *pResult = getArgVal<DPoint>(sName);
+ }
+}
+
+const ArgMap& ArgList::getArgMap() const
+{
+ return m_Args;
+}
+
+void ArgList::setArg(const ArgBase& newArg)
+{
+ m_Args.insert(ArgMap::value_type(newArg.getName(), ArgBasePtr(newArg.createCopy())));
+}
+
+void ArgList::setArgs(const ArgList& args)
+{
+ for (ArgMap::const_iterator it = args.m_Args.begin(); it != args.m_Args.end(); it++) {
+ m_Args.insert(*it);
+ }
+}
+
+void ArgList::setMembers(Node * pNode) const
+{
+ for (ArgMap::const_iterator it = m_Args.begin(); it != m_Args.end(); it++) {
+ const ArgBasePtr pCurArg = it->second;
+ pCurArg->setMember(pNode);
+ }
+ pNode->setArgs(*this);
+}
+
+template<class T>
+void setArgValue(Arg<T>* pArg, const std::string & sName,
+ const boost::python::object& value)
+{
+ boost::python::extract<T> valProxy(value);
+ if (!valProxy.check()) {
+ string sTypeName = getFriendlyTypeName(pArg->getValue());
+ throw Exception(AVG_ERR_INVALID_ARGS, "Type error in argument "+sName+": "
+ +sTypeName+" expected.");
+ }
+ pArg->setValue(valProxy());
+}
+
+void ArgList::setArgValue(const std::string & sName, const boost::python::object& value)
+{
+ ArgBasePtr pArg = getArg(sName);
+ Arg<string>* pStringArg = dynamic_cast<Arg<string>* >(&*pArg);
+ Arg<UTF8String>* pUTF8StringArg = dynamic_cast<Arg<UTF8String>* >(&*pArg);
+ Arg<int>* pIntArg = dynamic_cast<Arg<int>* >(&*pArg);
+ Arg<double>* pDoubleArg = dynamic_cast<Arg<double>* >(&*pArg);
+ Arg<float>* pFloatArg = dynamic_cast<Arg<float>* >(&*pArg);
+ Arg<bool>* pBoolArg = dynamic_cast<Arg<bool>* >(&*pArg);
+ Arg<DPoint>* pDPointArg = dynamic_cast<Arg<DPoint>* >(&*pArg);
+ Arg<IntTriple>* pIntTripleArg = dynamic_cast<Arg<IntTriple>* >(&*pArg);
+ Arg<DTriple>* pDTripleArg = dynamic_cast<Arg<DTriple>* >(&*pArg);
+ Arg<vector<double> >* pDVectorArg = dynamic_cast<Arg<vector<double> >* >(&*pArg);
+ Arg<vector<DPoint> >* pDPointVectorArg =
+ dynamic_cast<Arg<vector<DPoint> >* >(&*pArg);
+ Arg<vector<IntTriple> >* pIntTripleVectorArg =
+ dynamic_cast<Arg<vector<IntTriple> >* >(&*pArg);
+ if(pStringArg) {
+ avg::setArgValue(pStringArg, sName, value);
+ } else if (pUTF8StringArg) {
+ avg::setArgValue(pUTF8StringArg, sName, value);
+ } else if (pIntArg) {
+ avg::setArgValue(pIntArg, sName, value);
+ } else if (pDoubleArg) {
+ avg::setArgValue(pDoubleArg, sName, value);
+ } else if (pFloatArg) {
+ avg::setArgValue(pFloatArg, sName, value);
+ } else if (pBoolArg) {
+ avg::setArgValue(pBoolArg, sName, value);
+ } else if (pDPointArg) {
+ avg::setArgValue(pDPointArg, sName, value);
+ } else if (pDVectorArg) {
+ avg::setArgValue(pDVectorArg, sName, value);
+ } else if (pDPointVectorArg) {
+ avg::setArgValue(pDPointVectorArg, sName, value);
+ } else if (pIntTripleArg) {
+ avg::setArgValue(pIntTripleArg, sName, value);
+ } else if (pDTripleArg) {
+ avg::setArgValue(pDTripleArg, sName, value);
+ } else if (pIntTripleVectorArg) {
+ avg::setArgValue(pIntTripleVectorArg, sName, value);
+ } else {
+ AVG_ASSERT(false);
+ }
+}
+
+void ArgList::setArgValue(const std::string & sName, const std::string & sValue)
+{
+ ArgBasePtr pArg = getArg(sName);
+ Arg<string>* pStringArg = dynamic_cast<Arg<string>* >(&*pArg);
+ Arg<UTF8String>* pUTF8StringArg = dynamic_cast<Arg<UTF8String>* >(&*pArg);
+ Arg<int>* pIntArg = dynamic_cast<Arg<int>* >(&*pArg);
+ Arg<double>* pDoubleArg = dynamic_cast<Arg<double>* >(&*pArg);
+ Arg<float>* pFloatArg = dynamic_cast<Arg<float>* >(&*pArg);
+ Arg<bool>* pBoolArg = dynamic_cast<Arg<bool>* >(&*pArg);
+ Arg<DPoint>* pDPointArg = dynamic_cast<Arg<DPoint>* >(&*pArg);
+ Arg<IntTriple>* pIntTripleArg = dynamic_cast<Arg<IntTriple>* >(&*pArg);
+ Arg<vector<double> >* pDVectorArg = dynamic_cast<Arg<vector<double> >* >(&*pArg);
+ Arg<vector<DPoint> >* pDPointVectorArg =
+ dynamic_cast<Arg<vector<DPoint> >* >(&*pArg);
+ Arg<vector<IntTriple> >* pIntTripleVectorArg =
+ dynamic_cast<Arg<vector<IntTriple> >* >(&*pArg);
+
+ if (pStringArg) {
+ pStringArg->setValue(sValue);
+ } else if (pUTF8StringArg) {
+ pUTF8StringArg->setValue(sValue);
+ } else if (pIntArg) {
+ pIntArg->setValue(stringToInt(sValue));
+ } else if (pDoubleArg) {
+ pDoubleArg->setValue(stringToDouble(sValue));
+ } else if (pFloatArg) {
+ pFloatArg->setValue(float(stringToDouble(sValue)));
+ } else if (pBoolArg) {
+ pBoolArg->setValue(stringToBool(sValue));
+ } else if (pDPointArg) {
+ pDPointArg->setValue(stringToDPoint(sValue));
+ } else if (pIntTripleArg) {
+ pIntTripleArg->setValue(stringToIntTriple(sValue));
+ } else if (pDVectorArg) {
+ vector<double> v;
+ fromString(sValue, v);
+ pDVectorArg->setValue(v);
+ } else if (pDPointVectorArg) {
+ vector<DPoint> v;
+ fromString(sValue, v);
+ pDPointVectorArg->setValue(v);
+ } else if (pIntTripleVectorArg) {
+ vector<IntTriple> v;
+ fromString(sValue, v);
+ pIntTripleVectorArg->setValue(v);
+ } else {
+ AVG_ASSERT(false);
+ }
+}
+
+void ArgList::copyArgsFrom(const ArgList& argTemplates)
+{
+ for (ArgMap::const_iterator it = argTemplates.m_Args.begin();
+ it != argTemplates.m_Args.end(); it++)
+ {
+ string sKey = it->first;
+ ArgBasePtr pArg = ArgBasePtr(it->second->createCopy());
+ m_Args[sKey] = pArg;
+ }
+}
+
+}
+
diff --git a/src/player/ArgList.h b/src/player/ArgList.h
new file mode 100644
index 0000000..d04b1d4
--- /dev/null
+++ b/src/player/ArgList.h
@@ -0,0 +1,84 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _ArgList_H_
+#define _ArgList_H_
+
+#include "../api.h"
+
+#include "BoostPython.h"
+#include "Arg.h"
+
+#include <libxml/parser.h>
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+typedef std::map<std::string, ArgBasePtr> ArgMap;
+
+class Node;
+
+class AVG_API ArgList
+{
+public:
+ ArgList();
+ ArgList(const ArgList& argTemplates, const xmlNodePtr xmlNode);
+ ArgList(const ArgList& argTemplates, const boost::python::dict& PyDict);
+ virtual ~ArgList();
+
+ bool hasArg(const std::string& sName) const;
+ const ArgBasePtr getArg(const std::string& sName) const;
+
+ template<class T>
+ const T& getArgVal(const std::string& sName) const;
+
+ void getOverlayedArgVal(DPoint* pResult, const std::string& sName,
+ const std::string& sOverlay1, const std::string& sOverlay2,
+ const std::string& sID) const;
+
+ const ArgMap& getArgMap() const;
+
+ void setArg(const ArgBase& newArg);
+ void setArgs(const ArgList& args);
+ void setMembers(Node * pNode) const;
+
+ void copyArgsFrom(const ArgList& argTemplates);
+
+private:
+ void setArgValue(const std::string & sName, const boost::python::object& value);
+ void setArgValue(const std::string & sName, const std::string & sValue);
+ ArgMap m_Args;
+};
+
+template<class T>
+const T& ArgList::getArgVal(const std::string& sName) const
+{
+ return (dynamic_cast<Arg<T>* >(&*getArg(sName)))->getValue();
+}
+
+
+}
+
+#endif
diff --git a/src/player/BlurFXNode.cpp b/src/player/BlurFXNode.cpp
new file mode 100644
index 0000000..3a0ad19
--- /dev/null
+++ b/src/player/BlurFXNode.cpp
@@ -0,0 +1,89 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "BlurFXNode.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+#include "../graphics/ShaderRegistry.h"
+
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+BlurFXNode::BlurFXNode()
+ : FXNode(),
+ m_StdDev(1)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+BlurFXNode::~BlurFXNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void BlurFXNode::connect()
+{
+ if (!GLTexture::isFloatFormatSupported()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Cannot create BlurFX: OpenGL configuration doesn't support Blur (no float textures).");
+ }
+ setDirty();
+ FXNode::connect();
+}
+
+void BlurFXNode::disconnect()
+{
+ m_pFilter = GPUBlurFilterPtr();
+ FXNode::disconnect();
+}
+
+void BlurFXNode::setParam(double stdDev)
+{
+ setRadius(stdDev);
+}
+
+void BlurFXNode::setRadius(double stdDev)
+{
+ m_StdDev = stdDev;
+ if (m_pFilter) {
+ m_pFilter->setStdDev(stdDev);
+ }
+ setDirty();
+}
+
+double BlurFXNode::getRadius() const
+{
+ return m_StdDev;
+}
+
+GPUFilterPtr BlurFXNode::createFilter(const IntPoint& size)
+{
+ m_pFilter = GPUBlurFilterPtr(new GPUBlurFilter(size, B8G8R8A8, B8G8R8A8, m_StdDev,
+ false, false));
+ return m_pFilter;
+}
+
+}
+
diff --git a/src/player/BlurFXNode.h b/src/player/BlurFXNode.h
new file mode 100644
index 0000000..62eb535
--- /dev/null
+++ b/src/player/BlurFXNode.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _BlurFXNode_H_
+#define _BlurFXNode_H_
+
+#include "../api.h"
+
+#include "FXNode.h"
+#include "../graphics/GPUBlurFilter.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API BlurFXNode: public FXNode {
+public:
+ BlurFXNode();
+ virtual ~BlurFXNode();
+
+ void connect();
+ virtual void disconnect();
+ void setParam(double stdDev);
+
+ void setRadius(double stdDev);
+ double getRadius() const;
+
+private:
+ virtual GPUFilterPtr createFilter(const IntPoint& size);
+
+ GPUBlurFilterPtr m_pFilter;
+
+ double m_StdDev;
+};
+
+typedef boost::shared_ptr<BlurFXNode> BlurFXNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/BoostPython.h b/src/player/BoostPython.h
new file mode 100644
index 0000000..db1c0c5
--- /dev/null
+++ b/src/player/BoostPython.h
@@ -0,0 +1,33 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifdef _WIN32
+#pragma warning(push)
+#pragma warning(disable: 4267)
+#pragma warning(disable: 4244)
+#endif
+
+#include "../api.h"
+#include <boost/python.hpp>
+
+#ifdef _WIN32
+#pragma warning(pop)
+#endif
diff --git a/src/player/CameraNode.cpp b/src/player/CameraNode.cpp
new file mode 100644
index 0000000..8f08dfa
--- /dev/null
+++ b/src/player/CameraNode.cpp
@@ -0,0 +1,404 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "CameraNode.h"
+#include "OGLSurface.h"
+#include "NodeDefinition.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../base/XMLHelper.h"
+
+#include "../graphics/Filterfill.h"
+#include "../graphics/TextureMover.h"
+#include "../graphics/GLTexture.h"
+
+#include "../imaging/Camera.h"
+#include "../imaging/FWCamera.h"
+#include "../imaging/FakeCamera.h"
+
+#include <iostream>
+#include <sstream>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition CameraNode::createDefinition()
+{
+ return NodeDefinition("camera", Node::buildNode<CameraNode>)
+ .extendDefinition(RasterNode::createDefinition())
+ .addArg(Arg<string>("driver", "firewire"))
+ .addArg(Arg<string>("device", ""))
+ .addArg(Arg<int>("unit", -1))
+ .addArg(Arg<bool>("fw800", false))
+ .addArg(Arg<double>("framerate", 15))
+ .addArg(Arg<int>("capturewidth", 640))
+ .addArg(Arg<int>("captureheight", 480))
+ .addArg(Arg<string>("pixelformat", "RGB"))
+ .addArg(Arg<int>("brightness", -1))
+ .addArg(Arg<int>("exposure", -1))
+ .addArg(Arg<int>("sharpness", -1))
+ .addArg(Arg<int>("saturation", -1))
+ .addArg(Arg<int>("camgamma", -1))
+ .addArg(Arg<int>("shutter", -1))
+ .addArg(Arg<int>("gain", -1))
+ .addArg(Arg<int>("strobeduration", -1));
+}
+
+CameraNode::CameraNode(const ArgList& args)
+ : m_bIsPlaying(false),
+ m_FrameNum(0),
+ m_bIsAutoUpdateCameraImage(true),
+ m_bNewBmp(false)
+{
+ args.setMembers(this);
+ string sDriver = args.getArgVal<string>("driver");
+ string sDevice = args.getArgVal<string>("device");
+ int unit = args.getArgVal<int>("unit");
+ bool bFW800 = args.getArgVal<bool>("fw800");
+ double frameRate = args.getArgVal<double>("framerate");
+ int width = args.getArgVal<int>("capturewidth");
+ int height = args.getArgVal<int>("captureheight");
+ string sPF = args.getArgVal<string>("pixelformat");
+
+ PixelFormat camPF = stringToPixelFormat(sPF);
+ if (camPF == NO_PIXELFORMAT) {
+ throw Exception(AVG_ERR_INVALID_ARGS, "Unknown camera pixel format "+sPF+".");
+ }
+ PixelFormat destPF;
+ if (pixelFormatIsColored(camPF)) {
+ destPF = B8G8R8X8;
+ } else {
+ destPF = I8;
+ }
+// cerr << "CameraNode ctor: " << camPF << "-->" << destPF << endl;
+
+ m_pCamera = createCamera(sDriver, sDevice, unit, bFW800, IntPoint(width, height),
+ camPF, destPF, frameRate);
+ AVG_TRACE(Logger::CONFIG, "Got Camera " << m_pCamera->getDevice() << " from driver: "
+ << m_pCamera->getDriverName());
+
+ m_pCamera->setFeature(CAM_FEATURE_BRIGHTNESS, args.getArgVal<int>("brightness"));
+ m_pCamera->setFeature(CAM_FEATURE_EXPOSURE, args.getArgVal<int>("exposure"));
+ m_pCamera->setFeature(CAM_FEATURE_SHARPNESS, args.getArgVal<int>("sharpness"));
+ m_pCamera->setFeature(CAM_FEATURE_SATURATION, args.getArgVal<int>("saturation"));
+ m_pCamera->setFeature(CAM_FEATURE_GAMMA, args.getArgVal<int>("camgamma"));
+ m_pCamera->setFeature(CAM_FEATURE_SHUTTER, args.getArgVal<int>("shutter"));
+ m_pCamera->setFeature(CAM_FEATURE_GAIN, args.getArgVal<int>("gain"));
+ m_pCamera->setFeature(CAM_FEATURE_STROBE_DURATION,
+ args.getArgVal<int>("strobeduration"));
+}
+
+CameraNode::~CameraNode()
+{
+ m_pCamera = CameraPtr();
+}
+
+void CameraNode::connectDisplay()
+{
+ RasterNode::connectDisplay();
+ if (m_bIsPlaying) {
+ open();
+ }
+}
+
+void CameraNode::connect(CanvasPtr pCanvas)
+{
+ if (!m_pCamera) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Can't use camera node after disconnect(True).");
+ }
+ RasterNode::connect(pCanvas);
+}
+
+void CameraNode::disconnect(bool bKill)
+{
+ if (bKill) {
+ m_pCamera = CameraPtr();
+ }
+ RasterNode::disconnect(bKill);
+}
+
+void CameraNode::play()
+{
+ if (getState() == NS_CANRENDER) {
+ open();
+ }
+ m_bIsPlaying = true;
+}
+
+void CameraNode::stop()
+{
+ m_bIsPlaying = false;
+}
+
+bool CameraNode::isAvailable()
+{
+ if (!m_pCamera || boost::dynamic_pointer_cast<FakeCamera>(m_pCamera)) {
+ return false;
+ } else {
+ return true;
+ }
+}
+
+int CameraNode::getBrightness() const
+{
+ return getFeature(CAM_FEATURE_BRIGHTNESS);
+}
+
+void CameraNode::setBrightness(int value)
+{
+ setFeature(CAM_FEATURE_BRIGHTNESS, value);
+}
+
+int CameraNode::getSharpness() const
+{
+ return getFeature(CAM_FEATURE_SHARPNESS);
+}
+
+void CameraNode::setSharpness(int value)
+{
+ setFeature(CAM_FEATURE_SHARPNESS, value);
+}
+
+int CameraNode::getSaturation() const
+{
+ return getFeature(CAM_FEATURE_SATURATION);
+}
+
+void CameraNode::setSaturation(int value)
+{
+ setFeature(CAM_FEATURE_SATURATION, value);
+}
+
+int CameraNode::getCamGamma() const
+{
+ return getFeature(CAM_FEATURE_GAMMA);
+}
+
+void CameraNode::setCamGamma(int value)
+{
+ setFeature(CAM_FEATURE_GAMMA, value);
+}
+
+int CameraNode::getShutter() const
+{
+ return getFeature(CAM_FEATURE_SHUTTER);
+}
+
+void CameraNode::setShutter(int value)
+{
+ setFeature(CAM_FEATURE_SHUTTER, value);
+}
+
+int CameraNode::getGain() const
+{
+ return getFeature(CAM_FEATURE_GAIN);
+}
+
+void CameraNode::setGain(int value)
+{
+ setFeature(CAM_FEATURE_GAIN, value);
+}
+
+int CameraNode::getWhitebalanceU() const
+{
+ return m_pCamera->getWhitebalanceU();
+}
+
+int CameraNode::getWhitebalanceV() const
+{
+ return m_pCamera->getWhitebalanceV();
+}
+
+void CameraNode::setWhitebalance(int u, int v)
+{
+ m_pCamera->setWhitebalance(u, v);
+}
+
+void CameraNode::doOneShotWhitebalance()
+{
+ // The first line turns off auto white balance.
+ m_pCamera->setWhitebalance(m_pCamera->getWhitebalanceU(),
+ m_pCamera->getWhitebalanceV());
+ m_pCamera->setFeatureOneShot(CAM_FEATURE_WHITE_BALANCE);
+}
+
+int CameraNode::getStrobeDuration() const
+{
+ return getFeature(CAM_FEATURE_STROBE_DURATION);
+}
+
+void CameraNode::setStrobeDuration(int value)
+{
+ setFeature(CAM_FEATURE_STROBE_DURATION, value);
+}
+
+
+IntPoint CameraNode::getMediaSize()
+{
+ return m_pCamera->getImgSize();
+}
+
+BitmapPtr CameraNode::getBitmap()
+{
+ if (m_pCurBmp) {
+ return m_pCurBmp;
+ } else {
+ throw Exception(AVG_ERR_CAMERA_NONFATAL,
+ "CameraNode.getBitmap: No camera image available.");
+ }
+}
+
+void CameraNode::dumpCameras()
+{
+ avg::dumpCameras();
+}
+
+void CameraNode::resetFirewireBus()
+{
+ FWCamera::resetBus();
+}
+
+double CameraNode::getFPS() const
+{
+ return m_pCamera->getFrameRate();
+}
+
+void CameraNode::open()
+{
+ m_pCamera->startCapture();
+ setViewport(-32767, -32767, -32767, -32767);
+ PixelFormat pf = getPixelFormat();
+ IntPoint size = getMediaSize();
+ bool bMipmap = getMaterial().getUseMipmaps();
+ m_pTex = GLTexturePtr(new GLTexture(size, pf, bMipmap));
+ m_pTex->enableStreaming();
+ getSurface()->create(pf, m_pTex);
+
+ BitmapPtr pBmp = m_pTex->lockStreamingBmp();
+ if (pf == B8G8R8X8 || pf == B8G8R8A8) {
+ FilterFill<Pixel32> Filter(Pixel32(0,0,0,255));
+ Filter.applyInPlace(pBmp);
+ } else if (pf == I8) {
+ FilterFill<Pixel8> Filter(0);
+ Filter.applyInPlace(pBmp);
+ }
+ m_pTex->unlockStreamingBmp(true);
+}
+
+int CameraNode::getFeature(CameraFeature feature) const
+{
+ return m_pCamera->getFeature(feature);
+}
+
+void CameraNode::setFeature(CameraFeature feature, int value)
+{
+ m_pCamera->setFeature(feature, value);
+}
+
+int CameraNode::getFrameNum() const
+{
+ return m_FrameNum;
+}
+
+static ProfilingZoneID CameraFetchImage("Camera fetch image");
+static ProfilingZoneID CameraDownloadProfilingZone("Camera tex download");
+
+void CameraNode::preRender()
+{
+ Node::preRender();
+ if (isAutoUpdateCameraImage()) {
+ ScopeTimer Timer(CameraFetchImage);
+ updateToLatestCameraImage();
+ }
+ if (m_bNewBmp && isVisible()) {
+ ScopeTimer Timer(CameraDownloadProfilingZone);
+ m_FrameNum++;
+ BitmapPtr pBmp = m_pTex->lockStreamingBmp();
+ if (pBmp->getPixelFormat() != m_pCurBmp->getPixelFormat()) {
+ cerr << "Surface: " << pBmp->getPixelFormat() << ", CamDest: "
+ << m_pCurBmp->getPixelFormat() << endl;
+ }
+ AVG_ASSERT(pBmp->getPixelFormat() == m_pCurBmp->getPixelFormat());
+ pBmp->copyPixels(*m_pCurBmp);
+ m_pTex->unlockStreamingBmp(true);
+ bind();
+ renderFX(getSize(), Pixel32(255, 255, 255, 255), false);
+ m_bNewBmp = false;
+ }
+}
+
+static ProfilingZoneID CameraProfilingZone("Camera::render");
+
+void CameraNode::render(const DRect& rect)
+{
+ if (m_bIsPlaying) {
+ ScopeTimer Timer(CameraProfilingZone);
+ blt32(getSize(), getEffectiveOpacity(), getBlendMode());
+ }
+}
+
+PixelFormat CameraNode::getPixelFormat()
+{
+ return m_pCamera->getDestPF();
+}
+
+void CameraNode::updateToLatestCameraImage()
+{
+ BitmapPtr pTmpBmp = m_pCamera->getImage(false);
+ while (pTmpBmp) {
+ m_bNewBmp = true;
+ m_pCurBmp = pTmpBmp;
+ pTmpBmp = m_pCamera->getImage(false);
+ }
+}
+
+void CameraNode::updateCameraImage()
+{
+ if (!isAutoUpdateCameraImage()) {
+ m_pCurBmp = m_pCamera->getImage(false);
+ blt32(getSize(), getEffectiveOpacity(), getBlendMode());
+ }
+}
+
+bool CameraNode::isAutoUpdateCameraImage() const
+{
+ return m_bIsAutoUpdateCameraImage;
+}
+
+void CameraNode::setAutoUpdateCameraImage(bool bVal)
+{
+ m_bIsAutoUpdateCameraImage = bVal;
+}
+
+bool CameraNode::isImageAvailable() const
+{
+ return m_pCurBmp.get() != NULL;
+}
+
+
+}
diff --git a/src/player/CameraNode.h b/src/player/CameraNode.h
new file mode 100644
index 0000000..874593b
--- /dev/null
+++ b/src/player/CameraNode.h
@@ -0,0 +1,132 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CameraNode_H_
+#define _CameraNode_H_
+
+#include "../api.h"
+#include "../avgconfigwrapper.h"
+
+#include "RasterNode.h"
+
+#include "../imaging/Camera.h"
+
+#include <boost/thread/thread.hpp>
+
+#include <string>
+#include <map>
+
+namespace avg {
+
+class TextureMover;
+typedef boost::shared_ptr<TextureMover> TextureMoverPtr;
+
+class AVG_API CameraNode : public RasterNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ CameraNode(const ArgList& args);
+ virtual ~CameraNode();
+
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+
+ void play();
+ void stop();
+ bool isAvailable();
+
+ const std::string& getDevice() const
+ {
+ return m_pCamera->getDevice();
+ }
+
+ const std::string& getDriverName() const
+ {
+ return m_pCamera->getDriverName();
+ }
+
+ double getFrameRate() const
+ {
+ return m_pCamera->getFrameRate();
+ }
+
+ int getBrightness() const;
+ void setBrightness(int value);
+ int getSharpness() const;
+ void setSharpness(int value);
+ int getSaturation() const;
+ void setSaturation(int value);
+ int getCamGamma() const;
+ void setCamGamma(int value);
+ int getShutter() const;
+ void setShutter(int value);
+ int getGain() const;
+ void setGain(int value);
+ int getWhitebalanceU() const;
+ int getWhitebalanceV() const;
+ void setWhitebalance(int u, int v);
+ void doOneShotWhitebalance();
+ int getStrobeDuration() const;
+ void setStrobeDuration(int value);
+
+ void updateCameraImage();
+ bool isAutoUpdateCameraImage() const;
+ void setAutoUpdateCameraImage(bool bVal);
+ bool isImageAvailable() const;
+
+ virtual void preRender();
+ virtual void render(const DRect& Rect);
+
+ int getFrameNum() const;
+ IntPoint getMediaSize();
+ virtual BitmapPtr getBitmap();
+
+ static void dumpCameras();
+ static void resetFirewireBus();
+
+ private:
+ int getFeature (CameraFeature feature) const;
+ void setFeature (CameraFeature feature, int value);
+
+ virtual double getFPS() const;
+ virtual void open();
+ virtual PixelFormat getPixelFormat();
+ void setFeature(int FeatureID);
+
+ void updateToLatestCameraImage();
+
+ bool m_bIsPlaying;
+
+ CameraPtr m_pCamera;
+ int m_FrameNum;
+ BitmapPtr m_pCurBmp;
+ bool m_bIsAutoUpdateCameraImage;
+ bool m_bNewBmp;
+
+ GLTexturePtr m_pTex;
+};
+
+}
+
+#endif
+
diff --git a/src/player/Canvas.cpp b/src/player/Canvas.cpp
new file mode 100644
index 0000000..0a21f8a
--- /dev/null
+++ b/src/player/Canvas.cpp
@@ -0,0 +1,350 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Canvas.h"
+
+#include "Player.h"
+#include "AVGNode.h"
+#include "Shape.h"
+#include "OffscreenCanvas.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+
+#include <iostream>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+CanvasPtr Canvas::s_pActiveCanvas;
+
+Canvas::Canvas(Player * pPlayer)
+ : m_pPlayer(pPlayer),
+ m_bIsPlaying(false),
+ m_PlaybackEndSignal(&IPlaybackEndListener::onPlaybackEnd),
+ m_FrameEndSignal(&IFrameEndListener::onFrameEnd),
+ m_PreRenderSignal(&IPreRenderListener::onPreRender),
+ m_ClipLevel(0)
+{
+}
+
+Canvas::~Canvas()
+{
+}
+
+void Canvas::setRoot(NodePtr pRootNode)
+{
+ assert(!m_pRootNode);
+ m_pRootNode = dynamic_pointer_cast<CanvasNode>(pRootNode);
+ m_pRootNode->setParent(DivNodeWeakPtr(), Node::NS_CONNECTED,
+ shared_from_this());
+ registerNode(m_pRootNode);
+}
+
+void Canvas::initPlayback(int multiSampleSamples)
+{
+ m_bIsPlaying = true;
+ m_pRootNode->connectDisplay();
+ m_MultiSampleSamples = multiSampleSamples;
+}
+
+void Canvas::stopPlayback()
+{
+ if (m_bIsPlaying) {
+ m_PlaybackEndSignal.emit();
+ m_pRootNode->disconnect(true);
+ m_pRootNode = CanvasNodePtr();
+ m_IDMap.clear();
+ m_bIsPlaying = false;
+ }
+}
+
+NodePtr Canvas::getElementByID(const std::string& id)
+{
+ if (m_IDMap.find(id) != m_IDMap.end()) {
+ return m_IDMap.find(id)->second;
+ } else {
+ AVG_TRACE(Logger::WARNING, "getElementByID(\"" << id << "\") failed.");
+ return NodePtr();
+ }
+}
+
+void Canvas::registerNode(NodePtr pNode)
+{
+ addNodeID(pNode);
+ DivNodePtr pDivNode = boost::dynamic_pointer_cast<DivNode>(pNode);
+ if (pDivNode) {
+ for (unsigned i=0; i<pDivNode->getNumChildren(); i++) {
+ registerNode(pDivNode->getChild(i));
+ }
+ }
+}
+
+void Canvas::addNodeID(NodePtr pNode)
+{
+ const string& id = pNode->getID();
+ if (id != "") {
+ if (m_IDMap.find(id) != m_IDMap.end() &&
+ m_IDMap.find(id)->second != pNode)
+ {
+ throw (Exception (AVG_ERR_XML_DUPLICATE_ID,
+ string("Error: duplicate id ")+id));
+ }
+ m_IDMap.insert(NodeIDMap::value_type(id, pNode));
+ }
+}
+
+void Canvas::removeNodeID(const string& id)
+{
+ if (id != "") {
+ map<string, NodePtr>::iterator it;
+ it = m_IDMap.find(id);
+ if (it != m_IDMap.end()) {
+ m_IDMap.erase(it);
+ } else {
+ cerr << "removeNodeID(\"" << id << "\") failed." << endl;
+ AVG_ASSERT(false);
+ }
+ }
+}
+
+CanvasNodePtr Canvas::getRootNode() const
+{
+ return m_pRootNode;
+}
+
+static ProfilingZoneID RenderProfilingZone("Render");
+
+void Canvas::doFrame(bool bPythonAvailable)
+{
+ s_pActiveCanvas = shared_from_this();
+ emitPreRenderSignal();
+ if (!m_pPlayer->isStopping()) {
+ ScopeTimer Timer(RenderProfilingZone);
+ if (bPythonAvailable) {
+ Py_BEGIN_ALLOW_THREADS;
+ try {
+ render();
+ } catch(...) {
+ Py_BLOCK_THREADS;
+ throw;
+ }
+ Py_END_ALLOW_THREADS;
+ } else {
+ render();
+ }
+ }
+ emitFrameEndSignal();
+ s_pActiveCanvas = CanvasPtr();
+}
+
+IntPoint Canvas::getSize() const
+{
+ return IntPoint(m_pRootNode->getSize());
+}
+static ProfilingZoneID PushClipRectProfilingZone("pushClipRect");
+
+void Canvas::pushClipRect(VertexArrayPtr pVA)
+{
+ ScopeTimer timer(PushClipRectProfilingZone);
+ m_ClipLevel++;
+ clip(pVA, GL_INCR);
+}
+
+static ProfilingZoneID PopClipRectProfilingZone("popClipRect");
+
+void Canvas::popClipRect(VertexArrayPtr pVA)
+{
+ ScopeTimer timer(PopClipRectProfilingZone);
+ m_ClipLevel--;
+ clip(pVA, GL_DECR);
+}
+
+void Canvas::registerPlaybackEndListener(IPlaybackEndListener* pListener)
+{
+ m_PlaybackEndSignal.connect(pListener);
+}
+
+void Canvas::unregisterPlaybackEndListener(IPlaybackEndListener* pListener)
+{
+ m_PlaybackEndSignal.disconnect(pListener);
+}
+
+void Canvas::registerFrameEndListener(IFrameEndListener* pListener)
+{
+ m_FrameEndSignal.connect(pListener);
+}
+
+void Canvas::unregisterFrameEndListener(IFrameEndListener* pListener)
+{
+ m_FrameEndSignal.disconnect(pListener);
+}
+
+void Canvas::registerPreRenderListener(IPreRenderListener* pListener)
+{
+ m_PreRenderSignal.connect(pListener);
+}
+
+void Canvas::unregisterPreRenderListener(IPreRenderListener* pListener)
+{
+ m_PreRenderSignal.disconnect(pListener);
+}
+
+bool Canvas::operator ==(const Canvas& other) const
+{
+ return this == &other;
+}
+
+bool Canvas::operator !=(const Canvas& other) const
+{
+ return this != &other;
+}
+
+long Canvas::getHash() const
+{
+ return long(this);
+}
+
+CanvasPtr Canvas::getActive()
+{
+ return s_pActiveCanvas;
+}
+
+Player* Canvas::getPlayer() const
+{
+ return m_pPlayer;
+}
+
+vector<NodeWeakPtr> Canvas::getElementsByPos(const DPoint& pos) const
+{
+ vector<NodeWeakPtr> elements;
+ m_pRootNode->getElementsByPos(pos, elements);
+ return elements;
+}
+
+static ProfilingZoneID PreRenderProfilingZone("PreRender");
+
+void Canvas::render(IntPoint windowSize, bool bUpsideDown, FBOPtr pFBO,
+ ProfilingZoneID& renderProfilingZone)
+{
+ {
+ ScopeTimer Timer(PreRenderProfilingZone);
+ m_pRootNode->preRender();
+ }
+ if (pFBO) {
+ pFBO->activate();
+ } else {
+ glproc::BindFramebuffer(GL_FRAMEBUFFER_EXT, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "Canvas::render: BindFramebuffer()");
+ }
+ if (m_MultiSampleSamples > 1) {
+ glEnable(GL_MULTISAMPLE);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "Canvas::render: glEnable(GL_MULTISAMPLE)");
+ } else {
+ glDisable(GL_MULTISAMPLE);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "Canvas::render: glDisable(GL_MULTISAMPLE)");
+ }
+ clearGLBuffers(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+ glViewport(0, 0, windowSize.x, windowSize.y);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "Canvas::render: glViewport()");
+ glMatrixMode(GL_PROJECTION);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "Canvas::render: glMatrixMode()");
+ glLoadIdentity();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "Canvas::render: glLoadIdentity()");
+ IntPoint size = IntPoint(m_pRootNode->getSize());
+ if (bUpsideDown) {
+ gluOrtho2D(0, size.x, 0, size.y);
+ } else {
+ gluOrtho2D(0, size.x, size.y, 0);
+ }
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "Canvas::render: gluOrtho2D()");
+
+ const DRect rc(0,0, size.x, size.y);
+ glMatrixMode(GL_MODELVIEW);
+ {
+ ScopeTimer Timer(renderProfilingZone);
+ m_pRootNode->maybeRender(rc);
+
+ renderOutlines();
+ }
+}
+
+void Canvas::renderOutlines()
+{
+ GLContext* pContext = GLContext::getCurrent();
+ VertexArrayPtr pVA(new VertexArray);
+ pContext->setBlendMode(GLContext::BLEND_BLEND, false);
+ m_pRootNode->renderOutlines(pVA, Pixel32(0,0,0,0));
+ if (pVA->getCurVert() != 0) {
+ pVA->update();
+ pContext->enableTexture(false);
+ pContext->enableGLColorArray(true);
+ pVA->draw();
+ }
+}
+
+void Canvas::clip(VertexArrayPtr pVA, GLenum stencilOp)
+{
+ // Disable drawing to color buffer
+ glColorMask(0, 0, 0, 0);
+
+ // Enable drawing to stencil buffer
+ glStencilMask(~0);
+
+ // Draw clip rectangle into stencil buffer
+ glStencilFunc(GL_ALWAYS, 0, 0);
+ glStencilOp(stencilOp, stencilOp, stencilOp);
+
+ pVA->draw();
+
+ // Set stencil test to only let
+ glStencilFunc(GL_LEQUAL, m_ClipLevel, ~0);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+
+ // Disable drawing to stencil buffer
+ glStencilMask(0);
+
+ // Enable drawing to color buffer
+ glColorMask(~0, ~0, ~0, ~0);
+}
+
+static ProfilingZoneID PreRenderSignalProfilingZone("PreRender signal");
+
+void Canvas::emitPreRenderSignal()
+{
+ ScopeTimer Timer(PreRenderSignalProfilingZone);
+ m_PreRenderSignal.emit();
+}
+
+static ProfilingZoneID FrameEndProfilingZone("OnFrameEnd");
+
+void Canvas::emitFrameEndSignal()
+{
+ ScopeTimer Timer(FrameEndProfilingZone);
+ m_FrameEndSignal.emit();
+}
+
+}
diff --git a/src/player/Canvas.h b/src/player/Canvas.h
new file mode 100644
index 0000000..a5e30ac
--- /dev/null
+++ b/src/player/Canvas.h
@@ -0,0 +1,128 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Canvas_H_
+#define _Canvas_H_
+
+#include "../api.h"
+
+#include "../base/IPlaybackEndListener.h"
+#include "../base/IFrameEndListener.h"
+#include "../base/IPreRenderListener.h"
+#include "../base/Signal.h"
+
+#include "../graphics/OGLHelper.h"
+#include "../graphics/Bitmap.h"
+
+#include <map>
+#include <string>
+#include <vector>
+#include <boost/enable_shared_from_this.hpp>
+
+namespace avg {
+
+class Player;
+class Node;
+class CanvasNode;
+class AudioEngine;
+class TestHelper;
+class ProfilingZoneID;
+class Canvas;
+class FBO;
+class VertexArray;
+
+typedef boost::shared_ptr<Node> NodePtr;
+typedef boost::weak_ptr<Node> NodeWeakPtr;
+typedef boost::shared_ptr<CanvasNode> CanvasNodePtr;
+typedef boost::shared_ptr<FBO> FBOPtr;
+typedef boost::shared_ptr<VertexArray> VertexArrayPtr;
+
+class Canvas;
+typedef boost::shared_ptr<Canvas> CanvasPtr;
+typedef boost::weak_ptr<Canvas> CanvasWeakPtr;
+
+class AVG_API Canvas: public boost::enable_shared_from_this<Canvas>
+{
+ public:
+ Canvas(Player * pPlayer);
+ virtual ~Canvas();
+ virtual void setRoot(NodePtr pRootNode);
+ void initPlayback(int multiSampleSamples);
+ virtual void stopPlayback();
+
+ CanvasNodePtr getRootNode() const;
+ NodePtr getElementByID(const std::string& id);
+ void registerNode(NodePtr pNode);
+ void addNodeID(NodePtr pNode);
+ void removeNodeID(const std::string& id);
+ virtual void doFrame(bool bPythonAvailable);
+ IntPoint getSize() const;
+ virtual BitmapPtr screenshot() const = 0;
+ virtual void pushClipRect(VertexArrayPtr pVA);
+ virtual void popClipRect(VertexArrayPtr pVA);
+
+ void registerPlaybackEndListener(IPlaybackEndListener* pListener);
+ void unregisterPlaybackEndListener(IPlaybackEndListener* pListener);
+ void registerFrameEndListener(IFrameEndListener* pListener);
+ void unregisterFrameEndListener(IFrameEndListener* pListener);
+ void registerPreRenderListener(IPreRenderListener* pListener);
+ void unregisterPreRenderListener(IPreRenderListener* pListener);
+
+ std::vector<NodeWeakPtr> getElementsByPos(const DPoint& Pos) const;
+
+ bool operator ==(const Canvas& other) const;
+ bool operator !=(const Canvas& other) const;
+ long getHash() const;
+
+ static CanvasPtr getActive();
+
+ protected:
+ Player * getPlayer() const;
+ void render(IntPoint windowSize, bool bUpsideDown, FBOPtr pFBO,
+ ProfilingZoneID& renderProfilingZone);
+ void emitPreRenderSignal();
+ void emitFrameEndSignal();
+
+
+ private:
+ virtual void render()=0;
+ void renderOutlines();
+
+ void clip(VertexArrayPtr pVA, GLenum stencilOp);
+ Player * m_pPlayer;
+ CanvasNodePtr m_pRootNode;
+ bool m_bIsPlaying;
+
+ typedef std::map<std::string, NodePtr> NodeIDMap;
+ NodeIDMap m_IDMap;
+
+ Signal<IPlaybackEndListener> m_PlaybackEndSignal;
+ Signal<IFrameEndListener> m_FrameEndSignal;
+ Signal<IPreRenderListener> m_PreRenderSignal;
+
+ int m_MultiSampleSamples;
+ int m_ClipLevel;
+
+ static CanvasPtr s_pActiveCanvas;
+};
+
+}
+#endif
diff --git a/src/player/CanvasNode.cpp b/src/player/CanvasNode.cpp
new file mode 100644
index 0000000..cfa836e
--- /dev/null
+++ b/src/player/CanvasNode.cpp
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "CanvasNode.h"
+#include "Player.h"
+
+#include "NodeDefinition.h"
+
+#include "../base/FileHelper.h"
+#include "../base/Exception.h"
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition CanvasNode::createDefinition()
+{
+ return NodeDefinition("canvasbase", Node::buildNode<CanvasNode>)
+ .extendDefinition(DivNode::createDefinition());
+}
+
+CanvasNode::CanvasNode(const ArgList& args)
+ : DivNode(args)
+{
+ args.setMembers(this);
+ if (getSize() == DPoint(0, 0)) {
+ throw (Exception(AVG_ERR_OUT_OF_RANGE,
+ "<avg> and <canvas> node width and height attributes are mandatory."));
+ }
+}
+
+CanvasNode::~CanvasNode()
+{
+}
+
+string CanvasNode::getEffectiveMediaDir()
+{
+ string sMediaDir = getMediaDir();
+ if (!isAbsPath(sMediaDir)) {
+ sMediaDir = Player::get()->getCurDirName()+sMediaDir;
+ }
+ if (sMediaDir[sMediaDir.length()-1] != '/') {
+ sMediaDir += '/';
+ }
+ return sMediaDir;
+}
+
+}
diff --git a/src/player/CanvasNode.h b/src/player/CanvasNode.h
new file mode 100644
index 0000000..eaf361d
--- /dev/null
+++ b/src/player/CanvasNode.h
@@ -0,0 +1,47 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CanvasNode_H_
+#define _CanvasNode_H_
+
+#include "../api.h"
+#include "DivNode.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API CanvasNode : public DivNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ CanvasNode(const ArgList& args);
+ virtual ~CanvasNode();
+
+ virtual std::string getEffectiveMediaDir();
+};
+
+typedef boost::shared_ptr<CanvasNode> CanvasNodePtr;
+
+}
+
+#endif
diff --git a/src/player/ChromaKeyFXNode.cpp b/src/player/ChromaKeyFXNode.cpp
new file mode 100644
index 0000000..f243ba2
--- /dev/null
+++ b/src/player/ChromaKeyFXNode.cpp
@@ -0,0 +1,155 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ChromaKeyFXNode.h"
+
+#include "../base/ObjectCounter.h"
+#include "../graphics/ShaderRegistry.h"
+
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+ChromaKeyFXNode::ChromaKeyFXNode()
+ : FXNode(),
+ m_sColorName("00FF00"),
+ m_Color(0, 255, 0),
+ m_HTolerance(0.0),
+ m_STolerance(0.0),
+ m_LTolerance(0.0),
+ m_Softness(0.0),
+ m_Erosion(0),
+ m_SpillThreshold(0.0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+ChromaKeyFXNode::~ChromaKeyFXNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void ChromaKeyFXNode::disconnect()
+{
+ m_pFilter = GPUChromaKeyFilterPtr();
+ FXNode::disconnect();
+}
+
+
+void ChromaKeyFXNode::setColor(const std::string& sColorName)
+{
+ m_sColorName = sColorName;
+ m_Color = colorStringToColor(m_sColorName);
+ updateFilter();
+}
+
+const std::string& ChromaKeyFXNode::getColor() const
+{
+ return m_sColorName;
+}
+
+void ChromaKeyFXNode::setHTolerance(double tolerance)
+{
+ m_HTolerance = tolerance;
+ updateFilter();
+}
+
+double ChromaKeyFXNode::getHTolerance() const
+{
+ return m_HTolerance;
+}
+
+void ChromaKeyFXNode::setSTolerance(double tolerance)
+{
+ m_STolerance = tolerance;
+ updateFilter();
+}
+
+double ChromaKeyFXNode::getSTolerance() const
+{
+ return m_STolerance;
+}
+
+void ChromaKeyFXNode::setLTolerance(double tolerance)
+{
+ m_LTolerance = tolerance;
+ updateFilter();
+}
+
+double ChromaKeyFXNode::getLTolerance() const
+{
+ return m_LTolerance;
+}
+
+void ChromaKeyFXNode::setSoftness(double softness)
+{
+ m_Softness = softness;
+ updateFilter();
+}
+
+double ChromaKeyFXNode::getSoftness() const
+{
+ return m_Softness;
+}
+
+void ChromaKeyFXNode::setErosion(int erosion)
+{
+ m_Erosion = erosion;
+ updateFilter();
+}
+
+int ChromaKeyFXNode::getErosion() const
+{
+ return m_Erosion;
+}
+
+void ChromaKeyFXNode::setSpillThreshold(double spillThreshold)
+{
+ m_SpillThreshold = spillThreshold;
+ updateFilter();
+}
+
+double ChromaKeyFXNode::getSpillThreshold() const
+{
+ return m_SpillThreshold;
+}
+
+GPUFilterPtr ChromaKeyFXNode::createFilter(const IntPoint& size)
+{
+ m_pFilter = GPUChromaKeyFilterPtr(new GPUChromaKeyFilter(size, B8G8R8A8, false));
+ m_pFilter->setParams(m_Color, m_HTolerance, m_STolerance, m_LTolerance, m_Softness,
+ m_Erosion, m_SpillThreshold);
+ setDirty();
+ return m_pFilter;
+}
+
+void ChromaKeyFXNode::updateFilter()
+{
+ if (m_pFilter) {
+ m_pFilter->setParams(m_Color, m_HTolerance, m_STolerance, m_LTolerance,
+ m_Softness, m_Erosion, m_SpillThreshold);
+ setDirty();
+ }
+}
+
+}
diff --git a/src/player/ChromaKeyFXNode.h b/src/player/ChromaKeyFXNode.h
new file mode 100644
index 0000000..c8cbe33
--- /dev/null
+++ b/src/player/ChromaKeyFXNode.h
@@ -0,0 +1,77 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ChromaKeyFXNode_H_
+#define _ChromaKeyFXNode_H_
+
+#include "../api.h"
+
+#include "FXNode.h"
+#include "../graphics/GPUChromaKeyFilter.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API ChromaKeyFXNode: public FXNode {
+public:
+ ChromaKeyFXNode();
+ virtual ~ChromaKeyFXNode();
+
+ virtual void disconnect();
+
+ void setColor(const std::string& sColorName);
+ const std::string& getColor() const;
+ void setHTolerance(double tolerance);
+ double getHTolerance() const;
+ void setSTolerance(double tolerance);
+ double getSTolerance() const;
+ void setLTolerance(double tolerance);
+ double getLTolerance() const;
+ void setSoftness(double softness);
+ double getSoftness() const;
+ void setErosion(int erosion);
+ int getErosion() const;
+ void setSpillThreshold(double spillThreshold);
+ double getSpillThreshold() const;
+
+private:
+ virtual GPUFilterPtr createFilter(const IntPoint& size);
+ void updateFilter();
+
+ GPUChromaKeyFilterPtr m_pFilter;
+
+ std::string m_sColorName;
+ Pixel32 m_Color;
+ double m_HTolerance;
+ double m_STolerance;
+ double m_LTolerance;
+ double m_Softness;
+ int m_Erosion;
+ double m_SpillThreshold;
+};
+
+typedef boost::shared_ptr<ChromaKeyFXNode> ChromaKeyFXNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/CircleNode.cpp b/src/player/CircleNode.cpp
new file mode 100644
index 0000000..1691d4d
--- /dev/null
+++ b/src/player/CircleNode.cpp
@@ -0,0 +1,287 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "CircleNode.h"
+
+#include "NodeDefinition.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition CircleNode::createDefinition()
+{
+ return NodeDefinition("circle", Node::buildNode<CircleNode>)
+ .extendDefinition(FilledVectorNode::createDefinition())
+ .addArg(Arg<DPoint>("pos", DPoint(0,0), false, offsetof(CircleNode, m_Pos)))
+ .addArg(Arg<double>("r", 1, false, offsetof(CircleNode, m_Radius)))
+ .addArg(Arg<double>("texcoord1", 0, false, offsetof(CircleNode, m_TC1)))
+ .addArg(Arg<double>("texcoord2", 1, false, offsetof(CircleNode, m_TC2)))
+ ;
+}
+
+CircleNode::CircleNode(const ArgList& args)
+ : FilledVectorNode(args)
+{
+ args.setMembers(this);
+}
+
+CircleNode::~CircleNode()
+{
+}
+
+const DPoint& CircleNode::getPos() const
+{
+ return m_Pos;
+}
+
+void CircleNode::setPos(const DPoint& pt)
+{
+ m_Pos = pt;
+ setDrawNeeded();
+}
+
+double CircleNode::getR() const
+{
+ return m_Radius;
+}
+
+void CircleNode::setR(double r)
+{
+ if (int(r) <= 0) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE, "Circle radius must be a positive number.");
+ }
+ m_Radius = r;
+ setDrawNeeded();
+}
+
+double CircleNode::getTexCoord1() const
+{
+ return m_TC1;
+}
+
+void CircleNode::setTexCoord1(double tc)
+{
+ m_TC1 = tc;
+ setDrawNeeded();
+}
+
+double CircleNode::getTexCoord2() const
+{
+ return m_TC2;
+}
+
+void CircleNode::setTexCoord2(double tc)
+{
+ m_TC2 = tc;
+ setDrawNeeded();
+}
+
+void CircleNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ if (calcDist(pos, m_Pos) <= m_Radius && reactsToMouseEvents()) {
+ pElements.push_back(shared_from_this());
+ }
+}
+
+void CircleNode::calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ // TODO: This gets called whenever the circle position changes and is quite
+ // expensive. Should be optimized away.
+ DPoint firstPt1 = getCirclePt(0, m_Radius+getStrokeWidth()/2)+m_Pos;
+ DPoint firstPt2 = getCirclePt(0, m_Radius-getStrokeWidth()/2)+m_Pos;
+ int curVertex = 0;
+ pVertexArray->appendPos(firstPt1, DPoint(m_TC1, 0), color);
+ pVertexArray->appendPos(firstPt2, DPoint(m_TC1, 1), color);
+ vector<DPoint> innerCircle;
+ getEigthCirclePoints(innerCircle, m_Radius-getStrokeWidth()/2);
+ vector<DPoint> outerCircle;
+ getEigthCirclePoints(outerCircle, m_Radius+getStrokeWidth()/2);
+
+ typedef vector<DPoint>::iterator DPointIt;
+ typedef vector<DPoint>::reverse_iterator DPointRIt;
+ int i = 0;
+ for (DPointIt iit = innerCircle.begin()+1, oit = outerCircle.begin()+1;
+ iit != innerCircle.end(); ++iit, ++oit)
+ {
+ appendCirclePoint(pVertexArray, *iit, *oit, color, i, curVertex);
+ }
+ for (DPointRIt iit = innerCircle.rbegin()+1, oit = outerCircle.rbegin()+1;
+ iit != innerCircle.rend(); ++iit, ++oit)
+ {
+ DPoint iPt = DPoint(-iit->y, -iit->x);
+ DPoint oPt = DPoint(-oit->y, -oit->x);
+ appendCirclePoint(pVertexArray, iPt, oPt, color, i, curVertex);
+ }
+ for (DPointIt iit = innerCircle.begin()+1, oit = outerCircle.begin()+1;
+ iit != innerCircle.end(); ++iit, ++oit)
+ {
+ DPoint iPt = DPoint(-iit->y, iit->x);
+ DPoint oPt = DPoint(-oit->y, oit->x);
+ appendCirclePoint(pVertexArray, iPt, oPt, color, i, curVertex);
+ }
+ for (DPointRIt iit = innerCircle.rbegin()+1, oit = outerCircle.rbegin()+1;
+ iit !=innerCircle.rend(); ++iit, ++oit)
+ {
+ DPoint iPt = DPoint(iit->x, -iit->y);
+ DPoint oPt = DPoint(oit->x, -oit->y);
+ appendCirclePoint(pVertexArray, iPt, oPt, color, i, curVertex);
+ }
+ for (DPointIt iit = innerCircle.begin()+1, oit = outerCircle.begin()+1;
+ iit != innerCircle.end(); ++iit, ++oit)
+ {
+ DPoint iPt = DPoint(-iit->x, -iit->y);
+ DPoint oPt = DPoint(-oit->x, -oit->y);
+ appendCirclePoint(pVertexArray, iPt, oPt, color, i, curVertex);
+ }
+ for (DPointRIt iit = innerCircle.rbegin()+1, oit = outerCircle.rbegin()+1;
+ iit != innerCircle.rend(); ++iit, ++oit)
+ {
+ DPoint iPt = DPoint(iit->y, iit->x);
+ DPoint oPt = DPoint(oit->y, oit->x);
+ appendCirclePoint(pVertexArray, iPt, oPt, color, i, curVertex);
+ }
+ for (DPointIt iit = innerCircle.begin()+1, oit = outerCircle.begin()+1;
+ iit != innerCircle.end(); ++iit, ++oit)
+ {
+ DPoint iPt = DPoint(iit->y, -iit->x);
+ DPoint oPt = DPoint(oit->y, -oit->x);
+ appendCirclePoint(pVertexArray, iPt, oPt, color, i, curVertex);
+ }
+ for (DPointRIt iit = innerCircle.rbegin()+1, oit = outerCircle.rbegin()+1;
+ iit != innerCircle.rend(); ++iit, ++oit)
+ {
+ DPoint iPt = DPoint(-iit->x, iit->y);
+ DPoint oPt = DPoint(-oit->x, oit->y);
+ appendCirclePoint(pVertexArray, iPt, oPt, color, i, curVertex);
+ }
+}
+
+void CircleNode::calcFillVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ DPoint minPt = m_Pos-DPoint(m_Radius, m_Radius);
+ DPoint maxPt = m_Pos+DPoint(m_Radius, m_Radius);
+ DPoint centerTexCoord = calcFillTexCoord(m_Pos, minPt, maxPt);
+ pVertexArray->appendPos(m_Pos, centerTexCoord, color);
+ int curVertex = 1;
+ DPoint firstPt = getCirclePt(0, m_Radius)+m_Pos;
+ DPoint firstTexCoord = calcFillTexCoord(firstPt, minPt, maxPt);
+ pVertexArray->appendPos(firstPt, firstTexCoord, color);
+ vector<DPoint> circlePoints;
+ getEigthCirclePoints(circlePoints, m_Radius);
+
+ for (vector<DPoint>::iterator it = circlePoints.begin()+1; it != circlePoints.end();
+ ++it)
+ {
+ DPoint curPt = *it+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+ for (vector<DPoint>::reverse_iterator it = circlePoints.rbegin()+1;
+ it != circlePoints.rend(); ++it)
+ {
+ DPoint curPt = DPoint(-it->y, -it->x)+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+ for (vector<DPoint>::iterator it = circlePoints.begin()+1; it != circlePoints.end();
+ ++it)
+ {
+ DPoint curPt = DPoint(-it->y, it->x)+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+ for (vector<DPoint>::reverse_iterator it = circlePoints.rbegin()+1;
+ it != circlePoints.rend(); ++it)
+ {
+ DPoint curPt = DPoint(it->x, -it->y)+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+ for (vector<DPoint>::iterator it = circlePoints.begin()+1; it != circlePoints.end();
+ ++it)
+ {
+ DPoint curPt = DPoint(-it->x, -it->y)+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+ for (vector<DPoint>::reverse_iterator it = circlePoints.rbegin()+1;
+ it != circlePoints.rend(); ++it)
+ {
+ DPoint curPt = DPoint(it->y, it->x)+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+ for (vector<DPoint>::iterator it = circlePoints.begin()+1; it != circlePoints.end();
+ ++it)
+ {
+ DPoint curPt = DPoint(it->y, -it->x)+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+ for (vector<DPoint>::reverse_iterator it = circlePoints.rbegin()+1;
+ it != circlePoints.rend(); ++it)
+ {
+ DPoint curPt = DPoint(-it->x, it->y)+m_Pos;
+ appendFillCirclePoint(pVertexArray, curPt, minPt, maxPt, color, curVertex);
+ }
+}
+
+void CircleNode::appendCirclePoint(VertexArrayPtr& pVertexArray, const DPoint& iPt,
+ const DPoint& oPt, Pixel32 color, int& i, int& curVertex)
+{
+ i++;
+ double ratio = (double(i)/getNumCircumferencePoints());
+ double curTC = (1-ratio)*m_TC1+ratio*m_TC2;
+ pVertexArray->appendPos(oPt+m_Pos, DPoint(curTC, 0), color);
+ pVertexArray->appendPos(iPt+m_Pos, DPoint(curTC, 1), color);
+ pVertexArray->appendQuadIndexes(curVertex+1, curVertex, curVertex+3, curVertex+2);
+ curVertex += 2;
+}
+
+void CircleNode::appendFillCirclePoint(VertexArrayPtr& pVertexArray, const DPoint& curPt,
+ const DPoint& minPt, const DPoint& maxPt, Pixel32 color, int& curVertex)
+{
+ DPoint curTexCoord = calcFillTexCoord(curPt, minPt, maxPt);
+ pVertexArray->appendPos(curPt, curTexCoord, color);
+ pVertexArray->appendTriIndexes(0, curVertex, curVertex+1);
+ curVertex++;
+}
+
+int CircleNode::getNumCircumferencePoints()
+{
+ return int(ceil((m_Radius*3)/8)*8);
+}
+
+void CircleNode::getEigthCirclePoints(vector<DPoint>& pts, double radius)
+{
+ int numPts = getNumCircumferencePoints();
+ for (int i = 0; i <= numPts/8; ++i) {
+ double ratio = (double(i)/numPts);
+ double angle = ratio*2*3.14159;
+ pts.push_back(getCirclePt(angle, radius));
+ }
+}
+
+DPoint CircleNode::getCirclePt(double angle, double radius)
+{
+ return DPoint(sin(angle)*radius, -cos(angle)*radius);
+}
+
+}
diff --git a/src/player/CircleNode.h b/src/player/CircleNode.h
new file mode 100644
index 0000000..10ce112
--- /dev/null
+++ b/src/player/CircleNode.h
@@ -0,0 +1,75 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CircleNode_H_
+#define _CircleNode_H_
+
+#include "../api.h"
+#include "FilledVectorNode.h"
+
+#include "../graphics/Pixel32.h"
+
+namespace avg {
+
+class AVG_API CircleNode : public FilledVectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ CircleNode(const ArgList& args);
+ virtual ~CircleNode();
+
+ const DPoint& getPos() const;
+ void setPos(const DPoint& pt);
+
+ double getR() const;
+ void setR(double r);
+
+ double getTexCoord1() const;
+ void setTexCoord1(double tc);
+
+ double getTexCoord2() const;
+ void setTexCoord2(double tc);
+
+ void getElementsByPos(const DPoint& pos, std::vector<NodeWeakPtr>& pElements);
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+ virtual void calcFillVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+
+ private:
+ void appendCirclePoint(VertexArrayPtr& pVertexArray, const DPoint& iPt,
+ const DPoint& oPt, Pixel32 color, int& i, int& curVertex);
+ void appendFillCirclePoint(VertexArrayPtr& pVertexArray, const DPoint& curPt,
+ const DPoint& minPt, const DPoint& maxPt, Pixel32 color, int& curVertex);
+ int getNumCircumferencePoints();
+ void getEigthCirclePoints(std::vector<DPoint>& pts, double radius);
+ DPoint getCirclePt(double angle, double radius);
+ DPoint calcTexCoord(const DPoint& pt, const DPoint& minPt, const DPoint& maxPt);
+
+ DPoint m_Pos;
+ double m_Radius;
+ double m_TC1;
+ double m_TC2;
+};
+
+}
+
+#endif
+
diff --git a/src/player/Contact.cpp b/src/player/Contact.cpp
new file mode 100644
index 0000000..a19abcc
--- /dev/null
+++ b/src/player/Contact.cpp
@@ -0,0 +1,235 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Contact.h"
+
+#include "CursorEvent.h"
+#include "BoostPython.h"
+#include "Player.h"
+
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+int Contact::s_LastListenerID = 0;
+
+Contact::Contact(CursorEventPtr pEvent)
+ : m_bSendingEvents(false),
+ m_bCurListenerIsDead(false),
+ m_CursorID(pEvent->getCursorID()),
+ m_DistanceTravelled(0)
+{
+ m_Events.push_back(pEvent);
+}
+
+Contact::~Contact()
+{
+}
+
+int Contact::connectListener(PyObject* pMotionCallback, PyObject* pUpCallback)
+{
+ s_LastListenerID++;
+ pair<int, Listener> val =
+ pair<int, Listener>(s_LastListenerID, Listener(pMotionCallback, pUpCallback));
+ m_ListenerMap.insert(val);
+ return s_LastListenerID;
+}
+
+void Contact::disconnectListener(int id)
+{
+ map<int, Listener>::iterator it = m_ListenerMap.find(id);
+ if (it == m_ListenerMap.end() || (m_CurListenerID == id && m_bCurListenerIsDead)) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Contact.disconnectListener: id " + toString(id) + " is not connected.");
+ }
+ if (m_bSendingEvents && m_CurListenerID == id) {
+ m_bCurListenerIsDead = true;
+ } else {
+ m_ListenerMap.erase(it);
+ }
+}
+
+long long Contact::getAge() const
+{
+ return m_Events.back()->getWhen() - m_Events[0]->getWhen();
+}
+
+double Contact::getDistanceFromStart() const
+{
+ return getMotionVec().getNorm();
+}
+
+double Contact::getMotionAngle() const
+{
+ DPoint motion = getMotionVec();
+ if (motion == DPoint(0,0)) {
+ return 0;
+ } else {
+ return motion.getAngle();
+ }
+}
+
+DPoint Contact::getMotionVec() const
+{
+ return m_Events.back()->getPos() - m_Events[0]->getPos();
+}
+
+double Contact::getDistanceTravelled() const
+{
+ return m_DistanceTravelled;
+}
+
+vector<CursorEventPtr> Contact::getEvents() const
+{
+ return m_Events;
+}
+
+void Contact::addEvent(CursorEventPtr pEvent)
+{
+ pEvent->setCursorID(m_CursorID);
+ pEvent->setContact(shared_from_this());
+ calcSpeed(pEvent, m_Events.back());
+ updateDistanceTravelled(m_Events.back(), pEvent);
+ m_Events.back()->removeBlob();
+ m_Events.push_back(pEvent);
+}
+
+bool Contact::hasListeners() const
+{
+ return !(m_ListenerMap.empty() ||
+ (m_ListenerMap.size() == 1 && m_bCurListenerIsDead));
+}
+
+void Contact::sendEventToListeners(CursorEventPtr pCursorEvent)
+{
+ m_bSendingEvents = true;
+ AVG_ASSERT(pCursorEvent->getContact() == shared_from_this());
+ EventPtr pEvent = boost::dynamic_pointer_cast<Event>(pCursorEvent);
+ m_bCurListenerIsDead = false;
+ for (map<int, Listener>::iterator it = m_ListenerMap.begin();
+ it != m_ListenerMap.end();)
+ {
+ Listener listener = it->second;
+ m_CurListenerID = it->first;
+ m_bCurListenerIsDead = false;
+ switch (pCursorEvent->getType()) {
+ case Event::CURSORMOTION:
+ if (listener.m_pMotionCallback != Py_None) {
+ boost::python::call<void>(listener.m_pMotionCallback, pEvent);
+ }
+ break;
+ case Event::CURSORUP:
+ if (listener.m_pUpCallback != Py_None) {
+ boost::python::call<void>(listener.m_pUpCallback, pEvent);
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ map<int, Listener>::iterator lastIt = it;
+ ++it;
+ if (m_bCurListenerIsDead) {
+ m_ListenerMap.erase(lastIt);
+ m_bCurListenerIsDead = false;
+ }
+ }
+ m_bSendingEvents = false;
+}
+
+int Contact::getID() const
+{
+ return m_CursorID;
+}
+
+bool Contact::operator ==(const Contact& other) const
+{
+ return (shared_from_this() == other.shared_from_this());
+}
+
+bool Contact::operator !=(const Contact& other) const
+{
+ return (shared_from_this() != other.shared_from_this());
+}
+
+long Contact::getHash() const
+{
+ return long(&*shared_from_this());
+
+}
+
+void Contact::calcSpeed(CursorEventPtr pEvent, CursorEventPtr pOldEvent)
+{
+ if (pEvent->getSpeed() == DPoint(0,0)) {
+ DPoint posDiff = pEvent->getPos() - pOldEvent->getPos();
+ long long timeDiff = pEvent->getWhen() - pOldEvent->getWhen();
+ if (timeDiff != 0) {
+ pEvent->setSpeed(posDiff/double(timeDiff));
+ }
+ }
+}
+
+void Contact::updateDistanceTravelled(CursorEventPtr pEvent1, CursorEventPtr pEvent2)
+{
+ double dist = (pEvent2->getPos() - pEvent1->getPos()).getNorm();
+ m_DistanceTravelled += dist;
+}
+
+void Contact::dumpListeners(string sFuncName)
+{
+ cerr << " " << sFuncName << ": ";
+ for (map<int, Listener>::iterator it = m_ListenerMap.begin();
+ it != m_ListenerMap.end(); ++it)
+ {
+ cerr << it->first << ", ";
+ }
+ cerr << endl;
+}
+
+Contact::Listener::Listener(PyObject * pMotionCallback, PyObject * pUpCallback)
+{
+ Py_INCREF(pMotionCallback);
+ m_pMotionCallback = pMotionCallback;
+ Py_INCREF(pUpCallback);
+ m_pUpCallback = pUpCallback;
+}
+
+Contact::Listener::Listener(const Listener& other)
+{
+ Py_INCREF(other.m_pMotionCallback);
+ m_pMotionCallback = other.m_pMotionCallback;
+ Py_INCREF(other.m_pUpCallback);
+ m_pUpCallback = other.m_pUpCallback;
+}
+
+Contact::Listener::~Listener()
+{
+ Py_DECREF(m_pMotionCallback);
+ Py_DECREF(m_pUpCallback);
+}
+
+
+}
+
diff --git a/src/player/Contact.h b/src/player/Contact.h
new file mode 100644
index 0000000..922dff8
--- /dev/null
+++ b/src/player/Contact.h
@@ -0,0 +1,99 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Contact_H_
+#define _Contact_H_
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+// Python docs say python.h should be included before any standard headers (!)
+#include "WrapPython.h"
+
+#include <vector>
+#include <map>
+#include <set>
+#include <boost/enable_shared_from_this.hpp>
+
+namespace avg {
+
+class CursorEvent;
+typedef boost::shared_ptr<class CursorEvent> CursorEventPtr;
+class Contact;
+typedef boost::shared_ptr<class Contact> ContactPtr;
+//typedef boost::weak_ptr<class Contact> ContactWeakPtr;
+
+class AVG_API Contact: public boost::enable_shared_from_this<Contact> {
+public:
+ Contact(CursorEventPtr pEvent);
+ virtual ~Contact();
+
+ int connectListener(PyObject* pMotionCallback, PyObject* pUpCallback);
+ void disconnectListener(int id);
+
+ long long getAge() const;
+ double getDistanceFromStart() const;
+ double getMotionAngle() const;
+ DPoint getMotionVec() const;
+ double getDistanceTravelled() const;
+ std::vector<CursorEventPtr> getEvents() const;
+
+ void addEvent(CursorEventPtr pEvent);
+ bool hasListeners() const;
+ void sendEventToListeners(CursorEventPtr pCursorEvent);
+
+ int getID() const;
+
+ bool operator ==(const Contact& other) const;
+ bool operator !=(const Contact& other) const;
+ long getHash() const;
+
+private:
+ void calcSpeed(CursorEventPtr pEvent, CursorEventPtr pOldEvent);
+ void updateDistanceTravelled(CursorEventPtr pEvent1, CursorEventPtr pEvent2);
+ void dumpListeners(std::string sFuncName);
+
+ std::vector<CursorEventPtr> m_Events;
+
+ bool m_bSendingEvents;
+
+ struct Listener
+ {
+ Listener(PyObject * pMotionCallback, PyObject * pUpCallback);
+ Listener(const Listener& other);
+ ~Listener();
+ PyObject* m_pMotionCallback;
+ PyObject* m_pUpCallback;
+ };
+
+ static int s_LastListenerID;
+ std::map<int, Listener> m_ListenerMap;
+ int m_CurListenerID;
+ bool m_bCurListenerIsDead;
+ int m_CursorID;
+ double m_DistanceTravelled;
+};
+
+}
+
+#endif
diff --git a/src/player/CursorEvent.cpp b/src/player/CursorEvent.cpp
new file mode 100644
index 0000000..df71c5c
--- /dev/null
+++ b/src/player/CursorEvent.cpp
@@ -0,0 +1,135 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "CursorEvent.h"
+
+#include "Node.h"
+#include "Contact.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+CursorEvent::CursorEvent(int id, Type eventType, const IntPoint& position, Source source,
+ int when)
+ : Event(eventType, source, when),
+ m_Position(position),
+ m_ID(id),
+ m_Speed(0,0)
+{
+}
+
+CursorEvent::~CursorEvent()
+{
+}
+
+CursorEventPtr CursorEvent::cloneAs(Type eventType) const
+{
+ CursorEventPtr pClone(new CursorEvent(*this));
+ pClone->m_Type = eventType;
+ return pClone;
+}
+
+void CursorEvent::setPos(const DPoint& pos)
+{
+ m_Position = IntPoint(pos);
+}
+
+DPoint CursorEvent::getPos() const
+{
+ return DPoint(m_Position);
+}
+
+int CursorEvent::getXPosition() const
+{
+ return m_Position.x;
+}
+
+int CursorEvent::getYPosition() const
+{
+ return m_Position.y;
+}
+
+void CursorEvent::setCursorID(int id)
+{
+ m_ID = id;
+}
+
+int CursorEvent::getCursorID() const
+{
+ return m_ID;
+}
+
+void CursorEvent::setNode(NodePtr pNode)
+{
+ m_pNode = pNode;
+}
+
+NodePtr CursorEvent::getNode() const
+{
+ return m_pNode.lock();
+}
+
+void CursorEvent::setSpeed(DPoint speed)
+{
+ m_Speed = speed;
+}
+
+const DPoint& CursorEvent::getSpeed() const
+{
+ return m_Speed;
+}
+
+void CursorEvent::setContact(ContactPtr pContact)
+{
+ m_pContact = pContact;
+}
+
+ContactPtr CursorEvent::getContact() const
+{
+ return m_pContact.lock();
+}
+
+bool operator ==(const CursorEvent& event1, const CursorEvent& event2)
+{
+ return (event1.m_Position == event2.m_Position &&
+ event1.getWhen() == event2.getWhen());
+}
+
+void CursorEvent::trace()
+{
+ string sType = typeStr();
+ if (m_pNode.expired()) {
+ AVG_TRACE(Logger::EVENTS, sType);
+ } else {
+ AVG_TRACE(Logger::EVENTS, m_pNode.lock()->getID()+", "+sType);
+ }
+}
+
+}
+
diff --git a/src/player/CursorEvent.h b/src/player/CursorEvent.h
new file mode 100644
index 0000000..5c6e699
--- /dev/null
+++ b/src/player/CursorEvent.h
@@ -0,0 +1,87 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#ifndef _CursorEvent_h_
+#define _CursorEvent_h_
+
+#include "../api.h"
+#include "Event.h"
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+namespace avg {
+
+const int MOUSECURSORID=-1;
+
+class AVG_API CursorEvent;
+typedef boost::shared_ptr<class CursorEvent> CursorEventPtr;
+
+class AVG_API Contact;
+typedef boost::shared_ptr<class Contact> ContactPtr;
+typedef boost::weak_ptr<class Contact> ContactWeakPtr;
+
+class Node;
+typedef boost::shared_ptr<class Node> NodePtr;
+typedef boost::weak_ptr<class Node> NodeWeakPtr;
+
+class AVG_API CursorEvent: public Event
+{
+ public:
+ CursorEvent(int id, Type eventType, const IntPoint& position, Source source,
+ int when=-1);
+ virtual ~CursorEvent();
+ virtual CursorEventPtr cloneAs(Type eventType) const;
+ void setPos(const DPoint& pos);
+ DPoint getPos() const;
+ int getXPosition() const;
+ int getYPosition() const;
+ void setCursorID(int id);
+ int getCursorID() const;
+ void setNode(NodePtr pNode);
+ NodePtr getNode() const;
+ void setSpeed(DPoint speed);
+ virtual const DPoint& getSpeed() const;
+
+ void setContact(ContactPtr pContact);
+ ContactPtr getContact() const;
+ virtual void removeBlob() {};
+
+ friend bool operator ==(const CursorEvent& event1, const CursorEvent& event2);
+ virtual void trace();
+
+ private:
+ IntPoint m_Position;
+ int m_ID;
+ ContactWeakPtr m_pContact;
+ NodeWeakPtr m_pNode;
+ DPoint m_Speed;
+};
+
+bool operator ==(const CursorEvent& event1, const CursorEvent& event2);
+
+}
+
+#endif
diff --git a/src/player/CursorState.cpp b/src/player/CursorState.cpp
new file mode 100644
index 0000000..d1f52bb
--- /dev/null
+++ b/src/player/CursorState.cpp
@@ -0,0 +1,58 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "CursorState.h"
+#include "Node.h"
+
+using namespace std;
+
+namespace avg {
+
+CursorState::CursorState(const CursorEventPtr pEvent,
+ const vector<NodeWeakPtr>& pNodes)
+ : m_pNodes(pNodes)
+{
+ m_pLastEvent = pEvent;
+}
+
+CursorState::~CursorState()
+{
+}
+
+void CursorState::setInfo(const CursorEventPtr pEvent,
+ const vector<NodeWeakPtr>& pNodes)
+{
+ m_pLastEvent = pEvent;
+ m_pNodes = pNodes;
+}
+
+const vector<NodeWeakPtr>& CursorState::getNodes() const
+{
+ return m_pNodes;
+}
+
+CursorEventPtr CursorState::getLastEvent() const
+{
+ return m_pLastEvent;
+}
+
+}
+
diff --git a/src/player/CursorState.h b/src/player/CursorState.h
new file mode 100644
index 0000000..b9d7693
--- /dev/null
+++ b/src/player/CursorState.h
@@ -0,0 +1,56 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CursorState_H_
+#define _CursorState_H_
+
+#include "../api.h"
+
+#include <vector>
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class Node;
+typedef boost::weak_ptr<Node> NodeWeakPtr;
+class CursorEvent;
+typedef boost::shared_ptr<CursorEvent> CursorEventPtr;
+
+class AVG_API CursorState {
+public:
+ CursorState(const CursorEventPtr pEvent, const std::vector<NodeWeakPtr>& pNodes);
+ ~CursorState();
+
+ void setInfo(const CursorEventPtr pEvent, const std::vector<NodeWeakPtr>& pNodes);
+ const std::vector<NodeWeakPtr>& getNodes() const;
+ CursorEventPtr getLastEvent() const;
+
+private:
+ CursorState(const CursorState&);
+
+ std::vector<NodeWeakPtr> m_pNodes;
+ CursorEventPtr m_pLastEvent;
+};
+
+typedef boost::shared_ptr<CursorState> CursorStatePtr;
+
+}
+#endif
diff --git a/src/player/CurveNode.cpp b/src/player/CurveNode.cpp
new file mode 100644
index 0000000..adaabe5
--- /dev/null
+++ b/src/player/CurveNode.cpp
@@ -0,0 +1,178 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "CurveNode.h"
+
+#include "NodeDefinition.h"
+
+#include "../graphics/VertexArray.h"
+#include "../base/Exception.h"
+#include "../base/MathHelper.h"
+#include "../base/BezierCurve.h"
+
+#include <math.h>
+#include <float.h>
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition CurveNode::createDefinition()
+{
+ return NodeDefinition("curve", Node::buildNode<CurveNode>)
+ .extendDefinition(VectorNode::createDefinition())
+ .addArg(Arg<DPoint>("pos1", DPoint(0,0), false, offsetof(CurveNode, m_P1)))
+ .addArg(Arg<DPoint>("pos2", DPoint(0,0), false, offsetof(CurveNode, m_P2)))
+ .addArg(Arg<DPoint>("pos3", DPoint(0,0), false, offsetof(CurveNode, m_P3)))
+ .addArg(Arg<DPoint>("pos4", DPoint(0,0), false, offsetof(CurveNode, m_P4)))
+ .addArg(Arg<double>("texcoord1", 0, true, offsetof(CurveNode, m_TC1)))
+ .addArg(Arg<double>("texcoord2", 1, true, offsetof(CurveNode, m_TC2)));
+}
+
+CurveNode::CurveNode(const ArgList& args)
+ : VectorNode(args)
+{
+ args.setMembers(this);
+}
+
+CurveNode::~CurveNode()
+{
+}
+
+const DPoint& CurveNode::getPos1() const
+{
+ return m_P1;
+}
+
+void CurveNode::setPos1(const DPoint& pt)
+{
+ m_P1 = pt;
+ setDrawNeeded();
+}
+
+const DPoint& CurveNode::getPos2() const
+{
+ return m_P2;
+}
+
+void CurveNode::setPos2(const DPoint& pt)
+{
+ m_P2 = pt;
+ setDrawNeeded();
+}
+
+const DPoint& CurveNode::getPos3() const
+{
+ return m_P3;
+}
+
+void CurveNode::setPos3(const DPoint& pt)
+{
+ m_P3 = pt;
+ setDrawNeeded();
+}
+
+const DPoint& CurveNode::getPos4() const
+{
+ return m_P4;
+}
+
+void CurveNode::setPos4(const DPoint& pt)
+{
+ m_P4 = pt;
+ setDrawNeeded();
+}
+
+double CurveNode::getTexCoord1() const
+{
+ return m_TC1;
+}
+
+void CurveNode::setTexCoord1(double tc)
+{
+ m_TC1 = tc;
+ setDrawNeeded();
+}
+
+double CurveNode::getTexCoord2() const
+{
+ return m_TC2;
+}
+
+void CurveNode::setTexCoord2(double tc)
+{
+ m_TC2 = tc;
+ setDrawNeeded();
+}
+
+void CurveNode::calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ updateLines();
+
+ pVertexArray->appendPos(m_LeftCurve[0], DPoint(m_TC1,1), color);
+ pVertexArray->appendPos(m_RightCurve[0], DPoint(m_TC2,0), color);
+ for (unsigned i = 0; i < m_LeftCurve.size()-1; ++i) {
+ double ratio = i/double(m_LeftCurve.size());
+ double tc = (1-ratio)*m_TC1+ratio*m_TC2;
+ pVertexArray->appendPos(m_LeftCurve[i+1], DPoint(tc,1), color);
+ pVertexArray->appendPos(m_RightCurve[i+1], DPoint(tc,0), color);
+ pVertexArray->appendQuadIndexes((i+1)*2, i*2, (i+1)*2+1, i*2+1);
+ }
+}
+
+int CurveNode::getCurveLen()
+{
+ // Calc. upper bound for spline length.
+ double curveLen = calcDist(m_P2,m_P1)+calcDist(m_P3,m_P2)+calcDist(m_P4,m_P3);
+ if (curveLen > 50000) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE, "Illegal points in curve.");
+ }
+ return int(curveLen);
+}
+
+void CurveNode::updateLines()
+{
+ BezierCurve curve(m_P1, m_P2, m_P3, m_P4);
+
+ double len = getCurveLen();
+ m_LeftCurve.clear();
+ m_RightCurve.clear();
+ m_LeftCurve.reserve(int(len+1.5));
+ m_RightCurve.reserve(int(len+1.5));
+
+ for (unsigned i = 0; i < len; ++i) {
+ double t = i/len;
+ addLRCurvePoint(curve.interpolate(t), curve.getDeriv(t));
+ }
+ addLRCurvePoint(curve.interpolate(1), curve.getDeriv(1));
+}
+
+void CurveNode::addLRCurvePoint(const DPoint& pos, const DPoint& deriv)
+{
+ DPoint m = deriv.getNormalized();
+ DPoint w = DPoint(m.y, -m.x)*getStrokeWidth()/2;
+ m_LeftCurve.push_back(pos-w);
+ m_RightCurve.push_back(pos+w);
+}
+
+}
diff --git a/src/player/CurveNode.h b/src/player/CurveNode.h
new file mode 100644
index 0000000..0a93292
--- /dev/null
+++ b/src/player/CurveNode.h
@@ -0,0 +1,78 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _CurveNode_H_
+#define _CurveNode_H_
+
+#include "../api.h"
+#include "VectorNode.h"
+
+#include "../graphics/Pixel32.h"
+
+namespace avg {
+
+class AVG_API CurveNode : public VectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ CurveNode(const ArgList& args);
+ virtual ~CurveNode();
+
+ const DPoint& getPos1() const;
+ void setPos1(const DPoint& pt);
+
+ const DPoint& getPos2() const;
+ void setPos2(const DPoint& pt);
+
+ const DPoint& getPos3() const;
+ void setPos3(const DPoint& pt);
+
+ const DPoint& getPos4() const;
+ void setPos4(const DPoint& pt);
+
+ double getTexCoord1() const;
+ void setTexCoord1(double tc);
+
+ double getTexCoord2() const;
+ void setTexCoord2(double tc);
+
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+
+ private:
+ int getCurveLen();
+ void updateLines();
+ void addLRCurvePoint(const DPoint& pos, const DPoint& deriv);
+ DPoint m_P1;
+ DPoint m_P2;
+ DPoint m_P3;
+ DPoint m_P4;
+ double m_TC1;
+ double m_TC2;
+
+ std::vector<DPoint> m_LeftCurve;
+ std::vector<DPoint> m_RightCurve;
+};
+
+}
+
+#endif
+
diff --git a/src/player/DisplayEngine.cpp b/src/player/DisplayEngine.cpp
new file mode 100644
index 0000000..1f46847
--- /dev/null
+++ b/src/player/DisplayEngine.cpp
@@ -0,0 +1,187 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "DisplayEngine.h"
+
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+#include "../base/TimeSource.h"
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+using namespace std;
+
+namespace avg {
+
+DisplayEngine::DisplayEngine()
+ : m_NumFrames(0),
+ m_VBRate(0),
+ m_Framerate(60),
+ m_bInitialized(false),
+ m_EffFramerate(0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+DisplayEngine::~DisplayEngine()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+
+void DisplayEngine::initRender()
+{
+ m_NumFrames = 0;
+ m_FramesTooLate = 0;
+ m_TimeSpentWaiting = 0;
+ m_StartTime = TimeSource::get()->getCurrentMicrosecs();
+ m_LastFrameTime = m_StartTime;
+ m_bInitialized = true;
+ if (m_VBRate != 0) {
+ setVBlankRate(m_VBRate);
+ } else {
+ setFramerate(m_Framerate);
+ }
+}
+
+void DisplayEngine::deinitRender()
+{
+ AVG_TRACE(Logger::PROFILE, "Framerate statistics: ");
+ AVG_TRACE(Logger::PROFILE, " Total frames: " << m_NumFrames);
+ double TotalTime = double(TimeSource::get()->getCurrentMicrosecs()
+ -m_StartTime)/1000000;
+ AVG_TRACE(Logger::PROFILE, " Total time: " << TotalTime << " seconds");
+ double actualFramerate = (m_NumFrames+1)/TotalTime;
+ AVG_TRACE(Logger::PROFILE, " Framerate achieved: "
+ << actualFramerate);
+ AVG_TRACE(Logger::PROFILE, " Frames too late: " << m_FramesTooLate);
+ AVG_TRACE(Logger::PROFILE, " Percent of time spent waiting: "
+ << double (m_TimeSpentWaiting)/(10000*TotalTime));
+ if (m_Framerate != 0) {
+ AVG_TRACE(Logger::PROFILE, " Framerate goal was: " << m_Framerate);
+ if (m_Framerate*2 < actualFramerate && m_NumFrames > 10) {
+ AVG_TRACE(Logger::WARNING,
+ "Actual framerate was a lot higher than framerate goal. Is vblank sync forced off?");
+ }
+ }
+ m_bInitialized = false;
+}
+
+void DisplayEngine::setFramerate(double rate)
+{
+ if (rate != 0 && m_bInitialized) {
+ initVBlank(0);
+ }
+ m_Framerate = rate;
+ m_VBRate = 0;
+}
+
+double DisplayEngine::getFramerate()
+{
+ return m_Framerate;
+}
+
+double DisplayEngine::getEffectiveFramerate()
+{
+ return m_EffFramerate;
+}
+
+void DisplayEngine::setVBlankRate(int rate)
+{
+ m_VBRate = rate;
+ if (m_bInitialized) {
+ bool bOK = initVBlank(rate);
+ m_Framerate = getRefreshRate()/m_VBRate;
+ if (!bOK || rate == 0) {
+ AVG_TRACE(Logger::WARNING, "Using framerate of " << m_Framerate <<
+ " instead of VBRate of " << m_VBRate);
+ m_VBRate = 0;
+ }
+ }
+}
+
+bool DisplayEngine::wasFrameLate()
+{
+ return m_bFrameLate;
+}
+
+static ProfilingZoneID WaitProfilingZone("Render - wait");
+
+void DisplayEngine::frameWait()
+{
+ ScopeTimer Timer(WaitProfilingZone);
+
+ m_NumFrames++;
+
+ m_FrameWaitStartTime = TimeSource::get()->getCurrentMicrosecs();
+ m_TargetTime = m_LastFrameTime+(long long)(1000000/m_Framerate);
+ if (m_VBRate != 0) {
+ m_bFrameLate = !vbWait(m_VBRate);
+ } else {
+ m_bFrameLate = false;
+ if (m_FrameWaitStartTime <= m_TargetTime) {
+ long long WaitTime = (m_TargetTime-m_FrameWaitStartTime)/1000;
+ if (WaitTime > 5000) {
+ AVG_TRACE (Logger::WARNING,
+ "DisplayEngine: waiting " << WaitTime << " ms.");
+ }
+ TimeSource::get()->sleepUntil(m_TargetTime/1000);
+ }
+ }
+}
+
+long long DisplayEngine::getDisplayTime()
+{
+ return (m_LastFrameTime-m_StartTime)/1000;
+}
+
+void DisplayEngine::checkJitter()
+{
+ if (m_LastFrameTime == 0) {
+ m_EffFramerate = 0;
+ } else {
+ long long CurIntervalTime = TimeSource::get()->getCurrentMicrosecs()
+ -m_LastFrameTime;
+ m_EffFramerate = 1000000.0/CurIntervalTime;
+ }
+
+ long long frameTime = TimeSource::get()->getCurrentMicrosecs();
+ int maxDelay;
+ if (m_VBRate == 0) {
+ maxDelay = 2;
+ } else {
+ maxDelay = 6;
+ }
+ if ((frameTime - m_TargetTime)/1000 > maxDelay || m_bFrameLate) {
+ AVG_TRACE (Logger::PROFILE_LATEFRAMES,
+ "DisplayEngine: frame too late by "
+ << (frameTime - m_TargetTime)/1000 << " ms.");
+ m_bFrameLate = true;
+ m_FramesTooLate++;
+ }
+
+ m_LastFrameTime = frameTime;
+ m_TimeSpentWaiting += m_LastFrameTime-m_FrameWaitStartTime;
+// cerr << m_LastFrameTime << ", m_FrameWaitStartTime=" << m_FrameWaitStartTime << endl;
+// cerr << m_TimeSpentWaiting << endl;
+}
+
+}
diff --git a/src/player/DisplayEngine.h b/src/player/DisplayEngine.h
new file mode 100644
index 0000000..1025f6a
--- /dev/null
+++ b/src/player/DisplayEngine.h
@@ -0,0 +1,97 @@
+
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DisplayEngine_H_
+#define _DisplayEngine_H_
+
+#include "../api.h"
+#include "DisplayParams.h"
+
+#include "../graphics/Pixel32.h"
+#include "../graphics/Bitmap.h"
+
+#include "../base/Rect.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <string>
+
+namespace avg {
+
+class Region;
+
+class AVG_API DisplayEngine
+{
+ public:
+ DisplayEngine();
+ virtual ~DisplayEngine();
+ virtual void teardown() = 0;
+ void initRender();
+ void deinitRender();
+ void setFramerate(double rate);
+ double getFramerate();
+ double getEffectiveFramerate();
+ void setVBlankRate(int rate);
+ bool wasFrameLate();
+ virtual double getRefreshRate() = 0;
+ virtual void setGamma(double Red, double Green, double Blue) = 0;
+ virtual void setMousePos(const IntPoint& pos) = 0;
+ virtual int getKeyModifierState() const = 0;
+
+ void frameWait();
+ virtual void swapBuffers() = 0;
+ void checkJitter();
+ long long getDisplayTime();
+
+ virtual IntPoint getSize() = 0;
+
+ virtual void showCursor(bool bShow) = 0;
+
+ virtual BitmapPtr screenshot(int buffer=0) = 0;
+
+ protected:
+
+ private:
+ virtual bool initVBlank(int rate) = 0;
+ virtual bool vbWait(int rate) = 0;
+
+ int m_NumFrames;
+ int m_FramesTooLate;
+ long long m_StartTime;
+ long long m_TimeSpentWaiting;
+
+ // Per-Frame timings.
+ long long m_LastFrameTime;
+ long long m_FrameWaitStartTime;
+ long long m_TargetTime;
+ int m_VBRate;
+ double m_Framerate;
+ bool m_bInitialized;
+ bool m_bFrameLate;
+
+ double m_EffFramerate;
+};
+
+typedef boost::shared_ptr<DisplayEngine> DisplayEnginePtr;
+
+}
+
+#endif //_DisplayEngine_H_
diff --git a/src/player/DisplayParams.cpp b/src/player/DisplayParams.cpp
new file mode 100644
index 0000000..eb376c5
--- /dev/null
+++ b/src/player/DisplayParams.cpp
@@ -0,0 +1,70 @@
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "DisplayParams.h"
+
+#include "../base/ObjectCounter.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+DisplayParams::DisplayParams()
+ : m_Pos(-1, -1),
+ m_Size(0, 0),
+ m_bFullscreen(false),
+ m_BPP(24),
+ m_WindowSize(0, 0),
+ m_bShowCursor(true),
+ m_VBRate(1),
+ m_Framerate(0),
+ m_bHasWindowFrame(true),
+ m_DotsPerMM(0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ m_Gamma[0] = -1.0;
+ m_Gamma[1] = -1.0;
+ m_Gamma[2] = -1.0;
+}
+
+DisplayParams::~DisplayParams()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void DisplayParams::dump() const
+{
+ cerr << "DisplayParams: " << endl;
+ cerr << " pos: " << m_Pos << endl;
+ cerr << " size: " << m_Size << endl;
+ cerr << " fullscreen: " << m_bFullscreen << endl;
+ cerr << " bpp: " << m_BPP << endl;
+ cerr << " window size: " << m_WindowSize << endl;
+ cerr << " show cursor: " << m_bShowCursor << endl;
+ cerr << " vbrate: " << m_VBRate << endl;
+ cerr << " framerate: " << m_Framerate << endl;
+ cerr << " has window frame: " << m_bHasWindowFrame << endl;
+ cerr << " dots per mm: " << m_DotsPerMM << endl;
+}
+
+}
+
diff --git a/src/player/DisplayParams.h b/src/player/DisplayParams.h
new file mode 100644
index 0000000..1a2114d
--- /dev/null
+++ b/src/player/DisplayParams.h
@@ -0,0 +1,53 @@
+
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DisplayParams_H_
+#define _DisplayParams_H_
+
+#include "../api.h"
+
+#include "../base/Point.h"
+
+namespace avg {
+
+struct AVG_API DisplayParams {
+ DisplayParams();
+ virtual ~DisplayParams();
+
+ void dump() const;
+
+ IntPoint m_Pos;
+ IntPoint m_Size;
+ bool m_bFullscreen;
+ int m_BPP;
+ IntPoint m_WindowSize;
+ bool m_bShowCursor;
+ int m_VBRate;
+ double m_Framerate;
+ bool m_bHasWindowFrame;
+ double m_DotsPerMM;
+
+ double m_Gamma[3];
+};
+
+}
+
+#endif
diff --git a/src/player/DivNode.cpp b/src/player/DivNode.cpp
new file mode 100644
index 0000000..7d3dc7c
--- /dev/null
+++ b/src/player/DivNode.cpp
@@ -0,0 +1,425 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "DivNode.h"
+#include "Player.h"
+#include "NodeDefinition.h"
+#include "Canvas.h"
+
+#include "../base/Point.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/StringHelper.h"
+#include "../base/FileHelper.h"
+#include "../base/MathHelper.h"
+#include "../base/ObjectCounter.h"
+
+#include <iostream>
+#include <sstream>
+#include <limits>
+
+using namespace std;
+using namespace boost;
+
+#define DEFAULT_SIZE 100000
+
+namespace avg {
+
+
+NodeDefinition DivNode::createDefinition()
+{
+ string sChildArray[] = {"image", "div", "canvas", "words", "video", "camera",
+ "panoimage", "sound", "line", "rect", "curve", "polyline", "polygon",
+ "circle", "mesh"};
+ vector<string> sChildren = vectorFromCArray(
+ sizeof(sChildArray) / sizeof(*sChildArray), sChildArray);
+ return NodeDefinition("div", Node::buildNode<DivNode>)
+ .extendDefinition(AreaNode::createDefinition())
+ .addChildren(sChildren)
+ .addArg(Arg<bool>("crop", false, false, offsetof(DivNode, m_bCrop)))
+ .addArg(Arg<string>("elementoutlinecolor", "", false,
+ offsetof(DivNode, m_sElementOutlineColor)))
+ .addArg(Arg<UTF8String>("mediadir", "", false, offsetof(DivNode, m_sMediaDir)));
+}
+
+DivNode::DivNode(const ArgList& args)
+{
+ args.setMembers(this);
+ setElementOutlineColor(m_sElementOutlineColor);
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+DivNode::~DivNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void DivNode::connectDisplay()
+{
+ AreaNode::connectDisplay();
+ for (unsigned i = 0; i < getNumChildren(); ++i) {
+ getChild(i)->connectDisplay();
+ }
+ m_pClipVertexes = VertexArrayPtr(new VertexArray());
+}
+
+void DivNode::connect(CanvasPtr pCanvas)
+{
+ AreaNode::connect(pCanvas);
+ for (unsigned i = 0; i < getNumChildren(); ++i) {
+ getChild(i)->connect(pCanvas);
+ }
+}
+
+void DivNode::disconnect(bool bKill)
+{
+ for (unsigned i = 0; i < getNumChildren(); ++i) {
+ getChild(i)->disconnect(bKill);
+ }
+ if (m_pClipVertexes) {
+ m_pClipVertexes = VertexArrayPtr();
+ }
+ AreaNode::disconnect(bKill);
+}
+
+DPoint DivNode::getPivot() const
+{
+ DPoint pivot = AreaNode::getPivot();
+ if (pivot == DPoint(DEFAULT_SIZE / 2, DEFAULT_SIZE / 2)) {
+ return DPoint(0, 0);
+ }
+ return pivot;
+}
+
+unsigned DivNode::getNumChildren()
+{
+ return m_Children.size();
+}
+
+const NodePtr& DivNode::getChild(unsigned i)
+{
+ if (i >= m_Children.size()) {
+ stringstream s;
+ s << "Index " << i << " is out of range in Node::getChild()";
+ throw(Exception(AVG_ERR_OUT_OF_RANGE, s.str()));
+ }
+ return m_Children[i];
+}
+
+void DivNode::appendChild(NodePtr pNewNode)
+{
+ insertChild(pNewNode, unsigned(m_Children.size()));
+}
+
+void DivNode::insertChildBefore(NodePtr pNewNode, NodePtr pOldChild)
+{
+ if (!pOldChild) {
+ throw Exception(AVG_ERR_NO_NODE,
+ getID()+"::insertChildBefore called without a node.");
+ }
+ unsigned i = indexOf(pOldChild);
+ insertChild(pNewNode, i);
+}
+
+void DivNode::insertChildAfter(NodePtr pNewNode, NodePtr pOldChild)
+{
+ if (!pOldChild) {
+ throw Exception(AVG_ERR_NO_NODE,
+ getID()+"::insertChildBefore called without a node.");
+ }
+ unsigned i = indexOf(pOldChild);
+ insertChild(pNewNode, i+1);
+}
+
+void DivNode::insertChild(NodePtr pChild, unsigned i)
+{
+ if (!pChild) {
+ throw Exception(AVG_ERR_NO_NODE,
+ getID()+"::insertChild called without a node.");
+ }
+ if (pChild->getState() == NS_CONNECTED || pChild->getState() == NS_CANRENDER) {
+ throw(Exception(AVG_ERR_ALREADY_CONNECTED,
+ "Can't connect node with id "+pChild->getID()+
+ ": already connected."));
+ }
+ if (getState() == NS_CONNECTED || getState() == NS_CANRENDER) {
+ getCanvas()->registerNode(pChild);
+ }
+ DivNodePtr ptr = dynamic_pointer_cast<DivNode>(shared_from_this());
+ pChild->checkSetParentError(ptr);
+ if (!isChildTypeAllowed(pChild->getTypeStr())) {
+ throw(Exception(AVG_ERR_ALREADY_CONNECTED,
+ "Can't insert a node of type "+pChild->getTypeStr()+
+ " into a node of type "+getTypeStr()+"."));
+ }
+ if (i > m_Children.size()) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ pChild->getID()+"::insertChild: index out of bounds."));
+ }
+ std::vector<NodePtr>::iterator pos = m_Children.begin()+i;
+ m_Children.insert(pos, pChild);
+ try {
+ pChild->setParent(ptr, getState(), getCanvas());
+ } catch (Exception&) {
+ m_Children.erase(m_Children.begin()+i);
+ throw;
+ }
+ if (getState() == NS_CANRENDER) {
+ pChild->connectDisplay();
+ }
+}
+
+void DivNode::reorderChild(NodePtr pChild, unsigned j)
+{
+ if (j > m_Children.size()-1) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ getID()+"::reorderChild: index "+toString(j)+" out of bounds."));
+ }
+ int i = indexOf(pChild);
+ m_Children.erase(m_Children.begin()+i);
+ std::vector<NodePtr>::iterator pos = m_Children.begin()+j;
+ m_Children.insert(pos, pChild);
+}
+
+void DivNode::reorderChild(unsigned i, unsigned j)
+{
+ if (i > m_Children.size()-1 || j > m_Children.size()-1) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ getID()+"::reorderChild: index out of bounds."));
+ }
+ NodePtr pChild = getChild(i);
+ m_Children.erase(m_Children.begin()+i);
+ std::vector<NodePtr>::iterator pos = m_Children.begin()+j;
+ m_Children.insert(pos, pChild);
+}
+
+unsigned DivNode::indexOf(NodePtr pChild)
+{
+ if (!pChild) {
+ throw Exception(AVG_ERR_NO_NODE,
+ getID()+"::indexOf called without a node.");
+ }
+ for (unsigned i = 0; i < m_Children.size(); ++i) {
+ if (m_Children[i] == pChild) {
+ return i;
+ }
+ }
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "indexOf: node '"+pChild->getID()+"' is not a child of node '"
+ +getID()+"'"));
+}
+
+void DivNode::removeChild(NodePtr pChild)
+{
+ removeChild(pChild, false);
+}
+
+void DivNode::removeChild(unsigned i)
+{
+ removeChild(i, false);
+}
+
+void DivNode::removeChild(NodePtr pChild, bool bKill)
+{
+ pChild->removeParent();
+ if (pChild->getState() != NS_UNCONNECTED) {
+ pChild->disconnect(bKill);
+ }
+ unsigned i = indexOf(pChild);
+ if (i > m_Children.size()-1) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ getID()+"::removeChild: index "+toString(i)+" out of bounds."));
+ }
+ m_Children.erase(m_Children.begin()+i);
+}
+
+void DivNode::removeChild(unsigned i, bool bKill)
+{
+ NodePtr pChild = getChild(i);
+ removeChild(pChild, bKill);
+}
+
+bool DivNode::getCrop() const
+{
+ return m_bCrop;
+}
+
+void DivNode::setCrop(bool bCrop)
+{
+ m_bCrop = bCrop;
+}
+
+const std::string& DivNode::getElementOutlineColor() const
+{
+ return m_sElementOutlineColor;
+}
+
+void DivNode::setElementOutlineColor(const std::string& sColor)
+{
+ m_sElementOutlineColor = sColor;
+ if (sColor == "") {
+ m_ElementOutlineColor = Pixel32(0,0,0,0);
+ } else {
+ m_ElementOutlineColor = colorStringToColor(m_sElementOutlineColor);
+ }
+}
+
+const UTF8String& DivNode::getMediaDir() const
+{
+ return m_sMediaDir;
+}
+
+void DivNode::setMediaDir(const UTF8String& sMediaDir)
+{
+ m_sMediaDir = sMediaDir;
+ checkReload();
+}
+
+void DivNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ if (reactsToMouseEvents() &&
+ ((getSize() == DPoint(DEFAULT_SIZE, DEFAULT_SIZE) ||
+ (pos.x >= 0 && pos.y >= 0 && pos.x < getSize().x && pos.y < getSize().y))))
+ {
+ for (int i = getNumChildren()-1; i >= 0; i--) {
+ NodePtr pCurChild = getChild(i);
+ DPoint relPos = pCurChild->toLocal(pos);
+ pCurChild->getElementsByPos(relPos, pElements);
+ if (!pElements.empty()) {
+ pElements.push_back(shared_from_this());
+ return;
+ }
+ }
+ // pos isn't in any of the children.
+ if (getSize() != DPoint(DEFAULT_SIZE, DEFAULT_SIZE)) {
+ // Explicit width/height given for div - div reacts on its own.
+ pElements.push_back(shared_from_this());
+ }
+ }
+}
+
+void DivNode::preRender()
+{
+ Node::preRender();
+ for (unsigned i = 0; i < getNumChildren(); i++) {
+ getChild(i)->preRender();
+ }
+}
+
+void DivNode::render(const DRect& rect)
+{
+ DPoint viewport = getSize();
+
+ m_pClipVertexes->reset();
+ m_pClipVertexes->appendPos(DPoint(0,0), DPoint(0,0), Pixel32(0,0,0,0));
+ m_pClipVertexes->appendPos(DPoint(0,viewport.y), DPoint(0,0), Pixel32(0,0,0,0));
+ m_pClipVertexes->appendPos(DPoint(viewport.x,0), DPoint(0,0), Pixel32(0,0,0,0));
+ m_pClipVertexes->appendPos(viewport, DPoint(0,0), Pixel32(0,0,0,0));
+ m_pClipVertexes->appendQuadIndexes(0, 1, 2, 3);
+
+ if (getCrop()) {
+ getCanvas()->pushClipRect(m_pClipVertexes);
+ }
+ for (unsigned i = 0; i < getNumChildren(); i++) {
+ getChild(i)->maybeRender(rect);
+ }
+ if (getCrop()) {
+ getCanvas()->popClipRect(m_pClipVertexes);
+ }
+}
+
+void DivNode::renderOutlines(const VertexArrayPtr& pVA, Pixel32 color)
+{
+ Pixel32 effColor = color;
+ if (m_ElementOutlineColor != Pixel32(0,0,0,0)) {
+ effColor = m_ElementOutlineColor;
+ effColor.setA(128);
+ }
+ if (effColor != Pixel32(0,0,0,0)) {
+ DPoint size = getSize();
+ if (size == DPoint(DEFAULT_SIZE, DEFAULT_SIZE)) {
+ DPoint p0 = getAbsPos(DPoint(-4, 0.5));
+ DPoint p1 = getAbsPos(DPoint(5, 0.5));
+ DPoint p2 = getAbsPos(DPoint(0.5, -4));
+ DPoint p3 = getAbsPos(DPoint(0.5, 5));
+ pVA->addLineData(effColor, p0, p1, 1);
+ pVA->addLineData(effColor, p2, p3, 1);
+ } else {
+ DPoint p0 = getAbsPos(DPoint(0.5, 0.5));
+ DPoint p1 = getAbsPos(DPoint(size.x+0.5,0.5));
+ DPoint p2 = getAbsPos(DPoint(size.x+0.5,size.y+0.5));
+ DPoint p3 = getAbsPos(DPoint(0.5,size.y+0.5));
+ pVA->addLineData(effColor, p0, p1, 1);
+ pVA->addLineData(effColor, p1, p2, 1);
+ pVA->addLineData(effColor, p2, p3, 1);
+ pVA->addLineData(effColor, p3, p0, 1);
+ }
+ }
+ for (unsigned i = 0; i < getNumChildren(); i++) {
+ getChild(i)->renderOutlines(pVA, effColor);
+ }
+}
+
+string DivNode::getEffectiveMediaDir()
+{
+ // TODO: There is no test for this function.
+ string sMediaDir = m_sMediaDir;
+ if (!isAbsPath(sMediaDir)) {
+ if (getParent()) {
+ sMediaDir = getParent()->getEffectiveMediaDir()+m_sMediaDir;
+ } else {
+ sMediaDir = Player::get()->getRootMediaDir()+m_sMediaDir;
+ }
+ }
+ if (sMediaDir[sMediaDir.length()-1] != '/') {
+ sMediaDir += '/';
+ }
+ return sMediaDir;
+}
+
+void DivNode::checkReload()
+{
+ for(unsigned i = 0; i < getNumChildren(); ++i) {
+ getChild(i)->checkReload();
+ }
+}
+
+string DivNode::dump(int indent)
+{
+ string dumpStr = AreaNode::dump () + "\n";
+ vector<NodePtr>::iterator it;
+ for(unsigned i = 0; i < getNumChildren(); ++i) {
+ getChild(i)->dump(indent+2)+"\n";
+ }
+ return dumpStr;
+}
+
+IntPoint DivNode::getMediaSize()
+{
+ return IntPoint(DEFAULT_SIZE, DEFAULT_SIZE);
+}
+
+bool DivNode::isChildTypeAllowed(const string& sType)
+{
+ return getDefinition()->isChildAllowed(sType);
+}
+
+}
diff --git a/src/player/DivNode.h b/src/player/DivNode.h
new file mode 100644
index 0000000..573f2e5
--- /dev/null
+++ b/src/player/DivNode.h
@@ -0,0 +1,99 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _DivNode_H_
+#define _DivNode_H_
+
+#include "../api.h"
+#include "AreaNode.h"
+
+#include "../base/UTF8String.h"
+#include "../graphics/VertexArray.h"
+
+#include <string>
+
+namespace avg {
+
+class VertexArray;
+
+class AVG_API DivNode : public AreaNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ DivNode(const ArgList& args);
+ virtual ~DivNode();
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+
+ unsigned getNumChildren();
+ const NodePtr& getChild(unsigned i);
+ void appendChild(NodePtr pNewNode);
+ void insertChildBefore(NodePtr pNewNode, NodePtr pOldChild);
+ void insertChildAfter(NodePtr pNewNode, NodePtr pOldChild);
+ virtual void insertChild(NodePtr pNewNode, unsigned i);
+ void reorderChild(NodePtr pNode, unsigned j);
+ void reorderChild(unsigned i, unsigned j);
+ unsigned indexOf(NodePtr pChild);
+ void removeChild(NodePtr pNode);
+ void removeChild(unsigned i);
+ void removeChild(NodePtr pNode, bool bKill);
+ void removeChild(unsigned i, bool bKill);
+
+ virtual DPoint getPivot() const;
+
+ bool getCrop() const;
+ void setCrop(bool bCrop);
+
+ const std::string& getElementOutlineColor() const;
+ void setElementOutlineColor(const std::string& sColor);
+
+ const UTF8String& getMediaDir() const;
+ void setMediaDir(const UTF8String& mediaDir);
+
+ void getElementsByPos(const DPoint& pos, std::vector<NodeWeakPtr>& pElements);
+ virtual void preRender();
+ virtual void render(const DRect& rect);
+ virtual void renderOutlines(const VertexArrayPtr& pVA, Pixel32 color);
+
+ virtual std::string getEffectiveMediaDir();
+ virtual void checkReload();
+
+ virtual std::string dump(int indent = 0);
+ IntPoint getMediaSize();
+
+ private:
+ bool isChildTypeAllowed(const std::string& sType);
+
+ UTF8String m_sMediaDir;
+ bool m_bCrop;
+ std::string m_sElementOutlineColor;
+ Pixel32 m_ElementOutlineColor;
+
+ VertexArrayPtr m_pClipVertexes;
+
+ std::vector<NodePtr> m_Children;
+};
+
+}
+
+#endif
diff --git a/src/player/Event.cpp b/src/player/Event.cpp
new file mode 100644
index 0000000..a12d31c
--- /dev/null
+++ b/src/player/Event.cpp
@@ -0,0 +1,141 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Event.h"
+#include "IInputDevice.h"
+#include "Player.h"
+
+#include "../base/TimeSource.h"
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+int Event::s_CurCounter = 0;
+
+Event::Event(Type type, Source source, int when)
+ : m_Type(type),
+ m_Source(source),
+ m_pInputDevice()
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ if (when == -1) {
+ m_When = Player::get()->getFrameTime();
+ } else {
+ m_When = when;
+ }
+ // Make sure two events with the same timestamp are ordered correctly.
+ s_CurCounter++;
+ m_Counter = s_CurCounter;
+}
+
+Event::Event(const Event& e)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ *this = e;
+}
+
+Event::~Event()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+long long Event::getWhen() const
+{
+ return m_When;
+}
+
+Event::Type Event::getType() const
+{
+ return m_Type;
+}
+
+Event::Source Event::getSource() const
+{
+ return m_Source;
+}
+
+IInputDevicePtr Event::getInputDevice() const
+{
+ return m_pInputDevice.lock();
+}
+
+bool Event::hasInputDevice() const
+{
+ return !m_pInputDevice.expired();
+}
+
+void Event::setInputDevice(IInputDevicePtr pInputDevice)
+{
+ m_pInputDevice = pInputDevice;
+}
+
+const std::string& Event::getInputDeviceName() const
+{
+ return m_pInputDevice.lock()->getName();
+}
+
+string Event::typeStr() const
+{
+ return typeStr(m_Type);
+}
+
+string Event::typeStr(Event::Type type)
+{
+ switch(type) {
+ case KEYUP:
+ return "KEYUP";
+ case KEYDOWN:
+ return "KEYDOWN";
+ case CURSORMOTION:
+ return "CURSORMOTION";
+ case CURSORUP:
+ return "CURSORUP";
+ case CURSORDOWN:
+ return "CURSORDOWN";
+ case CURSOROVER:
+ return "CURSOROVER";
+ case CURSOROUT:
+ return "CURSOROUT";
+ case CUSTOMEVENT:
+ return "CUSTOMEVENT";
+ case RESIZE:
+ return "RESIZE";
+ case QUIT:
+ return "QUIT";
+ default:
+ return "UNKNOWN";
+ }
+
+}
+
+void Event::trace()
+{
+ string sType = typeStr();
+ AVG_TRACE(Logger::EVENTS, sType);
+}
+
+}
diff --git a/src/player/Event.h b/src/player/Event.h
new file mode 100644
index 0000000..9ac5a89
--- /dev/null
+++ b/src/player/Event.h
@@ -0,0 +1,99 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Event_H_
+#define _Event_H_
+
+#include "../api.h"
+#include <functional>
+#include <string>
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+
+#undef _POSIX_C_SOURCE
+
+namespace avg {
+
+class IInputDevice;
+typedef boost::shared_ptr<class IInputDevice> IInputDevicePtr;
+typedef boost::weak_ptr<class IInputDevice> IInputDeviceWeakPtr;
+
+class AVG_API Event {
+ public:
+ enum Type {
+ KEYUP,
+ KEYDOWN,
+ CURSORMOTION,
+ CURSORUP,
+ CURSORDOWN,
+ CURSOROVER,
+ CURSOROUT,
+ CUSTOMEVENT,
+ RESIZE,
+ QUIT
+ };
+ enum Source {MOUSE=1, TOUCH=2, TRACK=4, CUSTOM=8, NONE=16};
+
+ Event(Type type, Source source=NONE, int when=-1);
+ Event(const Event& e);
+ virtual ~Event();
+
+ long long getWhen() const;
+ Type getType() const;
+ Event::Source getSource() const;
+ IInputDevicePtr getInputDevice() const;
+ void setInputDevice(IInputDevicePtr pInputDevice);
+ bool hasInputDevice() const;
+ const std::string& getInputDeviceName() const;
+
+ std::string typeStr() const;
+ static std::string typeStr(Event::Type type);
+
+ virtual void trace();
+
+ friend struct isEventAfter;
+
+ protected:
+ Type m_Type;
+
+ private:
+ long long m_When;
+ int m_Counter;
+ Source m_Source;
+
+ IInputDeviceWeakPtr m_pInputDevice;
+ static int s_CurCounter;
+};
+
+typedef boost::shared_ptr<class Event> EventPtr;
+
+// Functor to compare two EventPtrs chronologically
+struct isEventAfter:std::binary_function<EventPtr, EventPtr, bool> {
+ bool operator()(const EventPtr & x, const EventPtr & y) const {
+ if (x->getWhen() == y->getWhen()) {
+ return x->m_Counter > y->m_Counter;
+ }
+ return x->getWhen() > y->getWhen();
+ }
+};
+
+}
+#endif //_Event_H_
diff --git a/src/player/EventDispatcher.cpp b/src/player/EventDispatcher.cpp
new file mode 100644
index 0000000..f63c42a
--- /dev/null
+++ b/src/player/EventDispatcher.cpp
@@ -0,0 +1,159 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "EventDispatcher.h"
+#include "Event.h"
+#include "Player.h"
+#include "Contact.h"
+#include "CursorEvent.h"
+
+#include "../base/Exception.h"
+
+#include <string>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+EventDispatcher::EventDispatcher(Player* pPlayer)
+ : m_pPlayer(pPlayer),
+ m_NumMouseButtonsDown(0)
+{
+}
+
+EventDispatcher::~EventDispatcher()
+{
+}
+
+void EventDispatcher::dispatch()
+{
+ vector<EventPtr> events;
+
+ for (unsigned int i = 0; i < m_InputDevices.size(); ++i) {
+ IInputDevicePtr pCurInputDevice = m_InputDevices[i];
+
+ vector<EventPtr> curEvents = pCurInputDevice->pollEvents();
+ vector<EventPtr>::iterator eventIt = curEvents.begin();
+ events.insert(events.end(), curEvents.begin(), curEvents.end());
+
+ for ( ; eventIt != curEvents.end(); eventIt++) {
+ (*eventIt)->setInputDevice(pCurInputDevice);
+ }
+ }
+
+ vector<EventPtr>::iterator it;
+ for (it = events.begin(); it != events.end(); ++it) {
+ EventPtr pEvent = *it;
+// cerr << " " << pEvent->typeStr() << ", " << pEvent->getSource() << endl;
+ testAddContact(pEvent);
+ handleEvent(*it);
+ testRemoveContact(pEvent);
+ }
+}
+
+void EventDispatcher::addInputDevice(IInputDevicePtr pInputDevice)
+{
+ m_InputDevices.push_back(pInputDevice);
+}
+
+void EventDispatcher::sendEvent(EventPtr pEvent)
+{
+ handleEvent(pEvent);
+}
+
+ContactPtr EventDispatcher::getContact(int id)
+{
+ std::map<int, ContactPtr>::iterator it = m_ContactMap.find(id);
+ if (it == m_ContactMap.end()) {
+ return ContactPtr();
+ } else {
+ return it->second;
+ }
+}
+
+void EventDispatcher::handleEvent(EventPtr pEvent)
+{
+ m_pPlayer->handleEvent(pEvent);
+}
+
+void EventDispatcher::testAddContact(EventPtr pEvent)
+{
+ ContactPtr pContact;
+ CursorEventPtr pCursorEvent = dynamic_pointer_cast<CursorEvent>(pEvent);
+ if (pCursorEvent) {
+ switch (pCursorEvent->getType()) {
+ case Event::CURSORDOWN:
+ if (pCursorEvent->getSource() == Event::MOUSE) {
+ m_NumMouseButtonsDown++;
+ if (m_NumMouseButtonsDown == 1) {
+ AVG_ASSERT(!getContact(MOUSECURSORID));
+ pContact = ContactPtr(new Contact(pCursorEvent));
+ m_ContactMap[MOUSECURSORID] = pContact;
+ }
+ } else {
+ pContact = ContactPtr(new Contact(pCursorEvent));
+ m_ContactMap[pCursorEvent->getCursorID()] = pContact;
+ }
+ break;
+ case Event::CURSORMOTION:
+ case Event::CURSORUP: {
+ pContact = getContact(pCursorEvent->getCursorID());
+ AVG_ASSERT(pContact || (
+ pCursorEvent->getSource() == Event::MOUSE &&
+ m_NumMouseButtonsDown == 0));
+ if (pContact) {
+ pContact->addEvent(pCursorEvent);
+ }
+ }
+ break;
+ case Event::CUSTOMEVENT:
+ break;
+ default:
+ cerr << pCursorEvent->typeStr() << endl;
+ AVG_ASSERT(false);
+ break;
+ }
+ if (pContact) {
+ pCursorEvent->setContact(pContact);
+ }
+ }
+}
+
+void EventDispatcher::testRemoveContact(EventPtr pEvent)
+{
+ if (pEvent->getType() == Event::CURSORUP) {
+ if (pEvent->getSource() == Event::MOUSE) {
+ AVG_ASSERT(m_NumMouseButtonsDown > 0);
+ m_NumMouseButtonsDown--;
+ if (m_NumMouseButtonsDown == 0) {
+ int rc = m_ContactMap.erase(MOUSECURSORID);
+ AVG_ASSERT(rc == 1);
+ }
+ } else {
+ int rc = m_ContactMap.erase(
+ dynamic_pointer_cast<CursorEvent>(pEvent)->getCursorID());
+ AVG_ASSERT(rc == 1);
+ }
+ }
+}
+
+}
diff --git a/src/player/EventDispatcher.h b/src/player/EventDispatcher.h
new file mode 100644
index 0000000..51da86e
--- /dev/null
+++ b/src/player/EventDispatcher.h
@@ -0,0 +1,65 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _EventDispatcher_h_
+#define _EventDispatcher_h_
+
+#include "../api.h"
+#include "IInputDevice.h"
+
+#include <vector>
+#include <map>
+
+namespace avg {
+
+class Event;
+typedef boost::shared_ptr<class Event> EventPtr;
+class Contact;
+typedef boost::shared_ptr<class Contact> ContactPtr;
+class Player;
+
+class AVG_API EventDispatcher {
+ public:
+ EventDispatcher(Player* pPlayer);
+ virtual ~EventDispatcher();
+ void dispatch();
+
+ void addInputDevice(IInputDevicePtr pInputDevice);
+
+ void sendEvent(EventPtr pEvent);
+ ContactPtr getContact(int id);
+
+ private:
+ void handleEvent(EventPtr pEvent);
+ void testAddContact(EventPtr pEvent);
+ void testRemoveContact(EventPtr pEvent);
+
+ std::vector<IInputDevicePtr> m_InputDevices;
+ Player* m_pPlayer;
+ std::map<int, ContactPtr> m_ContactMap;
+ int m_NumMouseButtonsDown;
+};
+typedef boost::shared_ptr<EventDispatcher> EventDispatcherPtr;
+
+}
+
+#endif
+
diff --git a/src/player/FXNode.cpp b/src/player/FXNode.cpp
new file mode 100644
index 0000000..c0483e5
--- /dev/null
+++ b/src/player/FXNode.cpp
@@ -0,0 +1,108 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FXNode.h"
+#include "Player.h"
+
+#include "../base/ObjectCounter.h"
+#include "../graphics/GLContext.h"
+
+namespace avg {
+
+using namespace std;
+
+FXNode::FXNode()
+ : m_Size(0, 0),
+ m_bDirty(true)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+FXNode::~FXNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void FXNode::connect()
+{
+ if (m_Size != IntPoint(0,0)) {
+ m_pFilter = createFilter(m_Size);
+ }
+}
+
+void FXNode::disconnect()
+{
+ m_pFilter = GPUFilterPtr();
+}
+
+void FXNode::setSize(const IntPoint& newSize)
+{
+ if (newSize != m_Size) {
+ m_Size = newSize;
+ if (m_pFilter) {
+ m_pFilter = createFilter(m_Size);
+ }
+ }
+}
+
+void FXNode::apply(GLTexturePtr pSrcTex)
+{
+ // blt overwrites everything, so no glClear necessary before.
+ GLContext::getCurrent()->setBlendMode(GLContext::BLEND_COPY);
+ m_pFilter->apply(pSrcTex);
+}
+
+GLTexturePtr FXNode::getTex()
+{
+ return m_pFilter->getDestTex();
+}
+
+BitmapPtr FXNode::getImage()
+{
+ return m_pFilter->getImage();
+}
+
+DRect FXNode::getRelDestRect() const
+{
+ return m_pFilter->getRelDestRect();
+}
+
+bool FXNode::isDirty() const
+{
+ return m_bDirty;
+}
+
+void FXNode::resetDirty()
+{
+ m_bDirty = false;
+}
+
+FBOPtr FXNode::getFBO()
+{
+ return m_pFilter->getFBO();
+}
+
+void FXNode::setDirty()
+{
+ m_bDirty = true;
+}
+
+}
diff --git a/src/player/FXNode.h b/src/player/FXNode.h
new file mode 100644
index 0000000..e602a9a
--- /dev/null
+++ b/src/player/FXNode.h
@@ -0,0 +1,69 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FXNode_H_
+#define _FXNode_H_
+
+#include "../api.h"
+
+#include "../graphics/GPUFilter.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API FXNode {
+public:
+ FXNode();
+ virtual ~FXNode();
+
+ virtual void connect();
+ virtual void disconnect();
+ virtual void setSize(const IntPoint& newSize);
+
+ virtual void apply(GLTexturePtr pSrcTex);
+
+ GLTexturePtr getTex();
+ BitmapPtr getImage();
+ DRect getRelDestRect() const;
+
+ bool isDirty() const;
+ void resetDirty();
+
+protected:
+ FBOPtr getFBO();
+ void setDirty();
+
+private:
+ virtual GPUFilterPtr createFilter(const IntPoint& size) = 0;
+
+ IntPoint m_Size;
+ GPUFilterPtr m_pFilter;
+
+ bool m_bDirty;
+};
+
+typedef boost::shared_ptr<FXNode> FXNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/FilledVectorNode.cpp b/src/player/FilledVectorNode.cpp
new file mode 100644
index 0000000..69d833b
--- /dev/null
+++ b/src/player/FilledVectorNode.cpp
@@ -0,0 +1,214 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FilledVectorNode.h"
+
+#include "NodeDefinition.h"
+#include "Image.h"
+#include "DivNode.h"
+
+#include "../base/ScopeTimer.h"
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+NodeDefinition FilledVectorNode::createDefinition()
+{
+ return NodeDefinition("filledvector")
+ .extendDefinition(VectorNode::createDefinition())
+ .addArg(Arg<UTF8String>("filltexhref", "", false,
+ offsetof(FilledVectorNode, m_FillTexHRef)))
+ .addArg(Arg<double>("fillopacity", 0, false,
+ offsetof(FilledVectorNode, m_FillOpacity)))
+ .addArg(Arg<string>("fillcolor", "FFFFFF", false,
+ offsetof(FilledVectorNode, m_sFillColorName)))
+ .addArg(Arg<DPoint>("filltexcoord1", DPoint(0,0), false,
+ offsetof(FilledVectorNode, m_FillTexCoord1)))
+ .addArg(Arg<DPoint>("filltexcoord2", DPoint(1,1), false,
+ offsetof(FilledVectorNode, m_FillTexCoord2)))
+ ;
+}
+
+FilledVectorNode::FilledVectorNode(const ArgList& args)
+ : VectorNode(args),
+ m_pFillShape(new Shape(MaterialInfo(GL_REPEAT, GL_REPEAT, false)))
+{
+ m_FillTexHRef = args.getArgVal<UTF8String>("filltexhref");
+ setFillTexHRef(m_FillTexHRef);
+ m_sFillColorName = args.getArgVal<string>("fillcolor");
+ m_FillColor = colorStringToColor(m_sFillColorName);
+}
+
+FilledVectorNode::~FilledVectorNode()
+{
+}
+
+void FilledVectorNode::connectDisplay()
+{
+ VectorNode::connectDisplay();
+ m_FillColor = colorStringToColor(m_sFillColorName);
+ m_pFillShape->moveToGPU();
+ m_OldOpacity = -1;
+}
+
+void FilledVectorNode::disconnect(bool bKill)
+{
+ if (bKill) {
+ m_pFillShape->discard();
+ } else {
+ m_pFillShape->moveToCPU();
+ }
+ VectorNode::disconnect(bKill);
+}
+
+void FilledVectorNode::checkReload()
+{
+ Node::checkReload(m_FillTexHRef, m_pFillShape->getImage());
+ if (getState() == Node::NS_CANRENDER) {
+ m_pFillShape->moveToGPU();
+ setDrawNeeded();
+ }
+ VectorNode::checkReload();
+}
+
+const UTF8String& FilledVectorNode::getFillTexHRef() const
+{
+ return m_FillTexHRef;
+}
+
+void FilledVectorNode::setFillTexHRef(const UTF8String& href)
+{
+ m_FillTexHRef = href;
+ checkReload();
+ setDrawNeeded();
+}
+
+void FilledVectorNode::setFillBitmap(BitmapPtr pBmp)
+{
+ m_FillTexHRef = "";
+ m_pFillShape->setBitmap(pBmp);
+ setDrawNeeded();
+}
+
+const DPoint& FilledVectorNode::getFillTexCoord1() const
+{
+ return m_FillTexCoord1;
+}
+
+void FilledVectorNode::setFillTexCoord1(const DPoint& pt)
+{
+ m_FillTexCoord1 = pt;
+ setDrawNeeded();
+}
+
+const DPoint& FilledVectorNode::getFillTexCoord2() const
+{
+ return m_FillTexCoord2;
+}
+
+void FilledVectorNode::setFillTexCoord2(const DPoint& pt)
+{
+ m_FillTexCoord2 = pt;
+ setDrawNeeded();
+}
+
+double FilledVectorNode::getFillOpacity() const
+{
+ return m_FillOpacity;
+}
+
+void FilledVectorNode::setFillOpacity(double opacity)
+{
+ m_FillOpacity = opacity;
+ setDrawNeeded();
+}
+
+void FilledVectorNode::preRender()
+{
+ Node::preRender();
+ double curOpacity = getParent()->getEffectiveOpacity()*m_FillOpacity;
+ VertexArrayPtr pFillVA;
+ pFillVA = m_pFillShape->getVertexArray();
+ if (isDrawNeeded() || curOpacity != m_OldOpacity) {
+ pFillVA->reset();
+ Pixel32 color = getFillColorVal();
+ color.setA((unsigned char)(curOpacity*255));
+ calcFillVertexes(pFillVA, color);
+ pFillVA->update();
+ m_OldOpacity = curOpacity;
+ }
+ VectorNode::preRender();
+}
+
+static ProfilingZoneID RenderProfilingZone("FilledVectorNode::render");
+
+void FilledVectorNode::render(const DRect& rect)
+{
+ ScopeTimer Timer(RenderProfilingZone);
+ double curOpacity = getParent()->getEffectiveOpacity()*m_FillOpacity;
+ if (curOpacity > 0.01) {
+ glColor4d(1.0, 1.0, 1.0, curOpacity);
+ m_pFillShape->draw();
+ }
+ VectorNode::render(rect);
+}
+
+void FilledVectorNode::setFillColor(const string& sColor)
+{
+ if (m_sFillColorName != sColor) {
+ m_sFillColorName = sColor;
+ m_FillColor = colorStringToColor(m_sFillColorName);
+ setDrawNeeded();
+ }
+}
+
+const string& FilledVectorNode::getFillColor() const
+{
+ return m_sFillColorName;
+}
+
+Pixel32 FilledVectorNode::getFillColorVal() const
+{
+ return m_FillColor;
+}
+
+DPoint FilledVectorNode::calcFillTexCoord(const DPoint& pt, const DPoint& minPt,
+ const DPoint& maxPt)
+{
+ DPoint texPt;
+ texPt.x = (m_FillTexCoord2.x-m_FillTexCoord1.x)*(pt.x-minPt.x)/(maxPt.x-minPt.x)
+ +m_FillTexCoord1.x;
+ texPt.y = (m_FillTexCoord2.y-m_FillTexCoord1.y)*(pt.y-minPt.y)/(maxPt.y-minPt.y)
+ +m_FillTexCoord1.y;
+ return texPt;
+}
+
+bool FilledVectorNode::isVisible() const
+{
+ return getActive() && (getEffectiveOpacity() > 0.01 ||
+ getParent()->getEffectiveOpacity()*m_FillOpacity > 0.01);
+}
+
+}
diff --git a/src/player/FilledVectorNode.h b/src/player/FilledVectorNode.h
new file mode 100644
index 0000000..ff8451d
--- /dev/null
+++ b/src/player/FilledVectorNode.h
@@ -0,0 +1,86 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FilledVectorNode_H_
+#define _FilledVectorNode_H_
+
+#include "../api.h"
+#include "VectorNode.h"
+
+#include "../base/UTF8String.h"
+
+namespace avg {
+
+class AVG_API FilledVectorNode : public VectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ FilledVectorNode(const ArgList& args);
+ virtual ~FilledVectorNode();
+ virtual void connectDisplay();
+ virtual void disconnect(bool bKill);
+ virtual void checkReload();
+
+ const UTF8String& getFillTexHRef() const;
+ void setFillTexHRef(const UTF8String& href);
+ void setFillBitmap(BitmapPtr pBmp);
+
+ const DPoint& getFillTexCoord1() const;
+ void setFillTexCoord1(const DPoint& pt);
+ const DPoint& getFillTexCoord2() const;
+ void setFillTexCoord2(const DPoint& pt);
+
+ void setFillColor(const std::string& sColor);
+ const std::string& getFillColor() const;
+
+ double getFillOpacity() const;
+ void setFillOpacity(double opacity);
+
+ virtual void preRender();
+ virtual void render(const DRect& rect);
+
+ virtual void calcFillVertexes(VertexArrayPtr& pVertexArray, Pixel32 color) = 0;
+
+ protected:
+ Pixel32 getFillColorVal() const;
+ DPoint calcFillTexCoord(const DPoint& pt, const DPoint& minPt,
+ const DPoint& maxPt);
+ virtual bool isVisible() const;
+
+ private:
+ double m_OldOpacity;
+
+ UTF8String m_FillTexHRef;
+ DPoint m_FillTexCoord1;
+ DPoint m_FillTexCoord2;
+ ShapePtr m_pFillShape;
+ double m_FillOpacity;
+ std::string m_sFillColorName;
+ Pixel32 m_FillColor;
+};
+
+typedef boost::shared_ptr<FilledVectorNode> FilledVectorNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/HueSatFXNode.cpp b/src/player/HueSatFXNode.cpp
new file mode 100644
index 0000000..c65e9fa
--- /dev/null
+++ b/src/player/HueSatFXNode.cpp
@@ -0,0 +1,157 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#include "HueSatFXNode.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Logger.h"
+#include "../graphics/ShaderRegistry.h"
+
+#include<sstream>
+
+using namespace std;
+
+namespace avg {
+
+HueSatFXNode::HueSatFXNode(int hue, int saturation, int lightness,
+ bool tint):
+ FXNode(),
+ m_fHue(hue),
+ m_fLightnessOffset(lightness),
+ m_fSaturation(saturation),
+ m_bColorize(tint)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+HueSatFXNode::~HueSatFXNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void HueSatFXNode::disconnect()
+{
+ filterPtr = GPUHueSatFilterPtr();
+ FXNode::disconnect();
+}
+
+int HueSatFXNode::getHue()
+{
+ if (m_bColorize) {
+ if (m_fHue < 0) {
+ return 360 + m_fHue;
+ }
+ return m_fHue;
+ }
+
+ if (m_fHue/180.0 > 1.0) {
+ return -360+m_fHue;
+ } else if (m_fHue/180.0 < -1.0) {
+ return 360+m_fHue;
+ }
+ return m_fHue;
+}
+
+int HueSatFXNode::getSaturation()
+{
+ return m_fSaturation;
+}
+
+int HueSatFXNode::getLightnessOffset()
+{
+ return m_fLightnessOffset;
+}
+
+bool HueSatFXNode::isColorizing()
+{
+ return m_bColorize;
+}
+
+void HueSatFXNode::setHue(int hue)
+{
+ m_fHue = hue % 360;
+ setFilterParams();
+}
+
+void HueSatFXNode::setSaturation(int saturation)
+{
+ if(m_bColorize){
+ m_fSaturation = clamp(saturation, 0, 100);
+ }else{
+ m_fSaturation = clamp(saturation, -100, 100);
+ }
+ setFilterParams();
+}
+
+void HueSatFXNode::setLightnessOffset(int lightnessOffset)
+{
+ m_fLightnessOffset= clamp(lightnessOffset, -100, 100);
+ setFilterParams();
+}
+
+void HueSatFXNode::setColorizing(bool colorize)
+{
+ m_bColorize = colorize;
+ m_fHue = 0;
+ m_fLightnessOffset = 0;
+ m_fSaturation = m_bColorize ? 50 : 0;
+ setFilterParams();
+}
+
+GPUFilterPtr HueSatFXNode::createFilter(const IntPoint& size)
+{
+ filterPtr = GPUHueSatFilterPtr(new GPUHueSatFilter(size, B8G8R8A8,
+ false));
+ setFilterParams();
+ return filterPtr;
+}
+
+void HueSatFXNode::setFilterParams()
+{
+ if (filterPtr) {
+ filterPtr->setParams(m_fHue, m_fSaturation, m_fLightnessOffset, m_bColorize);
+ setDirty();
+ }
+}
+
+std::string HueSatFXNode::toString()
+{
+ stringstream s;
+ s << "HueSatFXNode( Hue: " << m_fHue << ", Saturation: " << m_fSaturation <<
+ ", Lightness: " << m_fLightnessOffset << ", Colorize: " << m_bColorize <<
+ " )";
+ return s.str();
+}
+
+int HueSatFXNode::clamp(int val, int min, int max)
+{
+ int result = val;
+ if(val < min){
+ result = min;
+ }else if(val > max){
+ result = max;
+ }
+ return result;
+}
+
+}
+
diff --git a/src/player/HueSatFXNode.h b/src/player/HueSatFXNode.h
new file mode 100644
index 0000000..780c271
--- /dev/null
+++ b/src/player/HueSatFXNode.h
@@ -0,0 +1,73 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _HueSatFXNode_H_
+#define _HueSatFXNode_H_
+
+#include "../api.h"
+
+#include "FXNode.h"
+#include "../graphics/GPUHueSatFilter.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/python.hpp>
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+class AVG_API HueSatFXNode : public FXNode {
+public:
+ HueSatFXNode(int hue=0, int saturation=0, int lightness=0,
+ bool tint=false);
+ virtual ~HueSatFXNode();
+ virtual void disconnect();
+
+ void setHue(int hue);
+ void setSaturation(int saturation);
+ void setLightnessOffset(int lightnessOffset);
+ void setColorizing(bool colorize);
+ int getHue();
+ int getSaturation();
+ int getLightnessOffset();
+ bool isColorizing();
+
+ std::string toString();
+
+private:
+ virtual GPUFilterPtr createFilter(const IntPoint& size);
+ void setFilterParams();
+ int clamp(int val, int min, int max);
+
+ GPUHueSatFilterPtr filterPtr;
+
+ int m_fHue;
+ int m_fLightnessOffset;
+ int m_fSaturation;
+ bool m_bColorize;
+};
+
+typedef boost::shared_ptr<HueSatFXNode> HueSatFXNodePtr;
+} //end namespace avg
+
+#endif
+
diff --git a/src/player/IInputDevice.h b/src/player/IInputDevice.h
new file mode 100644
index 0000000..709809d
--- /dev/null
+++ b/src/player/IInputDevice.h
@@ -0,0 +1,82 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _IInputDevice_H_
+#define _IInputDevice_H_
+
+#include "../api.h"
+#include "DivNode.h"
+#include <boost/shared_ptr.hpp>
+#include <vector>
+#include <string>
+
+#define EXTRACT_INPUTDEVICE_CLASSNAME( classType ) (#classType)
+
+namespace avg {
+
+class Event;
+typedef boost::shared_ptr<Event> EventPtr;
+typedef boost::shared_ptr<DivNode> DivNodePtr;
+
+class AVG_API IInputDevice {
+ public:
+ IInputDevice(const std::string& name,
+ const DivNodePtr& pEventReceiverNode=DivNodePtr())
+ : m_sName(name),
+ m_pEventReceiverNode(pEventReceiverNode)
+ {
+ }
+
+ virtual ~IInputDevice()
+ {
+ };
+
+ virtual void start()
+ {
+ };
+
+ virtual std::vector<EventPtr> pollEvents() = 0;
+
+ const DivNodePtr& getEventReceiverNode() const
+ {
+ return m_pEventReceiverNode;
+ }
+
+ void setEventReceiverNode(const DivNodePtr pEventReceiverNode)
+ {
+ m_pEventReceiverNode = pEventReceiverNode;
+ }
+
+ const std::string& getName() const
+ {
+ return m_sName;
+ }
+
+ private:
+ std::string m_sName;
+ DivNodePtr m_pEventReceiverNode;
+};
+
+typedef boost::shared_ptr<IInputDevice> IInputDevicePtr;
+
+}
+
+#endif
diff --git a/src/player/Image.cpp b/src/player/Image.cpp
new file mode 100644
index 0000000..35e6801
--- /dev/null
+++ b/src/player/Image.cpp
@@ -0,0 +1,408 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Image.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/Filterfliprgb.h"
+
+#include "OGLSurface.h"
+#include "OffscreenCanvas.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+Image::Image(OGLSurface * pSurface, const MaterialInfo& material)
+ : m_sFilename(""),
+ m_pSurface(pSurface),
+ m_State(CPU),
+ m_Source(NONE),
+ m_Material(material)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ assertValid();
+}
+
+Image::~Image()
+{
+ if (m_State == GPU && m_Source != NONE) {
+ m_pSurface->destroy();
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void Image::moveToGPU()
+{
+ assertValid();
+ if (m_State == CPU) {
+ switch (m_Source) {
+ case FILE:
+ case BITMAP:
+ setupSurface();
+ break;
+ case SCENE:
+ m_pSurface->create(B8G8R8X8, m_pCanvas->getTex());
+ break;
+ case NONE:
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ m_State = GPU;
+ }
+ assertValid();
+}
+
+void Image::moveToCPU()
+{
+ assertValid();
+ if (m_State == GPU) {
+ switch (m_Source) {
+ case FILE:
+ case BITMAP:
+ m_pBmp = m_pSurface->getTex()->moveTextureToBmp();
+ break;
+ case SCENE:
+ break;
+ case NONE:
+ break;
+ default:
+ AVG_ASSERT(false);
+ return;
+ }
+ m_State = CPU;
+ m_pSurface->destroy();
+ }
+ assertValid();
+}
+
+void Image::discard()
+{
+ assertValid();
+ setEmpty();
+ m_State = CPU;
+ assertValid();
+}
+
+void Image::setEmpty()
+{
+ assertValid();
+ if (m_State == GPU) {
+ m_pSurface->destroy();
+ }
+ changeSource(NONE);
+ assertValid();
+}
+
+void Image::setFilename(const std::string& sFilename, TextureCompression comp)
+{
+ assertValid();
+ AVG_TRACE(Logger::MEMORY, "Loading " << sFilename);
+ BitmapPtr pBmp(new Bitmap(sFilename));
+ if (comp == TEXTURECOMPRESSION_B5G6R5 && pBmp->hasAlpha()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "B5G6R5-compressed textures with an alpha channel are not supported.");
+ }
+ changeSource(FILE);
+ m_pBmp = pBmp;
+
+ m_sFilename = sFilename;
+
+ switch (comp) {
+ case TEXTURECOMPRESSION_B5G6R5:
+ m_pBmp = BitmapPtr(new Bitmap(pBmp->getSize(), B5G6R5, sFilename));
+ m_pBmp->copyPixels(*pBmp);
+ break;
+ case TEXTURECOMPRESSION_NONE:
+ break;
+ default:
+ assert(false);
+ }
+
+ if (m_State == GPU) {
+ m_pSurface->destroy();
+ setupSurface();
+ }
+ assertValid();
+}
+
+void Image::setBitmap(BitmapPtr pBmp, TextureCompression comp)
+{
+ assertValid();
+ if (!pBmp) {
+ throw Exception(AVG_ERR_UNSUPPORTED, "setBitmap(): bitmap must not be None!");
+ }
+ if (comp == TEXTURECOMPRESSION_B5G6R5 && pBmp->hasAlpha()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "B5G6R5-compressed textures with an alpha channel are not supported.");
+ }
+ bool bSourceChanged = changeSource(BITMAP);
+ PixelFormat pf;
+ switch (comp) {
+ case TEXTURECOMPRESSION_NONE:
+ pf = calcSurfacePF(*pBmp);
+ break;
+ case TEXTURECOMPRESSION_B5G6R5:
+ pf = B5G6R5;
+ break;
+ default:
+ assert(false);
+ }
+ if (m_State == GPU) {
+ GLTexturePtr pTex = m_pSurface->getTex();
+ if (bSourceChanged || m_pSurface->getSize() != pBmp->getSize() ||
+ m_pSurface->getPixelFormat() != pf)
+ {
+ pTex = GLTexturePtr(new GLTexture(pBmp->getSize(), pf,
+ m_Material.getUseMipmaps(), m_Material.getWrapSMode(),
+ m_Material.getWrapTMode()));
+ m_pSurface->create(pf, pTex);
+ }
+ TextureMoverPtr pMover = TextureMover::create(pBmp->getSize(), pf,
+ GL_STATIC_DRAW);
+ BitmapPtr pMoverBmp = pMover->lock();
+ pMoverBmp->copyPixels(*pBmp);
+ pMover->unlock();
+ pMover->moveToTexture(*pTex);
+ m_pBmp = BitmapPtr();
+ } else {
+ m_pBmp = BitmapPtr(new Bitmap(pBmp->getSize(), pf, ""));
+ m_pBmp->copyPixels(*pBmp);
+ }
+ assertValid();
+}
+
+void Image::setCanvas(OffscreenCanvasPtr pCanvas)
+{
+ assertValid();
+ if (m_Source == SCENE && pCanvas == m_pCanvas) {
+ return;
+ }
+ changeSource(SCENE);
+ m_pCanvas = pCanvas;
+ if (m_State == GPU) {
+ m_pSurface->create(B8G8R8X8, m_pCanvas->getTex());
+ }
+ assertValid();
+}
+
+OffscreenCanvasPtr Image::getCanvas() const
+{
+ return m_pCanvas;
+}
+
+const string& Image::getFilename() const
+{
+ return m_sFilename;
+}
+
+BitmapPtr Image::getBitmap()
+{
+ if (m_Source == NONE) {
+ return BitmapPtr();
+ } else {
+ switch (m_State) {
+ case CPU:
+ if (m_Source == SCENE) {
+ return BitmapPtr();
+ } else {
+ return BitmapPtr(new Bitmap(*m_pBmp));
+ }
+ case GPU:
+ return m_pSurface->getTex()->moveTextureToBmp();
+ default:
+ AVG_ASSERT(false);
+ return BitmapPtr();
+ }
+ }
+}
+
+IntPoint Image::getSize()
+{
+ if (m_Source == NONE) {
+ return IntPoint(0,0);
+ } else {
+ switch (m_State) {
+ case CPU:
+ if (m_Source == SCENE) {
+ return m_pCanvas->getSize();
+ } else {
+ return m_pBmp->getSize();
+ }
+ case GPU:
+ return m_pSurface->getSize();
+ default:
+ AVG_ASSERT(false);
+ return IntPoint(0,0);
+ }
+ }
+}
+
+PixelFormat Image::getPixelFormat()
+{
+ if (m_Source == NONE) {
+ return B8G8R8X8;
+ } else {
+ switch (m_State) {
+ case CPU:
+ if (m_Source == SCENE) {
+ return B8G8R8X8;
+ } else {
+ return m_pBmp->getPixelFormat();
+ }
+ case GPU:
+ return m_pSurface->getPixelFormat();
+ default:
+ AVG_ASSERT(false);
+ return B8G8R8X8;
+ }
+ }
+}
+
+OGLSurface* Image::getSurface()
+{
+ AVG_ASSERT(m_State == GPU);
+ return m_pSurface;
+}
+
+Image::State Image::getState()
+{
+ return m_State;
+}
+
+Image::Source Image::getSource()
+{
+ return m_Source;
+}
+
+Image::TextureCompression Image::string2compression(const string& s)
+{
+ if (s == "none") {
+ return Image::TEXTURECOMPRESSION_NONE;
+ } else if (s == "B5G6R5") {
+ return Image::TEXTURECOMPRESSION_B5G6R5;
+ } else {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "Image compression "+s+" not supported."));
+ }
+}
+
+string Image::compression2String(TextureCompression compression)
+{
+ switch(compression) {
+ case Image::TEXTURECOMPRESSION_NONE:
+ return "none";
+ case Image::TEXTURECOMPRESSION_B5G6R5:
+ return "B5G6R5";
+ default:
+ AVG_ASSERT(false);
+ return 0;
+ }
+}
+
+void Image::setupSurface()
+{
+ PixelFormat pf = calcSurfacePF(*m_pBmp);
+ GLTexturePtr pTex(new GLTexture(m_pBmp->getSize(), pf, m_Material.getUseMipmaps(),
+ m_Material.getWrapSMode(), m_Material.getWrapTMode()));
+ m_pSurface->create(pf, pTex);
+ TextureMoverPtr pMover = TextureMover::create(m_pBmp->getSize(), pf, GL_STATIC_DRAW);
+ BitmapPtr pMoverBmp = pMover->lock();
+ pMoverBmp->copyPixels(*m_pBmp);
+ pMover->unlock();
+ pMover->moveToTexture(*pTex);
+ m_pBmp = BitmapPtr();
+}
+
+PixelFormat Image::calcSurfacePF(const Bitmap& bmp)
+{
+ PixelFormat pf;
+ pf = B8G8R8X8;
+ if (bmp.hasAlpha()) {
+ pf = B8G8R8A8;
+ }
+ if (bmp.getPixelFormat() == I8) {
+ pf = I8;
+ }
+ if (bmp.getPixelFormat() == B5G6R5) {
+ pf = B5G6R5;
+ }
+ return pf;
+}
+
+bool Image::changeSource(Source newSource)
+{
+ if (newSource != m_Source) {
+ switch (m_Source) {
+ case NONE:
+ break;
+ case FILE:
+ case BITMAP:
+ if (m_State == CPU) {
+ m_pBmp = BitmapPtr();
+ }
+ m_sFilename = "";
+ break;
+ case SCENE:
+ m_pCanvas = OffscreenCanvasPtr();
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ m_Source = newSource;
+ return true;
+ } else {
+ return false;
+ }
+}
+
+void Image::assertValid() const
+{
+ AVG_ASSERT(m_pSurface);
+ AVG_ASSERT((m_Source == FILE) == (m_sFilename != ""));
+ AVG_ASSERT((m_Source == SCENE) == bool(m_pCanvas));
+ switch (m_State) {
+ case CPU:
+ AVG_ASSERT((m_Source == FILE || m_Source == BITMAP) ==
+ bool(m_pBmp));
+ AVG_ASSERT(!(m_pSurface->isCreated()));
+ break;
+ case GPU:
+ AVG_ASSERT(!m_pBmp);
+ if (m_Source != NONE) {
+ AVG_ASSERT(m_pSurface->isCreated());
+ } else {
+ AVG_ASSERT(!m_pSurface->isCreated());
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+}
+
+}
diff --git a/src/player/Image.h b/src/player/Image.h
new file mode 100644
index 0000000..f7be873
--- /dev/null
+++ b/src/player/Image.h
@@ -0,0 +1,98 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Image_H_
+#define _Image_H_
+
+#include "../api.h"
+
+#include "MaterialInfo.h"
+
+#include "../base/Point.h"
+#include "../graphics/Bitmap.h"
+
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+namespace avg {
+
+class OGLSurface;
+class OffscreenCanvas;
+typedef boost::shared_ptr<OffscreenCanvas> OffscreenCanvasPtr;
+
+class AVG_API Image
+{
+ public:
+ enum State {CPU, GPU};
+ enum Source {NONE, FILE, BITMAP, SCENE};
+ enum TextureCompression {
+ TEXTURECOMPRESSION_NONE,
+ TEXTURECOMPRESSION_B5G6R5
+ };
+
+ Image(OGLSurface * pSurface, const MaterialInfo& material);
+ virtual ~Image();
+
+ virtual void moveToGPU();
+ virtual void moveToCPU();
+
+ void discard();
+ void setEmpty();
+ void setFilename(const std::string& sFilename,
+ TextureCompression comp = TEXTURECOMPRESSION_NONE);
+ void setBitmap(BitmapPtr pBmp,
+ TextureCompression comp = TEXTURECOMPRESSION_NONE);
+ void setCanvas(OffscreenCanvasPtr pCanvas);
+ OffscreenCanvasPtr getCanvas() const;
+ const std::string& getFilename() const;
+
+ BitmapPtr getBitmap();
+ IntPoint getSize();
+ PixelFormat getPixelFormat();
+ OGLSurface* getSurface();
+ State getState();
+ Source getSource();
+
+ static TextureCompression string2compression(const std::string& s);
+ static std::string compression2String(TextureCompression compression);
+
+ private:
+ void setupSurface();
+ PixelFormat calcSurfacePF(const Bitmap& Bmp);
+ bool changeSource(Source newSource);
+ void assertValid() const;
+
+ std::string m_sFilename;
+ BitmapPtr m_pBmp;
+ OGLSurface * m_pSurface;
+ OffscreenCanvasPtr m_pCanvas;
+
+ State m_State;
+ Source m_Source;
+ MaterialInfo m_Material;
+};
+
+typedef boost::shared_ptr<Image> ImagePtr;
+
+}
+
+#endif
+
diff --git a/src/player/ImageNode.cpp b/src/player/ImageNode.cpp
new file mode 100644
index 0000000..d584ef4
--- /dev/null
+++ b/src/player/ImageNode.cpp
@@ -0,0 +1,230 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ImageNode.h"
+
+#include "NodeDefinition.h"
+#include "OGLSurface.h"
+#include "Player.h"
+#include "OffscreenCanvas.h"
+
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+#include "../base/XMLHelper.h"
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/Filterfliprgb.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition ImageNode::createDefinition()
+{
+ return NodeDefinition("image", Node::buildNode<ImageNode>)
+ .extendDefinition(RasterNode::createDefinition())
+ .addArg(Arg<UTF8String>("href", "", false, offsetof(ImageNode, m_href)))
+ .addArg(Arg<string>("compression", "none"));
+}
+
+ImageNode::ImageNode(const ArgList& args)
+ : m_Compression(Image::TEXTURECOMPRESSION_NONE)
+{
+ args.setMembers(this);
+ m_pImage = ImagePtr(new Image(getSurface(), getMaterial()));
+ m_Compression = Image::string2compression(args.getArgVal<string>("compression"));
+ setHRef(m_href);
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+ImageNode::~ImageNode()
+{
+ // XXX: The following assert checks that disconnect(true) has been called.
+ // However, if connect() has been called but rendering never started,
+ // disconnect isn't called either.
+// AVG_ASSERT(!m_pImage->getCanvas());
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void ImageNode::connectDisplay()
+{
+ if (m_pImage->getSource() == Image::SCENE) {
+ checkCanvasValid(m_pImage->getCanvas());
+ }
+ getSurface()->attach();
+ m_pImage->moveToGPU();
+ RasterNode::connectDisplay();
+ if (m_pImage->getSource() == Image::SCENE) {
+ m_pImage->getCanvas()->addDependentCanvas(getCanvas());
+ }
+}
+
+void ImageNode::connect(CanvasPtr pCanvas)
+{
+ RasterNode::connect(pCanvas);
+ checkReload();
+}
+
+void ImageNode::disconnect(bool bKill)
+{
+ OffscreenCanvasPtr pCanvas = m_pImage->getCanvas();
+ if (pCanvas) {
+ pCanvas->removeDependentCanvas(getCanvas());
+ }
+ if (bKill) {
+ RasterNode::disconnect(bKill);
+ m_pImage = ImagePtr(new Image(getSurface(), getMaterial()));
+ m_href = "";
+ } else {
+ m_pImage->moveToCPU();
+ RasterNode::disconnect(bKill);
+ }
+}
+
+const UTF8String& ImageNode::getHRef() const
+{
+ return m_href;
+}
+
+void ImageNode::setHRef(const UTF8String& href)
+{
+ m_href = href;
+ if (m_pImage->getSource() == Image::SCENE && getState() == Node::NS_CANRENDER)
+ {
+ m_pImage->getCanvas()->removeDependentCanvas(getCanvas());
+ }
+ try {
+ if (href == "") {
+ m_pImage->setEmpty();
+ } else {
+ checkReload();
+ }
+ } catch (const Exception&) {
+ m_href = "";
+ m_pImage->setEmpty();
+ throw;
+ }
+}
+
+const string ImageNode::getCompression() const
+{
+ return Image::compression2String(m_Compression);
+}
+
+void ImageNode::setBitmap(BitmapPtr pBmp)
+{
+ if (m_pImage->getSource() == Image::SCENE && getState() == Node::NS_CANRENDER)
+ {
+ m_pImage->getCanvas()->removeDependentCanvas(getCanvas());
+ }
+ m_pImage->setBitmap(pBmp, m_Compression);
+ if (getState() == Node::NS_CANRENDER) {
+ bind();
+ }
+ m_href = "";
+ setViewport(-32767, -32767, -32767, -32767);
+}
+
+void ImageNode::preRender()
+{
+ Node::preRender();
+ if (isVisible()) {
+ renderFX(getSize(), Pixel32(255, 255, 255, 255), bool(m_pImage->getCanvas()));
+ }
+}
+
+static ProfilingZoneID RenderProfilingZone("ImageNode::render");
+
+void ImageNode::render(const DRect& Rect)
+{
+ ScopeTimer Timer(RenderProfilingZone);
+ if (m_pImage->getSource() != Image::NONE) {
+ blt32(getSize(), getEffectiveOpacity(), getBlendMode(),
+ bool(m_pImage->getCanvas()));
+ }
+}
+
+IntPoint ImageNode::getMediaSize()
+{
+ return m_pImage->getSize();
+}
+
+void ImageNode::checkReload()
+{
+ if (isCanvasURL(m_href)) {
+ if (m_Compression != Image::TEXTURECOMPRESSION_NONE) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Texture compression can't be used with canvas hrefs.");
+ }
+ OffscreenCanvasPtr pCanvas = Player::get()->getCanvasFromURL(m_href);
+ checkCanvasValid(pCanvas);
+ m_pImage->setCanvas(pCanvas);
+ if (getState() == NS_CANRENDER) {
+ pCanvas->addDependentCanvas(getCanvas());
+ }
+ } else {
+ Node::checkReload(m_href, m_pImage, m_Compression);
+ }
+ setViewport(-32767, -32767, -32767, -32767);
+ RasterNode::checkReload();
+}
+
+void ImageNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ if (reactsToMouseEvents()) {
+ OffscreenCanvasPtr pCanvas = m_pImage->getCanvas();
+ if (pCanvas && pCanvas->getHandleEvents()) {
+ DPoint nodeSize(getSize());
+ DPoint canvasSize(pCanvas->getSize());
+ DPoint localPos(pos.x*(canvasSize.x/nodeSize.x),
+ pos.y*(canvasSize.y/nodeSize.y));
+ pCanvas->getRootNode()->getElementsByPos(localPos, pElements);
+ } else {
+ RasterNode::getElementsByPos(pos, pElements);
+ }
+ }
+}
+
+BitmapPtr ImageNode::getBitmap()
+{
+ return m_pImage->getBitmap();
+}
+
+bool ImageNode::isCanvasURL(const std::string& sURL)
+{
+ return sURL.find("canvas:") == 0;
+}
+
+void ImageNode::checkCanvasValid(const CanvasPtr& pCanvas)
+{
+ if (pCanvas == getCanvas()) {
+ m_href = "";
+ m_pImage->setEmpty();
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Circular dependency between canvases.");
+ }
+}
+
+}
diff --git a/src/player/ImageNode.h b/src/player/ImageNode.h
new file mode 100644
index 0000000..e460c98
--- /dev/null
+++ b/src/player/ImageNode.h
@@ -0,0 +1,75 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ImageNode_H_
+#define _ImageNode_H_
+
+#include "../api.h"
+#include "RasterNode.h"
+#include "Image.h"
+
+#include "../graphics/Bitmap.h"
+#include "../base/UTF8String.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API ImageNode : public RasterNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ ImageNode(const ArgList& args);
+ virtual ~ImageNode();
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+ virtual void checkReload();
+
+ const UTF8String& getHRef() const;
+ void setHRef(const UTF8String& href);
+ const std::string getCompression() const;
+ void setBitmap(BitmapPtr pBmp);
+
+ virtual void preRender();
+ virtual void render(const DRect& Rect);
+
+ void getElementsByPos(const DPoint& pos, std::vector<NodeWeakPtr>& pElements);
+
+ virtual BitmapPtr getBitmap();
+ virtual IntPoint getMediaSize();
+
+ private:
+ bool isCanvasURL(const std::string& sURL);
+ void checkCanvasValid(const CanvasPtr& pCanvas);
+
+ UTF8String m_href;
+ Image::TextureCompression m_Compression;
+ ImagePtr m_pImage;
+};
+
+typedef boost::shared_ptr<ImageNode> ImageNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/InvertFXNode.cpp b/src/player/InvertFXNode.cpp
new file mode 100644
index 0000000..589675a
--- /dev/null
+++ b/src/player/InvertFXNode.cpp
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "InvertFXNode.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Logger.h"
+#include "../graphics/ShaderRegistry.h"
+
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+InvertFXNode::InvertFXNode():
+ FXNode()
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+InvertFXNode::~InvertFXNode() {
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void InvertFXNode::disconnect()
+{
+ filterPtr = GPUInvertFilterPtr();
+ FXNode::disconnect();
+}
+
+GPUFilterPtr InvertFXNode::createFilter(const IntPoint& size)
+{
+ filterPtr = GPUInvertFilterPtr(new GPUInvertFilter(size, B8G8R8A8,
+ false));
+ setDirty();
+ return filterPtr;
+}
+
+std::string InvertFXNode::toString()
+{
+ stringstream s;
+ s << "InvertFXNode" << std::endl;
+ return s.str();
+}
+
+}
+
diff --git a/src/player/InvertFXNode.h b/src/player/InvertFXNode.h
new file mode 100644
index 0000000..5b148b2
--- /dev/null
+++ b/src/player/InvertFXNode.h
@@ -0,0 +1,57 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _InvertFXNode_H_
+#define _InvertFXNode_H_
+
+#include "../api.h"
+
+#include "FXNode.h"
+#include "../graphics/GPUInvertFilter.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/python.hpp>
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+class AVG_API InvertFXNode : public FXNode {
+public:
+ InvertFXNode();
+ virtual ~InvertFXNode();
+ virtual void disconnect();
+
+ std::string toString();
+
+private:
+ virtual GPUFilterPtr createFilter(const IntPoint& size);
+
+ GPUInvertFilterPtr filterPtr;
+
+};
+
+typedef boost::shared_ptr<InvertFXNode> InvertFXNodePtr;
+} //end namespace avg
+
+#endif
+
diff --git a/src/player/KeyEvent.cpp b/src/player/KeyEvent.cpp
new file mode 100644
index 0000000..b922280
--- /dev/null
+++ b/src/player/KeyEvent.cpp
@@ -0,0 +1,80 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "KeyEvent.h"
+#include "../base/Logger.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+KeyEvent::KeyEvent(Type eventType, unsigned char scanCode, int keyCode,
+ const string& keyString, int unicode, int modifiers)
+ : Event(eventType)
+{
+ m_ScanCode = scanCode;
+ m_KeyCode = keyCode;
+ m_KeyString = keyString;
+ m_Unicode = unicode;
+ m_Modifiers = modifiers;
+}
+
+KeyEvent::~KeyEvent()
+{
+}
+
+unsigned char KeyEvent::getScanCode() const
+{
+ return m_ScanCode;
+}
+
+int KeyEvent::getKeyCode() const
+{
+ return m_KeyCode;
+}
+
+const std::string& KeyEvent::getKeyString() const
+{
+ return m_KeyString;
+}
+
+int KeyEvent::getUnicode() const
+{
+ return m_Unicode;
+}
+
+int KeyEvent::getModifiers() const
+{
+ return m_Modifiers;
+}
+
+void KeyEvent::trace()
+{
+ Event::trace();
+ AVG_TRACE(Logger::EVENTS2, "Scancode: " << m_ScanCode
+ << ", Keycode: " << m_KeyCode << ", KeyString: "
+ << m_KeyString << ", Modifiers: " << m_Modifiers);
+}
+
+}
diff --git a/src/player/KeyEvent.h b/src/player/KeyEvent.h
new file mode 100644
index 0000000..7559b7c
--- /dev/null
+++ b/src/player/KeyEvent.h
@@ -0,0 +1,335 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _KeyEvent_h_
+#define _KeyEvent_h_
+
+#include "../api.h"
+#include "Event.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API KeyEvent : public Event {
+ public:
+ KeyEvent(Type eventType, unsigned char scanCode, int keyCode,
+ const std::string& keyString, int unicode, int modifiers);
+ virtual ~KeyEvent();
+
+ unsigned char getScanCode() const;
+ int getKeyCode() const;
+ const std::string& getKeyString() const;
+ int getUnicode() const;
+ int getModifiers() const;
+
+ void trace();
+
+ private:
+ int m_ScanCode;
+ int m_KeyCode;
+ std::string m_KeyString;
+ int m_Unicode;
+ int m_Modifiers;
+};
+
+typedef boost::shared_ptr<class KeyEvent> KeyEventPtr;
+
+ namespace key {
+ // Plattform independent key codes and modifiers follow.
+ // The constants are borrowed from SDL.
+
+ // Enumeration of valid key mods (possibly OR'd together).
+ const long KEYMOD_NONE = 0x0000;
+ const long KEYMOD_LSHIFT= 0x0001;
+ const long KEYMOD_RSHIFT= 0x0002;
+ const long KEYMOD_LCTRL = 0x0040;
+ const long KEYMOD_RCTRL = 0x0080;
+ const long KEYMOD_LALT = 0x0100;
+ const long KEYMOD_RALT = 0x0200;
+ const long KEYMOD_LMETA = 0x0400;
+ const long KEYMOD_RMETA = 0x0800;
+ const long KEYMOD_NUM = 0x1000;
+ const long KEYMOD_CAPS = 0x2000;
+ const long KEYMOD_MODE = 0x4000;
+ const long KEYMOD_RESERVED = 0x8000;
+
+ const long KEYMOD_CTRL = (KEYMOD_LCTRL|KEYMOD_RCTRL);
+ const long KEYMOD_SHIFT = (KEYMOD_LSHIFT|KEYMOD_RSHIFT);
+ const long KEYMOD_ALT = (KEYMOD_LALT|KEYMOD_RALT);
+ const long KEYMOD_META = (KEYMOD_LMETA|KEYMOD_RMETA);
+
+
+ // Key syms. 'cleverly chosen to map to ASCII', sais SDL.
+ const long KEY_UNKNOWN = 0;
+ const long KEY_FIRST = 0;
+ const long KEY_BACKSPACE = 8;
+ const long KEY_TAB = 9;
+ const long KEY_CLEAR = 12;
+ const long KEY_RETURN = 13;
+ const long KEY_PAUSE = 19;
+ const long KEY_ESCAPE = 27;
+ const long KEY_SPACE = 32;
+ const long KEY_EXCLAIM = 33;
+ const long KEY_QUOTEDBL = 34;
+ const long KEY_HASH = 35;
+ const long KEY_DOLLAR = 36;
+ const long KEY_AMPERSAND = 38;
+ const long KEY_QUOTE = 39;
+ const long KEY_LEFTPAREN = 40;
+ const long KEY_RIGHTPAREN = 41;
+ const long KEY_ASTERISK = 42;
+ const long KEY_PLUS = 43;
+ const long KEY_COMMA = 44;
+ const long KEY_MINUS = 45;
+ const long KEY_PERIOD = 46;
+ const long KEY_SLASH = 47;
+ const long KEY_0 = 48;
+ const long KEY_1 = 49;
+ const long KEY_2 = 50;
+ const long KEY_3 = 51;
+ const long KEY_4 = 52;
+ const long KEY_5 = 53;
+ const long KEY_6 = 54;
+ const long KEY_7 = 55;
+ const long KEY_8 = 56;
+ const long KEY_9 = 57;
+ const long KEY_COLON = 58;
+ const long KEY_SEMICOLON = 59;
+ const long KEY_LESS = 60;
+ const long KEY_EQUALS = 61;
+ const long KEY_GREATER = 62;
+ const long KEY_QUESTION = 63;
+ const long KEY_AT = 64;
+ // Skip uppercase letters
+ const long KEY_LEFTBRACKET = 91;
+ const long KEY_BACKSLASH = 92;
+ const long KEY_RIGHTBRACKET = 93;
+ const long KEY_CARET = 94;
+ const long KEY_UNDERSCORE = 95;
+ const long KEY_BACKQUOTE = 96;
+ const long KEY_a = 97;
+ const long KEY_b = 98;
+ const long KEY_c = 99;
+ const long KEY_d = 100;
+ const long KEY_e = 101;
+ const long KEY_f = 102;
+ const long KEY_g = 103;
+ const long KEY_h = 104;
+ const long KEY_i = 105;
+ const long KEY_j = 106;
+ const long KEY_k = 107;
+ const long KEY_l = 108;
+ const long KEY_m = 109;
+ const long KEY_n = 110;
+ const long KEY_o = 111;
+ const long KEY_p = 112;
+ const long KEY_q = 113;
+ const long KEY_r = 114;
+ const long KEY_s = 115;
+ const long KEY_t = 116;
+ const long KEY_u = 117;
+ const long KEY_v = 118;
+ const long KEY_w = 119;
+ const long KEY_x = 120;
+ const long KEY_y = 121;
+ const long KEY_z = 122;
+ const long KEY_DELETE = 127;
+ // End of ASCII mapped keysyms
+
+ // International keyboard syms
+ const long KEY_WORLD_0 = 160; /* 0xA0 */
+ const long KEY_WORLD_1 = 161;
+ const long KEY_WORLD_2 = 162;
+ const long KEY_WORLD_3 = 163;
+ const long KEY_WORLD_4 = 164;
+ const long KEY_WORLD_5 = 165;
+ const long KEY_WORLD_6 = 166;
+ const long KEY_WORLD_7 = 167;
+ const long KEY_WORLD_8 = 168;
+ const long KEY_WORLD_9 = 169;
+ const long KEY_WORLD_10 = 170;
+ const long KEY_WORLD_11 = 171;
+ const long KEY_WORLD_12 = 172;
+ const long KEY_WORLD_13 = 173;
+ const long KEY_WORLD_14 = 174;
+ const long KEY_WORLD_15 = 175;
+ const long KEY_WORLD_16 = 176;
+ const long KEY_WORLD_17 = 177;
+ const long KEY_WORLD_18 = 178;
+ const long KEY_WORLD_19 = 179;
+ const long KEY_WORLD_20 = 180;
+ const long KEY_WORLD_21 = 181;
+ const long KEY_WORLD_22 = 182;
+ const long KEY_WORLD_23 = 183;
+ const long KEY_WORLD_24 = 184;
+ const long KEY_WORLD_25 = 185;
+ const long KEY_WORLD_26 = 186;
+ const long KEY_WORLD_27 = 187;
+ const long KEY_WORLD_28 = 188;
+ const long KEY_WORLD_29 = 189;
+ const long KEY_WORLD_30 = 190;
+ const long KEY_WORLD_31 = 191;
+ const long KEY_WORLD_32 = 192;
+ const long KEY_WORLD_33 = 193;
+ const long KEY_WORLD_34 = 194;
+ const long KEY_WORLD_35 = 195;
+ const long KEY_WORLD_36 = 196;
+ const long KEY_WORLD_37 = 197;
+ const long KEY_WORLD_38 = 198;
+ const long KEY_WORLD_39 = 199;
+ const long KEY_WORLD_40 = 200;
+ const long KEY_WORLD_41 = 201;
+ const long KEY_WORLD_42 = 202;
+ const long KEY_WORLD_43 = 203;
+ const long KEY_WORLD_44 = 204;
+ const long KEY_WORLD_45 = 205;
+ const long KEY_WORLD_46 = 206;
+ const long KEY_WORLD_47 = 207;
+ const long KEY_WORLD_48 = 208;
+ const long KEY_WORLD_49 = 209;
+ const long KEY_WORLD_50 = 210;
+ const long KEY_WORLD_51 = 211;
+ const long KEY_WORLD_52 = 212;
+ const long KEY_WORLD_53 = 213;
+ const long KEY_WORLD_54 = 214;
+ const long KEY_WORLD_55 = 215;
+ const long KEY_WORLD_56 = 216;
+ const long KEY_WORLD_57 = 217;
+ const long KEY_WORLD_58 = 218;
+ const long KEY_WORLD_59 = 219;
+ const long KEY_WORLD_60 = 220;
+ const long KEY_WORLD_61 = 221;
+ const long KEY_WORLD_62 = 222;
+ const long KEY_WORLD_63 = 223;
+ const long KEY_WORLD_64 = 224;
+ const long KEY_WORLD_65 = 225;
+ const long KEY_WORLD_66 = 226;
+ const long KEY_WORLD_67 = 227;
+ const long KEY_WORLD_68 = 228;
+ const long KEY_WORLD_69 = 229;
+ const long KEY_WORLD_70 = 230;
+ const long KEY_WORLD_71 = 231;
+ const long KEY_WORLD_72 = 232;
+ const long KEY_WORLD_73 = 233;
+ const long KEY_WORLD_74 = 234;
+ const long KEY_WORLD_75 = 235;
+ const long KEY_WORLD_76 = 236;
+ const long KEY_WORLD_77 = 237;
+ const long KEY_WORLD_78 = 238;
+ const long KEY_WORLD_79 = 239;
+ const long KEY_WORLD_80 = 240;
+ const long KEY_WORLD_81 = 241;
+ const long KEY_WORLD_82 = 242;
+ const long KEY_WORLD_83 = 243;
+ const long KEY_WORLD_84 = 244;
+ const long KEY_WORLD_85 = 245;
+ const long KEY_WORLD_86 = 246;
+ const long KEY_WORLD_87 = 247;
+ const long KEY_WORLD_88 = 248;
+ const long KEY_WORLD_89 = 249;
+ const long KEY_WORLD_90 = 250;
+ const long KEY_WORLD_91 = 251;
+ const long KEY_WORLD_92 = 252;
+ const long KEY_WORLD_93 = 253;
+ const long KEY_WORLD_94 = 254;
+ const long KEY_WORLD_95 = 255;
+
+ // Numeric keypad
+ const long KEY_KP0 = 256;
+ const long KEY_KP1 = 257;
+ const long KEY_KP2 = 258;
+ const long KEY_KP3 = 259;
+ const long KEY_KP4 = 260;
+ const long KEY_KP5 = 261;
+ const long KEY_KP6 = 262;
+ const long KEY_KP7 = 263;
+ const long KEY_KP8 = 264;
+ const long KEY_KP9 = 265;
+ const long KEY_KP_PERIOD = 266;
+ const long KEY_KP_DIVIDE = 267;
+ const long KEY_KP_MULTIPLY = 268;
+ const long KEY_KP_MINUS = 269;
+ const long KEY_KP_PLUS = 270;
+ const long KEY_KP_ENTER = 271;
+ const long KEY_KP_EQUALS = 272;
+
+ // Arrows + Home/End pad
+ const long KEY_UP = 273;
+ const long KEY_DOWN = 274;
+ const long KEY_RIGHT = 275;
+ const long KEY_LEFT = 276;
+ const long KEY_INSERT = 277;
+ const long KEY_HOME = 278;
+ const long KEY_END = 279;
+ const long KEY_PAGEUP = 280;
+ const long KEY_PAGEDOWN = 281;
+
+ // Function keys
+ const long KEY_F1 = 282;
+ const long KEY_F2 = 283;
+ const long KEY_F3 = 284;
+ const long KEY_F4 = 285;
+ const long KEY_F5 = 286;
+ const long KEY_F6 = 287;
+ const long KEY_F7 = 288;
+ const long KEY_F8 = 289;
+ const long KEY_F9 = 290;
+ const long KEY_F10 = 291;
+ const long KEY_F11 = 292;
+ const long KEY_F12 = 293;
+ const long KEY_F13 = 294;
+ const long KEY_F14 = 295;
+ const long KEY_F15 = 296;
+
+ // Key state modifier keys
+ const long KEY_NUMLOCK = 300;
+ const long KEY_CAPSLOCK = 301;
+ const long KEY_SCROLLOCK = 302;
+ const long KEY_RSHIFT = 303;
+ const long KEY_LSHIFT = 304;
+ const long KEY_RCTRL = 305;
+ const long KEY_LCTRL = 306;
+ const long KEY_RALT = 307;
+ const long KEY_LALT = 308;
+ const long KEY_RMETA = 309;
+ const long KEY_LMETA = 310;
+ const long KEY_LSUPER = 311; /* Left "Windows" key */
+ const long KEY_RSUPER = 312; /* Right "Windows" key */
+ const long KEY_MODE = 313; /* "Alt Gr" key */
+ const long KEY_COMPOSE = 314; /* Multi-key compose key */
+
+ // Miscellaneous function keys
+ const long KEY_HELP = 315;
+ const long KEY_PRINT = 316;
+ const long KEY_SYSREQ = 317;
+ const long KEY_BREAK = 318;
+ const long KEY_MENU = 319;
+ const long KEY_POWER = 320; /* Power Macintosh power key */
+ const long KEY_EURO = 321; /* Some european keyboards */
+ const long KEY_UNDO = 322; /* Atari keyboard has Undo */
+ // Add any other keys here
+ }
+
+}
+
+#endif
+
diff --git a/src/player/LibMTDevInputDevice.cpp b/src/player/LibMTDevInputDevice.cpp
new file mode 100644
index 0000000..30eb11c
--- /dev/null
+++ b/src/player/LibMTDevInputDevice.cpp
@@ -0,0 +1,189 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "LibMTDevInputDevice.h"
+
+#include "TouchEvent.h"
+#include "Player.h"
+#include "AVGNode.h"
+#include "TouchStatus.h"
+
+#include "../base/Logger.h"
+#include "../base/Point.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+#include "../base/OSHelper.h"
+
+#include <linux/input.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+extern "C" {
+#include <mtdev.h>
+#include <mtdev-mapping.h>
+}
+
+using namespace std;
+
+namespace avg {
+
+LibMTDevInputDevice::LibMTDevInputDevice()
+ : m_LastID(0),
+ m_pMTDevice(0)
+{
+}
+
+LibMTDevInputDevice::~LibMTDevInputDevice()
+{
+ if (m_pMTDevice) {
+ mtdev_close(m_pMTDevice);
+ delete m_pMTDevice;
+ }
+}
+
+void LibMTDevInputDevice::start()
+{
+ string sDevice("/dev/input/event3");
+ getEnv("AVG_LINUX_MULTITOUCH_DEVICE", sDevice);
+ m_DeviceFD = ::open(sDevice.c_str(), O_RDONLY | O_NONBLOCK);
+ if (m_DeviceFD == -1) {
+ throw Exception(AVG_ERR_MT_INIT,
+ string("Linux multitouch event source: Could not open device file '")+
+ sDevice+"'. "+strerror(errno)+".");
+ }
+ m_pMTDevice = new mtdev;
+ int err = mtdev_open(m_pMTDevice, m_DeviceFD);
+ if (err == -1) {
+ throw Exception(AVG_ERR_MT_INIT,
+ string("Linux multitouch event source: Could not open mtdev '")+
+ sDevice+"'. "+strerror(errno)+".");
+ }
+ input_absinfo* pAbsInfo;
+ pAbsInfo = &(m_pMTDevice->caps.abs[MTDEV_POSITION_X]);
+ m_Dimensions.tl.x = pAbsInfo->minimum;
+ m_Dimensions.br.x = pAbsInfo->maximum;
+ pAbsInfo = &(m_pMTDevice->caps.abs[MTDEV_POSITION_Y]);
+ m_Dimensions.tl.y = pAbsInfo->minimum;
+ m_Dimensions.br.y = pAbsInfo->maximum;
+
+ MultitouchInputDevice::start();
+ AVG_TRACE(Logger::CONFIG, "Linux MTDev Multitouch event source created.");
+}
+
+std::vector<EventPtr> LibMTDevInputDevice::pollEvents()
+{
+ struct input_event event;
+ static int curSlot = 0;
+
+ set<int> changedIDs;
+ while (mtdev_get(m_pMTDevice, m_DeviceFD, &event, 1) > 0) {
+ if (event.type == EV_SYN && event.code == SYN_REPORT) {
+// cerr << ">> SYN_REPORT" << endl;
+ processEvents(changedIDs);
+ changedIDs.clear();
+ } else if (event.type == EV_ABS && event.code == ABS_MT_SLOT) {
+// cerr << ">> slot " << event.value << endl;
+ curSlot = event.value;
+ } else {
+ TouchData* pTouch;
+ switch (event.code) {
+ case ABS_MT_TRACKING_ID:
+// cerr << ">> ABS_MT_TRACKING_ID: " << event.value << endl;
+ pTouch = &(m_Slots[curSlot]);
+ if (event.value == -1) {
+ TouchStatusPtr pTouchStatus = getTouchStatus(pTouch->id);
+// cerr << "up " << pTouch->id << endl;
+ if (pTouchStatus) {
+// cerr << " --> remove" << endl;
+ TouchEventPtr pOldEvent = pTouchStatus->getLastEvent();
+ TouchEventPtr pUpEvent =
+ boost::dynamic_pointer_cast<TouchEvent>(
+ pOldEvent->cloneAs(Event::CURSORUP));
+ pTouchStatus->pushEvent(pUpEvent);
+ removeTouchStatus(pTouch->id);
+ }
+ pTouch->id = -1;
+ } else {
+ pTouch->id = event.value;
+ changedIDs.insert(curSlot);
+ }
+ break;
+ case ABS_MT_POSITION_X:
+// cerr << ">> ABS_MT_POSITION_X: " << event.value << endl;
+ pTouch = &(m_Slots[curSlot]);
+ pTouch->pos.x = event.value;
+ changedIDs.insert(curSlot);
+ break;
+ case ABS_MT_POSITION_Y:
+// cerr << ">> ABS_MT_POSITION_Y: " << event.value << endl;
+ pTouch = &(m_Slots[curSlot]);
+ pTouch->pos.y = event.value;
+ changedIDs.insert(curSlot);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ return MultitouchInputDevice::pollEvents();
+}
+
+void LibMTDevInputDevice::processEvents(const set<int>& changedIDs)
+{
+ for (set<int>::iterator it = changedIDs.begin(); it != changedIDs.end(); ++it) {
+ map<int, TouchData>::iterator it2 = m_Slots.find(*it);
+ if (it2 != m_Slots.end()) {
+ const TouchData& touch = it2->second;
+// cerr << "slot: " << *it << ", id: " << touch.id << ", pos: " << touch.pos
+// << endl;
+// AVG_ASSERT(touch.pos.x != 0);
+ if (touch.id != -1) {
+ TouchStatusPtr pTouchStatus = getTouchStatus(touch.id);
+ if (!pTouchStatus) {
+ // Down
+ m_LastID++;
+ TouchEventPtr pEvent = createEvent(m_LastID, Event::CURSORDOWN,
+ touch.pos);
+// cerr << "down <" << touch.id << "> --> [" << m_LastID << "]" << endl;
+ addTouchStatus((long)touch.id, pEvent);
+ } else {
+// cerr << "move <" << touch.id << "> --> " << touch.pos << endl;
+ // Move
+ TouchEventPtr pEvent = createEvent(0, Event::CURSORMOTION, touch.pos);
+ pTouchStatus->pushEvent(pEvent);
+ }
+ }
+ }
+ }
+}
+
+TouchEventPtr LibMTDevInputDevice::createEvent(int id, Event::Type type, IntPoint pos)
+{
+ DPoint size = getWindowSize();
+ DPoint normPos = DPoint(double(pos.x-m_Dimensions.tl.x)/m_Dimensions.width(),
+ double(pos.y-m_Dimensions.tl.y)/m_Dimensions.height());
+ IntPoint screenPos(int(normPos.x*size.x+0.5), int(normPos.y*size.y+0.5));
+ return TouchEventPtr(new TouchEvent(id, type, screenPos, Event::TOUCH));
+}
+
+}
diff --git a/src/player/LibMTDevInputDevice.h b/src/player/LibMTDevInputDevice.h
new file mode 100644
index 0000000..cb07695
--- /dev/null
+++ b/src/player/LibMTDevInputDevice.h
@@ -0,0 +1,73 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _LibMTDevInputDevice_H_
+#define _LibMTDevInputDevice_H_
+
+#include "../api.h"
+#include "MultitouchInputDevice.h"
+#include "Event.h"
+
+#include "../base/Rect.h"
+
+#include <vector>
+#include <set>
+#include <map>
+
+struct mtdev;
+
+namespace avg {
+
+class AVG_API LibMTDevInputDevice: public MultitouchInputDevice
+{
+public:
+ LibMTDevInputDevice();
+ virtual ~LibMTDevInputDevice();
+ virtual void start();
+
+ std::vector<EventPtr> pollEvents();
+
+private:
+ void processEvents(const std::set<int>& changedIDs);
+ TouchEventPtr createEvent(int id, Event::Type type, IntPoint pos);
+
+ int m_DeviceFD;
+ int m_LastID;
+ mtdev* m_pMTDevice;
+ IntRect m_Dimensions;
+
+ struct TouchData
+ {
+ TouchData() { id = -1; }
+ int id;
+ bool bUp;
+ IntPoint pos;
+ };
+ std::map<int, TouchData> m_Slots;
+
+};
+
+typedef boost::shared_ptr<LibMTDevInputDevice> LibMTDevInputDevicePtr;
+
+}
+
+#endif
+
diff --git a/src/player/LineNode.cpp b/src/player/LineNode.cpp
new file mode 100644
index 0000000..1ee299f
--- /dev/null
+++ b/src/player/LineNode.cpp
@@ -0,0 +1,105 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "LineNode.h"
+
+#include "NodeDefinition.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition LineNode::createDefinition()
+{
+ return NodeDefinition("line", Node::buildNode<LineNode>)
+ .extendDefinition(VectorNode::createDefinition())
+ .addArg(Arg<DPoint>("pos1", DPoint(0,0), false, offsetof(LineNode, m_P1)))
+ .addArg(Arg<DPoint>("pos2", DPoint(0,0), false, offsetof(LineNode, m_P2)))
+ .addArg(Arg<double>("texcoord1", 0, false, offsetof(LineNode, m_TC1)))
+ .addArg(Arg<double>("texcoord2", 1, false, offsetof(LineNode, m_TC2)))
+ ;
+}
+
+LineNode::LineNode(const ArgList& args)
+ : VectorNode(args)
+{
+ args.setMembers(this);
+}
+
+LineNode::~LineNode()
+{
+}
+
+const DPoint& LineNode::getPos1() const
+{
+ return m_P1;
+}
+
+void LineNode::setPos1(const DPoint& pt)
+{
+ m_P1 = pt;
+ setDrawNeeded();
+}
+
+const DPoint& LineNode::getPos2() const
+{
+ return m_P2;
+}
+
+void LineNode::setPos2(const DPoint& pt)
+{
+ m_P2 = pt;
+ setDrawNeeded();
+}
+
+double LineNode::getTexCoord1() const
+{
+ return m_TC1;
+}
+
+void LineNode::setTexCoord1(double tc)
+{
+ m_TC1 = tc;
+ setDrawNeeded();
+}
+
+double LineNode::getTexCoord2() const
+{
+ return m_TC2;
+}
+
+void LineNode::setTexCoord2(double tc)
+{
+ m_TC2 = tc;
+ setDrawNeeded();
+}
+
+void LineNode::calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ pVertexArray->addLineData(color, m_P1, m_P2, getStrokeWidth(), m_TC1, m_TC2);
+}
+
+}
diff --git a/src/player/LineNode.h b/src/player/LineNode.h
new file mode 100644
index 0000000..daa5fbd
--- /dev/null
+++ b/src/player/LineNode.h
@@ -0,0 +1,64 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _LineNode_H_
+#define _LineNode_H_
+
+#include "../api.h"
+#include "VectorNode.h"
+
+#include "../graphics/Pixel32.h"
+
+namespace avg {
+
+class AVG_API LineNode : public VectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ LineNode(const ArgList& args);
+ virtual ~LineNode();
+
+ const DPoint& getPos1() const;
+ void setPos1(const DPoint& pt);
+
+ const DPoint& getPos2() const;
+ void setPos2(const DPoint& pt);
+
+ double getTexCoord1() const;
+ void setTexCoord1(double tc);
+
+ double getTexCoord2() const;
+ void setTexCoord2(double tc);
+
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+
+ private:
+ DPoint m_P1;
+ DPoint m_P2;
+ double m_TC1;
+ double m_TC2;
+};
+
+}
+
+#endif
+
diff --git a/src/player/MainCanvas.cpp b/src/player/MainCanvas.cpp
new file mode 100644
index 0000000..c85db63
--- /dev/null
+++ b/src/player/MainCanvas.cpp
@@ -0,0 +1,82 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "MainCanvas.h"
+
+#include "Player.h"
+#include "SDLDisplayEngine.h"
+#include "AVGNode.h"
+
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../base/Logger.h"
+
+#include "../graphics/GLContext.h"
+
+#include <vector>
+
+using namespace boost;
+using namespace std;
+
+namespace avg {
+
+MainCanvas::MainCanvas(Player * pPlayer)
+ : Canvas(pPlayer)
+{
+}
+
+MainCanvas::~MainCanvas()
+{
+}
+
+void MainCanvas::setRoot(NodePtr pRootNode)
+{
+ Canvas::setRoot(pRootNode);
+ if (!dynamic_pointer_cast<AVGNode>(pRootNode)) {
+ throw (Exception(AVG_ERR_XML_PARSE,
+ "Root node of an avg tree needs to be an <avg> node."));
+ }
+}
+
+void MainCanvas::initPlayback(const SDLDisplayEnginePtr& pDisplayEngine)
+{
+ m_pDisplayEngine = pDisplayEngine;
+ Canvas::initPlayback(GLContext::getCurrent()->getConfig().m_MultiSampleSamples);
+}
+
+BitmapPtr MainCanvas::screenshot() const
+{
+ if (!m_pDisplayEngine) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "MainCanvas::screenshot(): Canvas is not being rendered. No screenshot available."));
+ }
+ return m_pDisplayEngine->screenshot();
+}
+
+static ProfilingZoneID RootRenderProfilingZone("Render MainCanvas");
+
+void MainCanvas::render()
+{
+ Canvas::render(m_pDisplayEngine->getWindowSize(), false, FBOPtr(),
+ RootRenderProfilingZone);
+}
+
+}
diff --git a/src/player/MainCanvas.h b/src/player/MainCanvas.h
new file mode 100644
index 0000000..c6d2310
--- /dev/null
+++ b/src/player/MainCanvas.h
@@ -0,0 +1,51 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _MainCanvas_H_
+#define _MainCanvas_H_
+
+#include "../api.h"
+#include "Canvas.h"
+
+namespace avg {
+
+class SDLDisplayEngine;
+typedef boost::shared_ptr<SDLDisplayEngine> SDLDisplayEnginePtr;
+
+class AVG_API MainCanvas: public Canvas
+{
+ public:
+ MainCanvas(Player * pPlayer);
+ virtual ~MainCanvas();
+ virtual void setRoot(NodePtr pRootNode);
+ void initPlayback(const SDLDisplayEnginePtr& pDisplayEngine);
+
+ virtual BitmapPtr screenshot() const;
+
+ private:
+ virtual void render();
+
+ SDLDisplayEnginePtr m_pDisplayEngine;
+};
+
+}
+#endif
+
diff --git a/src/player/Makefile.am b/src/player/Makefile.am
new file mode 100644
index 0000000..6dfd5e2
--- /dev/null
+++ b/src/player/Makefile.am
@@ -0,0 +1,102 @@
+INCLUDES = -I.. @XML2_CFLAGS@ @FREETYPE_CFLAGS@ \
+ @PANGOFT2_CFLAGS@ @PYTHON_INCLUDES@ @GL_CFLAGS@ @FFMPEG_CFLAGS@ \
+ @DC1394_2_CFLAGS@ @LIBRSVG_CFLAGS@ @FONTCONFIG_CFLAGS@ \
+ $(MTDEV_CFLAGS)
+
+if APPLE
+ APPLE_SOURCES = SDLMain.m AppleTrackpadInputDevice.cpp
+ APPLE_LINKFLAGS=-read_only_relocs suppress -F/System/Library/PrivateFrameworks -framework MultitouchSupport
+ XGL_LIBS =
+else
+ APPLE_SOURCES =
+ APPLE_LINKFLAGS=
+ XGL_LIBS = -lXxf86vm -lX11
+endif
+
+if ENABLE_MTDEV
+ MTDEV_SOURCES = LibMTDevInputDevice.cpp
+ MTDEV_INCLUDES = LibMTDevInputDevice.h
+else
+ MTDEV_SOURCES =
+ MTDEV_INCLUDES =
+endif
+
+if HAVE_XI2_1
+ XINPUT2_SOURCES = XInputMTInputDevice.cpp
+ XINPUT2_INCLUDES = XInputMTInputDevice.h
+else
+if HAVE_XI2_2
+ XINPUT2_SOURCES = XInputMTInputDevice.cpp
+ XINPUT2_INCLUDES = XInputMTInputDevice.h
+else
+ XINPUT2_SOURCES =
+ XINPUT2_INCLUDES =
+endif
+endif
+
+GL_SOURCES = OGLSurface.cpp SDLDisplayEngine.cpp
+GL_INCLUDES = OGLSurface.h SDLDisplayEngine.h
+
+ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
+
+ALL_H = Player.h PluginManager.h IInputDevice.h VideoNode.h \
+ DisplayEngine.h NodeRegistry.h Arg.h ArgBase.h ArgList.h \
+ Node.h AreaNode.h DisplayParams.h NodeDefinition.h TextEngine.h \
+ AVGNode.h DivNode.h CursorState.h MaterialInfo.h Canvas.h MainCanvas.h \
+ Image.h ImageNode.h Timeout.h WordsNode.h WrapPython.h OffscreenCanvas.h \
+ EventDispatcher.h CursorEvent.h MouseEvent.h \
+ Event.h KeyEvent.h PanoImageNode.h TestHelper.h CanvasNode.h \
+ OffscreenCanvasNode.h MultitouchInputDevice.h \
+ RasterNode.h CameraNode.h TrackerInputDevice.h TrackerCalibrator.h \
+ TouchEvent.h Contact.h TouchStatus.h TrackerTouchStatus.h BoostPython.h \
+ SoundNode.h \
+ VectorNode.h FilledVectorNode.h LineNode.h PolyLineNode.h RectNode.h \
+ CurveNode.h PolygonNode.h CircleNode.h Shape.h MeshNode.h FXNode.h \
+ NullFXNode.h BlurFXNode.h ShadowFXNode.h ChromaKeyFXNode.h HueSatFXNode.h \
+ InvertFXNode.h TUIOInputDevice.h VideoWriter.h VideoWriterThread.h \
+ SVG.h SVGElement.h \
+ $(MTDEV_INCLUDES) $(GL_INCLUDES) $(XINPUT2_INCLUDES)
+
+TESTS=testcalibrator testplayer
+
+EXTRA_DIST = SDLMain.h
+
+noinst_LTLIBRARIES = libplayer.la
+noinst_PROGRAMS = testcalibrator testplayer
+testplayer_SOURCES=testplayer.cpp
+testplayer_LDADD = libplayer.la ../video/libvideo.la ../audio/libaudio.la \
+ ../imaging/libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ ../lmfit/liblmfit.la ../oscpack/liboscpack.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ @PANGOFT2_LIBS@ @LIBRSVG_LIBS@\
+ @DC1394_2_LIBS@ @GLU_LIBS@ $(ALL_GL_LIBS) $(XI2_1_LIBS) $(XI2_2_LIBS) \
+ @LIBFFMPEG@ $(BOOST_PYTHON_LIBS) $(PYTHON_LIBS) @GDK_PIXBUF_LIBS@ \
+ @FONTCONFIG_LIBS@
+
+testplayer_LDFLAGS = $(APPLE_LINKFLAGS) -module -XCClinker
+
+testcalibrator_SOURCES=testcalibrator.cpp
+testcalibrator_LDADD = libplayer.la ../video/libvideo.la ../audio/libaudio.la \
+ ../imaging/libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ ../lmfit/liblmfit.la ../oscpack/liboscpack.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ @LIBRSVG_LIBS@ @GDK_PIXBUF_LIBS@
+
+libplayer_la_LIBADD = $(BOOST_PYTHON_LIBS) $(PYTHON_LIBS) $(MTDEV_LIBS)
+libplayer_la_SOURCES = $(GL_SOURCES) \
+ Arg.cpp AreaNode.cpp RasterNode.cpp DivNode.cpp VideoNode.cpp \
+ Player.cpp PluginManager.cpp NodeRegistry.cpp ArgBase.cpp ArgList.cpp \
+ DisplayEngine.cpp Canvas.cpp CanvasNode.cpp OffscreenCanvasNode.cpp \
+ MainCanvas.cpp Node.cpp MultitouchInputDevice.cpp \
+ PanoImageNode.cpp WordsNode.cpp CameraNode.cpp NodeDefinition.cpp TextEngine.cpp \
+ Timeout.cpp Event.cpp DisplayParams.cpp CursorState.cpp MaterialInfo.cpp \
+ Image.cpp ImageNode.cpp EventDispatcher.cpp KeyEvent.cpp CursorEvent.cpp \
+ MouseEvent.cpp TouchEvent.cpp AVGNode.cpp TestHelper.cpp \
+ TrackerInputDevice.cpp TrackerTouchStatus.cpp TrackerCalibrator.cpp \
+ SoundNode.cpp \
+ VectorNode.cpp FilledVectorNode.cpp LineNode.cpp PolyLineNode.cpp \
+ RectNode.cpp CurveNode.cpp PolygonNode.cpp CircleNode.cpp Shape.cpp MeshNode.cpp \
+ Contact.cpp TouchStatus.cpp OffscreenCanvas.cpp FXNode.cpp TUIOInputDevice.cpp \
+ NullFXNode.cpp BlurFXNode.cpp ShadowFXNode.cpp ChromaKeyFXNode.cpp \
+ InvertFXNode.cpp HueSatFXNode.cpp VideoWriter.cpp VideoWriterThread.cpp \
+ SVG.cpp SVGElement.cpp \
+ $(MTDEV_SOURCES) $(XINPUT2_SOURCES) $(APPLE_SOURCES) $(ALL_H)
+libplayer_a_CXXFLAGS = -DPREFIXDIR=\"$(prefix)\"
diff --git a/src/player/Makefile.in b/src/player/Makefile.in
new file mode 100644
index 0000000..047b46a
--- /dev/null
+++ b/src/player/Makefile.in
@@ -0,0 +1,967 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+TESTS = testcalibrator$(EXEEXT) testplayer$(EXEEXT)
+noinst_PROGRAMS = testcalibrator$(EXEEXT) testplayer$(EXEEXT)
+subdir = src/player
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+libplayer_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am__libplayer_la_SOURCES_DIST = OGLSurface.cpp SDLDisplayEngine.cpp \
+ Arg.cpp AreaNode.cpp RasterNode.cpp DivNode.cpp VideoNode.cpp \
+ Player.cpp PluginManager.cpp NodeRegistry.cpp ArgBase.cpp \
+ ArgList.cpp DisplayEngine.cpp Canvas.cpp CanvasNode.cpp \
+ OffscreenCanvasNode.cpp MainCanvas.cpp Node.cpp \
+ MultitouchInputDevice.cpp PanoImageNode.cpp WordsNode.cpp \
+ CameraNode.cpp NodeDefinition.cpp TextEngine.cpp Timeout.cpp \
+ Event.cpp DisplayParams.cpp CursorState.cpp MaterialInfo.cpp \
+ Image.cpp ImageNode.cpp EventDispatcher.cpp KeyEvent.cpp \
+ CursorEvent.cpp MouseEvent.cpp TouchEvent.cpp AVGNode.cpp \
+ TestHelper.cpp TrackerInputDevice.cpp TrackerTouchStatus.cpp \
+ TrackerCalibrator.cpp SoundNode.cpp VectorNode.cpp \
+ FilledVectorNode.cpp LineNode.cpp PolyLineNode.cpp \
+ RectNode.cpp CurveNode.cpp PolygonNode.cpp CircleNode.cpp \
+ Shape.cpp MeshNode.cpp Contact.cpp TouchStatus.cpp \
+ OffscreenCanvas.cpp FXNode.cpp TUIOInputDevice.cpp \
+ NullFXNode.cpp BlurFXNode.cpp ShadowFXNode.cpp \
+ ChromaKeyFXNode.cpp InvertFXNode.cpp HueSatFXNode.cpp \
+ VideoWriter.cpp VideoWriterThread.cpp SVG.cpp SVGElement.cpp \
+ LibMTDevInputDevice.cpp XInputMTInputDevice.cpp SDLMain.m \
+ AppleTrackpadInputDevice.cpp Player.h PluginManager.h \
+ IInputDevice.h VideoNode.h DisplayEngine.h NodeRegistry.h \
+ Arg.h ArgBase.h ArgList.h Node.h AreaNode.h DisplayParams.h \
+ NodeDefinition.h TextEngine.h AVGNode.h DivNode.h \
+ CursorState.h MaterialInfo.h Canvas.h MainCanvas.h Image.h \
+ ImageNode.h Timeout.h WordsNode.h WrapPython.h \
+ OffscreenCanvas.h EventDispatcher.h CursorEvent.h MouseEvent.h \
+ Event.h KeyEvent.h PanoImageNode.h TestHelper.h CanvasNode.h \
+ OffscreenCanvasNode.h MultitouchInputDevice.h RasterNode.h \
+ CameraNode.h TrackerInputDevice.h TrackerCalibrator.h \
+ TouchEvent.h Contact.h TouchStatus.h TrackerTouchStatus.h \
+ BoostPython.h SoundNode.h VectorNode.h FilledVectorNode.h \
+ LineNode.h PolyLineNode.h RectNode.h CurveNode.h PolygonNode.h \
+ CircleNode.h Shape.h MeshNode.h FXNode.h NullFXNode.h \
+ BlurFXNode.h ShadowFXNode.h ChromaKeyFXNode.h HueSatFXNode.h \
+ InvertFXNode.h TUIOInputDevice.h VideoWriter.h \
+ VideoWriterThread.h SVG.h SVGElement.h LibMTDevInputDevice.h \
+ OGLSurface.h SDLDisplayEngine.h XInputMTInputDevice.h
+am__objects_1 = OGLSurface.lo SDLDisplayEngine.lo
+@ENABLE_MTDEV_TRUE@am__objects_2 = LibMTDevInputDevice.lo
+@HAVE_XI2_1_FALSE@@HAVE_XI2_2_TRUE@am__objects_3 = \
+@HAVE_XI2_1_FALSE@@HAVE_XI2_2_TRUE@ XInputMTInputDevice.lo
+@HAVE_XI2_1_TRUE@am__objects_3 = XInputMTInputDevice.lo
+@APPLE_TRUE@am__objects_4 = SDLMain.lo AppleTrackpadInputDevice.lo
+am__objects_5 =
+am__objects_6 = $(am__objects_5) $(am__objects_5) $(am__objects_5)
+am_libplayer_la_OBJECTS = $(am__objects_1) Arg.lo AreaNode.lo \
+ RasterNode.lo DivNode.lo VideoNode.lo Player.lo \
+ PluginManager.lo NodeRegistry.lo ArgBase.lo ArgList.lo \
+ DisplayEngine.lo Canvas.lo CanvasNode.lo \
+ OffscreenCanvasNode.lo MainCanvas.lo Node.lo \
+ MultitouchInputDevice.lo PanoImageNode.lo WordsNode.lo \
+ CameraNode.lo NodeDefinition.lo TextEngine.lo Timeout.lo \
+ Event.lo DisplayParams.lo CursorState.lo MaterialInfo.lo \
+ Image.lo ImageNode.lo EventDispatcher.lo KeyEvent.lo \
+ CursorEvent.lo MouseEvent.lo TouchEvent.lo AVGNode.lo \
+ TestHelper.lo TrackerInputDevice.lo TrackerTouchStatus.lo \
+ TrackerCalibrator.lo SoundNode.lo VectorNode.lo \
+ FilledVectorNode.lo LineNode.lo PolyLineNode.lo RectNode.lo \
+ CurveNode.lo PolygonNode.lo CircleNode.lo Shape.lo MeshNode.lo \
+ Contact.lo TouchStatus.lo OffscreenCanvas.lo FXNode.lo \
+ TUIOInputDevice.lo NullFXNode.lo BlurFXNode.lo ShadowFXNode.lo \
+ ChromaKeyFXNode.lo InvertFXNode.lo HueSatFXNode.lo \
+ VideoWriter.lo VideoWriterThread.lo SVG.lo SVGElement.lo \
+ $(am__objects_2) $(am__objects_3) $(am__objects_4) \
+ $(am__objects_6)
+libplayer_la_OBJECTS = $(am_libplayer_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+PROGRAMS = $(noinst_PROGRAMS)
+am_testcalibrator_OBJECTS = testcalibrator.$(OBJEXT)
+testcalibrator_OBJECTS = $(am_testcalibrator_OBJECTS)
+testcalibrator_DEPENDENCIES = libplayer.la ../video/libvideo.la \
+ ../audio/libaudio.la ../imaging/libimaging.la \
+ ../graphics/libgraphics.la ../base/libbase.la \
+ ../lmfit/liblmfit.la ../oscpack/liboscpack.la
+am_testplayer_OBJECTS = testplayer.$(OBJEXT)
+testplayer_OBJECTS = $(am_testplayer_OBJECTS)
+am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
+testplayer_DEPENDENCIES = libplayer.la ../video/libvideo.la \
+ ../audio/libaudio.la ../imaging/libimaging.la \
+ ../graphics/libgraphics.la ../base/libbase.la \
+ ../lmfit/liblmfit.la ../oscpack/liboscpack.la \
+ $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1)
+testplayer_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(testplayer_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+OBJCCOMPILE = $(OBJC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_OBJCFLAGS) $(OBJCFLAGS)
+LTOBJCCOMPILE = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(OBJC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_OBJCFLAGS) $(OBJCFLAGS)
+AM_V_OBJC = $(am__v_OBJC_$(V))
+am__v_OBJC_ = $(am__v_OBJC_$(AM_DEFAULT_VERBOSITY))
+am__v_OBJC_0 = @echo " OBJC " $@;
+OBJCLD = $(OBJC)
+OBJCLINK = $(LIBTOOL) $(AM_V_lt) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+ --mode=link $(OBJCLD) $(AM_OBJCFLAGS) $(OBJCFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_OBJCLD = $(am__v_OBJCLD_$(V))
+am__v_OBJCLD_ = $(am__v_OBJCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_OBJCLD_0 = @echo " OBJCLD" $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libplayer_la_SOURCES) $(testcalibrator_SOURCES) \
+ $(testplayer_SOURCES)
+DIST_SOURCES = $(am__libplayer_la_SOURCES_DIST) \
+ $(testcalibrator_SOURCES) $(testplayer_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.. @XML2_CFLAGS@ @FREETYPE_CFLAGS@ \
+ @PANGOFT2_CFLAGS@ @PYTHON_INCLUDES@ @GL_CFLAGS@ @FFMPEG_CFLAGS@ \
+ @DC1394_2_CFLAGS@ @LIBRSVG_CFLAGS@ @FONTCONFIG_CFLAGS@ \
+ $(MTDEV_CFLAGS)
+
+@APPLE_FALSE@APPLE_SOURCES =
+@APPLE_TRUE@APPLE_SOURCES = SDLMain.m AppleTrackpadInputDevice.cpp
+@APPLE_FALSE@APPLE_LINKFLAGS =
+@APPLE_TRUE@APPLE_LINKFLAGS = -read_only_relocs suppress -F/System/Library/PrivateFrameworks -framework MultitouchSupport
+@APPLE_FALSE@XGL_LIBS = -lXxf86vm -lX11
+@APPLE_TRUE@XGL_LIBS =
+@ENABLE_MTDEV_FALSE@MTDEV_SOURCES =
+@ENABLE_MTDEV_TRUE@MTDEV_SOURCES = LibMTDevInputDevice.cpp
+@ENABLE_MTDEV_FALSE@MTDEV_INCLUDES =
+@ENABLE_MTDEV_TRUE@MTDEV_INCLUDES = LibMTDevInputDevice.h
+@HAVE_XI2_1_FALSE@@HAVE_XI2_2_FALSE@XINPUT2_SOURCES =
+@HAVE_XI2_1_FALSE@@HAVE_XI2_2_TRUE@XINPUT2_SOURCES = XInputMTInputDevice.cpp
+@HAVE_XI2_1_TRUE@XINPUT2_SOURCES = XInputMTInputDevice.cpp
+@HAVE_XI2_1_FALSE@@HAVE_XI2_2_FALSE@XINPUT2_INCLUDES =
+@HAVE_XI2_1_FALSE@@HAVE_XI2_2_TRUE@XINPUT2_INCLUDES = XInputMTInputDevice.h
+@HAVE_XI2_1_TRUE@XINPUT2_INCLUDES = XInputMTInputDevice.h
+GL_SOURCES = OGLSurface.cpp SDLDisplayEngine.cpp
+GL_INCLUDES = OGLSurface.h SDLDisplayEngine.h
+ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
+ALL_H = Player.h PluginManager.h IInputDevice.h VideoNode.h \
+ DisplayEngine.h NodeRegistry.h Arg.h ArgBase.h ArgList.h \
+ Node.h AreaNode.h DisplayParams.h NodeDefinition.h TextEngine.h \
+ AVGNode.h DivNode.h CursorState.h MaterialInfo.h Canvas.h MainCanvas.h \
+ Image.h ImageNode.h Timeout.h WordsNode.h WrapPython.h OffscreenCanvas.h \
+ EventDispatcher.h CursorEvent.h MouseEvent.h \
+ Event.h KeyEvent.h PanoImageNode.h TestHelper.h CanvasNode.h \
+ OffscreenCanvasNode.h MultitouchInputDevice.h \
+ RasterNode.h CameraNode.h TrackerInputDevice.h TrackerCalibrator.h \
+ TouchEvent.h Contact.h TouchStatus.h TrackerTouchStatus.h BoostPython.h \
+ SoundNode.h \
+ VectorNode.h FilledVectorNode.h LineNode.h PolyLineNode.h RectNode.h \
+ CurveNode.h PolygonNode.h CircleNode.h Shape.h MeshNode.h FXNode.h \
+ NullFXNode.h BlurFXNode.h ShadowFXNode.h ChromaKeyFXNode.h HueSatFXNode.h \
+ InvertFXNode.h TUIOInputDevice.h VideoWriter.h VideoWriterThread.h \
+ SVG.h SVGElement.h \
+ $(MTDEV_INCLUDES) $(GL_INCLUDES) $(XINPUT2_INCLUDES)
+
+EXTRA_DIST = SDLMain.h
+noinst_LTLIBRARIES = libplayer.la
+testplayer_SOURCES = testplayer.cpp
+testplayer_LDADD = libplayer.la ../video/libvideo.la ../audio/libaudio.la \
+ ../imaging/libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ ../lmfit/liblmfit.la ../oscpack/liboscpack.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @PANGOFT2_LIBS@ @LIBRSVG_LIBS@\
+ @DC1394_2_LIBS@ @GLU_LIBS@ $(ALL_GL_LIBS) $(XI2_1_LIBS) $(XI2_2_LIBS) \
+ @LIBFFMPEG@ $(BOOST_PYTHON_LIBS) $(PYTHON_LIBS) @GDK_PIXBUF_LIBS@ \
+ @FONTCONFIG_LIBS@
+
+testplayer_LDFLAGS = $(APPLE_LINKFLAGS) -module -XCClinker
+testcalibrator_SOURCES = testcalibrator.cpp
+testcalibrator_LDADD = libplayer.la ../video/libvideo.la ../audio/libaudio.la \
+ ../imaging/libimaging.la ../graphics/libgraphics.la ../base/libbase.la \
+ ../lmfit/liblmfit.la ../oscpack/liboscpack.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ @LIBRSVG_LIBS@ @GDK_PIXBUF_LIBS@
+
+libplayer_la_LIBADD = $(BOOST_PYTHON_LIBS) $(PYTHON_LIBS) $(MTDEV_LIBS)
+libplayer_la_SOURCES = $(GL_SOURCES) \
+ Arg.cpp AreaNode.cpp RasterNode.cpp DivNode.cpp VideoNode.cpp \
+ Player.cpp PluginManager.cpp NodeRegistry.cpp ArgBase.cpp ArgList.cpp \
+ DisplayEngine.cpp Canvas.cpp CanvasNode.cpp OffscreenCanvasNode.cpp \
+ MainCanvas.cpp Node.cpp MultitouchInputDevice.cpp \
+ PanoImageNode.cpp WordsNode.cpp CameraNode.cpp NodeDefinition.cpp TextEngine.cpp \
+ Timeout.cpp Event.cpp DisplayParams.cpp CursorState.cpp MaterialInfo.cpp \
+ Image.cpp ImageNode.cpp EventDispatcher.cpp KeyEvent.cpp CursorEvent.cpp \
+ MouseEvent.cpp TouchEvent.cpp AVGNode.cpp TestHelper.cpp \
+ TrackerInputDevice.cpp TrackerTouchStatus.cpp TrackerCalibrator.cpp \
+ SoundNode.cpp \
+ VectorNode.cpp FilledVectorNode.cpp LineNode.cpp PolyLineNode.cpp \
+ RectNode.cpp CurveNode.cpp PolygonNode.cpp CircleNode.cpp Shape.cpp MeshNode.cpp \
+ Contact.cpp TouchStatus.cpp OffscreenCanvas.cpp FXNode.cpp TUIOInputDevice.cpp \
+ NullFXNode.cpp BlurFXNode.cpp ShadowFXNode.cpp ChromaKeyFXNode.cpp \
+ InvertFXNode.cpp HueSatFXNode.cpp VideoWriter.cpp VideoWriterThread.cpp \
+ SVG.cpp SVGElement.cpp \
+ $(MTDEV_SOURCES) $(XINPUT2_SOURCES) $(APPLE_SOURCES) $(ALL_H)
+
+libplayer_a_CXXFLAGS = -DPREFIXDIR=\"$(prefix)\"
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .m .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/player/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/player/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libplayer.la: $(libplayer_la_OBJECTS) $(libplayer_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libplayer_la_OBJECTS) $(libplayer_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+testcalibrator$(EXEEXT): $(testcalibrator_OBJECTS) $(testcalibrator_DEPENDENCIES)
+ @rm -f testcalibrator$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(testcalibrator_OBJECTS) $(testcalibrator_LDADD) $(LIBS)
+testplayer$(EXEEXT): $(testplayer_OBJECTS) $(testplayer_DEPENDENCIES)
+ @rm -f testplayer$(EXEEXT)
+ $(AM_V_CXXLD)$(testplayer_LINK) $(testplayer_OBJECTS) $(testplayer_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AVGNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AppleTrackpadInputDevice.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AreaNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Arg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ArgBase.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ArgList.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/BlurFXNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CameraNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Canvas.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CanvasNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ChromaKeyFXNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CircleNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Contact.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CursorEvent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CursorState.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/CurveNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisplayEngine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DisplayParams.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/DivNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Event.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/EventDispatcher.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FXNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FilledVectorNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/HueSatFXNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Image.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ImageNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/InvertFXNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/KeyEvent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LibMTDevInputDevice.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/LineNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MainCanvas.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MaterialInfo.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MeshNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MouseEvent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/MultitouchInputDevice.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Node.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NodeDefinition.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NodeRegistry.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/NullFXNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OGLSurface.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OffscreenCanvas.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/OffscreenCanvasNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PanoImageNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Player.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PluginManager.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PolyLineNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PolygonNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RasterNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/RectNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SDLDisplayEngine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SDLMain.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVG.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SVGElement.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ShadowFXNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Shape.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SoundNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TUIOInputDevice.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TestHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TextEngine.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/Timeout.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TouchEvent.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TouchStatus.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerCalibrator.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerInputDevice.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/TrackerTouchStatus.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VectorNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoWriter.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoWriterThread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WordsNode.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/XInputMTInputDevice.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testcalibrator.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testplayer.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+.m.o:
+@am__fastdepOBJC_TRUE@ $(AM_V_OBJC)$(OBJCCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepOBJC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepOBJC_FALSE@ $(AM_V_OBJC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepOBJC_FALSE@ $(OBJCCOMPILE) -c -o $@ $<
+
+.m.obj:
+@am__fastdepOBJC_TRUE@ $(AM_V_OBJC)$(OBJCCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepOBJC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepOBJC_FALSE@ $(AM_V_OBJC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepOBJC_FALSE@ $(OBJCCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.m.lo:
+@am__fastdepOBJC_TRUE@ $(AM_V_OBJC)$(LTOBJCCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepOBJC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepOBJC_FALSE@ $(AM_V_OBJC) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepOBJC_FALSE@ DEPDIR=$(DEPDIR) $(OBJCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepOBJC_FALSE@ $(LTOBJCCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/player/MaterialInfo.cpp b/src/player/MaterialInfo.cpp
new file mode 100644
index 0000000..f77d89e
--- /dev/null
+++ b/src/player/MaterialInfo.cpp
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "MaterialInfo.h"
+
+#include "../base/Exception.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+MaterialInfo::MaterialInfo(int wrapSMode, int wrapTMode, bool bUseMipmaps)
+ : m_WrapSMode(wrapSMode),
+ m_WrapTMode(wrapTMode),
+ m_bUseMipmaps(bUseMipmaps)
+{}
+
+int MaterialInfo::getWrapSMode() const
+{
+ return m_WrapSMode;
+}
+
+int MaterialInfo::getWrapTMode() const
+{
+ return m_WrapTMode;
+}
+
+bool MaterialInfo::getUseMipmaps() const
+{
+ return m_bUseMipmaps;
+}
+
+}
diff --git a/src/player/MaterialInfo.h b/src/player/MaterialInfo.h
new file mode 100644
index 0000000..871e48f
--- /dev/null
+++ b/src/player/MaterialInfo.h
@@ -0,0 +1,49 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _MaterialInfo_H_
+#define _MaterialInfo_H_
+
+#include "../api.h"
+
+#include "../base/Point.h"
+
+namespace avg {
+
+class AVG_API MaterialInfo {
+public:
+ MaterialInfo(int wrapSMode, int wrapTMode, bool bUseMipmaps);
+
+ int getWrapSMode() const;
+ int getWrapTMode() const;
+ bool getUseMipmaps() const;
+
+private:
+ int m_WrapSMode;
+ int m_WrapTMode;
+ bool m_bUseMipmaps;
+};
+
+}
+
+#endif
+
+
diff --git a/src/player/MeshNode.cpp b/src/player/MeshNode.cpp
new file mode 100644
index 0000000..363e00a
--- /dev/null
+++ b/src/player/MeshNode.cpp
@@ -0,0 +1,142 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "MeshNode.h"
+
+#include "../wrapper/WrapHelper.h"
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+
+#include "NodeDefinition.h"
+#include "VectorNode.h"
+
+#include <cstdlib>
+#include <string>
+#include <iostream>
+
+using namespace std;
+using namespace boost::python;
+
+namespace avg {
+
+NodeDefinition MeshNode::createDefinition()
+{
+ vector<DPoint> vVert;
+ vector<DPoint> vTex;
+ vector<IntTriple> vTriangle;
+
+ return NodeDefinition("mesh", (NodeBuilder)MeshNode::buildNode<MeshNode>)
+ .extendDefinition(VectorNode::createDefinition())
+ .addArg(Arg<vector<DPoint> >("vertexcoords", vVert, false,
+ offsetof(MeshNode, m_VertexCoords)))
+ .addArg(Arg<vector<DPoint> >("texcoords", vTex, false,
+ offsetof(MeshNode, m_TexCoords)))
+ .addArg(Arg<vector<IntTriple> >("triangles", vTriangle, false,
+ offsetof(MeshNode, m_Triangles)))
+ ;
+}
+
+MeshNode::MeshNode(const ArgList& args)
+ : VectorNode(args)
+{
+ args.setMembers(this);
+ isValid(m_TexCoords);
+}
+
+MeshNode::~MeshNode()
+{
+}
+
+void MeshNode::isValid(const vector<DPoint>& coords)
+{
+ if (coords.size() != m_VertexCoords.size()) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Coordinates Out of Range"));
+ }
+}
+
+const vector<DPoint>& MeshNode::getVertexCoords() const
+{
+ return m_VertexCoords;
+}
+
+void MeshNode::setVertexCoords(const vector<DPoint>& coords)
+{
+ isValid(coords);
+ m_VertexCoords = coords;
+ setDrawNeeded();
+}
+
+const vector<DPoint>& MeshNode::getTexCoords() const
+{
+ return m_TexCoords;
+}
+
+void MeshNode::setTexCoords(const vector<DPoint>& coords)
+{
+ isValid(coords);
+ m_TexCoords = coords;
+ setDrawNeeded();
+}
+
+const vector<IntTriple>& MeshNode::getTriangles() const
+{
+ return m_Triangles;
+}
+
+
+void MeshNode::setTriangles(const vector<IntTriple>& triangles)
+{
+ for (unsigned int i = 0; i < triangles.size(); i++) {
+
+ if (static_cast<unsigned int>(triangles[i].x) < 0 ||
+ static_cast<unsigned int>(triangles[i].y) < 0 ||
+ static_cast<unsigned int>(triangles[i].z) < 0)
+ {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Triangle Index Out of Range < 0"));
+ }
+
+ if (static_cast<unsigned int>(triangles[i].x) > m_VertexCoords.size() ||
+ static_cast<unsigned int>(triangles[i].y) > m_VertexCoords.size() ||
+ static_cast<unsigned int>(triangles[i].z) > m_VertexCoords.size())
+ {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Triangle Index Out of Range > max triangles"));
+ }
+ }
+ m_Triangles = triangles;
+ setDrawNeeded();
+}
+
+void MeshNode::calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ for (unsigned int i = 0; i < m_VertexCoords.size(); i++) {
+ pVertexArray->appendPos(m_VertexCoords[i],m_TexCoords[i], color);
+ }
+
+ for (unsigned int i = 0; i < m_Triangles.size(); i++) {
+ pVertexArray->appendTriIndexes(m_Triangles[i].x, m_Triangles[i].y,
+ m_Triangles[i].z);
+ }
+}
+
+}
diff --git a/src/player/MeshNode.h b/src/player/MeshNode.h
new file mode 100644
index 0000000..5f8f40b
--- /dev/null
+++ b/src/player/MeshNode.h
@@ -0,0 +1,62 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#ifndef _MeshNode_H_
+#define _MeshNode_H_
+
+#include "../api.h"
+#include "VectorNode.h"
+#include "../graphics/Pixel32.h"
+#include "../base/Triple.h"
+#include <vector>
+
+namespace avg {
+
+class AVG_API MeshNode : public VectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ MeshNode(const ArgList& args);
+ virtual ~MeshNode();
+
+ void isValid(const std::vector<DPoint>& coords);
+
+ const std::vector<DPoint>& getVertexCoords() const;
+ void setVertexCoords(const std::vector<DPoint>& coords);
+
+ const std::vector<DPoint>& getTexCoords() const;
+ void setTexCoords(const std::vector<DPoint>& coords);
+
+ const std::vector<IntTriple>& getTriangles() const;
+ void setTriangles(const std::vector<IntTriple>& pts);
+
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+
+ private:
+ std::vector<DPoint> m_TexCoords;
+ std::vector<DPoint> m_VertexCoords;
+ std::vector<IntTriple> m_Triangles;
+};
+}
+#endif
+
diff --git a/src/player/MouseEvent.cpp b/src/player/MouseEvent.cpp
new file mode 100644
index 0000000..39acc83
--- /dev/null
+++ b/src/player/MouseEvent.cpp
@@ -0,0 +1,89 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "MouseEvent.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+MouseEvent::MouseEvent(Event::Type eventType,
+ bool leftButtonState, bool middleButtonState, bool rightButtonState,
+ const IntPoint& pos, int button, const DPoint& speed, int when)
+ : CursorEvent(MOUSECURSORID, eventType, pos, MOUSE, when)
+{
+ m_LeftButtonState = leftButtonState;
+ m_MiddleButtonState = middleButtonState;
+ m_RightButtonState = rightButtonState;
+ m_Button = button;
+ setSpeed(speed);
+}
+
+MouseEvent::~MouseEvent()
+{
+}
+
+int MouseEvent::getButton() const
+{
+ return m_Button;
+}
+
+bool MouseEvent::getLeftButtonState() const
+{
+ return m_LeftButtonState;
+}
+
+bool MouseEvent::getMiddleButtonState() const
+{
+ return m_MiddleButtonState;
+}
+
+bool MouseEvent::getRightButtonState() const
+{
+ return m_RightButtonState;
+}
+
+bool MouseEvent::isAnyButtonPressed() const
+{
+ return m_LeftButtonState || m_MiddleButtonState || m_RightButtonState;
+}
+
+void MouseEvent::trace()
+{
+ CursorEvent::trace();
+ AVG_TRACE(Logger::EVENTS2, "pos: " << getPos()
+ << ", button: " << m_Button);
+}
+
+CursorEventPtr MouseEvent::cloneAs(Type EventType) const
+{
+ MouseEventPtr pClone(new MouseEvent(*this));
+ pClone->m_Type = EventType;
+ return pClone;
+}
+
+}
diff --git a/src/player/MouseEvent.h b/src/player/MouseEvent.h
new file mode 100644
index 0000000..0c8e3ab
--- /dev/null
+++ b/src/player/MouseEvent.h
@@ -0,0 +1,66 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _MouseEvent_h_
+#define _MouseEvent_h_
+
+#include "../api.h"
+#include "Event.h"
+#include "CursorEvent.h"
+
+namespace avg {
+
+class AVG_API MouseEvent : public CursorEvent {
+ public:
+ MouseEvent(Event::Type eventType,
+ bool leftButtonState, bool middleButtonState, bool rightButtonState,
+ const IntPoint& pos, int button, const DPoint& speed=DPoint(0,0),
+ int when=-1);
+ virtual ~MouseEvent();
+
+ //REFACTORME: get*ButtonState -> getButtonState(num=*)
+ bool getLeftButtonState() const;
+ bool getMiddleButtonState() const;
+ bool getRightButtonState() const;
+ bool isAnyButtonPressed() const;
+ int getButton() const;
+ virtual CursorEventPtr cloneAs(Type EventType) const;
+ virtual void trace();
+ static const long NO_BUTTON=0;
+ static const long LEFT_BUTTON=1;
+ static const long RIGHT_BUTTON=2;
+ static const long MIDDLE_BUTTON=3;
+ static const long WHEELUP_BUTTON=4;
+ static const long WHEELDOWN_BUTTON=5;
+
+ private:
+ bool m_LeftButtonState;
+ bool m_MiddleButtonState;
+ bool m_RightButtonState;
+ int m_Button;
+};
+
+typedef boost::shared_ptr<class MouseEvent> MouseEventPtr;
+
+}
+
+#endif
+
diff --git a/src/player/MultitouchInputDevice.cpp b/src/player/MultitouchInputDevice.cpp
new file mode 100644
index 0000000..b89aaef
--- /dev/null
+++ b/src/player/MultitouchInputDevice.cpp
@@ -0,0 +1,128 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "MultitouchInputDevice.h"
+#include "TouchEvent.h"
+#include "Player.h"
+#include "AVGNode.h"
+#include "TouchStatus.h"
+
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+using namespace std;
+
+namespace avg {
+
+MultitouchInputDevice::MultitouchInputDevice()
+ : IInputDevice(EXTRACT_INPUTDEVICE_CLASSNAME(MultitouchInputDevice))
+{
+}
+
+MultitouchInputDevice::~MultitouchInputDevice()
+{
+}
+
+void MultitouchInputDevice::start()
+{
+ m_WindowSize = Player::get()->getRootNode()->getSize();
+ m_pMutex = MutexPtr(new boost::mutex);
+}
+
+vector<EventPtr> MultitouchInputDevice::pollEvents()
+{
+ boost::mutex::scoped_lock lock(*m_pMutex);
+
+ vector<EventPtr> events;
+ vector<TouchStatusPtr>::iterator it;
+// cerr << "--------poll---------" << endl;
+ for (it = m_Touches.begin(); it != m_Touches.end(); ) {
+// cerr << it->first << " ";
+ CursorEventPtr pEvent = (*it)->pollEvent();
+ if (pEvent) {
+ events.push_back(pEvent);
+ if (pEvent->getType() == Event::CURSORUP) {
+ it = m_Touches.erase(it);
+ } else {
+ ++it;
+ }
+ } else {
+ ++it;
+ }
+ }
+// cerr << endl;
+ return events;
+}
+
+const DPoint& MultitouchInputDevice::getWindowSize() const
+{
+ return m_WindowSize;
+}
+
+int MultitouchInputDevice::getNumTouches() const
+{
+ return m_TouchIDMap.size();
+}
+
+TouchStatusPtr MultitouchInputDevice::getTouchStatus(int id)
+{
+ map<int, TouchStatusPtr>::iterator it = m_TouchIDMap.find(id);
+ if (it == m_TouchIDMap.end()) {
+ return TouchStatusPtr();
+ } else {
+ return it->second;
+ }
+}
+
+void MultitouchInputDevice::addTouchStatus(int id, TouchEventPtr pInitialEvent)
+{
+ TouchStatusPtr pTouchStatus(new TouchStatus(pInitialEvent));
+ m_TouchIDMap[id] = pTouchStatus;
+ m_Touches.push_back(pTouchStatus);
+}
+
+void MultitouchInputDevice::removeTouchStatus(int id)
+{
+ unsigned numRemoved = m_TouchIDMap.erase(id);
+ AVG_ASSERT(numRemoved == 1);
+}
+
+void MultitouchInputDevice::getDeadIDs(const set<int>& liveIDs, set<int>& deadIDs)
+{
+ map<int, TouchStatusPtr>::iterator it;
+ for (it = m_TouchIDMap.begin(); it != m_TouchIDMap.end(); ++it) {
+ int id = it->first;
+ set<int>::const_iterator foundIt = liveIDs.find(id);
+ if (foundIt == liveIDs.end()) {
+ deadIDs.insert(id);
+ }
+ }
+}
+
+boost::mutex& MultitouchInputDevice::getMutex()
+{
+ return *m_pMutex;
+}
+
+}
diff --git a/src/player/MultitouchInputDevice.h b/src/player/MultitouchInputDevice.h
new file mode 100644
index 0000000..71aa2c5
--- /dev/null
+++ b/src/player/MultitouchInputDevice.h
@@ -0,0 +1,76 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _MultitouchInputDevice_H_
+#define _MultitouchInputDevice_H_
+
+#include "../api.h"
+#include "IInputDevice.h"
+
+#include "../base/Point.h"
+
+#include <boost/thread.hpp>
+#include <map>
+#include <set>
+
+typedef boost::shared_ptr<boost::mutex> MutexPtr;
+
+namespace avg {
+
+class TouchStatus;
+typedef boost::shared_ptr<class TouchStatus> TouchStatusPtr;
+class TouchEvent;
+typedef boost::shared_ptr<class TouchEvent> TouchEventPtr;
+class Event;
+typedef boost::shared_ptr<Event> EventPtr;
+
+class AVG_API MultitouchInputDevice: public IInputDevice
+{
+public:
+ MultitouchInputDevice();
+ virtual ~MultitouchInputDevice() = 0;
+ virtual void start();
+
+ std::vector<EventPtr> pollEvents();
+
+protected:
+ const DPoint& getWindowSize() const;
+ int getNumTouches() const;
+ // Note that the id used here is not the libavg cursor id but a touch-driver-specific
+ // id handed up from the driver level.
+ TouchStatusPtr getTouchStatus(int id);
+ void addTouchStatus(int id, TouchEventPtr pInitialEvent);
+ void removeTouchStatus(int id);
+ void getDeadIDs(const std::set<int>& liveIDs, std::set<int>& deadIDs);
+ boost::mutex& getMutex();
+
+private:
+ std::map<int, TouchStatusPtr> m_TouchIDMap;
+ std::vector<TouchStatusPtr> m_Touches;
+ DPoint m_WindowSize;
+ MutexPtr m_pMutex;
+};
+
+typedef boost::shared_ptr<MultitouchInputDevice> MultitouchInputDevicePtr;
+
+}
+
+#endif
diff --git a/src/player/Node.cpp b/src/player/Node.cpp
new file mode 100644
index 0000000..eeedc5f
--- /dev/null
+++ b/src/player/Node.cpp
@@ -0,0 +1,620 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Node.h"
+
+#include "NodeDefinition.h"
+#include "Arg.h"
+#include "Canvas.h"
+#include "DivNode.h"
+#include "Player.h"
+#include "CursorEvent.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+#include "../base/StringHelper.h"
+#include "../base/OSHelper.h"
+
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition Node::createDefinition()
+{
+ return NodeDefinition("node")
+ .addArg(Arg<string>("id", "", false, offsetof(Node, m_ID)))
+ .addArg(Arg<string>("oncursormove", ""))
+ .addArg(Arg<string>("oncursorup", ""))
+ .addArg(Arg<string>("oncursordown", ""))
+ .addArg(Arg<string>("oncursorover", ""))
+ .addArg(Arg<string>("oncursorout", ""))
+ .addArg(Arg<bool>("active", true, false, offsetof(Node, m_bActive)))
+ .addArg(Arg<bool>("sensitive", true, false, offsetof(Node, m_bSensitive)))
+ .addArg(Arg<double>("opacity", 1.0, false, offsetof(Node, m_Opacity)));
+}
+
+Node::Node()
+ : m_pCanvas(),
+ m_State(NS_UNCONNECTED)
+
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+Node::~Node()
+{
+ m_EventHandlerMap.clear();
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void Node::setArgs(const ArgList& args)
+{
+ addArgEventHandlers(Event::CURSORMOTION, args.getArgVal<string> ("oncursormove"));
+ addArgEventHandlers(Event::CURSORUP, args.getArgVal<string> ("oncursorup"));
+ addArgEventHandlers(Event::CURSORDOWN, args.getArgVal<string> ("oncursordown"));
+ addArgEventHandlers(Event::CURSOROVER, args.getArgVal<string> ("oncursorover"));
+ addArgEventHandlers(Event::CURSOROUT, args.getArgVal<string> ("oncursorout"));
+}
+
+void Node::setTypeInfo(const NodeDefinition * pDefinition)
+{
+ m_pDefinition = pDefinition;
+}
+
+void Node::checkSetParentError(DivNodeWeakPtr pParent)
+{
+ if (getParent() && !!(pParent.lock())) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ string("Can't change parent of node (") + getID() + ")."));
+ }
+}
+
+void Node::setParent(DivNodeWeakPtr pParent, NodeState parentState,
+ CanvasPtr pCanvas)
+{
+ AVG_ASSERT(getState() == NS_UNCONNECTED);
+ checkSetParentError(pParent);
+ m_pParent = pParent;
+ if (parentState != NS_UNCONNECTED) {
+ connect(pCanvas);
+ }
+}
+
+void Node::removeParent()
+{
+ m_pParent = DivNodePtr();
+}
+
+DivNodePtr Node::getParent() const
+{
+ if (m_pParent.expired()) {
+ return DivNodePtr();
+ } else {
+ return m_pParent.lock();
+ }
+}
+
+vector<NodeWeakPtr> Node::getParentChain()
+{
+ vector<NodeWeakPtr> pNodes;
+ boost::shared_ptr<Node> pCurNode = shared_from_this();
+ while (pCurNode) {
+ pNodes.push_back(pCurNode);
+ pCurNode = pCurNode->getParent();
+ }
+ return pNodes;
+}
+
+void Node::connectDisplay()
+{
+ AVG_ASSERT(getState() == NS_CONNECTED);
+ setState(NS_CANRENDER);
+}
+
+void Node::connect(CanvasPtr pCanvas)
+{
+ m_pCanvas = pCanvas;
+ setState(NS_CONNECTED);
+}
+
+void Node::disconnect(bool bKill)
+{
+ AVG_ASSERT(getState() != NS_UNCONNECTED);
+ m_pCanvas.lock()->removeNodeID(getID());
+ setState(NS_UNCONNECTED);
+ if (bKill) {
+ m_EventHandlerMap.clear();
+ }
+}
+
+void Node::unlink(bool bKill)
+{
+ DivNodePtr pParent = getParent();
+ if (pParent != DivNodePtr()) {
+ pParent->removeChild(shared_from_this(), bKill);
+ }
+}
+
+const string& Node::getID() const
+{
+ return m_ID;
+}
+
+void Node::setID(const std::string& id)
+{
+ if (getState() != NS_UNCONNECTED) {
+ throw Exception(AVG_ERR_UNSUPPORTED, "Node with ID "+getID()
+ +" is connected. setID invalid.");
+ }
+ m_ID = id;
+}
+
+double Node::getOpacity() const
+{
+ return m_Opacity;
+}
+
+void Node::setOpacity(double opacity)
+{
+ m_Opacity = opacity;
+ if (m_Opacity < 0.0) {
+ m_Opacity = 0.0;
+ } else if (m_Opacity > 1.0) {
+ m_Opacity = 1.0;
+ }
+}
+
+bool Node::getActive() const
+{
+ return m_bActive;
+}
+
+void Node::setActive(bool bActive)
+{
+ if (bActive != m_bActive) {
+ m_bActive = bActive;
+ }
+}
+
+bool Node::getSensitive() const
+{
+ return m_bSensitive;
+}
+
+void Node::setSensitive(bool bSensitive)
+{
+ m_bSensitive = bSensitive;
+}
+
+void Node::setMouseEventCapture()
+{
+ setEventCapture(MOUSECURSORID);
+}
+
+void Node::releaseMouseEventCapture()
+{
+ releaseEventCapture(MOUSECURSORID);
+}
+
+void Node::setEventCapture(int cursorID)
+{
+ Player::get()->setEventCapture(shared_from_this(), cursorID);
+}
+
+void Node::releaseEventCapture(int cursorID)
+{
+ Player::get()->releaseEventCapture(cursorID);
+}
+
+void Node::setEventHandler(Event::Type type, int sources, PyObject * pFunc)
+{
+ for (int source = 1; source <= Event::NONE; source *= 2) {
+ if (source & sources) {
+ EventID id(type, (Event::Source)source);
+ EventHandlerMap::iterator it = m_EventHandlerMap.find(id);
+ if (it != m_EventHandlerMap.end()) {
+ m_EventHandlerMap.erase(it);
+ }
+ if (pFunc != Py_None) {
+ connectOneEventHandler(id, Py_None, pFunc);
+ }
+ }
+ }
+}
+
+void Node::connectEventHandler(Event::Type type, int sources,
+ PyObject * pObj, PyObject * pFunc)
+{
+ for (int source = 1; source <= Event::NONE; source *= 2) {
+ if (source & sources) {
+ EventID id(type, (Event::Source)source);
+ connectOneEventHandler(id, pObj, pFunc);
+ }
+ }
+// cerr << "connectEventHandler" << endl;
+// dumpEventHandlers();
+}
+
+void Node::disconnectEventHandler(PyObject * pObj, PyObject * pFunc)
+{
+ int numDisconnected = 0;
+ EventHandlerMap::iterator it;
+ for (it = m_EventHandlerMap.begin(); it != m_EventHandlerMap.end();) {
+ EventHandlerArrayPtr pEventHandlers = it->second;
+ EventHandlerArray::iterator listIt;
+ for (listIt = pEventHandlers->begin(); listIt != pEventHandlers->end();)
+ {
+ EventHandler& eventHandler = *listIt;
+ if (eventHandler.m_pObj == pObj &&
+ (pFunc == 0 ||
+ PyObject_RichCompareBool(eventHandler.m_pMethod, pFunc, Py_EQ)))
+ {
+ listIt = pEventHandlers->erase(listIt);
+ numDisconnected++;
+ } else {
+ ++listIt;
+ }
+ }
+
+ if (pEventHandlers->empty()) {
+ EventHandlerMap::iterator itErase = it;
+ ++it;
+ m_EventHandlerMap.erase(itErase);
+ } else {
+ ++it;
+ }
+ }
+// cerr << "disconnectEventHandler" << endl;
+// dumpEventHandlers();
+}
+
+bool Node::reactsToMouseEvents()
+{
+ return m_bActive && m_bSensitive;
+}
+
+DPoint Node::getRelPos(const DPoint& absPos) const
+{
+ DPoint parentPos;
+ if (m_pParent.expired()) {
+ parentPos = absPos;
+ } else {
+ parentPos = m_pParent.lock()->getRelPos(absPos);
+ }
+ return toLocal(parentPos);
+}
+
+DPoint Node::getAbsPos(const DPoint& relPos) const
+{
+ DPoint thisPos = toGlobal(relPos);
+ DPoint parentPos;
+ if (m_pParent.expired()) {
+ parentPos = thisPos;
+ } else {
+ parentPos = m_pParent.lock()->getAbsPos(thisPos);
+ }
+ return parentPos;
+}
+
+DPoint Node::toLocal(const DPoint& globalPos) const
+{
+ return globalPos;
+}
+
+DPoint Node::toGlobal(const DPoint& localPos) const
+{
+ return localPos;
+}
+
+NodePtr Node::getElementByPos(const DPoint& pos)
+{
+ vector<NodeWeakPtr> elements;
+ getElementsByPos(pos, elements);
+ if (elements.empty()) {
+ return NodePtr();
+ } else {
+ return elements[0].lock();
+ }
+}
+
+void Node::getElementsByPos(const DPoint& pos,
+ vector<NodeWeakPtr>& pElements)
+{
+}
+
+void Node::preRender()
+{
+ if (getParent()) {
+ m_EffectiveOpacity = m_Opacity*getParent()->getEffectiveOpacity();
+ } else {
+ m_EffectiveOpacity = m_Opacity;
+ }
+}
+
+Node::NodeState Node::getState() const
+{
+ return m_State;
+}
+
+CanvasPtr Node::getCanvas() const
+{
+ return m_pCanvas.lock();
+}
+
+bool Node::handleEvent(EventPtr pEvent)
+{
+ EventID id(pEvent->getType(), pEvent->getSource());
+ EventHandlerMap::iterator it = m_EventHandlerMap.find(id);
+ if (it != m_EventHandlerMap.end()) {
+ bool bHandled = false;
+ // We need to copy the array because python code in callbacks can
+ /// connect and disconnect event handlers.
+ EventHandlerArray eventHandlers = *(it->second);
+ EventHandlerArray::iterator listIt;
+ for (listIt = eventHandlers.begin(); listIt != eventHandlers.end(); ++listIt) {
+ bHandled = callPython(listIt->m_pMethod, pEvent);
+ }
+ return bHandled;
+ } else {
+ return false;
+ }
+}
+
+void Node::addArgEventHandlers(Event::Type eventType, const string& sCode)
+{
+ addArgEventHandler(eventType, Event::MOUSE, sCode);
+ addArgEventHandler(eventType, Event::TOUCH, sCode);
+ addArgEventHandler(eventType, Event::TRACK, sCode);
+}
+
+void Node::addArgEventHandler(Event::Type eventType, Event::Source source,
+ const string& sCode)
+{
+ PyObject * pFunc = findPythonFunc(sCode);
+ if (pFunc) {
+ EventID id(eventType, source);
+ connectOneEventHandler(id, Py_None, pFunc);
+ }
+}
+
+double Node::getEffectiveOpacity() const
+{
+ return m_EffectiveOpacity;
+}
+
+string Node::dump(int indent)
+{
+ string dumpStr = string(indent, ' ') + getTypeStr() + ": m_ID=" + getID() +
+ "m_Opacity=" + toString(m_Opacity);
+ return dumpStr;
+}
+
+void Node::setState(Node::NodeState state)
+{
+/*
+ cerr << m_ID << " state: ";
+ switch(state) {
+ case NS_UNCONNECTED:
+ cerr << "unconnected" << endl;
+ break;
+ case NS_CONNECTED:
+ cerr << "connected" << endl;
+ break;
+ case NS_CANRENDER:
+ cerr << "canrender" << endl;
+ break;
+ }
+*/
+ if (m_State == NS_UNCONNECTED) {
+ AVG_ASSERT(state != NS_CANRENDER);
+ }
+ if (m_State == NS_CANRENDER) {
+ AVG_ASSERT(state != NS_CONNECTED);
+ }
+
+ m_State = state;
+}
+
+void Node::initFilename(string& sFilename)
+{
+ if (sFilename != "") {
+ bool bAbsDir = sFilename[0] == '/';
+#ifdef _WIN32
+ if (!bAbsDir) {
+ bAbsDir = (sFilename[0] == '\\' || sFilename[1] == ':');
+ }
+#endif
+ if (!bAbsDir) {
+ DivNodePtr pParent = getParent();
+ if (!pParent) {
+ sFilename = Player::get()->getRootMediaDir()+sFilename;
+ } else {
+ sFilename = pParent->getEffectiveMediaDir()+sFilename;
+ }
+ }
+ }
+}
+
+void Node::checkReload(const std::string& sHRef, const ImagePtr& pImage,
+ Image::TextureCompression comp)
+{
+ string sLastFilename = pImage->getFilename();
+ string sFilename = sHRef;
+ initFilename(sFilename);
+ if (sLastFilename != sFilename) {
+ try {
+ sFilename = convertUTF8ToFilename(sFilename);
+ if (sHRef == "") {
+ pImage->setEmpty();
+ } else {
+ pImage->setFilename(sFilename, comp);
+ }
+ } catch (Exception& ex) {
+ pImage->setEmpty();
+ if (getState() != Node::NS_UNCONNECTED) {
+ AVG_TRACE(Logger::ERROR, ex.getStr());
+ } else {
+ AVG_TRACE(Logger::MEMORY, ex.getStr());
+ }
+ }
+ }
+}
+
+bool Node::isVisible() const
+{
+ return getEffectiveActive() && getEffectiveOpacity() > 0.01;
+}
+
+bool Node::getEffectiveActive() const
+{
+ if (getParent()) {
+ return m_bActive && getParent()->getEffectiveActive();
+ } else {
+ return m_bActive;
+ }
+}
+
+void Node::connectOneEventHandler(const EventID& id, PyObject * pObj,
+ PyObject * pFunc)
+{
+ EventHandlerMap::iterator it = m_EventHandlerMap.find(id);
+ EventHandlerArrayPtr pEventHandlers;
+ if (it == m_EventHandlerMap.end()) {
+ pEventHandlers = EventHandlerArrayPtr(new EventHandlerArray);
+ m_EventHandlerMap[id] = pEventHandlers;
+ } else {
+ pEventHandlers = it->second;
+ }
+ pEventHandlers->push_back(EventHandler(pObj, pFunc));
+}
+
+void Node::dumpEventHandlers()
+{
+ EventHandlerMap::iterator it;
+ cerr << "-----" << endl;
+ for (it = m_EventHandlerMap.begin(); it != m_EventHandlerMap.end(); ++it) {
+ EventID id = it->first;
+ EventHandlerArrayPtr pEventHandlers = it->second;
+ cerr << "type: " << id.m_Type << ", source: " << id.m_Source << endl;
+ EventHandlerArray::iterator listIt;
+ for (listIt = pEventHandlers->begin(); listIt != pEventHandlers->end(); ++listIt)
+ {
+ EventHandler& handler = *listIt;
+ cerr << " " << handler.m_pObj << ", " << handler.m_pMethod
+ << endl;
+ }
+ }
+ cerr << "-----" << endl;
+}
+
+PyObject * Node::findPythonFunc(const string& sCode)
+{
+ if (sCode.empty()) {
+ return 0;
+ } else {
+ PyObject * pModule = PyImport_AddModule("__main__");
+ if (!pModule) {
+ cerr << "Could not find module __main__." << endl;
+ exit(-1);
+ }
+ PyObject * pDict = PyModule_GetDict(pModule);
+ PyObject * pFunc = PyDict_GetItemString(pDict, sCode.c_str());
+ if (!pFunc) {
+ AVG_TRACE(Logger::ERROR, "Function \"" << sCode <<
+ "\" not defined for node with id '"+getID()+"'. Aborting.");
+ exit(-1);
+ }
+ return pFunc;
+ }
+}
+
+bool Node::callPython(PyObject * pFunc, EventPtr pEvent)
+{
+ bool bOk = boost::python::call<bool>(pFunc, pEvent);
+ return bOk;
+}
+
+bool Node::operator ==(const Node& other) const
+{
+ return this == &other;
+}
+
+bool Node::operator !=(const Node& other) const
+{
+ return this != &other;
+}
+
+long Node::getHash() const
+{
+ return long(this);
+}
+
+const NodeDefinition* Node::getDefinition() const
+{
+ return m_pDefinition;
+}
+
+string Node::getTypeStr() const
+{
+ return m_pDefinition->getName();
+}
+
+Node::EventID::EventID(Event::Type eventType, Event::Source source)
+ : m_Type(eventType),
+ m_Source(source)
+{
+}
+
+bool Node::EventID::operator < (const EventID& other) const
+{
+ if (m_Type == other.m_Type) {
+ return m_Source < other.m_Source;
+ } else {
+ return m_Type < other.m_Type;
+ }
+}
+
+Node::EventHandler::EventHandler(PyObject * pObj, PyObject * pMethod)
+{
+ Py_INCREF(pObj);
+ m_pObj = pObj;
+ Py_INCREF(pMethod);
+ m_pMethod = pMethod;
+}
+
+Node::EventHandler::EventHandler(const EventHandler& other)
+{
+ Py_INCREF(other.m_pObj);
+ m_pObj = other.m_pObj;
+ Py_INCREF(other.m_pMethod);
+ m_pMethod = other.m_pMethod;
+}
+
+Node::EventHandler::~EventHandler()
+{
+ Py_DECREF(m_pObj);
+ Py_DECREF(m_pMethod);
+}
+
+}
diff --git a/src/player/Node.h b/src/player/Node.h
new file mode 100644
index 0000000..1130607
--- /dev/null
+++ b/src/player/Node.h
@@ -0,0 +1,214 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Node_H_
+#define _Node_H_
+
+#include "../api.h"
+
+#include "Event.h"
+#include "Image.h"
+
+#include "../base/Rect.h"
+#include "../graphics/Pixel32.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <boost/enable_shared_from_this.hpp>
+
+#include <string>
+#include <vector>
+
+// Python docs say python.h should be included before any standard headers (!)
+#include "WrapPython.h"
+
+#include <string>
+#include <list>
+#include <map>
+
+namespace avg {
+
+class Node;
+typedef boost::shared_ptr<Node> NodePtr;
+typedef boost::weak_ptr<Node> NodeWeakPtr;
+class DivNode;
+typedef boost::shared_ptr<DivNode> DivNodePtr;
+typedef boost::weak_ptr<DivNode> DivNodeWeakPtr;
+class ArgList;
+class NodeDefinition;
+
+class CanvasNode;
+typedef boost::shared_ptr<CanvasNode> CanvasNodePtr;
+typedef boost::weak_ptr<CanvasNode> CanvasNodeWeakPtr;
+class AVGNode;
+typedef boost::shared_ptr<AVGNode> AVGNodePtr;
+typedef boost::weak_ptr<AVGNode> AVGNodeWeakPtr;
+class Image;
+typedef boost::shared_ptr<Image> ImagePtr;
+class VertexArray;
+typedef boost::shared_ptr<VertexArray> VertexArrayPtr;
+class Canvas;
+typedef boost::shared_ptr<Canvas> CanvasPtr;
+typedef boost::weak_ptr<Canvas> CanvasWeakPtr;
+
+class AVG_API Node: public boost::enable_shared_from_this<Node>
+{
+ public:
+ enum NodeState {NS_UNCONNECTED, NS_CONNECTED, NS_CANRENDER};
+
+ static NodeDefinition createDefinition();
+ template<class NodeType>
+ static NodePtr buildNode(const ArgList& Args)
+ {
+ return NodePtr(new NodeType(Args));
+ }
+ virtual void setTypeInfo(const NodeDefinition * pDefinition);
+
+ virtual ~Node();
+ virtual void setArgs(const ArgList& args);
+ virtual void setParent(DivNodeWeakPtr pParent, NodeState parentState,
+ CanvasPtr pCanvas);
+ virtual void removeParent();
+ void checkSetParentError(DivNodeWeakPtr pParent);
+ DivNodePtr getParent() const;
+ std::vector<NodeWeakPtr> getParentChain();
+
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+ void unlink(bool bKill=false);
+
+ virtual void checkReload() {};
+
+ virtual void setID(const std::string& ID);
+
+ double getOpacity() const;
+ void setOpacity(double opacity);
+
+ bool getActive() const;
+ void setActive(bool bActive);
+
+ bool getSensitive() const;
+ void setSensitive(bool bSensitive);
+
+ void setMouseEventCapture();
+ void releaseMouseEventCapture();
+ void setEventCapture(int cursorID);
+ void releaseEventCapture(int cursorID);
+ void setEventHandler(Event::Type Type, int Sources, PyObject * pFunc);
+ void connectEventHandler(Event::Type type, int sources,
+ PyObject * pObj, PyObject * pFunc);
+ void disconnectEventHandler(PyObject * pObj, PyObject * pFunc=0);
+
+ DPoint getRelPos(const DPoint& absPos) const;
+ DPoint getAbsPos(const DPoint& relPos) const;
+ virtual DPoint toLocal(const DPoint& pos) const;
+ virtual DPoint toGlobal(const DPoint& pos) const;
+ NodePtr getElementByPos(const DPoint& pos);
+ virtual void getElementsByPos(const DPoint& pos,
+ std::vector<NodeWeakPtr>& pElements);
+
+ virtual void preRender();
+ virtual void maybeRender(const DRect& Rect) {};
+ virtual void render(const DRect& Rect) {};
+
+ double getEffectiveOpacity() const;
+ virtual std::string dump(int indent = 0);
+
+ NodeState getState() const;
+ CanvasPtr getCanvas() const;
+
+ virtual bool handleEvent(EventPtr pEvent);
+
+ virtual const std::string& getID() const;
+ std::string getTypeStr() const;
+
+ bool operator ==(const Node& other) const;
+ bool operator !=(const Node& other) const;
+ long getHash() const;
+
+ virtual const NodeDefinition* getDefinition() const;
+
+ virtual void renderOutlines(const VertexArrayPtr& pVA, Pixel32 color) {};
+
+ protected:
+ Node();
+
+ void addArgEventHandlers(Event::Type eventType, const std::string& sCode);
+ void addArgEventHandler(Event::Type eventType, Event::Source source,
+ const std::string& sCode);
+ bool reactsToMouseEvents();
+
+ void setState(NodeState state);
+ void initFilename(std::string& sFilename);
+ void checkReload(const std::string& sHRef, const ImagePtr& pImage,
+ Image::TextureCompression comp = Image::TEXTURECOMPRESSION_NONE);
+ virtual bool isVisible() const;
+ bool getEffectiveActive() const;
+
+ private:
+ std::string m_ID;
+ const NodeDefinition* m_pDefinition;
+
+ DivNodeWeakPtr m_pParent;
+
+ struct EventID {
+ EventID(Event::Type eventType, Event::Source source);
+
+ bool operator < (const EventID& other) const;
+
+ Event::Type m_Type;
+ Event::Source m_Source;
+ };
+
+ struct EventHandler {
+ EventHandler(PyObject * pObj, PyObject * pMethod);
+ EventHandler(const EventHandler& other);
+ ~EventHandler();
+
+ PyObject * m_pObj;
+ PyObject * m_pMethod;
+ };
+
+ typedef std::list<EventHandler> EventHandlerArray;
+ typedef boost::shared_ptr<EventHandlerArray> EventHandlerArrayPtr;
+ typedef std::map<EventID, EventHandlerArrayPtr> EventHandlerMap;
+
+ void connectOneEventHandler(const EventID& id, PyObject * pObj, PyObject * pFunc);
+ void dumpEventHandlers();
+ PyObject * findPythonFunc(const std::string& sCode);
+ bool callPython(PyObject * pFunc, avg::EventPtr pEvent);
+
+ EventHandlerMap m_EventHandlerMap;
+
+ CanvasWeakPtr m_pCanvas;
+
+ double m_Opacity;
+ NodeState m_State;
+
+ bool m_bActive;
+ bool m_bSensitive;
+ double m_EffectiveOpacity;
+};
+
+}
+
+#endif
diff --git a/src/player/NodeDefinition.cpp b/src/player/NodeDefinition.cpp
new file mode 100644
index 0000000..32cfb68
--- /dev/null
+++ b/src/player/NodeDefinition.cpp
@@ -0,0 +1,122 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "NodeDefinition.h"
+
+#include "../base/Logger.h"
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition::NodeDefinition() :
+ m_pBuilder(0)
+{
+}
+
+NodeDefinition::NodeDefinition(const string& sName, NodeBuilder pBuilder)
+ : m_sName(sName),
+ m_pBuilder(pBuilder)
+{
+}
+
+NodeDefinition::~NodeDefinition()
+{
+}
+
+const std::string& NodeDefinition::getName() const
+{
+ return m_sName;
+}
+
+NodeBuilder NodeDefinition::getBuilder() const
+{
+ return m_pBuilder;
+}
+
+const ArgList& NodeDefinition::getDefaultArgs() const
+{
+ return m_Args;
+}
+
+const string& NodeDefinition::getDTDElements() const
+{
+ return m_sDTDElements;
+}
+
+string NodeDefinition::getDTDChildrenString() const
+{
+ if (m_sChildren.empty()) {
+ return "EMPTY";
+ } else {
+ string sChildren = "(";
+
+ for (unsigned i=0; i<m_sChildren.size()-1; ++i) {
+ sChildren += m_sChildren[i]+"|";
+ }
+ sChildren += m_sChildren[m_sChildren.size()-1]+")*";
+ return sChildren;
+ }
+}
+
+bool NodeDefinition::isChildAllowed(const string& sChild) const
+{
+ for (unsigned i=0; i<m_sChildren.size(); ++i) {
+ if (m_sChildren[i] == sChild) {
+ return true;
+ }
+ }
+ return false;
+}
+
+bool NodeDefinition::hasChildren() const
+{
+ return !m_sChildren.empty();
+}
+
+NodeDefinition& NodeDefinition::extendDefinition(const NodeDefinition& Def)
+{
+ m_Args.copyArgsFrom(Def.m_Args);
+ m_sChildren = Def.m_sChildren;
+ return *this;
+}
+
+NodeDefinition& NodeDefinition::addArg(const ArgBase& newArg)
+{
+ m_Args.setArg(newArg);
+ return *this;
+}
+
+NodeDefinition& NodeDefinition::addDTDElements(const string& s)
+{
+ m_sDTDElements = s;
+ return *this;
+}
+
+NodeDefinition& NodeDefinition::addChildren(const vector<string>& sChildren)
+{
+ m_sChildren.insert(m_sChildren.end(), sChildren.begin(), sChildren.end());
+ return *this;
+}
+
+}
diff --git a/src/player/NodeDefinition.h b/src/player/NodeDefinition.h
new file mode 100644
index 0000000..aeda123
--- /dev/null
+++ b/src/player/NodeDefinition.h
@@ -0,0 +1,74 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _NodeDefinition_H_
+#define _NodeDefinition_H_
+
+#include "../api.h"
+
+#include "ArgList.h"
+
+#include <map>
+#include <string>
+
+namespace avg {
+
+class Node;
+typedef boost::shared_ptr<Node> NodePtr;
+class NodeDefinition;
+
+typedef NodePtr (*NodeBuilder)(const ArgList& Args);
+typedef std::map<std::string, NodeDefinition> ChildMap;
+
+class AVG_API NodeDefinition
+{
+public:
+ NodeDefinition();
+ NodeDefinition(const std::string& sName, NodeBuilder pBuilder = 0);
+ virtual ~NodeDefinition();
+
+ const std::string& getName() const;
+ NodeBuilder getBuilder() const;
+ const ArgList& getDefaultArgs() const;
+ const std::string& getDTDElements() const;
+ std::string getDTDChildrenString() const;
+ bool isChildAllowed(const std::string& sChild) const;
+ bool hasChildren() const;
+
+ NodeDefinition& extendDefinition(const NodeDefinition& Def);
+ NodeDefinition& addArg(const ArgBase& newArg);
+ NodeDefinition& addDTDElements(const std::string& s);
+ NodeDefinition& addChildren(const std::vector<std::string>& sChildren);
+
+private:
+ std::string m_sName;
+ NodeBuilder m_pBuilder;
+ ArgList m_Args;
+ std::string m_sDTDElements;
+ std::vector<std::string> m_sChildren;
+
+};
+
+}
+
+#endif
diff --git a/src/player/NodeRegistry.cpp b/src/player/NodeRegistry.cpp
new file mode 100644
index 0000000..854e827
--- /dev/null
+++ b/src/player/NodeRegistry.cpp
@@ -0,0 +1,126 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "NodeRegistry.h"
+#include "NodeDefinition.h"
+
+#include "../base/Exception.h"
+
+#include <set>
+
+using namespace std;
+
+namespace avg {
+
+NodeRegistry::NodeRegistry()
+{
+}
+
+NodeRegistry::~NodeRegistry()
+{
+}
+
+void NodeRegistry::registerNodeType(const NodeDefinition& def)
+{
+ m_NodeDefs.insert(NodeDefMap::value_type(def.getName(), def));
+}
+
+void NodeRegistry::updateNodeDefinition(const NodeDefinition& def)
+{
+ m_NodeDefs[def.getName()] = def;
+}
+
+NodePtr NodeRegistry::createNode(const string& sType, const xmlNodePtr xmlNode)
+{
+ const NodeDefinition& def = getNodeDef(sType);
+ ArgList args(def.getDefaultArgs(), xmlNode);
+ NodeBuilder builder = def.getBuilder();
+ NodePtr pNode = builder(args);
+ pNode->setTypeInfo(&def);
+ return pNode;
+}
+
+NodePtr NodeRegistry::createNode(const string& sType, const boost::python::dict& pyDict)
+{
+ const NodeDefinition& def = getNodeDef(sType);
+ ArgList args(def.getDefaultArgs(), pyDict);
+ NodeBuilder builder = def.getBuilder();
+ NodePtr pNode = builder(args);
+ pNode->setTypeInfo(&def);
+ return pNode;
+}
+
+string NodeRegistry::getDTD() const
+{
+ if (m_NodeDefs.empty()) {
+ return string("");
+ }
+
+ stringstream ss;
+
+ for (NodeDefMap::const_iterator defIt = m_NodeDefs.begin();
+ defIt != m_NodeDefs.end(); defIt++)
+ {
+ const NodeDefinition& def = defIt->second;
+ writeNodeDTD(def, ss);
+ }
+
+ for (NodeDefMap::const_iterator defIt = m_NodeDefs.begin();
+ defIt != m_NodeDefs.end(); defIt++)
+ {
+ const NodeDefinition& def = defIt->second;
+ ss << def.getDTDElements();
+ }
+
+ return ss.str();
+}
+
+const NodeDefinition& NodeRegistry::getNodeDef(const string& sType)
+{
+ NodeDefMap::const_iterator it = m_NodeDefs.find(sType);
+ if (it == m_NodeDefs.end()) {
+ throw (Exception (AVG_ERR_XML_NODE_UNKNOWN,
+ string("Unknown node type ") + sType + " encountered."));
+ }
+ return it->second;
+}
+
+void NodeRegistry::writeNodeDTD(const NodeDefinition& def, stringstream& ss) const
+{
+ ss << "<!ELEMENT " << def.getName() << " " << def.getDTDChildrenString() << " >\n";
+ if (!def.getDefaultArgs().getArgMap().empty()) {
+ ss << "<!ATTLIST " << def.getName();
+ for (ArgMap::const_iterator argIt = def.getDefaultArgs().getArgMap().begin();
+ argIt != def.getDefaultArgs().getArgMap().end(); argIt++)
+ {
+ string argName = argIt->first;
+ string argType = (argName == "id") ? "ID" : "CDATA";
+ string argRequired = def.getDefaultArgs().getArg(argName)->isRequired() ?
+ "#REQUIRED" : "#IMPLIED";
+ ss << "\n " << argName << " " << argType << " " << argRequired;
+ }
+ ss << " >\n";
+ }
+}
+
+}
diff --git a/src/player/NodeRegistry.h b/src/player/NodeRegistry.h
new file mode 100644
index 0000000..9aee371
--- /dev/null
+++ b/src/player/NodeRegistry.h
@@ -0,0 +1,62 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _NodeRegistry_H_
+#define _NodeRegistry_H_
+
+#include "../api.h"
+#include "WrapPython.h"
+#include "Node.h"
+#include "ArgList.h"
+#include "NodeDefinition.h"
+
+#include <map>
+#include <string>
+#include <sstream>
+
+namespace avg {
+
+class AVG_API NodeRegistry
+{
+public:
+ NodeRegistry();
+ virtual ~NodeRegistry();
+
+ void registerNodeType(const NodeDefinition& def);
+ void updateNodeDefinition(const NodeDefinition& def);
+ const NodeDefinition& getNodeDef(const std::string& Type);
+ NodePtr createNode(const std::string& Type, const xmlNodePtr xmlNode);
+ NodePtr createNode(const std::string& Type, const boost::python::dict& PyDict);
+
+ std::string getDTD() const;
+
+private:
+ void writeNodeDTD(const NodeDefinition& def, std::stringstream& ss) const;
+
+ typedef std::map<std::string, NodeDefinition> NodeDefMap;
+ NodeDefMap m_NodeDefs;
+};
+
+}
+
+#endif
diff --git a/src/player/NullFXNode.cpp b/src/player/NullFXNode.cpp
new file mode 100644
index 0000000..544b6d9
--- /dev/null
+++ b/src/player/NullFXNode.cpp
@@ -0,0 +1,62 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "NullFXNode.h"
+
+#include "../base/ObjectCounter.h"
+#include "../graphics/ShaderRegistry.h"
+
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+NullFXNode::NullFXNode()
+ : FXNode()
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+NullFXNode::~NullFXNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void NullFXNode::connect()
+{
+ FXNode::connect();
+}
+
+void NullFXNode::disconnect()
+{
+ m_pFilter = GPUNullFilterPtr();
+ FXNode::disconnect();
+}
+
+GPUFilterPtr NullFXNode::createFilter(const IntPoint& size)
+{
+ m_pFilter = GPUNullFilterPtr(new GPUNullFilter(size, false));
+ setDirty();
+ return m_pFilter;
+}
+
+}
diff --git a/src/player/NullFXNode.h b/src/player/NullFXNode.h
new file mode 100644
index 0000000..b79c7b4
--- /dev/null
+++ b/src/player/NullFXNode.h
@@ -0,0 +1,53 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _NullFXNode_H_
+#define _NullFXNode_H_
+
+#include "../api.h"
+
+#include "FXNode.h"
+#include "../graphics/GPUNullFilter.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+class AVG_API NullFXNode: public FXNode {
+public:
+ NullFXNode();
+ virtual ~NullFXNode();
+
+ virtual void connect();
+ virtual void disconnect();
+
+private:
+ virtual GPUFilterPtr createFilter(const IntPoint& size);
+
+ GPUNullFilterPtr m_pFilter;
+};
+
+typedef boost::shared_ptr<NullFXNode> NullFXNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/OGLSurface.cpp b/src/player/OGLSurface.cpp
new file mode 100644
index 0000000..c83acbe
--- /dev/null
+++ b/src/player/OGLSurface.cpp
@@ -0,0 +1,379 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "OGLSurface.h"
+
+#include "../base/MathHelper.h"
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/ShaderRegistry.h"
+#include "../graphics/GLContext.h"
+#include "../graphics/GLTexture.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+#define COLORSPACE_SHADER "COLORSPACE"
+
+static float yuvCoeff[3][4] =
+{
+ {1.0f, 0.0f, 1.40f, 0.0f},
+ {1.0f, -0.34f, -0.71f, 0.0f},
+ {1.0f, 1.77f, 0.0f, 0.0f},
+};
+
+namespace avg {
+
+OGLSurface::OGLSurface()
+ : m_Size(-1,-1),
+ m_Gamma(1,1,1),
+ m_Brightness(1,1,1),
+ m_Contrast(1,1,1),
+ m_bIsDirty(true)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+OGLSurface::~OGLSurface()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void OGLSurface::attach()
+{
+ if (!GLContext::getCurrent()->isUsingShaders()) {
+ if (m_pMaskTexture) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ "Can't set mask bitmap since shader support is disabled.");
+ }
+ if (gammaIsModified() || colorIsModified()) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ "Can't use color correction (gamma, brightness, contrast) since shader support is disabled.");
+ }
+ }
+}
+
+void OGLSurface::create(PixelFormat pf, GLTexturePtr pTex0, GLTexturePtr pTex1,
+ GLTexturePtr pTex2, GLTexturePtr pTex3)
+{
+ m_pf = pf;
+ m_Size = pTex0->getSize();
+ m_pTextures[0] = pTex0;
+ m_pTextures[1] = pTex1;
+ m_pTextures[2] = pTex2;
+ m_pTextures[3] = pTex3;
+ m_bIsDirty = true;
+
+ // Make sure pixel format and number of textures line up.
+ if (pixelFormatIsPlanar(pf)) {
+ AVG_ASSERT(m_pTextures[2]);
+ if (pixelFormatHasAlpha(m_pf)) {
+ AVG_ASSERT(m_pTextures[3]);
+ } else {
+ AVG_ASSERT(!m_pTextures[3]);
+ }
+ } else {
+ AVG_ASSERT(!m_pTextures[1]);
+ }
+}
+
+void OGLSurface::setMask(GLTexturePtr pTex)
+{
+ m_pMaskTexture = pTex;
+ m_bIsDirty = true;
+}
+
+void OGLSurface::destroy()
+{
+ m_pTextures[0] = GLTexturePtr();
+ m_pTextures[1] = GLTexturePtr();
+ m_pTextures[2] = GLTexturePtr();
+ m_pTextures[3] = GLTexturePtr();
+}
+
+void OGLSurface::activate(const IntPoint& logicalSize, bool bPremultipliedAlpha) const
+{
+ if (useShader()) {
+ OGLShaderPtr pShader = getShader(COLORSPACE_SHADER);
+ pShader->activate();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "OGLSurface::activate()");
+ switch (m_pf) {
+ case YCbCr420p:
+ case YCbCrJ420p:
+ pShader->setUniformIntParam("colorModel", 1);
+ break;
+ case YCbCrA420p:
+ pShader->setUniformIntParam("colorModel", 3);
+ break;
+ case A8:
+ pShader->setUniformIntParam("colorModel", 2);
+ break;
+ default:
+ pShader->setUniformIntParam("colorModel", 0);
+ }
+
+ m_pTextures[0]->activate(GL_TEXTURE0);
+ pShader->setUniformIntParam("texture", 0);
+
+ if (pixelFormatIsPlanar(m_pf)) {
+ m_pTextures[1]->activate(GL_TEXTURE1);
+ pShader->setUniformIntParam("cbTexture", 1);
+ m_pTextures[2]->activate(GL_TEXTURE2);
+ pShader->setUniformIntParam("crTexture", 2);
+ if (m_pf == YCbCrA420p) {
+ m_pTextures[3]->activate(GL_TEXTURE3);
+ pShader->setUniformIntParam("aTexture", 3);
+ }
+ }
+ if (pixelFormatIsPlanar(m_pf) || colorIsModified()) {
+ Matrix3x4 mat = calcColorspaceMatrix();
+ pShader->setUniformVec4fParam("colorCoeff0",
+ mat.val[0][0], mat.val[1][0], mat.val[2][0], 0);
+ pShader->setUniformVec4fParam("colorCoeff1",
+ mat.val[0][1], mat.val[1][1], mat.val[2][1], 0);
+ pShader->setUniformVec4fParam("colorCoeff2",
+ mat.val[0][2], mat.val[1][2], mat.val[2][2], 0);
+ pShader->setUniformVec4fParam("colorCoeff3",
+ mat.val[0][3], mat.val[1][3], mat.val[2][3], 1);
+ }
+
+ pShader->setUniformVec4fParam("gamma", float(1/m_Gamma.x), float(1/m_Gamma.y),
+ float(1/m_Gamma.z), 1.0);
+ pShader->setUniformIntParam("bUseColorCoeff", colorIsModified());
+
+ pShader->setUniformIntParam("bPremultipliedAlpha", bPremultipliedAlpha);
+ pShader->setUniformIntParam("bUseMask", bool(m_pMaskTexture));
+ if (m_pMaskTexture) {
+ m_pMaskTexture->activate(GL_TEXTURE4);
+ pShader->setUniformIntParam("maskTexture", 4);
+ pShader->setUniformDPointParam("maskPos", m_MaskPos);
+ // maskScale is (1,1) for everything excepting words nodes.
+ DPoint maskScale(1,1);
+ if (logicalSize != IntPoint(0,0)) {
+ maskScale = DPoint((double)logicalSize.x/m_Size.x,
+ (double)logicalSize.y/m_Size.y);
+ }
+ pShader->setUniformDPointParam("maskSize", m_MaskSize*maskScale);
+ }
+
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "OGLSurface::activate: params");
+ } else {
+ m_pTextures[0]->activate(GL_TEXTURE0);
+ if (GLContext::getCurrent()->isUsingShaders()) {
+ glproc::UseProgramObject(0);
+ }
+ for (int i=1; i<5; ++i) {
+ glproc::ActiveTexture(GL_TEXTURE0 + i);
+ glDisable(GL_TEXTURE_2D);
+ }
+ glproc::ActiveTexture(GL_TEXTURE0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "OGLSurface::activate: fixed function");
+ }
+}
+
+GLTexturePtr OGLSurface::getTex(int i) const
+{
+ return m_pTextures[i];
+}
+
+void OGLSurface::setMaskCoords(DPoint maskPos, DPoint maskSize)
+{
+ m_MaskPos = maskPos;
+ m_MaskSize = maskSize;
+ m_bIsDirty = true;
+}
+
+PixelFormat OGLSurface::getPixelFormat()
+{
+ return m_pf;
+}
+
+IntPoint OGLSurface::getSize()
+{
+ return m_Size;
+}
+
+IntPoint OGLSurface::getTextureSize()
+{
+ return m_pTextures[0]->getGLSize();
+}
+
+bool OGLSurface::isCreated() const
+{
+ return m_pTextures[0];
+}
+
+void OGLSurface::setColorParams(const DTriple& gamma, const DTriple& brightness,
+ const DTriple& contrast)
+{
+ m_Gamma = gamma;
+ m_Brightness = brightness;
+ m_Contrast = contrast;
+ if (!GLContext::getCurrent()->isUsingShaders() &&
+ (gammaIsModified() || colorIsModified()))
+ {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ "Can't use color correction (gamma, brightness, contrast) since shader support is disabled.");
+ }
+ m_bIsDirty = true;
+}
+
+void OGLSurface::createShader()
+{
+ string sProgram =
+ "uniform sampler2D texture;\n"
+ "uniform sampler2D yTexture;\n"
+ "uniform sampler2D cbTexture;\n"
+ "uniform sampler2D crTexture;\n"
+ "uniform sampler2D aTexture;\n"
+ "uniform sampler2D maskTexture;\n"
+ "uniform int colorModel; // 0=rgb, 1=yuv, 2=greyscale, 3=yuva\n"
+ "uniform vec4 colorCoeff0;\n"
+ "uniform vec4 colorCoeff1;\n"
+ "uniform vec4 colorCoeff2;\n"
+ "uniform vec4 colorCoeff3;\n"
+ "uniform bool bUseColorCoeff;\n"
+ "uniform vec4 gamma;\n"
+ "uniform bool bPremultipliedAlpha;\n"
+ "uniform bool bUseMask;\n"
+ "uniform vec2 maskPos;\n"
+ "uniform vec2 maskSize;\n"
+ "\n"
+ "vec4 convertYCbCr(mat4 colorCoeff)\n"
+ "{\n"
+ " vec4 yuv;\n"
+ " yuv = vec4(texture2D(texture, gl_TexCoord[0].st).r,\n"
+ " texture2D(cbTexture, (gl_TexCoord[0].st)).r,\n"
+ " texture2D(crTexture, (gl_TexCoord[0].st)).r,\n"
+ " 1.0);\n"
+ " vec4 rgb;\n"
+ " rgb = colorCoeff*yuv;\n"
+ " return vec4(rgb.rgb, gl_Color.a);\n"
+ "}\n"
+ "\n"
+ "void main(void)\n"
+ "{\n"
+ " vec4 rgba;\n"
+ " mat4 colorCoeff;\n"
+ " colorCoeff[0] = colorCoeff0;\n"
+ " colorCoeff[1] = colorCoeff1;\n"
+ " colorCoeff[2] = colorCoeff2;\n"
+ " colorCoeff[3] = colorCoeff3;\n"
+ " if (colorModel == 0) {\n"
+ " rgba = texture2D(texture, gl_TexCoord[0].st);\n"
+ " if (bUseColorCoeff) {\n"
+ " rgba = colorCoeff*rgba;\n"
+ " };\n"
+ " rgba.a *= gl_Color.a;\n"
+ " } else if (colorModel == 1) {\n"
+ " rgba = convertYCbCr(colorCoeff);\n"
+ " } else if (colorModel == 2) {\n"
+ " rgba = gl_Color;\n"
+ " if (bUseColorCoeff) {\n"
+ " rgba = colorCoeff*rgba;\n"
+ " };\n"
+ " rgba.a *= texture2D(texture, gl_TexCoord[0].st).a;\n"
+ " } else if (colorModel == 3) {\n"
+ " rgba = convertYCbCr(colorCoeff);\n"
+ " rgba.a *= texture2D(aTexture, gl_TexCoord[0].st).r;\n"
+ " } else {\n"
+ " rgba = vec4(1,1,1,1);\n"
+ " }\n"
+ " rgba = pow(rgba, gamma);\n"
+ " if (bUseMask) {\n"
+ " if (bPremultipliedAlpha) {\n"
+ " rgba.rgb *= texture2D(maskTexture,\n"
+ " (gl_TexCoord[0].st/maskSize)-maskPos).r;\n"
+ " }\n"
+ " rgba.a *= texture2D(maskTexture,\n"
+ " (gl_TexCoord[0].st/maskSize)-maskPos).r;\n"
+ " }\n"
+ " gl_FragColor = rgba;\n"
+ "}\n";
+ getOrCreateShader(COLORSPACE_SHADER, sProgram);
+}
+
+bool OGLSurface::isDirty() const
+{
+ bool bIsDirty = m_bIsDirty;
+ for (unsigned i=0; i<getNumPixelFormatPlanes(m_pf); ++i) {
+ if (m_pTextures[i]->isDirty()) {
+ bIsDirty = true;
+ }
+ }
+ return bIsDirty;
+}
+
+void OGLSurface::resetDirty()
+{
+ m_bIsDirty = false;
+ for (unsigned i=0; i<getNumPixelFormatPlanes(m_pf); ++i) {
+ m_pTextures[i]->resetDirty();
+ }
+}
+
+bool OGLSurface::useShader() const
+{
+ return GLContext::getCurrent()->isUsingShaders() &&
+ (m_pMaskTexture || pixelFormatIsPlanar(m_pf) || gammaIsModified() ||
+ colorIsModified());
+}
+
+Matrix3x4 OGLSurface::calcColorspaceMatrix() const
+{
+ Matrix3x4 mat;
+ if (colorIsModified()) {
+ mat *= Matrix3x4::createScale(m_Brightness);
+ mat *= Matrix3x4::createTranslate(float(0.5-m_Contrast.x/2),
+ float(0.5-m_Contrast.y/2), float(0.5-m_Contrast.z/2));
+ mat *= Matrix3x4::createScale(m_Contrast);
+ }
+ if (m_pf == YCbCr420p || m_pf == YCbCrJ420p || m_pf == YCbCrA420p) {
+ mat *= Matrix3x4(*yuvCoeff);
+ mat *= Matrix3x4::createTranslate(0.0, -0.5, -0.5);
+ if (m_pf == YCbCr420p || m_pf == YCbCrA420p) {
+ mat *= Matrix3x4::createScale(255.0f/(235-16), 255.0f/(240-16) ,
+ 255.0f/(240-16));
+ mat *= Matrix3x4::createTranslate(-16.0f/255, -16.0f/255, -16.0f/255);
+ }
+ }
+ return mat;
+}
+
+bool OGLSurface::gammaIsModified() const
+{
+ return (fabs(m_Gamma.x-1.0) > 0.00001 || fabs(m_Gamma.y-1.0) > 0.00001 ||
+ fabs(m_Gamma.z-1.0) > 0.00001);
+}
+
+bool OGLSurface::colorIsModified() const
+{
+ return (fabs(m_Brightness.x-1.0) > 0.00001 || fabs(m_Brightness.y-1.0) > 0.00001 ||
+ fabs(m_Brightness.z-1.0) > 0.00001 || fabs(m_Contrast.x-1.0) > 0.00001 ||
+ fabs(m_Contrast.y-1.0) > 0.00001 || fabs(m_Contrast.z-1.0) > 0.00001);
+}
+
+}
diff --git a/src/player/OGLSurface.h b/src/player/OGLSurface.h
new file mode 100644
index 0000000..a780b4a
--- /dev/null
+++ b/src/player/OGLSurface.h
@@ -0,0 +1,96 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _OGLSurface_H_
+#define _OGLSurface_H_
+
+#include "../api.h"
+
+#include "../base/Point.h"
+#include "../base/Triple.h"
+#include "../base/Matrix3x4.h"
+
+#include "../graphics/Bitmap.h"
+#include "../graphics/OGLHelper.h"
+
+#include <vector>
+#include <string>
+
+namespace avg {
+
+class GLTexture;
+typedef boost::shared_ptr<GLTexture> GLTexturePtr;
+
+
+class AVG_API OGLSurface {
+public:
+ OGLSurface();
+ virtual ~OGLSurface();
+
+ void attach();
+ virtual void create(PixelFormat pf, GLTexturePtr pTex0,
+ GLTexturePtr pTex1 = GLTexturePtr(), GLTexturePtr pTex2 = GLTexturePtr(),
+ GLTexturePtr pTex3 = GLTexturePtr());
+ void setMask(GLTexturePtr pTex);
+ virtual void destroy();
+ void activate(const IntPoint& logicalSize = IntPoint(1,1),
+ bool bPremultipliedAlpha = false) const;
+ GLTexturePtr getTex(int i=0) const;
+
+ void setMaskCoords(DPoint maskPos, DPoint maskSize);
+
+ PixelFormat getPixelFormat();
+ IntPoint getSize();
+ IntPoint getTextureSize();
+ bool isCreated() const;
+
+ void setColorParams(const DTriple& gamma, const DTriple& brightness,
+ const DTriple& contrast);
+ static void createShader();
+
+ bool isDirty() const;
+ void resetDirty();
+
+private:
+ bool useShader() const;
+ Matrix3x4 calcColorspaceMatrix() const;
+ bool gammaIsModified() const;
+ bool colorIsModified() const;
+
+ GLTexturePtr m_pTextures[4];
+ IntPoint m_Size;
+ PixelFormat m_pf;
+ GLTexturePtr m_pMaskTexture;
+ DPoint m_MaskPos;
+ DPoint m_MaskSize;
+
+
+ DTriple m_Gamma;
+ DTriple m_Brightness;
+ DTriple m_Contrast;
+
+ bool m_bIsDirty;
+};
+
+}
+
+#endif
+
diff --git a/src/player/OffscreenCanvas.cpp b/src/player/OffscreenCanvas.cpp
new file mode 100644
index 0000000..6ff1c52
--- /dev/null
+++ b/src/player/OffscreenCanvas.cpp
@@ -0,0 +1,260 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "OffscreenCanvas.h"
+
+#include "CanvasNode.h"
+#include "Player.h"
+
+#include "../base/Exception.h"
+#include "../base/ProfilingZone.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/FilterUnmultiplyAlpha.h"
+
+#include <iostream>
+
+using namespace boost;
+using namespace std;
+
+namespace avg {
+
+OffscreenCanvas::OffscreenCanvas(Player * pPlayer)
+ : Canvas(pPlayer),
+ m_bIsRendered(false),
+ m_pCameraNodeRef(0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+OffscreenCanvas::~OffscreenCanvas()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void OffscreenCanvas::setRoot(NodePtr pRootNode)
+{
+ Canvas::setRoot(pRootNode);
+ if (!getRootNode()) {
+ throw (Exception(AVG_ERR_XML_PARSE,
+ "Root node of a canvas tree needs to be a <canvas> node."));
+ }
+}
+
+void OffscreenCanvas::initPlayback()
+{
+ m_bUseMipmaps = getMipmap();
+ m_pFBO = FBOPtr(new FBO(getSize(), B8G8R8A8, 1, getMultiSampleSamples(), true,
+ m_bUseMipmaps));
+ Canvas::initPlayback(getMultiSampleSamples());
+ m_bIsRendered = false;
+}
+
+void OffscreenCanvas::stopPlayback()
+{
+ m_pFBO = FBOPtr();
+ Canvas::stopPlayback();
+ m_bIsRendered = false;
+}
+
+BitmapPtr OffscreenCanvas::screenshot() const
+{
+ return screenshot(false);
+}
+
+static ProfilingZoneID OffscreenRenderProfilingZone("Render OffscreenCanvas");
+
+BitmapPtr OffscreenCanvas::screenshot(bool bIgnoreAlpha) const
+{
+ if (!isRunning() || !m_bIsRendered) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "OffscreenCanvas::screenshot(): Canvas has not been rendered. No screenshot available"));
+ }
+ BitmapPtr pBmp = m_pFBO->getImage(0);
+ if (bIgnoreAlpha) {
+ pBmp->setPixelFormat(B8G8R8X8);
+ } else {
+ FilterUnmultiplyAlpha().applyInPlace(pBmp);
+ }
+ return pBmp;
+}
+
+bool OffscreenCanvas::getHandleEvents() const
+{
+ return dynamic_pointer_cast<OffscreenCanvasNode>(getRootNode())->getHandleEvents();
+}
+
+int OffscreenCanvas::getMultiSampleSamples() const
+{
+ return dynamic_pointer_cast<OffscreenCanvasNode>(
+ getRootNode())->getMultiSampleSamples();
+}
+
+bool OffscreenCanvas::getMipmap() const
+{
+ return dynamic_pointer_cast<OffscreenCanvasNode>(getRootNode())->getMipmap();
+}
+
+bool OffscreenCanvas::getAutoRender() const
+{
+ return dynamic_pointer_cast<OffscreenCanvasNode>(getRootNode())->getAutoRender();
+}
+
+void OffscreenCanvas::setAutoRender(bool bAutoRender)
+{
+ dynamic_pointer_cast<OffscreenCanvasNode>(getRootNode())->setAutoRender(bAutoRender);
+}
+
+void OffscreenCanvas::manualRender()
+{
+ emitPreRenderSignal();
+ render();
+ emitFrameEndSignal();
+}
+
+std::string OffscreenCanvas::getID() const
+{
+ return getRootNode()->getID();
+}
+
+bool OffscreenCanvas::isRunning() const
+{
+ return (m_pFBO != FBOPtr());
+}
+
+GLTexturePtr OffscreenCanvas::getTex() const
+{
+ AVG_ASSERT(isRunning());
+ return m_pFBO->getTex();
+}
+
+FBOPtr OffscreenCanvas::getFBO() const
+{
+ AVG_ASSERT(isRunning());
+ return m_pFBO;
+}
+
+void OffscreenCanvas::registerCameraNode(CameraNode* pCameraNode)
+{
+ m_pCameraNodeRef = pCameraNode;
+ m_pCameraNodeRef->setAutoUpdateCameraImage(false);
+}
+
+void OffscreenCanvas::unregisterCameraNode()
+{
+ m_pCameraNodeRef->setAutoUpdateCameraImage(true);
+ m_pCameraNodeRef = NULL;
+}
+
+void OffscreenCanvas::updateCameraImage()
+{
+ m_pCameraNodeRef->updateCameraImage();
+}
+
+bool OffscreenCanvas::hasRegisteredCamera() const
+{
+ return m_pCameraNodeRef != NULL;
+}
+
+bool OffscreenCanvas::isCameraImageAvailable() const
+{
+ if (!hasRegisteredCamera()) {
+ return false;
+ }
+ return m_pCameraNodeRef->isImageAvailable();
+}
+
+void OffscreenCanvas::addDependentCanvas(CanvasPtr pCanvas)
+{
+ AVG_ASSERT(!(pCanvas == shared_from_this()));
+ m_pDependentCanvases.push_back(pCanvas);
+ Player::get()->newCanvasDependency(
+ dynamic_pointer_cast<OffscreenCanvas>(shared_from_this()));
+}
+
+void OffscreenCanvas::removeDependentCanvas(CanvasPtr pCanvas)
+{
+ for (unsigned i = 0; i < m_pDependentCanvases.size(); ++i) {
+ if (pCanvas == m_pDependentCanvases[i]) {
+ m_pDependentCanvases.erase(m_pDependentCanvases.begin()+i);
+// dump();
+ return;
+ }
+ }
+ AVG_ASSERT(false);
+}
+
+bool OffscreenCanvas::hasDependentCanvas(CanvasPtr pCanvas) const
+{
+ for (unsigned i = 0; i < m_pDependentCanvases.size(); ++i) {
+ if (pCanvas == m_pDependentCanvases[i]) {
+ return true;
+ }
+ }
+ return false;
+}
+
+unsigned OffscreenCanvas::getNumDependentCanvases() const
+{
+ return m_pDependentCanvases.size();
+}
+
+bool OffscreenCanvas::isSupported()
+{
+ if (!Player::get()->isPlaying()) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "OffscreenCanvas::isSupported(): Player.play() needs to be called before support can be queried."));
+ }
+
+ return FBO::isFBOSupported() && FBO::isPackedDepthStencilSupported();
+}
+
+bool OffscreenCanvas::isMultisampleSupported()
+{
+ if (!Player::get()->isPlaying()) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "OffscreenCanvas::isMultisampleSupported(): Player.play() needs to be called before multisample support can be queried."));
+ }
+
+ return FBO::isMultisampleFBOSupported();
+}
+
+void OffscreenCanvas::dump() const
+{
+ cerr << "Canvas: " << getRootNode()->getID() << endl;
+ for (unsigned i = 0; i < m_pDependentCanvases.size(); ++i) {
+ cerr << " " << m_pDependentCanvases[i]->getRootNode()->getID() << endl;
+ }
+}
+
+void OffscreenCanvas::render()
+{
+ if (!isRunning()) {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "OffscreenCanvas::render(): Player.play() needs to be called before rendering offscreen canvases."));
+ }
+ Canvas::render(IntPoint(getRootNode()->getSize()), true, m_pFBO,
+ OffscreenRenderProfilingZone);
+ m_pFBO->copyToDestTexture();
+ m_bIsRendered = true;
+}
+
+}
diff --git a/src/player/OffscreenCanvas.h b/src/player/OffscreenCanvas.h
new file mode 100644
index 0000000..808f950
--- /dev/null
+++ b/src/player/OffscreenCanvas.h
@@ -0,0 +1,92 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _OffscreenCanvas_H_
+#define _OffscreenCanvas_H_
+
+#include "../api.h"
+#include "Canvas.h"
+#include "OffscreenCanvasNode.h"
+
+#include "CameraNode.h"
+
+#include "../graphics/FBO.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API OffscreenCanvas: public Canvas
+{
+ public:
+ OffscreenCanvas(Player * pPlayer);
+ virtual ~OffscreenCanvas();
+ virtual void setRoot(NodePtr pRootNode);
+ virtual void initPlayback();
+ virtual void stopPlayback();
+
+ virtual BitmapPtr screenshot() const;
+ virtual BitmapPtr screenshot(bool bIgnoreAlpha) const;
+ bool getHandleEvents() const;
+ int getMultiSampleSamples() const;
+ bool getMipmap() const;
+ bool getAutoRender() const;
+ void setAutoRender(bool bAutoRender);
+ void manualRender(); // This is the render that can be called from python.
+
+ std::string getID() const;
+ bool isRunning() const;
+ GLTexturePtr getTex() const;
+ FBOPtr getFBO() const;
+
+ void registerCameraNode(CameraNode* pCameraNode);
+ void unregisterCameraNode();
+ void updateCameraImage();
+ bool hasRegisteredCamera() const;
+ bool isCameraImageAvailable() const;
+
+ void addDependentCanvas(CanvasPtr pCanvas);
+ void removeDependentCanvas(CanvasPtr pCanvas);
+ bool hasDependentCanvas(CanvasPtr pCanvas) const;
+ unsigned getNumDependentCanvases() const;
+
+ static bool isSupported();
+ static bool isMultisampleSupported();
+ void dump() const;
+
+ protected:
+ virtual void render();
+
+ private:
+ FBOPtr m_pFBO;
+ bool m_bUseMipmaps;
+ std::vector<CanvasPtr> m_pDependentCanvases;
+
+ bool m_bIsRendered;
+ CameraNode* m_pCameraNodeRef;
+ int m_cameraFrameRate;
+};
+
+typedef boost::shared_ptr<OffscreenCanvas> OffscreenCanvasPtr;
+
+}
+#endif
+
diff --git a/src/player/OffscreenCanvasNode.cpp b/src/player/OffscreenCanvasNode.cpp
new file mode 100644
index 0000000..5c72802
--- /dev/null
+++ b/src/player/OffscreenCanvasNode.cpp
@@ -0,0 +1,82 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "OffscreenCanvasNode.h"
+#include "Player.h"
+
+#include "NodeDefinition.h"
+
+#include "../base/FileHelper.h"
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition OffscreenCanvasNode::createDefinition()
+{
+ return NodeDefinition("canvas", Node::buildNode<OffscreenCanvasNode>)
+ .extendDefinition(CanvasNode::createDefinition())
+ .addArg(Arg<bool>("handleevents", false, false,
+ offsetof(OffscreenCanvasNode, m_bHandleEvents)))
+ .addArg(Arg<int>("multisamplesamples", 1, false,
+ offsetof(OffscreenCanvasNode, m_MultiSampleSamples)))
+ .addArg(Arg<bool>("mipmap", false, false,
+ offsetof(OffscreenCanvasNode, m_bMipmap)))
+ .addArg(Arg<bool>("autorender", true, false,
+ offsetof(OffscreenCanvasNode, m_bAutoRender)));
+}
+
+OffscreenCanvasNode::OffscreenCanvasNode(const ArgList& args)
+ : CanvasNode(args)
+{
+ args.setMembers(this);
+}
+
+OffscreenCanvasNode::~OffscreenCanvasNode()
+{
+}
+
+bool OffscreenCanvasNode::getHandleEvents() const
+{
+ return m_bHandleEvents;
+}
+
+int OffscreenCanvasNode::getMultiSampleSamples() const
+{
+ return m_MultiSampleSamples;
+}
+
+bool OffscreenCanvasNode::getMipmap() const
+{
+ return m_bMipmap;
+}
+
+bool OffscreenCanvasNode::getAutoRender() const
+{
+ return m_bAutoRender;
+}
+
+void OffscreenCanvasNode::setAutoRender(bool bAutoRender)
+{
+ m_bAutoRender = bAutoRender;
+}
+
+}
diff --git a/src/player/OffscreenCanvasNode.h b/src/player/OffscreenCanvasNode.h
new file mode 100644
index 0000000..47e1ed7
--- /dev/null
+++ b/src/player/OffscreenCanvasNode.h
@@ -0,0 +1,57 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _OffscreenCanvasNode_H_
+#define _OffscreenCanvasNode_H_
+
+#include "../api.h"
+#include "CanvasNode.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API OffscreenCanvasNode : public CanvasNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ OffscreenCanvasNode(const ArgList& args);
+ virtual ~OffscreenCanvasNode();
+
+ bool getHandleEvents() const;
+ int getMultiSampleSamples() const;
+ bool getMipmap() const;
+ bool getAutoRender() const;
+ void setAutoRender(bool bAutoRender);
+
+ private:
+ bool m_bHandleEvents;
+ int m_MultiSampleSamples;
+ bool m_bMipmap;
+ bool m_bAutoRender;
+};
+
+typedef boost::shared_ptr<OffscreenCanvasNode> OffscreenCanvasNodePtr;
+
+}
+
+#endif
diff --git a/src/player/PanoImageNode.cpp b/src/player/PanoImageNode.cpp
new file mode 100644
index 0000000..89157bb
--- /dev/null
+++ b/src/player/PanoImageNode.cpp
@@ -0,0 +1,351 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "PanoImageNode.h"
+#include "NodeDefinition.h"
+
+#include "../base/MathHelper.h"
+#include "../base/Logger.h"
+#include "../base/ProfilingZone.h"
+#include "../base/ScopeTimer.h"
+#include "../base/Exception.h"
+#include "../base/XMLHelper.h"
+
+#include "../graphics/OGLHelper.h"
+
+#include <iostream>
+#include <sstream>
+#include <math.h>
+
+using namespace std;
+
+const int TEX_WIDTH = 64;
+
+namespace avg {
+
+NodeDefinition PanoImageNode::createDefinition()
+{
+ return NodeDefinition("panoimage", Node::buildNode<PanoImageNode>)
+ .extendDefinition(AreaNode::createDefinition())
+ .addArg(Arg<UTF8String>("href", "", false, offsetof(PanoImageNode, m_href)))
+ .addArg(Arg<double>("sensorwidth", 1.0, false, offsetof(PanoImageNode, m_SensorWidth)))
+ .addArg(Arg<double>("sensorheight", 1.0, false, offsetof(PanoImageNode, m_SensorHeight)))
+ .addArg(Arg<double>("focallength", 10.0, false, offsetof(PanoImageNode, m_FocalLength)))
+ .addArg(Arg<double>("rotation", -1.0, false, offsetof(PanoImageNode, m_Rotation)));
+}
+
+PanoImageNode::PanoImageNode (const ArgList& Args)
+{
+ Args.setMembers(this);
+ m_pBmp = BitmapPtr(new Bitmap(IntPoint(1,1), R8G8B8));
+ load();
+}
+
+PanoImageNode::~PanoImageNode ()
+{
+ clearTextures();
+}
+
+void PanoImageNode::connectDisplay()
+{
+ AreaNode::connectDisplay();
+
+ setupTextures();
+}
+
+void PanoImageNode::disconnect(bool bKill)
+{
+ clearTextures();
+ AreaNode::disconnect(bKill);
+}
+
+static ProfilingZoneID PanoRenderProfilingZone("PanoImageNode::render");
+
+void PanoImageNode::render(const DRect& Rect)
+{
+ ScopeTimer Timer(PanoRenderProfilingZone);
+ pushGLState();
+ glproc::ActiveTexture(GL_TEXTURE0);
+
+ gluLookAt(0, 0, 0, // Eye
+ 0, 0, -1, // Center
+ 0, 1, 0); // Up.
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: gluLookAt()");
+
+ glMatrixMode(GL_PROJECTION);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glMatrixMode(GL_PROJECTION)");
+ glLoadIdentity();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glLoadIdentity()");
+
+ calcProjection();
+ gluPerspective(m_fovy*180/M_PI, m_aspect, 0.1, 2);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: gluPerspective()");
+ glMatrixMode(GL_MODELVIEW);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glMatrixMode(GL_MODELVIEW)");
+
+ glDisable (GL_CLIP_PLANE0);
+ glDisable (GL_CLIP_PLANE1);
+ glDisable (GL_CLIP_PLANE2);
+ glDisable (GL_CLIP_PLANE3);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glDisable(GL_CLIP_PLANEx)");
+ DPoint Vpt = getSize();
+ glViewport(0, 0, int(Vpt.x), int(Vpt.y));
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glViewport()");
+ glColor4d(1.0, 1.0, 1.0, getEffectiveOpacity());
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glColor4d()");
+//glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+
+ double HorizOffset = m_Rotation+m_fovy*m_aspect/2;
+// glutWireSphere(1, 20, 16);
+ for (unsigned int i=0; i<m_TileTextureIDs.size(); ++i) {
+ unsigned int TexID = m_TileTextureIDs[i];
+ glBindTexture(GL_TEXTURE_2D, TexID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glBindTexture()");
+ double StartAngle=i*m_SliceAngle-HorizOffset;
+ double StartX = sin(StartAngle);
+ double StartZ = -cos(StartAngle);
+ double EndAngle;
+ if (i<m_TileTextureIDs.size()-1) {
+ EndAngle = (i+1)*m_SliceAngle-HorizOffset;
+ } else {
+ EndAngle = m_CylAngle-HorizOffset;
+ }
+ double EndX = sin(EndAngle);
+ double EndZ = -cos(EndAngle);
+ double TexPartUsed = double(m_pBmp->getSize().y)/m_TexHeight;
+ glBegin(GL_QUADS);
+ glTexCoord2d(0.0, 0.0);
+ glVertex3d(StartX, m_CylHeight, StartZ);
+ glTexCoord2d(0.0, TexPartUsed);
+ glVertex3d(StartX, -m_CylHeight, StartZ);
+ glTexCoord2d(1.0, TexPartUsed);
+ glVertex3d(EndX, -m_CylHeight, EndZ);
+ glTexCoord2d(1.0, 0.0);
+ glVertex3d(EndX, m_CylHeight, EndZ);
+ glEnd();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::render: glEnd()");
+ }
+
+ popGLState();
+}
+
+double PanoImageNode::getScreenPosFromAngle(double Angle) const
+{
+ double HorizOffsetAngle = Angle-m_Rotation-m_fovy*m_aspect/2;
+ double PixelDistFromCenter = m_FocalLength*tan(HorizOffsetAngle)/m_SensorWidth
+ *getSize().x;
+ return PixelDistFromCenter+getSize().x/2;
+}
+
+double PanoImageNode::getScreenPosFromPanoPos(int PanoPos) const
+{
+ double AnglePerPixel = m_CylAngle*1/double(m_pBmp->getSize().x);
+ return getScreenPosFromAngle(AnglePerPixel*PanoPos);
+}
+
+const UTF8String& PanoImageNode::getHRef() const
+{
+ return m_href;
+}
+
+void PanoImageNode::setHRef(const UTF8String& href)
+{
+ m_href = href;
+ load();
+ if (getState() == NS_CANRENDER) {
+ setupTextures();
+ }
+}
+
+double PanoImageNode::getSensorWidth () const
+{
+ return m_SensorWidth;
+}
+
+void PanoImageNode::setSensorWidth (double sensorWidth)
+{
+ m_SensorWidth = sensorWidth;
+}
+
+double PanoImageNode::getSensorHeight () const
+{
+ return m_SensorHeight;
+}
+
+void PanoImageNode::setSensorHeight (double sensorHeight)
+{
+ m_SensorHeight = sensorHeight;
+}
+
+double PanoImageNode::getFocalLength () const
+{
+ return m_FocalLength;
+}
+
+void PanoImageNode::setFocalLength (double focalLength)
+{
+ m_FocalLength = focalLength;
+}
+
+double PanoImageNode::getRotation () const
+{
+ return m_Rotation;
+}
+
+void PanoImageNode::setRotation (double rotation)
+{
+ m_Rotation = rotation;
+}
+
+double PanoImageNode::getMaxRotation () const
+{
+ return m_MaxRotation;
+}
+
+void PanoImageNode::calcProjection()
+{
+ // Takes SensorWidth, SensorHeight and FocalLength and calculates
+ // loads of derived values needed for projection.
+ m_fovy = 2*atan((m_SensorHeight/2)/m_FocalLength);
+ m_aspect = m_SensorWidth/m_SensorHeight;
+ m_CylHeight = tan(m_fovy)/2;
+ m_CylAngle = m_fovy*m_pBmp->getSize().x/m_pBmp->getSize().y;
+ m_SliceAngle = m_CylAngle*TEX_WIDTH/double(m_pBmp->getSize().x);
+ m_MaxRotation = m_CylAngle-m_fovy*m_aspect;
+}
+
+DPoint PanoImageNode::getPreferredMediaSize()
+{
+ double SensorAspect = m_SensorWidth/m_SensorHeight;
+ double Width = m_pBmp->getSize().y*SensorAspect;
+ return DPoint(Width, m_pBmp->getSize().y);
+}
+
+void PanoImageNode::load()
+{
+ m_Filename = m_href;
+ AVG_TRACE(Logger::MEMORY, "Loading " << m_Filename);
+ if (m_Filename != "") {
+ initFilename(m_Filename);
+ try {
+
+ m_pBmp = BitmapPtr(new Bitmap(m_Filename));
+ } catch (Exception & ex) {
+ AVG_TRACE(Logger::ERROR, ex.getStr());
+ }
+ }
+
+ calcProjection();
+ if (m_Rotation == -1) {
+ m_Rotation = m_MaxRotation/2;
+ }
+}
+
+void PanoImageNode::setupTextures()
+{
+ if (!m_TileTextureIDs.empty()) {
+ clearTextures();
+ }
+ m_TexHeight = nextpow2(m_pBmp->getSize().y);
+ int NumTextures = int(ceil(double(m_pBmp->getSize().x)/TEX_WIDTH));
+ glproc::ActiveTexture(GL_TEXTURE0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glproc::ActiveTexture(GL_TEXTURE0);");
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glPixelStorei(GL_UNPACK_ALIGNMENT)");
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, m_pBmp->getSize().x);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glPixelStorei(GL_UNPACK_ROW_LENGTH)");
+ glEnable(GL_TEXTURE_2D);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glEnable(GL_TEXTURE_2D);");
+ for (int i=0; i<NumTextures; i++) {
+ BitmapPtr pRegion;
+ if (i != NumTextures-1) {
+ pRegion = BitmapPtr(new Bitmap(*m_pBmp,
+ IntRect(i*TEX_WIDTH, 0, (i+1)*TEX_WIDTH, m_pBmp->getSize().y)));
+ } else {
+ // The last column isn't necessarily as wide as the others.
+ pRegion = BitmapPtr(new Bitmap(*m_pBmp,
+ IntRect(i*TEX_WIDTH, 0,
+ m_pBmp->getSize().x, m_pBmp->getSize().y)));
+ }
+
+ unsigned int TexID;
+ glGenTextures(1, &TexID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glGenTextures()");
+ m_TileTextureIDs.push_back(TexID);
+ glBindTexture(GL_TEXTURE_2D, TexID);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glBindTexture()");
+
+ glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MIN_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D,
+ GL_TEXTURE_MAG_FILTER, GL_LINEAR);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glTexParameteri()");
+
+ int DestMode;
+ if (pRegion->getPixelFormat() == R8G8B8X8) {
+ DestMode = GL_RGB;
+ } else {
+ DestMode = GL_RGBA;
+ }
+ glTexImage2D(GL_TEXTURE_2D, 0,
+ DestMode, TEX_WIDTH, m_TexHeight, 0,
+ GL_RGBA, GL_UNSIGNED_BYTE, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glTexImage2D()");
+ unsigned char * pStartPos = pRegion->getPixels();
+ glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
+ pRegion->getSize().x, pRegion->getSize().y,
+ GL_RGBA, GL_UNSIGNED_BYTE, pStartPos);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL,
+ "PanoImageNode::setupTextures: glTexSubImage2D()");
+ }
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+}
+
+void PanoImageNode::clearTextures()
+{
+ for (unsigned int i=0; i<m_TileTextureIDs.size(); ++i) {
+ unsigned int TexID = m_TileTextureIDs[i];
+ glDeleteTextures(1, &TexID);
+ }
+ m_TileTextureIDs.clear();
+}
+
+}
diff --git a/src/player/PanoImageNode.h b/src/player/PanoImageNode.h
new file mode 100644
index 0000000..916d2f2
--- /dev/null
+++ b/src/player/PanoImageNode.h
@@ -0,0 +1,95 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _PanoImageNode_H_
+#define _PanoImageNode_H_
+
+#include "../api.h"
+#include "../avgconfigwrapper.h"
+
+#include "AreaNode.h"
+#include "../base/UTF8String.h"
+#include "../graphics/Bitmap.h"
+
+#include <string>
+#include <vector>
+
+namespace avg {
+
+class AVG_API PanoImageNode: public AreaNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ PanoImageNode(const ArgList& Args);
+ virtual ~PanoImageNode();
+
+ virtual void connectDisplay();
+ virtual void disconnect(bool bKill);
+ virtual void render(const DRect& Rect);
+
+ double getScreenPosFromPanoPos(int PanoPos) const;
+ double getScreenPosFromAngle(double Angle) const;
+ const UTF8String& getHRef() const;
+ void setHRef(const UTF8String& href);
+ double getSensorWidth() const;
+ void setSensorWidth(double sensorWidth);
+ double getSensorHeight() const;
+ void setSensorHeight(double sensorHeight);
+ double getFocalLength() const;
+ void setFocalLength(double focalLength);
+ double getRotation() const;
+ void setRotation(double rotation);
+ double getMaxRotation() const;
+
+ protected:
+ virtual DPoint getPreferredMediaSize();
+
+ private:
+ void load();
+ void calcProjection();
+ void setupTextures();
+ void clearTextures();
+
+ UTF8String m_href;
+ std::string m_Filename;
+ double m_SensorWidth;
+ double m_SensorHeight;
+ double m_FocalLength;
+ BitmapPtr m_pBmp;
+ int m_TexHeight;
+ std::vector<unsigned int> m_TileTextureIDs;
+
+ // Derived values calculated in calcProjection
+ double m_fovy; // Vertical field of view
+ double m_aspect; // Sensor aspect ratio
+ double m_CylHeight;
+ double m_CylAngle; // Total angle covered by panorama
+ double m_SliceAngle; // Angle per slice
+ double m_MaxRotation; // Maximum rotation angle (=Total angle - visible area)
+
+ double m_Rotation;
+};
+
+}
+
+#endif //_PanoImageNode_H_
+
diff --git a/src/player/Player.cpp b/src/player/Player.cpp
new file mode 100644
index 0000000..086f168
--- /dev/null
+++ b/src/player/Player.cpp
@@ -0,0 +1,1716 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Player.h"
+
+#include "../avgconfigwrapper.h"
+
+#include "AVGNode.h"
+#include "DivNode.h"
+#include "WordsNode.h"
+#include "VideoNode.h"
+#include "CameraNode.h"
+#include "ImageNode.h"
+#include "PanoImageNode.h"
+#include "SoundNode.h"
+#include "LineNode.h"
+#include "RectNode.h"
+#include "CurveNode.h"
+#include "PolyLineNode.h"
+#include "PolygonNode.h"
+#include "CircleNode.h"
+#include "MeshNode.h"
+#include "NodeDefinition.h"
+#include "PluginManager.h"
+#include "TextEngine.h"
+#include "TestHelper.h"
+#include "MainCanvas.h"
+#include "OffscreenCanvas.h"
+#include "TrackerInputDevice.h"
+#include "SDLDisplayEngine.h"
+#include "MultitouchInputDevice.h"
+#include "TUIOInputDevice.h"
+#ifdef __APPLE__
+ #include "AppleTrackpadInputDevice.h"
+#endif
+#if defined(_WIN32) && defined(SM_DIGITIZER)
+ #include "Win7TouchInputDevice.h"
+#endif
+#ifdef AVG_ENABLE_MTDEV
+ #include "LibMTDevInputDevice.h"
+#endif
+#if defined(HAVE_XI2_1) || defined(HAVE_XI2_2)
+ #include "XInputMTInputDevice.h"
+#endif
+#include "Contact.h"
+#include "KeyEvent.h"
+#include "MouseEvent.h"
+#include "EventDispatcher.h"
+
+#include "../base/FileHelper.h"
+#include "../base/StringHelper.h"
+#include "../base/OSHelper.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ConfigMgr.h"
+#include "../base/XMLHelper.h"
+#include "../base/ScopeTimer.h"
+#include "../base/MathHelper.h"
+
+#include "../graphics/BitmapManager.h"
+
+#include "../imaging/Camera.h"
+
+#include "../audio/SDLAudioEngine.h"
+
+#include <libxml/xmlmemory.h>
+
+#ifdef _WIN32
+#include <direct.h>
+#define getcwd _getcwd
+#endif
+
+#include <iostream>
+
+#ifdef __linux
+#include <fenv.h>
+#endif
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+Player * Player::s_pPlayer=0;
+
+Player::Player()
+ : m_pDisplayEngine(),
+ m_pMultitouchInputDevice(),
+ m_bInHandleTimers(false),
+ m_bCurrentTimeoutDeleted(false),
+ m_bStopOnEscape(true),
+ m_bIsPlaying(false),
+ m_bFakeFPS(false),
+ m_FakeFPS(0),
+ m_FrameTime(0),
+ m_Volume(1),
+ m_dtd(0),
+ m_bPythonAvailable(true),
+ m_pLastMouseEvent(new MouseEvent(Event::CURSORMOTION, false, false, false,
+ IntPoint(-1, -1), MouseEvent::NO_BUTTON, DPoint(-1, -1), 0)),
+ m_EventHookPyFunc(Py_None)
+{
+string sDummy;
+#ifdef _WIN32
+ if (getEnv("AVG_WIN_CRASH_SILENTLY", sDummy)) {
+ DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
+ SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
+ }
+#endif
+#ifdef __linux
+// Turning this on causes fp exceptions in the linux nvidia drivers.
+// feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);
+#endif
+ if (s_pPlayer) {
+ throw Exception(AVG_ERR_UNKNOWN, "Player has already been instantiated.");
+ }
+ ThreadProfilerPtr pProfiler = ThreadProfiler::get();
+ pProfiler->setName("main");
+ initConfig();
+
+ // Register all node types
+ registerNodeType(AVGNode::createDefinition());
+ registerNodeType(OffscreenCanvasNode::createDefinition());
+ registerNodeType(CanvasNode::createDefinition());
+ registerNodeType(DivNode::createDefinition());
+ registerNodeType(ImageNode::createDefinition());
+ registerNodeType(WordsNode::createDefinition());
+ registerNodeType(VideoNode::createDefinition());
+ registerNodeType(CameraNode::createDefinition());
+ registerNodeType(PanoImageNode::createDefinition());
+ registerNodeType(SoundNode::createDefinition());
+ registerNodeType(LineNode::createDefinition());
+ registerNodeType(RectNode::createDefinition());
+ registerNodeType(CurveNode::createDefinition());
+ registerNodeType(PolyLineNode::createDefinition());
+ registerNodeType(PolygonNode::createDefinition());
+ registerNodeType(CircleNode::createDefinition());
+ registerNodeType(MeshNode::createDefinition());
+
+ m_pTestHelper = TestHelperPtr(new TestHelper());
+
+ s_pPlayer = this;
+
+ m_CurDirName = getCWD();
+ if (getEnv("AVG_BREAK_ON_IMPORT", sDummy)) {
+ debugBreak();
+ }
+}
+
+void deletePlayer()
+{
+ delete Player::s_pPlayer;
+ Player::s_pPlayer = 0;
+}
+
+Player::~Player()
+{
+ if (m_dtd) {
+ xmlFreeDtd(m_dtd);
+ }
+}
+
+Player* Player::get()
+{
+ if (!s_pPlayer) {
+ s_pPlayer = new Player();
+ atexit(deletePlayer);
+ }
+ return s_pPlayer;
+}
+
+bool Player::exists()
+{
+ return s_pPlayer != 0;
+}
+
+void Player::setResolution(bool bFullscreen, int width, int height, int bpp)
+{
+ errorIfPlaying("Player.setResolution");
+ m_DP.m_bFullscreen = bFullscreen;
+ if (bpp) {
+ m_DP.m_BPP = bpp;
+ }
+ if (width) {
+ m_DP.m_WindowSize.x = width;
+ }
+ if (height) {
+ m_DP.m_WindowSize.y = height;
+ }
+}
+
+bool Player::isFullscreen()
+{
+ return m_DP.m_bFullscreen;
+}
+
+void Player::setWindowFrame(bool bHasWindowFrame)
+{
+ errorIfPlaying("Player.setWindowFrame");
+ m_DP.m_bHasWindowFrame = bHasWindowFrame;
+}
+
+void Player::setWindowPos(int x, int y)
+{
+ errorIfPlaying("Player.setWindowPos");
+ m_DP.m_Pos.x = x;
+ m_DP.m_Pos.y = y;
+}
+
+void Player::setOGLOptions(bool bUsePOTTextures, bool bUseShaders,
+ bool bUsePixelBuffers, int multiSampleSamples)
+{
+ errorIfPlaying("Player.setOGLOptions");
+ m_GLConfig.m_bUsePOTTextures = bUsePOTTextures;
+ m_GLConfig.m_bUseShaders = bUseShaders;
+ m_GLConfig.m_bUsePixelBuffers = bUsePixelBuffers;
+ m_GLConfig.m_MultiSampleSamples = multiSampleSamples;
+}
+
+void Player::setMultiSampleSamples(int multiSampleSamples)
+{
+ errorIfPlaying("Player.setMultiSampleSamples");
+ m_GLConfig.m_MultiSampleSamples = multiSampleSamples;
+}
+
+void Player::setAudioOptions(int samplerate, int channels)
+{
+ errorIfPlaying("Player.setAudioOptions");
+ m_AP.m_SampleRate = samplerate;
+ m_AP.m_Channels = channels;
+}
+
+DPoint Player::getScreenResolution()
+{
+ return DPoint(safeGetDisplayEngine()->getScreenResolution());
+}
+
+double Player::getPixelsPerMM()
+{
+ return safeGetDisplayEngine()->getPixelsPerMM();
+}
+
+DPoint Player::getPhysicalScreenDimensions()
+{
+ return safeGetDisplayEngine()->getPhysicalScreenDimensions();
+}
+
+void Player::assumePixelsPerMM(double ppmm)
+{
+ safeGetDisplayEngine()->assumePixelsPerMM(ppmm);
+}
+
+CanvasPtr Player::loadFile(const string& sFilename)
+{
+ errorIfPlaying("Player.loadFile");
+ NodePtr pNode = loadMainNodeFromFile(sFilename);
+ m_pEventDispatcher = EventDispatcherPtr(new EventDispatcher(this));
+ if (m_pMainCanvas) {
+ cleanup();
+ }
+
+ m_pMainCanvas = MainCanvasPtr(new MainCanvas(this));
+ m_pMainCanvas->setRoot(pNode);
+ m_DP.m_Size = m_pMainCanvas->getSize();
+
+ registerFrameEndListener(BitmapManager::get());
+
+ return m_pMainCanvas;
+}
+
+CanvasPtr Player::loadString(const string& sAVG)
+{
+ errorIfPlaying("Player.loadString");
+ if (m_pMainCanvas) {
+ cleanup();
+ }
+
+ NodePtr pNode = loadMainNodeFromString(sAVG);
+ m_pEventDispatcher = EventDispatcherPtr(new EventDispatcher(this));
+ m_pMainCanvas = MainCanvasPtr(new MainCanvas(this));
+ m_pMainCanvas->setRoot(pNode);
+ m_DP.m_Size = m_pMainCanvas->getSize();
+
+ registerFrameEndListener(BitmapManager::get());
+
+ return m_pMainCanvas;
+}
+
+OffscreenCanvasPtr Player::loadCanvasFile(const string& sFilename)
+{
+ NodePtr pNode = loadMainNodeFromFile(sFilename);
+ return registerOffscreenCanvas(pNode);
+}
+
+OffscreenCanvasPtr Player::loadCanvasString(const string& sAVG)
+{
+ NodePtr pNode = loadMainNodeFromString(sAVG);
+ return registerOffscreenCanvas(pNode);
+}
+
+CanvasPtr Player::createMainCanvas(const boost::python::dict& params)
+{
+ errorIfPlaying("Player.createMainCanvas");
+ if (m_pMainCanvas) {
+ cleanup();
+ }
+
+ NodePtr pNode = createNode("avg", params);
+
+ m_pEventDispatcher = EventDispatcherPtr(new EventDispatcher(this));
+ m_pMainCanvas = MainCanvasPtr(new MainCanvas(this));
+ m_pMainCanvas->setRoot(pNode);
+ m_DP.m_Size = m_pMainCanvas->getSize();
+
+ registerFrameEndListener(BitmapManager::get());
+
+ return m_pMainCanvas;
+}
+
+OffscreenCanvasPtr Player::createCanvas(const boost::python::dict& params)
+{
+ NodePtr pNode = createNode("canvas", params);
+ return registerOffscreenCanvas(pNode);
+}
+
+void Player::deleteCanvas(const string& sID)
+{
+ vector<OffscreenCanvasPtr>::iterator it;
+ for (it = m_pCanvases.begin(); it != m_pCanvases.end(); ++it) {
+ if ((*it)->getID() == sID) {
+ if ((*it)->getNumDependentCanvases() > 0) {
+ throw (Exception(AVG_ERR_INVALID_ARGS,
+ string("deleteCanvas: Canvas with id ")+sID
+ +" is still referenced."));
+ }
+ (*it)->stopPlayback();
+ m_pCanvases.erase(it);
+ return;
+ }
+ }
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ string("deleteCanvas: Canvas with id ")+sID+" does not exist."));
+}
+
+CanvasPtr Player::getMainCanvas() const
+{
+ return m_pMainCanvas;
+}
+
+OffscreenCanvasPtr Player::getCanvas(const string& sID) const
+{
+ OffscreenCanvasPtr pCanvas = findCanvas(sID);
+ if (pCanvas) {
+ return pCanvas;
+ } else {
+ throw (Exception(AVG_ERR_INVALID_ARGS,
+ string("Player::getCanvas(): No canvas with id '")+sID+"' exists."));
+ }
+}
+
+void Player::newCanvasDependency(const OffscreenCanvasPtr pCanvas)
+{
+ OffscreenCanvasPtr pNewCanvas;
+ unsigned i;
+ for (i = 0; i < m_pCanvases.size(); ++i) {
+ if (pCanvas == m_pCanvases[i]) {
+ pNewCanvas = m_pCanvases[i];
+ m_pCanvases.erase(m_pCanvases.begin()+i);
+ continue;
+ }
+ }
+ AVG_ASSERT(pNewCanvas);
+ bool bFound = false;
+ for (i = 0; i < m_pCanvases.size(); ++i) {
+ if (pNewCanvas->hasDependentCanvas(m_pCanvases[i])) {
+ bFound = true;
+ break;
+ }
+ }
+ if (bFound) {
+ for (unsigned j = i; j < m_pCanvases.size(); ++j) {
+ if (m_pCanvases[j]->hasDependentCanvas(pNewCanvas)) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Circular dependency between canvases.");
+ }
+ }
+ m_pCanvases.insert(m_pCanvases.begin()+i, pNewCanvas);
+ } else {
+ AVG_ASSERT(pNewCanvas->hasDependentCanvas(m_pMainCanvas));
+ m_pCanvases.push_back(pNewCanvas);
+ }
+/*
+ for (unsigned k=0; k<m_pCanvases.size(); ++k) {
+ m_pCanvases[k]->dump();
+ }
+*/
+}
+
+NodePtr Player::loadMainNodeFromFile(const string& sFilename)
+{
+ string RealFilename;
+ try {
+ AVG_TRACE(Logger::MEMORY, std::string("Player::loadFile(") + sFilename + ")");
+
+ // When loading an avg file, assets are loaded from a directory relative
+ // to the file.
+ char szBuf[1024];
+ char * pBuf = getcwd(szBuf, 1024);
+ if (sFilename[0] == '/') {
+ RealFilename = sFilename;
+ } else {
+ m_CurDirName = string(pBuf)+"/";
+ RealFilename = m_CurDirName+sFilename;
+ }
+ m_CurDirName = RealFilename.substr(0, RealFilename.rfind('/')+1);
+
+ string sAVG;
+ readWholeFile(RealFilename, sAVG);
+ NodePtr pNode = internalLoad(sAVG);
+
+ // Reset the directory to load assets from to the current dir.
+ m_CurDirName = string(pBuf)+"/";
+ return pNode;
+ } catch (Exception& ex) {
+ switch (ex.getCode()) {
+ case AVG_ERR_XML_PARSE:
+ throw (Exception(AVG_ERR_XML_PARSE,
+ string("Error parsing xml document ")+RealFilename));
+ break;
+ case AVG_ERR_XML_VALID:
+ throw (Exception(AVG_ERR_XML_VALID,
+ RealFilename + " does not validate."));
+ break;
+ default:
+ throw;
+ }
+ }
+}
+
+NodePtr Player::loadMainNodeFromString(const string& sAVG)
+{
+ try {
+ AVG_TRACE(Logger::MEMORY, "Player::loadString()");
+
+ string sEffectiveDoc = removeStartEndSpaces(sAVG);
+ NodePtr pNode = internalLoad(sEffectiveDoc);
+ return pNode;
+ } catch (Exception& ex) {
+ switch (ex.getCode()) {
+ case AVG_ERR_XML_PARSE:
+ throw Exception(AVG_ERR_XML_PARSE, "Error parsing xml string.");
+ break;
+ case AVG_ERR_XML_VALID:
+ throw Exception(AVG_ERR_XML_VALID, "Error validating xml string.");
+ break;
+ default:
+ throw;
+ }
+ }
+}
+
+void Player::play()
+{
+ try {
+ if (!m_pMainCanvas) {
+ throw Exception(AVG_ERR_NO_NODE, "Play called, but no xml file loaded.");
+ }
+ initPlayback();
+ try {
+ ThreadProfiler::get()->start();
+ doFrame(true);
+ while (!m_bStopping) {
+ doFrame(false);
+ }
+ } catch (...) {
+ cleanup();
+ throw;
+ }
+ cleanup();
+ AVG_TRACE(Logger::PLAYER, "Playback ended.");
+ } catch (Exception& ex) {
+ m_bIsPlaying = false;
+ AVG_TRACE(Logger::ERROR, ex.getStr());
+ throw;
+ }
+}
+
+void Player::stop()
+{
+ if (m_bIsPlaying) {
+ m_bStopping = true;
+ } else {
+ cleanup();
+ }
+}
+
+bool Player::isStopping()
+{
+ return m_bStopping;
+}
+
+void Player::initPlayback()
+{
+ m_bIsPlaying = true;
+ AVG_TRACE(Logger::PLAYER, "Playback started.");
+ initGraphics();
+ initAudio();
+ try {
+ for (unsigned i = 0; i < m_pCanvases.size(); ++i) {
+ m_pCanvases[i]->initPlayback();
+ }
+ m_pMainCanvas->initPlayback(m_pDisplayEngine);
+ } catch (Exception&) {
+ cleanup();
+ throw;
+ }
+ m_pEventDispatcher->addInputDevice(
+ boost::dynamic_pointer_cast<IInputDevice>(m_pDisplayEngine));
+ m_pEventDispatcher->addInputDevice(m_pTestHelper);
+
+ m_pDisplayEngine->initRender();
+ m_bStopping = false;
+ if (m_pMultitouchInputDevice) {
+ m_pMultitouchInputDevice->start();
+ }
+
+ m_FrameTime = 0;
+ m_NumFrames = 0;
+}
+
+bool Player::isPlaying()
+{
+ return m_bIsPlaying;
+}
+
+void Player::setFramerate(double rate)
+{
+ if (m_bIsPlaying) {
+ m_pDisplayEngine->setFramerate(rate);
+ } else {
+ m_DP.m_Framerate = rate;
+ m_DP.m_VBRate = 0;
+ }
+}
+
+void Player::setVBlankFramerate(int rate)
+{
+ if (m_bIsPlaying) {
+ m_pDisplayEngine->setVBlankRate(rate);
+ } else {
+ m_DP.m_Framerate = 0;
+ m_DP.m_VBRate = rate;
+ }
+}
+
+double Player::getEffectiveFramerate()
+{
+ if (m_bIsPlaying) {
+ if (m_bFakeFPS) {
+ return m_FakeFPS;
+ } else {
+ return m_pDisplayEngine->getEffectiveFramerate();
+ }
+ } else {
+ return 0;
+ }
+}
+
+TestHelper * Player::getTestHelper()
+{
+ return m_pTestHelper.get();
+}
+
+void Player::setFakeFPS(double fps)
+{
+ if (fabs(fps + 1.0) < 0.0001) {
+ // fps = -1
+ m_bFakeFPS = false;
+ } else {
+ m_bFakeFPS = true;
+ m_FakeFPS = fps;
+ }
+
+ if (SDLAudioEngine::get()) {
+ SDLAudioEngine::get()->setAudioEnabled(!m_bFakeFPS);
+ }
+}
+
+void Player::addInputDevice(IInputDevicePtr pSource)
+{
+ if (!m_pEventDispatcher) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "You must use loadFile() before addInputDevice().");
+ }
+ m_pEventDispatcher->addInputDevice(pSource);
+}
+
+long long Player::getFrameTime()
+{
+ return m_FrameTime;
+}
+
+double Player::getFrameDuration()
+{
+ if (!m_bIsPlaying) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Must call Player.play() before getFrameDuration().");
+ }
+ if (m_bFakeFPS) {
+ return 1000.0/m_FakeFPS;
+ } else {
+ double framerate = m_pDisplayEngine->getEffectiveFramerate();
+ if (framerate > 0) {
+ return 1000./framerate;
+ } else {
+ return 0;
+ }
+ }
+}
+
+TrackerInputDevice * Player::addTracker()
+{
+ if (!m_pMainCanvas) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "You must use loadFile() before addTracker().");
+ }
+ m_pMultitouchInputDevice = IInputDevicePtr(new TrackerInputDevice());
+ addInputDevice(m_pMultitouchInputDevice);
+ if (m_bIsPlaying) {
+ m_pMultitouchInputDevice->start();
+ }
+
+ return dynamic_cast<TrackerInputDevice*>(m_pMultitouchInputDevice.get());
+}
+
+TrackerInputDevice * Player::getTracker()
+{
+ TrackerInputDevice* pTracker = dynamic_cast<TrackerInputDevice*>(
+ m_pMultitouchInputDevice.get());
+ return pTracker;
+}
+
+void Player::enableMultitouch()
+{
+
+ string sDriver;
+ getEnv("AVG_MULTITOUCH_DRIVER", sDriver);
+ if (sDriver == "") {
+#if defined(_WIN32) && defined(SM_DIGITIZER)
+ sDriver = "WIN7TOUCH";
+#elif defined(HAVE_XI2_1) || defined(HAVE_XI2_2)
+ sDriver = "XINPUT";
+#elif defined (AVG_ENABLE_MTDEV)
+ sDriver = "LINUXMTDEV";
+#else
+ AVG_TRACE(Logger::WARNING, "Valid values for AVG_MULTITOUCH_DRIVER are WIN7TOUCH, XINPUT, LINUXMTDEV, TRACKER, TUIO and APPLETRACKPAD.");
+ throw Exception(AVG_ERR_MT_INIT,
+ "Multitouch support: No default driver available. Set AVG_MULTITOUCH_DRIVER.");
+#endif
+ }
+ if (sDriver == "TUIO") {
+ m_pMultitouchInputDevice = IInputDevicePtr(new TUIOInputDevice);
+#if defined(_WIN32) && defined(SM_DIGITIZER)
+ } else if (sDriver == "WIN7TOUCH") {
+ m_pMultitouchInputDevice = IInputDevicePtr(new Win7TouchInputDevice);
+#endif
+ } else if (sDriver == "XINPUT" || sDriver == "XINPUT21") {
+#if defined(HAVE_XI2_1) || defined(HAVE_XI2_2)
+ m_pMultitouchInputDevice = IInputDevicePtr(new XInputMTInputDevice);
+#else
+ throw Exception(AVG_ERR_MT_INIT,
+ "XInput multitouch event source: Support not configured.'");
+#endif
+#ifdef AVG_ENABLE_MTDEV
+ } else if (sDriver == "LINUXMTDEV") {
+ m_pMultitouchInputDevice = IInputDevicePtr(new LibMTDevInputDevice);
+#endif
+#ifdef __APPLE__
+ } else if (sDriver == "APPLETRACKPAD") {
+ m_pMultitouchInputDevice = IInputDevicePtr(new AppleTrackpadInputDevice);
+#endif
+ } else if (sDriver == "TRACKER") {
+ m_pMultitouchInputDevice = IInputDevicePtr(new TrackerInputDevice);
+ } else {
+ AVG_TRACE(Logger::WARNING, "Valid values for AVG_MULTITOUCH_DRIVER are WIN7TOUCH, XINPUT, LINUXMTDEV, TRACKER, TUIO and APPLETRACKPAD.");
+ throw Exception(AVG_ERR_UNSUPPORTED, string("Unsupported multitouch driver '")+
+ sDriver +"'.");
+ }
+ if (m_bIsPlaying) {
+ try {
+ m_pMultitouchInputDevice->start();
+ } catch (Exception&) {
+ m_pMultitouchInputDevice = IInputDevicePtr();
+ throw;
+ }
+ }
+ addInputDevice(m_pMultitouchInputDevice);
+}
+
+bool Player::isMultitouchAvailable() const
+{
+ if (m_bIsPlaying) {
+ return m_pMultitouchInputDevice != 0;
+ } else {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Must call Player.play() before isMultitouchAvailable().");
+ }
+}
+
+void Player::setEventCapture(NodePtr pNode, int cursorID=MOUSECURSORID)
+{
+ std::map<int, EventCaptureInfoPtr>::iterator it =
+ m_EventCaptureInfoMap.find(cursorID);
+ if (it != m_EventCaptureInfoMap.end() && !(it->second->m_pNode.expired())) {
+ EventCaptureInfoPtr pCaptureInfo = it->second;
+ NodePtr pOldNode = pCaptureInfo->m_pNode.lock();
+ if (pOldNode == pNode) {
+ pCaptureInfo->m_CaptureCount++;
+ } else {
+ throw Exception(AVG_ERR_INVALID_CAPTURE, "setEventCapture called for '"
+ + pNode->getID() + "', but cursor already captured by '"
+ + pOldNode->getID() + "'.");
+ }
+ } else {
+ m_EventCaptureInfoMap[cursorID] = EventCaptureInfoPtr(
+ new EventCaptureInfo(pNode));
+ }
+}
+
+void Player::releaseEventCapture(int cursorID)
+{
+ std::map<int, EventCaptureInfoPtr>::iterator it =
+ m_EventCaptureInfoMap.find(cursorID);
+ if (it == m_EventCaptureInfoMap.end() || (it->second->m_pNode.expired()) ) {
+ throw Exception(AVG_ERR_INVALID_CAPTURE,
+ "releaseEventCapture called, but cursor not captured.");
+ } else {
+ it->second->m_CaptureCount--;
+ if (it->second->m_CaptureCount == 0) {
+ m_EventCaptureInfoMap.erase(cursorID);
+ }
+ }
+}
+
+bool Player::isCaptured(int cursorID)
+{
+ std::map<int, EventCaptureInfoPtr>::iterator it =
+ m_EventCaptureInfoMap.find(cursorID);
+ return (it != m_EventCaptureInfoMap.end());
+}
+
+int Player::setInterval(int time, PyObject * pyfunc)
+{
+ Timeout* pTimeout = new Timeout(time, pyfunc, true, getFrameTime());
+ if (m_bInHandleTimers) {
+ m_NewTimeouts.push_back(pTimeout);
+ } else {
+ addTimeout(pTimeout);
+ }
+ return pTimeout->GetID();
+}
+
+int Player::setTimeout(int time, PyObject * pyfunc)
+{
+ Timeout* pTimeout = new Timeout(time, pyfunc, false, getFrameTime());
+ if (m_bInHandleTimers) {
+ m_NewTimeouts.push_back(pTimeout);
+ } else {
+ addTimeout(pTimeout);
+ }
+ return pTimeout->GetID();
+}
+
+int Player::setOnFrameHandler(PyObject * pyfunc)
+{
+ return setInterval(0, pyfunc);
+}
+
+bool Player::clearInterval(int id)
+{
+ vector<Timeout*>::iterator it;
+ for (it = m_PendingTimeouts.begin(); it != m_PendingTimeouts.end(); it++) {
+ if (id == (*it)->GetID()) {
+ if (it == m_PendingTimeouts.begin() && m_bInHandleTimers) {
+ m_bCurrentTimeoutDeleted = true;
+ }
+ delete *it;
+ m_PendingTimeouts.erase(it);
+ return true;
+ }
+ }
+ for (it = m_NewTimeouts.begin(); it != m_NewTimeouts.end(); it++) {
+ if (id == (*it)->GetID()) {
+ delete *it;
+ m_NewTimeouts.erase(it);
+ return true;
+ }
+ }
+ return false;
+}
+
+MouseEventPtr Player::getMouseState() const
+{
+ return m_pLastMouseEvent;
+}
+
+void Player::setMousePos(const IntPoint& pos)
+{
+ m_pDisplayEngine->setMousePos(pos);
+}
+
+int Player::getKeyModifierState() const
+{
+ return m_pDisplayEngine->getKeyModifierState();
+}
+
+BitmapPtr Player::screenshot()
+{
+ if (!m_bIsPlaying) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Must call Player.play() before screenshot().");
+ }
+ return m_pDisplayEngine->screenshot();
+}
+
+void Player::showCursor(bool bShow)
+{
+ if (m_pDisplayEngine) {
+ m_pDisplayEngine->showCursor(bShow);
+ }
+ m_DP.m_bShowCursor = bShow;
+}
+
+void Player::setCursor(const Bitmap* pBmp, IntPoint hotSpot)
+{
+ IntPoint size = pBmp->getSize();
+ if (size.x % 8 != 0 || size.y % 8 != 0 || pBmp->getPixelFormat() != R8G8B8A8) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "setCursor: Bitmap size must be divisible by 8 and in RGBA format.");
+ }
+ int i = -1;
+ unsigned char * pData = new unsigned char[size.x*size.y/8];
+ unsigned char * pMask = new unsigned char[size.x*size.y/8];
+ Pixel32 * pLine = (Pixel32*)(pBmp->getPixels());
+ int stride = pBmp->getStride()/4;
+ for (int y = 0; y < size.y; ++y) {
+ Pixel32 * pPixel = pLine;
+ for (int x = 0; x < size.x; ++x) {
+ if (x % 8 == 0) {
+ i++;
+ pData[i] = 0;
+ pMask[i] = 0;
+ } else {
+ pData[i] <<= 1;
+ pMask[i] <<= 1;
+ }
+ if (pPixel->getA() > 127) {
+ pMask[i] |= 0x01;
+ if (pPixel->getR() < 128) {
+ // Black Pixel
+ pData[i] |= 0x01;
+ }
+ }
+ pPixel++;
+ }
+ pLine += stride;
+ }
+ SDL_Cursor * pCursor = SDL_CreateCursor(pData, pMask, size.x, size.y,
+ hotSpot.x, hotSpot.y);
+ SDL_SetCursor(pCursor);
+ delete[] pData;
+ delete[] pMask;
+}
+
+NodePtr Player::getElementByID(const std::string& sID)
+{
+ if (m_pMainCanvas) {
+ return m_pMainCanvas->getElementByID(sID);
+ } else {
+ return NodePtr();
+ }
+}
+
+AVGNodePtr Player::getRootNode()
+{
+ if (m_pMainCanvas) {
+ return dynamic_pointer_cast<AVGNode>(m_pMainCanvas->getRootNode());
+ } else {
+ return AVGNodePtr();
+ }
+}
+
+string Player::getCurDirName()
+{
+ return m_CurDirName;
+}
+
+std::string Player::getRootMediaDir()
+{
+ string sMediaDir;
+ if (m_pMainCanvas) {
+ sMediaDir = m_pMainCanvas->getRootNode()->getEffectiveMediaDir();
+ } else {
+ sMediaDir = m_CurDirName;
+ }
+ return sMediaDir;
+}
+
+const NodeDefinition& Player::getNodeDef(const std::string& sType)
+{
+ return m_NodeRegistry.getNodeDef(sType);
+}
+
+void Player::disablePython()
+{
+ m_bPythonAvailable = false;
+}
+
+void Player::registerFrameEndListener(IFrameEndListener* pListener)
+{
+ AVG_ASSERT(m_pMainCanvas);
+ m_pMainCanvas->registerFrameEndListener(pListener);
+}
+
+void Player::unregisterFrameEndListener(IFrameEndListener* pListener)
+{
+ if (m_pMainCanvas) {
+ m_pMainCanvas->unregisterFrameEndListener(pListener);
+ }
+}
+
+void Player::registerPlaybackEndListener(IPlaybackEndListener* pListener)
+{
+ AVG_ASSERT(m_pMainCanvas);
+ m_pMainCanvas->registerPlaybackEndListener(pListener);
+}
+
+void Player::unregisterPlaybackEndListener(IPlaybackEndListener* pListener)
+{
+ if (m_pMainCanvas) {
+ m_pMainCanvas->unregisterPlaybackEndListener(pListener);
+ }
+}
+
+void Player::registerPreRenderListener(IPreRenderListener* pListener)
+{
+ AVG_ASSERT(m_pMainCanvas);
+ m_pMainCanvas->registerPreRenderListener(pListener);
+}
+
+void Player::unregisterPreRenderListener(IPreRenderListener* pListener)
+{
+ if (m_pMainCanvas) {
+ m_pMainCanvas->unregisterPreRenderListener(pListener);
+ }
+}
+
+bool Player::handleEvent(EventPtr pEvent)
+{
+ AVG_ASSERT(pEvent);
+
+ PyObject * pEventHook = getEventHook();
+ if (pEventHook != Py_None) {
+ // If the catchall returns true, stop processing the event
+ if (boost::python::call<bool>(pEventHook, pEvent)) {
+ return true;
+ }
+ }
+ if (MouseEventPtr pMouseEvent = boost::dynamic_pointer_cast<MouseEvent>(pEvent)) {
+ m_pLastMouseEvent = pMouseEvent;
+ }
+
+ if (CursorEventPtr pCursorEvent = boost::dynamic_pointer_cast<CursorEvent>(pEvent)) {
+ if (pEvent->getType() == Event::CURSOROUT ||
+ pEvent->getType() == Event::CURSOROVER)
+ {
+ pEvent->trace();
+ pCursorEvent->getNode()->handleEvent(pEvent);
+ } else {
+ handleCursorEvent(pCursorEvent);
+ }
+ }
+ else if (KeyEventPtr pKeyEvent = boost::dynamic_pointer_cast<KeyEvent>(pEvent))
+ {
+ pEvent->trace();
+ getRootNode()->handleEvent(pKeyEvent);
+ if (getStopOnEscape() && pEvent->getType() == Event::KEYDOWN
+ && pKeyEvent->getKeyCode() == avg::key::KEY_ESCAPE)
+ {
+ stop();
+ }
+ }
+ else {
+ if (pEvent->getType() != Event::QUIT) {
+ pEvent->trace();
+ getRootNode()->handleEvent(pEvent);
+ }
+ else {
+ stop();
+ }
+ }
+ return true;
+}
+
+static ProfilingZoneID MainProfilingZone("Player - Total frame time");
+static ProfilingZoneID TimersProfilingZone("Player - handleTimers");
+static ProfilingZoneID EventsProfilingZone("Dispatch events");
+
+void Player::doFrame(bool bFirstFrame)
+{
+ {
+ ScopeTimer Timer(MainProfilingZone);
+ if (!bFirstFrame) {
+ if (m_bFakeFPS) {
+ m_NumFrames++;
+ m_FrameTime = (long long)((m_NumFrames*1000.0)/m_FakeFPS);
+ } else {
+ m_FrameTime = m_pDisplayEngine->getDisplayTime();
+ }
+ {
+ ScopeTimer Timer(TimersProfilingZone);
+ handleTimers();
+ }
+ {
+ ScopeTimer Timer(EventsProfilingZone);
+ m_pEventDispatcher->dispatch();
+ sendFakeEvents();
+ }
+ }
+ for (unsigned i = 0; i < m_pCanvases.size(); ++i) {
+ dispatchOffscreenRendering(m_pCanvases[i].get());
+ }
+ m_pMainCanvas->doFrame(m_bPythonAvailable);
+ if (m_bPythonAvailable) {
+ Py_BEGIN_ALLOW_THREADS;
+ try {
+ endFrame();
+ } catch(...) {
+ Py_BLOCK_THREADS;
+ throw;
+ }
+ Py_END_ALLOW_THREADS;
+ } else {
+ endFrame();
+ }
+ }
+ if (m_pDisplayEngine->wasFrameLate()) {
+ ThreadProfiler::get()->dumpFrame();
+ }
+
+ ThreadProfiler::get()->reset();
+}
+
+void Player::endFrame()
+{
+ m_pDisplayEngine->frameWait();
+ m_pDisplayEngine->swapBuffers();
+ m_pDisplayEngine->checkJitter();
+}
+
+double Player::getFramerate()
+{
+ if (!m_pDisplayEngine) {
+ return m_DP.m_Framerate;
+ }
+ return m_pDisplayEngine->getFramerate();
+}
+
+double Player::getVideoRefreshRate()
+{
+ if (!m_pDisplayEngine) {
+ return 0;
+ }
+ return m_pDisplayEngine->getRefreshRate();
+}
+
+bool Player::isUsingShaders()
+{
+ if (!m_pDisplayEngine) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Player.isUsingShaders must be called after Player.play().");
+ }
+ return GLContext::getCurrent()->isUsingShaders();
+}
+
+void Player::setGamma(double red, double green, double blue)
+{
+ if (m_pDisplayEngine) {
+ m_pDisplayEngine->setGamma(red, green, blue);
+ } else {
+ m_DP.m_Gamma[0] = red;
+ m_DP.m_Gamma[1] = green;
+ m_DP.m_Gamma[2] = blue;
+ }
+}
+
+void Player::initConfig()
+{
+ // Get data from config files.
+ ConfigMgr* pMgr = ConfigMgr::get();
+
+ m_DP.m_BPP = atoi(pMgr->getOption("scr", "bpp")->c_str());
+ if (m_DP.m_BPP != 15 && m_DP.m_BPP != 16 && m_DP.m_BPP != 24 && m_DP.m_BPP != 32) {
+ AVG_TRACE(Logger::ERROR,
+ "BPP must be 15, 16, 24 or 32. Current value is "
+ << m_DP.m_BPP << ". Aborting." );
+ exit(-1);
+ }
+ m_DP.m_bFullscreen = pMgr->getBoolOption("scr", "fullscreen", false);
+
+ m_DP.m_WindowSize.x = atoi(pMgr->getOption("scr", "windowwidth")->c_str());
+ m_DP.m_WindowSize.y = atoi(pMgr->getOption("scr", "windowheight")->c_str());
+ m_DP.m_DotsPerMM = atof(pMgr->getOption("scr", "dotspermm")->c_str());
+
+ if (m_DP.m_bFullscreen && (m_DP.m_WindowSize != IntPoint(0, 0))) {
+ AVG_TRACE(Logger::ERROR,
+ "Can't set fullscreen and window size at once. Aborting.");
+ exit(-1);
+ }
+ if (m_DP.m_WindowSize.x != 0 && m_DP.m_WindowSize.y != 0) {
+ AVG_TRACE(Logger::ERROR, "Can't set window width and height at once");
+ AVG_TRACE(Logger::ERROR,
+ "(aspect ratio is determined by avg file). Aborting.");
+ exit(-1);
+ }
+
+ m_AP.m_Channels = atoi(pMgr->getOption("aud", "channels")->c_str());
+ m_AP.m_SampleRate = atoi(pMgr->getOption("aud", "samplerate")->c_str());
+ m_AP.m_OutputBufferSamples =
+ atoi(pMgr->getOption("aud", "outputbuffersamples")->c_str());
+
+ m_GLConfig.m_bUsePOTTextures = pMgr->getBoolOption("scr", "usepow2textures", false);
+ m_GLConfig.m_bUseShaders = pMgr->getBoolOption("scr", "useshaders", true);
+
+ m_GLConfig.m_bUsePixelBuffers = pMgr->getBoolOption("scr", "usepixelbuffers", true);
+ m_GLConfig.m_MultiSampleSamples = pMgr->getIntOption("scr", "multisamplesamples", 4);
+ pMgr->getGammaOption("scr", "gamma", m_DP.m_Gamma);
+}
+
+void Player::initGraphics()
+{
+ // Init display configuration.
+ AVG_TRACE(Logger::CONFIG, "Display bpp: " << m_DP.m_BPP);
+
+ if (!m_pDisplayEngine) {
+ m_pDisplayEngine = SDLDisplayEnginePtr(new SDLDisplayEngine());
+ }
+ AVG_TRACE(Logger::CONFIG, "Requested OpenGL configuration: ");
+ m_GLConfig.log();
+ m_pDisplayEngine->init(m_DP, m_GLConfig);
+}
+
+void Player::initAudio()
+{
+ SDLAudioEngine* pAudioEngine = SDLAudioEngine::get();
+ if (!pAudioEngine) {
+ pAudioEngine = new SDLAudioEngine();
+ }
+ pAudioEngine->init(m_AP, m_Volume);
+ pAudioEngine->setAudioEnabled(!m_bFakeFPS);
+ pAudioEngine->play();
+}
+
+void Player::updateDTD()
+{
+ if (m_dtd) {
+ xmlFreeDtd(m_dtd);
+ }
+ // Find and parse dtd.
+ registerDTDEntityLoader("avg.dtd", m_NodeRegistry.getDTD().c_str());
+ string sDTDFName = "avg.dtd";
+ m_dtd = xmlParseDTD(NULL, (const xmlChar*) sDTDFName.c_str());
+ assert (m_dtd);
+ m_bDirtyDTD = false;
+}
+
+NodePtr Player::internalLoad(const string& sAVG)
+{
+ xmlDocPtr doc = 0;
+ try {
+ xmlPedanticParserDefault(1);
+ xmlDoValidityCheckingDefaultValue=0;
+
+ doc = xmlParseMemory(sAVG.c_str(), sAVG.length());
+ if (!doc) {
+ throw (Exception(AVG_ERR_XML_PARSE, ""));
+ }
+
+ if (m_bDirtyDTD) {
+ updateDTD();
+ }
+
+ xmlValidCtxtPtr cvp = xmlNewValidCtxt();
+ cvp->error = xmlParserValidityError;
+ cvp->warning = xmlParserValidityWarning;
+ int valid=xmlValidateDtd(cvp, doc, m_dtd);
+ xmlFreeValidCtxt(cvp);
+ if (!valid) {
+ throw (Exception(AVG_ERR_XML_VALID, ""));
+ }
+ xmlNodePtr xmlNode = xmlDocGetRootElement(doc);
+ NodePtr pNode = createNodeFromXml(doc, xmlNode);
+ if (!pNode) {
+ throw (Exception(AVG_ERR_XML_PARSE,
+ "Root node of an avg tree needs to be an <avg> node."));
+ }
+ xmlFreeDoc(doc);
+ return pNode;
+ } catch (Exception& ex) {
+ AVG_TRACE(Logger::ERROR, ex.getStr());
+ if (doc) {
+ xmlFreeDoc(doc);
+ }
+ throw;
+ }
+}
+
+SDLDisplayEnginePtr Player::safeGetDisplayEngine()
+{
+ if (!m_pDisplayEngine) {
+ m_pDisplayEngine = SDLDisplayEnginePtr(new SDLDisplayEngine());
+ }
+ return m_pDisplayEngine;
+
+}
+
+void Player::registerNodeType(NodeDefinition def, const char* pParentNames[])
+{
+ m_NodeRegistry.registerNodeType(def);
+
+ if (pParentNames) {
+ string sChildArray[1];
+ sChildArray[0] = def.getName();
+ vector<string> sChildren = vectorFromCArray(1, sChildArray);
+ const char **ppCurParentName = pParentNames;
+
+ while (*ppCurParentName) {
+ NodeDefinition nodeDefinition = m_NodeRegistry.getNodeDef(*ppCurParentName);
+ nodeDefinition.addChildren(sChildren);
+ m_NodeRegistry.updateNodeDefinition(nodeDefinition);
+
+ ++ppCurParentName;
+ }
+ }
+ m_bDirtyDTD = true;
+}
+
+NodePtr Player::createNode(const string& sType, const boost::python::dict& params)
+{
+ DivNodePtr pParentNode;
+ boost::python::dict attrs = params;
+ boost::python::object parent;
+ if (params.has_key("parent")) {
+ parent = params["parent"];
+ attrs.attr("__delitem__")("parent");
+ pParentNode = boost::python::extract<DivNodePtr>(parent);
+ }
+ NodePtr pNode = m_NodeRegistry.createNode(sType, attrs);
+ if (pParentNode) {
+ pParentNode->appendChild(pNode);
+ }
+ if (parent) {
+ attrs["parent"] = parent;
+ }
+ return pNode;
+}
+
+NodePtr Player::createNodeFromXmlString(const string& sXML)
+{
+ xmlPedanticParserDefault(1);
+ xmlDoValidityCheckingDefaultValue =0;
+
+ xmlDocPtr doc;
+ doc = xmlParseMemory(sXML.c_str(), int(sXML.length()));
+ if (!doc) {
+ throw (Exception(AVG_ERR_XML_PARSE,
+ string("Error parsing xml:\n ")+sXML));
+ }
+ NodePtr pNode = createNodeFromXml(doc, xmlDocGetRootElement(doc));
+
+ if (m_bDirtyDTD)
+ updateDTD();
+
+ xmlValidCtxtPtr cvp = xmlNewValidCtxt();
+ cvp->error = xmlParserValidityError;
+ cvp->warning = xmlParserValidityWarning;
+ int valid=xmlValidateDtd(cvp, doc, m_dtd);
+ xmlFreeValidCtxt(cvp);
+ if (!valid) {
+ throw (Exception(AVG_ERR_XML_PARSE,
+ "Could not validate '"+sXML+"'"));
+ }
+
+ xmlFreeDoc(doc);
+ return pNode;
+}
+
+NodePtr Player::createNodeFromXml(const xmlDocPtr xmlDoc,
+ const xmlNodePtr xmlNode)
+{
+ NodePtr pCurNode;
+ const char * nodeType = (const char *)xmlNode->name;
+
+ if (!strcmp (nodeType, "text") ||
+ !strcmp (nodeType, "comment")) {
+ // Ignore whitespace & comments
+ return NodePtr();
+ }
+ pCurNode = m_NodeRegistry.createNode(nodeType, xmlNode);
+ if (!strcmp(nodeType, "words")) {
+ // TODO: This is an end-run around the generic serialization mechanism
+ // that will probably break at some point.
+ string s = getXmlChildrenAsString(xmlDoc, xmlNode);
+ boost::dynamic_pointer_cast<WordsNode>(pCurNode)->setTextFromNodeValue(s);
+ } else {
+ // If this is a container, recurse into children
+ if (pCurNode->getDefinition()->hasChildren()) {
+ xmlNodePtr curXmlChild = xmlNode->xmlChildrenNode;
+ while (curXmlChild) {
+ NodePtr curChild = createNodeFromXml(xmlDoc, curXmlChild);
+ if (curChild) {
+ DivNodePtr pDivNode = boost::dynamic_pointer_cast<DivNode>(pCurNode);
+ pDivNode->appendChild(curChild);
+ }
+ curXmlChild = curXmlChild->next;
+ }
+ }
+ }
+ return pCurNode;
+}
+
+OffscreenCanvasPtr Player::registerOffscreenCanvas(NodePtr pNode)
+{
+ OffscreenCanvasPtr pCanvas(new OffscreenCanvas(this));
+ pCanvas->setRoot(pNode);
+ if (findCanvas(pCanvas->getID())) {
+ throw (Exception(AVG_ERR_INVALID_ARGS,
+ string("Duplicate canvas id ")+pCanvas->getID()));
+ }
+ m_pCanvases.push_back(pCanvas);
+ if (m_bIsPlaying) {
+ try {
+ pCanvas->initPlayback();
+ } catch (...) {
+ m_pCanvases.pop_back();
+ throw;
+ }
+ }
+ return pCanvas;
+}
+
+OffscreenCanvasPtr Player::findCanvas(const string& sID) const
+{
+ for (unsigned i=0; i<m_pCanvases.size(); ++i) {
+ if (m_pCanvases[i]->getID() == sID) {
+ return m_pCanvases[i];
+ }
+ }
+ return OffscreenCanvasPtr();
+}
+
+void Player::sendFakeEvents()
+{
+ std::map<int, CursorStatePtr>::iterator it;
+ for (it = m_pLastCursorStates.begin(); it != m_pLastCursorStates.end(); ++it) {
+ CursorStatePtr pState = it->second;
+ handleCursorEvent(pState->getLastEvent(), true);
+ }
+}
+
+void Player::sendOver(const CursorEventPtr pOtherEvent, Event::Type type,
+ NodePtr pNode)
+{
+ if (pNode) {
+ CursorEventPtr pNewEvent = pOtherEvent->cloneAs(type);
+ pNewEvent->setNode(pNode);
+ m_pEventDispatcher->sendEvent(pNewEvent);
+ }
+}
+
+void Player::handleCursorEvent(CursorEventPtr pEvent, bool bOnlyCheckCursorOver)
+{
+ // Find all nodes under the cursor.
+ vector<NodeWeakPtr> pCursorNodes;
+ DivNodePtr pEventReceiverNode = pEvent->getInputDevice()->getEventReceiverNode();
+ if (!pEventReceiverNode) {
+ pEventReceiverNode = getRootNode();
+ }
+ pEventReceiverNode->getElementsByPos(pEvent->getPos(), pCursorNodes);
+ ContactPtr pContact = pEvent->getContact();
+ if (pContact && pContact->hasListeners() && !bOnlyCheckCursorOver) {
+ if (!pCursorNodes.empty()) {
+ NodePtr pNode = pCursorNodes.begin()->lock();
+ pEvent->setNode(pNode);
+ }
+ pContact->sendEventToListeners(pEvent);
+ }
+
+ int cursorID = pEvent->getCursorID();
+
+ // Determine the nodes the event should be sent to.
+ vector<NodeWeakPtr> pDestNodes = pCursorNodes;
+ if (m_EventCaptureInfoMap.find(cursorID) != m_EventCaptureInfoMap.end()) {
+ NodeWeakPtr pEventCaptureNode =
+ m_EventCaptureInfoMap[cursorID]->m_pNode;
+ if (pEventCaptureNode.expired()) {
+ m_EventCaptureInfoMap.erase(cursorID);
+ } else {
+ pDestNodes = pEventCaptureNode.lock()->getParentChain();
+ }
+ }
+
+ vector<NodeWeakPtr> pLastCursorNodes;
+ {
+ map<int, CursorStatePtr>::iterator it;
+ it = m_pLastCursorStates.find(cursorID);
+ if (it != m_pLastCursorStates.end()) {
+ pLastCursorNodes = it->second->getNodes();
+ }
+ }
+
+ // Send out events.
+ vector<NodeWeakPtr>::const_iterator itLast;
+ vector<NodeWeakPtr>::iterator itCur;
+ for (itLast = pLastCursorNodes.begin(); itLast != pLastCursorNodes.end();
+ ++itLast)
+ {
+ NodePtr pLastNode = itLast->lock();
+ for (itCur = pCursorNodes.begin(); itCur != pCursorNodes.end(); ++itCur) {
+ if (itCur->lock() == pLastNode) {
+ break;
+ }
+ }
+ if (itCur == pCursorNodes.end()) {
+ sendOver(pEvent, Event::CURSOROUT, pLastNode);
+ }
+ }
+
+ // Send over events.
+ for (itCur = pCursorNodes.begin(); itCur != pCursorNodes.end(); ++itCur) {
+ NodePtr pCurNode = itCur->lock();
+ for (itLast = pLastCursorNodes.begin(); itLast != pLastCursorNodes.end();
+ ++itLast)
+ {
+ if (itLast->lock() == pCurNode) {
+ break;
+ }
+ }
+ if (itLast == pLastCursorNodes.end()) {
+ sendOver(pEvent, Event::CURSOROVER, pCurNode);
+ }
+ }
+
+ if (!bOnlyCheckCursorOver) {
+ // Iterate through the nodes and send the event to all of them.
+ vector<NodeWeakPtr>::iterator it;
+ for (it = pDestNodes.begin(); it != pDestNodes.end(); ++it) {
+ NodePtr pNode = (*it).lock();
+ if (pNode) {
+ CursorEventPtr pNodeEvent = boost::dynamic_pointer_cast<CursorEvent>(
+ pEvent->cloneAs(pEvent->getType()));
+ pNodeEvent->setNode(pNode);
+ if (pNodeEvent->getType() != Event::CURSORMOTION) {
+ pNodeEvent->trace();
+ }
+ if (pNode->handleEvent(pNodeEvent) == true) {
+ // stop bubbling
+ break;
+ }
+ }
+ }
+ }
+
+ if (pEvent->getType() == Event::CURSORUP && pEvent->getSource() != Event::MOUSE) {
+ // Cursor has disappeared: send out events.
+ vector<NodeWeakPtr>::iterator it;
+ for (it = pCursorNodes.begin(); it != pCursorNodes.end(); ++it) {
+ NodePtr pNode = it->lock();
+ sendOver(pEvent, Event::CURSOROUT, pNode);
+ }
+ m_pLastCursorStates.erase(cursorID);
+ } else {
+ // Update list of nodes under cursor
+ if (m_pLastCursorStates.find(cursorID) != m_pLastCursorStates.end()) {
+ m_pLastCursorStates[cursorID]->setInfo(pEvent, pCursorNodes);
+ } else {
+ m_pLastCursorStates[cursorID] =
+ CursorStatePtr(new CursorState(pEvent, pCursorNodes));
+ }
+ }
+}
+
+void Player::dispatchOffscreenRendering(OffscreenCanvas* pOffscreenCanvas)
+{
+ if (!pOffscreenCanvas->getAutoRender()) {
+ return;
+ }
+ if (pOffscreenCanvas->hasRegisteredCamera()) {
+ pOffscreenCanvas->updateCameraImage();
+ while (pOffscreenCanvas->isCameraImageAvailable()) {
+ pOffscreenCanvas->doFrame(m_bPythonAvailable);
+ pOffscreenCanvas->updateCameraImage();
+ }
+ } else {
+ pOffscreenCanvas->doFrame(m_bPythonAvailable);
+ return;
+ }
+}
+
+void Player::errorIfPlaying(const std::string& sFunc) const
+{
+ if (m_bIsPlaying) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ sFunc + " must be called before Player.play().");
+ }
+}
+
+void Player::handleTimers()
+{
+ vector<Timeout *>::iterator it;
+ m_bInHandleTimers = true;
+
+ it = m_PendingTimeouts.begin();
+ while (it != m_PendingTimeouts.end() && (*it)->IsReady(getFrameTime())
+ && !m_bStopping)
+ {
+ (*it)->Fire(getFrameTime());
+ if (m_bCurrentTimeoutDeleted) {
+ it = m_PendingTimeouts.begin();
+ } else {
+ if ((*it)->IsInterval()) {
+ Timeout* pTempTimeout = *it;
+ it = m_PendingTimeouts.erase(it);
+ m_NewTimeouts.insert(m_NewTimeouts.begin(), pTempTimeout);
+ } else {
+ delete *it;
+ it = m_PendingTimeouts.erase(it);
+ }
+ }
+ m_bCurrentTimeoutDeleted = false;
+ }
+ for (it = m_NewTimeouts.begin(); it != m_NewTimeouts.end(); ++it) {
+ addTimeout(*it);
+ }
+ m_NewTimeouts.clear();
+ m_bInHandleTimers = false;
+
+}
+
+SDLDisplayEngine * Player::getDisplayEngine() const
+{
+ return m_pDisplayEngine.get();
+}
+
+void Player::setStopOnEscape(bool bStop)
+{
+ m_bStopOnEscape = bStop;
+}
+
+bool Player::getStopOnEscape() const
+{
+ return m_bStopOnEscape;
+}
+
+void Player::setVolume(double volume)
+{
+ m_Volume = volume;
+ if (SDLAudioEngine::get()) {
+ SDLAudioEngine::get()->setVolume(m_Volume);
+ }
+}
+
+double Player::getVolume() const
+{
+ return m_Volume;
+}
+
+OffscreenCanvasPtr Player::getCanvasFromURL(const std::string& sURL)
+{
+ if (sURL.substr(0, 7) != "canvas:") {
+ throw Exception(AVG_ERR_CANT_PARSE_STRING,
+ string("Invalid canvas url :'")+sURL+"'");
+ }
+ string sCanvasID = sURL.substr(7);
+ for (unsigned i=0; i < m_pCanvases.size(); ++i) {
+ if (m_pCanvases[i]->getID() == sCanvasID) {
+ return m_pCanvases[i];
+ }
+ }
+ throw Exception(AVG_ERR_CANT_PARSE_STRING,
+ string("Canvas with url '")+sURL+"' not found.");
+}
+
+void Player::cleanup()
+{
+ // Kill all timeouts.
+ vector<Timeout*>::iterator it;
+ for (it = m_PendingTimeouts.begin(); it != m_PendingTimeouts.end(); it++) {
+ delete *it;
+ }
+ m_PendingTimeouts.clear();
+ m_EventCaptureInfoMap.clear();
+ m_pLastCursorStates.clear();
+ m_pTestHelper->reset();
+ ThreadProfiler::get()->dumpStatistics();
+ if (m_pMainCanvas) {
+ unregisterFrameEndListener(BitmapManager::get());
+ delete BitmapManager::get();
+ m_pMainCanvas->stopPlayback();
+ m_pMainCanvas = MainCanvasPtr();
+ }
+
+ if (m_pMultitouchInputDevice) {
+ m_pMultitouchInputDevice = IInputDevicePtr();
+ }
+ for (unsigned i = 0; i < m_pCanvases.size(); ++i) {
+ m_pCanvases[i]->stopPlayback();
+ }
+ m_pCanvases.clear();
+
+ if (m_pDisplayEngine) {
+ m_pDisplayEngine->deinitRender();
+ m_pDisplayEngine->teardown();
+ }
+ if (SDLAudioEngine::get()) {
+ SDLAudioEngine::get()->teardown();
+ }
+ m_pEventDispatcher = EventDispatcherPtr();
+ m_pLastMouseEvent = MouseEventPtr(new MouseEvent(Event::CURSORMOTION, false, false,
+ false, IntPoint(-1, -1), MouseEvent::NO_BUTTON, DPoint(-1, -1), 0));
+
+ m_FrameTime = 0;
+ m_bIsPlaying = false;
+
+ m_CurDirName = getCWD();
+}
+
+int Player::addTimeout(Timeout* pTimeout)
+{
+ vector<Timeout*>::iterator it = m_PendingTimeouts.begin();
+ while (it != m_PendingTimeouts.end() && (**it)<*pTimeout) {
+ it++;
+ }
+ m_PendingTimeouts.insert(it, pTimeout);
+ return pTimeout->GetID();
+}
+
+
+void Player::removeTimeout(Timeout* pTimeout)
+{
+ delete pTimeout;
+ vector<Timeout*>::iterator it = m_PendingTimeouts.begin();
+ while (*it != pTimeout) {
+ it++;
+ }
+ m_PendingTimeouts.erase(it);
+}
+
+void Player::setPluginPath(const string& newPath)
+{
+ PluginManager::get().setSearchPath(newPath);
+}
+
+string Player::getPluginPath() const
+{
+ return PluginManager::get().getSearchPath();
+}
+
+boost::python::object Player::loadPlugin(const std::string& name)
+{
+ return PluginManager::get().loadPlugin(name);
+}
+
+void Player::setEventHook(PyObject * pyfunc)
+{
+ if (m_EventHookPyFunc != Py_None) {
+ Py_DECREF(m_EventHookPyFunc);
+ }
+
+ if (pyfunc != Py_None) {
+ Py_INCREF(pyfunc);
+ }
+
+ m_EventHookPyFunc = pyfunc;
+}
+
+PyObject * Player::getEventHook() const
+{
+ return m_EventHookPyFunc;
+}
+
+Player::EventCaptureInfo::EventCaptureInfo(const NodeWeakPtr& pNode)
+ : m_pNode(pNode),
+ m_CaptureCount(1)
+{
+}
+
+}
diff --git a/src/player/Player.h b/src/player/Player.h
new file mode 100644
index 0000000..8c8e786
--- /dev/null
+++ b/src/player/Player.h
@@ -0,0 +1,277 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Player_H_
+#define _Player_H_
+
+#include "../api.h"
+#include "Timeout.h"
+#include "NodeRegistry.h"
+#include "DisplayParams.h"
+#include "CursorState.h"
+#include "TestHelper.h"
+#include "BoostPython.h"
+
+#include "../audio/AudioParams.h"
+#include "../graphics/GLConfig.h"
+
+#include <libxml/parser.h>
+#include <boost/shared_ptr.hpp>
+
+#include <string>
+#include <vector>
+#include <set>
+
+namespace avg {
+
+class AudioEngine;
+class Node;
+class Canvas;
+class MainCanvas;
+class OffscreenCanvas;
+class TrackerInputDevice;
+class MultitouchInputDevice;
+class IFrameEndListener;
+class IPlaybackEndListener;
+class IPreRenderListener;
+class Contact;
+class EventDispatcher;
+class MouseEvent;
+class CursorEvent;
+class SDLDisplayEngine;
+
+typedef boost::shared_ptr<Node> NodePtr;
+typedef boost::weak_ptr<Node> NodeWeakPtr;
+typedef boost::shared_ptr<Canvas> CanvasPtr;
+typedef boost::shared_ptr<MainCanvas> MainCanvasPtr;
+typedef boost::shared_ptr<OffscreenCanvas> OffscreenCanvasPtr;
+typedef boost::shared_ptr<class Contact> ContactPtr;
+typedef boost::shared_ptr<EventDispatcher> EventDispatcherPtr;
+typedef boost::shared_ptr<MouseEvent> MouseEventPtr;
+typedef boost::shared_ptr<CursorEvent> CursorEventPtr;
+typedef boost::shared_ptr<SDLDisplayEngine> SDLDisplayEnginePtr;
+
+class AVG_API Player
+{
+ public:
+ Player();
+ virtual ~Player();
+ static Player* get();
+ static bool exists();
+
+ void setResolution(bool bFullscreen,
+ int width=0, int height=0, int bpp=0);
+ bool isFullscreen();
+ void setWindowFrame(bool bHasWindowFrame);
+ void setWindowPos(int x=0, int y=0);
+ void setOGLOptions(bool bUsePOTTextures, bool bUseShaders,
+ bool bUsePixelBuffers, int multiSampleSamples);
+ void setMultiSampleSamples(int multiSampleSamples);
+ void setAudioOptions(int samplerate, int channels);
+ DPoint getScreenResolution();
+ double getPixelsPerMM();
+ DPoint getPhysicalScreenDimensions();
+ void assumePixelsPerMM(double ppmm);
+
+ CanvasPtr loadFile(const std::string& sFilename);
+ CanvasPtr loadString(const std::string& sAVG);
+
+ OffscreenCanvasPtr loadCanvasFile(const std::string& sFilename);
+ OffscreenCanvasPtr loadCanvasString(const std::string& sAVG);
+ CanvasPtr createMainCanvas(const boost::python::dict& params);
+ OffscreenCanvasPtr createCanvas(const boost::python::dict& params);
+ void deleteCanvas(const std::string& sID);
+ CanvasPtr getMainCanvas() const;
+ OffscreenCanvasPtr getCanvas(const std::string& sID) const;
+ void newCanvasDependency(const OffscreenCanvasPtr pCanvas);
+
+ void play();
+ void stop();
+ bool isStopping();
+ void initPlayback();
+ void cleanup();
+ bool isPlaying();
+ void setFramerate(double rate);
+ void setVBlankFramerate(int rate);
+ double getEffectiveFramerate();
+ TestHelper * getTestHelper();
+ void setFakeFPS(double fps);
+ long long getFrameTime();
+ double getFrameDuration();
+
+ void registerNodeType(NodeDefinition Def, const char* pParentNames[] = 0);
+
+ NodePtr createNode(const std::string& sType, const boost::python::dict& PyDict);
+ NodePtr createNodeFromXmlString(const std::string& sXML);
+
+ int setInterval(int time, PyObject * pyfunc);
+ int setTimeout(int time, PyObject * pyfunc);
+ int setOnFrameHandler(PyObject * pyfunc);
+ bool clearInterval(int id);
+
+ void addInputDevice(IInputDevicePtr pSource);
+ MouseEventPtr getMouseState() const;
+ TrackerInputDevice * addTracker();
+ TrackerInputDevice * getTracker();
+ void enableMultitouch();
+ bool isMultitouchAvailable() const;
+ void setEventCapture(NodePtr pNode, int cursorID);
+ void releaseEventCapture(int cursorID);
+ bool isCaptured(int cursorID);
+ EventPtr getCurEvent() const;
+ void setMousePos(const IntPoint& pos);
+ int getKeyModifierState() const;
+
+ BitmapPtr screenshot();
+ void setCursor(const Bitmap* pBmp, IntPoint hotSpot);
+ void showCursor(bool bShow);
+
+ NodePtr getElementByID(const std::string& id);
+ AVGNodePtr getRootNode();
+ void doFrame(bool bFirstFrame);
+ double getFramerate();
+ double getVideoRefreshRate();
+ bool isUsingShaders();
+ void setGamma(double red, double green, double blue);
+ SDLDisplayEngine * getDisplayEngine() const;
+ void setStopOnEscape(bool bStop);
+ bool getStopOnEscape() const;
+ void setVolume(double volume);
+ double getVolume() const;
+
+ OffscreenCanvasPtr getCanvasFromURL(const std::string& sURL);
+
+ std::string getCurDirName();
+ std::string getRootMediaDir();
+ const NodeDefinition& getNodeDef(const std::string& sType);
+
+ void disablePython();
+
+ boost::python::object loadPlugin(const std::string& name);
+ void setPluginPath(const std::string& newPath);
+ std::string getPluginPath() const;
+
+ void setEventHook(PyObject * pyfunc);
+ PyObject * getEventHook() const;
+
+ void registerFrameEndListener(IFrameEndListener* pListener);
+ void unregisterFrameEndListener(IFrameEndListener* pListener);
+ void registerPlaybackEndListener(IPlaybackEndListener* pListener);
+ void unregisterPlaybackEndListener(IPlaybackEndListener* pListener);
+ void registerPreRenderListener(IPreRenderListener* pListener);
+ void unregisterPreRenderListener(IPreRenderListener* pListener);
+
+ bool handleEvent(EventPtr pEvent);
+
+ private:
+ void initConfig();
+ void initGraphics();
+ void initAudio();
+
+ void updateDTD();
+
+ NodePtr loadMainNodeFromFile(const std::string& sFilename);
+ NodePtr loadMainNodeFromString(const std::string& sAVG);
+ NodePtr internalLoad(const std::string& sAVG);
+ SDLDisplayEnginePtr safeGetDisplayEngine();
+
+ NodePtr createNodeFromXml(const xmlDocPtr xmlDoc,
+ const xmlNodePtr xmlNode);
+ OffscreenCanvasPtr registerOffscreenCanvas(NodePtr pNode);
+ OffscreenCanvasPtr findCanvas(const std::string& sID) const;
+ void endFrame();
+
+ void sendFakeEvents();
+ void sendOver(CursorEventPtr pOtherEvent, Event::Type type, NodePtr pNode);
+ void handleCursorEvent(CursorEventPtr pEvent, bool bOnlyCheckCursorOver=false);
+
+ void dispatchOffscreenRendering(OffscreenCanvas* pOffscreenCanvas);
+
+ void errorIfPlaying(const std::string& sFunc) const;
+
+ MainCanvasPtr m_pMainCanvas;
+
+ SDLDisplayEnginePtr m_pDisplayEngine;
+ TestHelperPtr m_pTestHelper;
+
+ std::string m_CurDirName;
+ bool m_bStopping;
+ NodeRegistry m_NodeRegistry;
+
+ IInputDevicePtr m_pMultitouchInputDevice;
+
+ int addTimeout(Timeout* pTimeout);
+ void removeTimeout(Timeout* pTimeout);
+ void handleTimers();
+ bool m_bInHandleTimers;
+ bool m_bCurrentTimeoutDeleted;
+
+ std::vector<Timeout *> m_PendingTimeouts;
+ std::vector<Timeout *> m_NewTimeouts; // Timeouts to be added this frame.
+
+ // Configuration variables.
+ DisplayParams m_DP;
+ AudioParams m_AP;
+ GLConfig m_GLConfig;
+
+ bool m_bStopOnEscape;
+ bool m_bIsPlaying;
+
+ // Time calculation
+ bool m_bFakeFPS;
+ double m_FakeFPS;
+ long long m_FrameTime;
+ long long m_PlayStartTime;
+ long long m_NumFrames;
+
+ double m_Volume;
+
+ bool m_bDirtyDTD;
+ xmlDtdPtr m_dtd;
+
+ bool m_bPythonAvailable;
+
+ std::vector<OffscreenCanvasPtr> m_pCanvases;
+
+ static Player * s_pPlayer;
+ friend void deletePlayer();
+
+ EventDispatcherPtr m_pEventDispatcher;
+ struct EventCaptureInfo {
+ EventCaptureInfo(const NodeWeakPtr& pNode);
+
+ NodeWeakPtr m_pNode;
+ int m_CaptureCount;
+ };
+ typedef boost::shared_ptr<EventCaptureInfo> EventCaptureInfoPtr;
+
+ std::map<int, EventCaptureInfoPtr> m_EventCaptureInfoMap;
+
+ MouseEventPtr m_pLastMouseEvent;
+
+ // The indexes of this map are cursorids.
+ std::map<int, CursorStatePtr> m_pLastCursorStates;
+
+ PyObject * m_EventHookPyFunc;
+};
+
+}
+#endif
diff --git a/src/player/PluginManager.cpp b/src/player/PluginManager.cpp
new file mode 100644
index 0000000..a117a5b
--- /dev/null
+++ b/src/player/PluginManager.cpp
@@ -0,0 +1,183 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Jan Boelsche (regular.gonzales@googlemail.com).
+//
+
+#include "PluginManager.h"
+
+#include "NodeDefinition.h"
+
+#include "../base/DlfcnWrapper.h"
+#include "../base/FileHelper.h"
+#include "../base/Logger.h"
+#include "../base/OSHelper.h"
+
+#include <iostream>
+#include <string>
+
+using namespace std;
+using namespace avg;
+
+#ifdef _WIN32
+#define PATH_DELIMITER ";"
+#define PLUGIN_EXTENSION ".dll"
+#else
+#define PATH_DELIMITER ":"
+#define PLUGIN_EXTENSION ".so"
+#endif
+
+PluginManager::PluginNotFound::PluginNotFound(const string& sMessage) :
+ Exception(AVG_ERR_FILEIO, sMessage) {}
+
+PluginManager::PluginCorrupted::PluginCorrupted(const string& sMessage) :
+ Exception(AVG_ERR_CORRUPT_PLUGIN, sMessage) {}
+
+PluginManager& PluginManager::get()
+{
+ static PluginManager s_Instance;
+ return s_Instance;
+}
+
+PluginManager::PluginManager()
+{
+ setSearchPath(string("."PATH_DELIMITER) + "./plugin"PATH_DELIMITER +
+ getAvgLibPath() + "plugin");
+}
+
+void PluginManager::setSearchPath(const string& sNewPath)
+{
+ m_sCurrentSearchPath = sNewPath;
+ parsePath(m_sCurrentSearchPath);
+}
+
+string PluginManager::getSearchPath() const
+{
+ return m_sCurrentSearchPath;
+}
+
+boost::python::object PluginManager::loadPlugin(const std::string& sPluginName)
+{
+ // is it loaded aready?
+ PluginMap::iterator i = m_LoadedPlugins.find(sPluginName);
+ if (i == m_LoadedPlugins.end()) {
+ // no, let's try to load it!
+ string sFullpath = locateSharedObject(sPluginName+PLUGIN_EXTENSION);
+ void *handle = internalLoadPlugin(sFullpath);
+ // add to map of loaded plugins
+ m_LoadedPlugins[sPluginName] = make_pair(handle, 1);
+ } else {
+ // yes, just increase the reference count
+ int referenceCount = i->second.second;
+ ++referenceCount;
+ m_LoadedPlugins[sPluginName] = make_pair(i->second.first, referenceCount);
+ }
+ boost::python::object sysModule(boost::python::handle<>(PyImport_ImportModule("sys")));
+ return sysModule.attr("modules")[sPluginName];
+}
+
+string PluginManager::locateSharedObject(const string& sFilename)
+{
+ vector<string>::iterator i = m_PathComponents.begin();
+ string sFullpath;
+ while (i != m_PathComponents.end()) {
+ sFullpath = *i + sFilename;
+ if (fileExists(sFullpath)) {
+ return sFullpath;
+ }
+ ++i;
+ }
+ string sMessage = "Unable to locate plugin file '" + sFilename
+ + "'. Was looking in " + m_sCurrentSearchPath;
+ AVG_TRACE(Logger::PLUGIN, sMessage);
+ throw PluginNotFound(sMessage);
+}
+
+string PluginManager::checkDirectory(const string& sDirectory)
+{
+ string sFixedDirectory;
+ char lastChar = *sDirectory.rbegin();
+ if (lastChar != '/' && lastChar != '\\') {
+ sFixedDirectory = sDirectory + "/";
+ } else {
+ sFixedDirectory = sDirectory;
+ }
+ return sFixedDirectory;
+}
+
+void PluginManager::parsePath(const string& sPath)
+{
+ // break the string into colon separated components
+ // and make sure each component has a trailing slash
+ // warn about non-existing directories
+
+ m_PathComponents.clear();
+ string sRemaining = sPath;
+ string::size_type i;
+ do {
+ i = sRemaining.find(PATH_DELIMITER);
+ string sDirectory;
+ if (i == string::npos) {
+ sDirectory = sRemaining;
+ sRemaining = "";
+ } else {
+ sDirectory = sRemaining.substr(0, i);
+ sRemaining = sRemaining.substr(i+1);
+ }
+ sDirectory = checkDirectory(sDirectory);
+
+ m_PathComponents.push_back(sDirectory);
+ } while (!sRemaining.empty());
+ AVG_TRACE(Logger::PLUGIN, "Plugin search path set to '" << sPath << "'");
+}
+
+void* PluginManager::internalLoadPlugin(const string& sFullpath)
+{
+ void *handle = dlopen(sFullpath.c_str(), RTLD_LOCAL | RTLD_NOW);
+ if (!handle) {
+ string sMessage(dlerror());
+ AVG_TRACE(Logger::PLUGIN, "Could not load plugin. dlopen failed with message '"
+ << sMessage << "'");
+ throw PluginCorrupted(sMessage);
+ }
+ try {
+ registerPlugin(handle);
+ } catch(PluginCorrupted& e) {
+ dlclose(handle);
+ throw e;
+ }
+ AVG_TRACE(Logger::PLUGIN, "Loaded plugin '" << sFullpath << "'");
+ return handle;
+}
+
+void PluginManager::registerPlugin(void* handle)
+{
+ typedef void (*RegisterPluginPtr)();
+ RegisterPluginPtr registerPlugin =
+ reinterpret_cast<RegisterPluginPtr>(dlsym(handle, "registerPlugin"));
+
+ if (registerPlugin) {
+ registerPlugin();
+ } else {
+ AVG_TRACE(Logger::PLUGIN, "No plugin registration function detected");
+ throw PluginCorrupted("No plugin registration function detected");
+ }
+}
+
diff --git a/src/player/PluginManager.h b/src/player/PluginManager.h
new file mode 100644
index 0000000..f46b8d7
--- /dev/null
+++ b/src/player/PluginManager.h
@@ -0,0 +1,76 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Jan Boelsche (regular.gonzales@googlemail.com).
+//
+#ifndef _PluginManager_H_
+#define _PluginManager_H_
+
+#include "../api.h"
+
+#include "BoostPython.h"
+
+#include "../base/Exception.h"
+
+#include <map>
+#include <vector>
+#include <memory>
+
+namespace avg {
+
+class AVG_API PluginManager
+{
+public:
+ class AVG_API PluginNotFound : public Exception {
+ public:
+ PluginNotFound(const std::string& sMessage);
+ };
+ class AVG_API PluginCorrupted : public Exception {
+ public:
+ PluginCorrupted(const std::string& sMessage);
+ };
+
+ static PluginManager& get();
+
+ void setSearchPath(const std::string& aNewPath);
+ std::string getSearchPath() const;
+
+ boost::python::object loadPlugin(const std::string& aPluginName);
+
+private:
+ PluginManager();
+
+ std::string checkDirectory(const std::string& sDirectory);
+ void parsePath(const std::string& sPath);
+ std::string locateSharedObject(const std::string& sPluginName);
+ void* internalLoadPlugin(const std::string& sPluginName);
+ void registerPlugin(void* pHandle);
+
+ // maps module names to a pair of handle and reference count
+ typedef std::map<std::string, std::pair<void*, int> > PluginMap;
+ PluginMap m_LoadedPlugins;
+ std::vector<std::string> m_PathComponents;
+ std::string m_sCurrentSearchPath;
+};
+
+}
+
+#endif
+
diff --git a/src/player/PolyLineNode.cpp b/src/player/PolyLineNode.cpp
new file mode 100644
index 0000000..48f40f6
--- /dev/null
+++ b/src/player/PolyLineNode.cpp
@@ -0,0 +1,124 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "PolyLineNode.h"
+
+#include "NodeDefinition.h"
+
+#include "../graphics/VertexArray.h"
+#include "../base/Exception.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition PolyLineNode::createDefinition()
+{
+ vector<DPoint> v;
+ vector<double> vd;
+ return NodeDefinition("polyline", Node::buildNode<PolyLineNode>)
+ .extendDefinition(VectorNode::createDefinition())
+ .addArg(Arg<string>("linejoin", "bevel"))
+ .addArg(Arg<vector<DPoint> >("pos", v, false, offsetof(PolyLineNode, m_Pts)))
+ .addArg(Arg<vector<double> >("texcoords", vd, false,
+ offsetof(PolyLineNode, m_TexCoords)))
+ ;
+}
+
+PolyLineNode::PolyLineNode(const ArgList& args)
+ : VectorNode(args)
+{
+ args.setMembers(this);
+ if (m_TexCoords.size() > m_Pts.size()) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Too many texture coordinates in polyline"));
+ }
+ setLineJoin(args.getArgVal<string>("linejoin"));
+ calcPolyLineCumulDist(m_CumulDist, m_Pts, false);
+}
+
+PolyLineNode::~PolyLineNode()
+{
+}
+
+const vector<DPoint>& PolyLineNode::getPos() const
+{
+ return m_Pts;
+}
+
+void PolyLineNode::setPos(const vector<DPoint>& pts)
+{
+ vector<DPoint>::const_iterator it;
+ for (it = pts.begin(); it != pts.end(); ++it) {
+ if (it->isNaN() || it->isInf()) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "polyline positions must not be nan or inf.");
+ }
+ }
+ m_Pts = pts;
+ m_TexCoords.clear();
+ m_EffTexCoords.clear();
+ calcPolyLineCumulDist(m_CumulDist, m_Pts, false);
+ setDrawNeeded();
+}
+
+const vector<double>& PolyLineNode::getTexCoords() const
+{
+ return m_TexCoords;
+}
+
+void PolyLineNode::setTexCoords(const vector<double>& coords)
+{
+ if (coords.size() > m_Pts.size()) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Too many texture coordinates in polyline"));
+ }
+ m_EffTexCoords.clear();
+ m_TexCoords = coords;
+ setDrawNeeded();
+}
+
+string PolyLineNode::getLineJoin() const
+{
+ return lineJoin2String(m_LineJoin);
+}
+
+void PolyLineNode::setLineJoin(const string& s)
+{
+ m_LineJoin = string2LineJoin(s);
+ setDrawNeeded();
+}
+
+void PolyLineNode::calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ if (getNumDifferentPts(m_Pts) < 2) {
+ return;
+ }
+ if (m_EffTexCoords.empty()) {
+ calcEffPolyLineTexCoords(m_EffTexCoords, m_TexCoords, m_CumulDist);
+ }
+ calcPolyLine(m_Pts, m_EffTexCoords, false, m_LineJoin, pVertexArray, color);
+}
+
+}
diff --git a/src/player/PolyLineNode.h b/src/player/PolyLineNode.h
new file mode 100644
index 0000000..80b4255
--- /dev/null
+++ b/src/player/PolyLineNode.h
@@ -0,0 +1,65 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _PolyLineNode_H_
+#define _PolyLineNode_H_
+
+#include "../api.h"
+#include "VectorNode.h"
+
+#include "../graphics/Pixel32.h"
+#include "../base/WideLine.h"
+
+#include <vector>
+
+namespace avg {
+
+class AVG_API PolyLineNode : public VectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ PolyLineNode(const ArgList& args);
+ virtual ~PolyLineNode();
+
+ const std::vector<DPoint>& getPos() const;
+ void setPos(const std::vector<DPoint>& pts);
+
+ const std::vector<double>& getTexCoords() const;
+ void setTexCoords(const std::vector<double>& coords);
+
+ std::string getLineJoin() const;
+ void setLineJoin(const std::string& s);
+
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+
+ private:
+ std::vector<DPoint> m_Pts;
+ std::vector<double> m_CumulDist;
+ std::vector<double> m_TexCoords;
+ std::vector<double> m_EffTexCoords;
+ LineJoin m_LineJoin;
+};
+
+}
+
+#endif
+
diff --git a/src/player/PolygonNode.cpp b/src/player/PolygonNode.cpp
new file mode 100644
index 0000000..4c9411d
--- /dev/null
+++ b/src/player/PolygonNode.cpp
@@ -0,0 +1,172 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "PolygonNode.h"
+
+#include "NodeDefinition.h"
+
+#include "../graphics/VertexArray.h"
+#include "../base/Exception.h"
+#include "../base/GeomHelper.h"
+#include "../base/Triangulate.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition PolygonNode::createDefinition()
+{
+ vector<DPoint> v;
+ vector<double> vd;
+ return NodeDefinition("polygon", Node::buildNode<PolygonNode>)
+ .extendDefinition(FilledVectorNode::createDefinition())
+ .addArg(Arg<string>("linejoin", "bevel"))
+ .addArg(Arg<vector<DPoint> >("pos", v, false, offsetof(PolygonNode, m_Pts)))
+ .addArg(Arg<vector<double> >("texcoords", vd, false,
+ offsetof(PolygonNode, m_TexCoords)))
+ ;
+}
+
+PolygonNode::PolygonNode(const ArgList& args)
+ : FilledVectorNode(args)
+{
+ args.setMembers(this);
+ if (m_TexCoords.size() > m_Pts.size()+1) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Too many texture coordinates in polygon"));
+ }
+ setLineJoin(args.getArgVal<string>("linejoin"));
+ calcPolyLineCumulDist(m_CumulDist, m_Pts, true);
+}
+
+PolygonNode::~PolygonNode()
+{
+}
+
+const vector<DPoint>& PolygonNode::getPos() const
+{
+ return m_Pts;
+}
+
+void PolygonNode::setPos(const vector<DPoint>& pts)
+{
+ m_Pts = pts;
+ m_TexCoords.clear();
+ m_EffTexCoords.clear();
+ calcPolyLineCumulDist(m_CumulDist, m_Pts, true);
+ setDrawNeeded();
+}
+
+const vector<double>& PolygonNode::getTexCoords() const
+{
+ return m_TexCoords;
+}
+
+void PolygonNode::setTexCoords(const vector<double>& coords)
+{
+ if (coords.size() > m_Pts.size()+1) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Too many texture coordinates in polygon"));
+ }
+ m_EffTexCoords.clear();
+ m_TexCoords = coords;
+ setDrawNeeded();
+}
+
+string PolygonNode::getLineJoin() const
+{
+ return lineJoin2String(m_LineJoin);
+}
+
+void PolygonNode::setLineJoin(const string& s)
+{
+ m_LineJoin = string2LineJoin(s);
+ setDrawNeeded();
+}
+
+void PolygonNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ if (reactsToMouseEvents() && pointInPolygon(pos, m_Pts)) {
+ pElements.push_back(shared_from_this());
+ }
+}
+
+void PolygonNode::calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ if (getNumDifferentPts(m_Pts) < 3) {
+ return;
+ }
+ if (m_EffTexCoords.empty()) {
+ calcEffPolyLineTexCoords(m_EffTexCoords, m_TexCoords, m_CumulDist);
+ }
+ calcPolyLine(m_Pts, m_EffTexCoords, true, m_LineJoin, pVertexArray, color);
+}
+
+void PolygonNode::calcFillVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ if (getNumDifferentPts(m_Pts) < 3) {
+ return;
+ }
+ // Remove duplicate points
+ vector<DPoint> pts;
+ pts.reserve(m_Pts.size());
+
+ pts.push_back(m_Pts[0]);
+ for (unsigned i = 1; i < m_Pts.size(); ++i) {
+ if (calcDistSquared(m_Pts[i], m_Pts[i-1]) > 0.1) {
+ pts.push_back(m_Pts[i]);
+ }
+ }
+
+ if (color.getA() > 0) {
+ DPoint minCoord = pts[0];
+ DPoint maxCoord = pts[0];
+ for (unsigned i = 1; i < pts.size(); ++i) {
+ if (pts[i].x < minCoord.x) {
+ minCoord.x = pts[i].x;
+ }
+ if (pts[i].x > maxCoord.x) {
+ maxCoord.x = pts[i].x;
+ }
+ if (pts[i].y < minCoord.y) {
+ minCoord.y = pts[i].y;
+ }
+ if (pts[i].y > maxCoord.y) {
+ maxCoord.y = pts[i].y;
+ }
+ }
+ vector<int> triIndexes;
+ triangulatePolygon(pts, triIndexes);
+ for (unsigned i = 0; i < pts.size(); ++i) {
+ DPoint texCoord = calcFillTexCoord(pts[i], minCoord, maxCoord);
+ pVertexArray->appendPos(pts[i], texCoord, color);
+ }
+ for (unsigned i = 0; i < triIndexes.size(); i+=3) {
+ pVertexArray->appendTriIndexes(triIndexes[i], triIndexes[i+1],
+ triIndexes[i+2]);
+ }
+ }
+}
+
+}
diff --git a/src/player/PolygonNode.h b/src/player/PolygonNode.h
new file mode 100644
index 0000000..e8d4899
--- /dev/null
+++ b/src/player/PolygonNode.h
@@ -0,0 +1,68 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _PolygonNode_H_
+#define _PolygonNode_H_
+
+#include "../api.h"
+#include "FilledVectorNode.h"
+
+#include "../graphics/Pixel32.h"
+#include "../base/WideLine.h"
+
+#include <vector>
+
+namespace avg {
+
+class AVG_API PolygonNode : public FilledVectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ PolygonNode(const ArgList& args);
+ virtual ~PolygonNode();
+
+ const std::vector<DPoint>& getPos() const;
+ void setPos(const std::vector<DPoint>& pts);
+
+ const std::vector<double>& getTexCoords() const;
+ void setTexCoords(const std::vector<double>& coords);
+
+ std::string getLineJoin() const;
+ void setLineJoin(const std::string& s);
+
+ void getElementsByPos(const DPoint& pos, std::vector<NodeWeakPtr>& pElements);
+
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+ virtual void calcFillVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+
+ private:
+ std::vector<DPoint> m_Pts;
+ std::vector<double> m_CumulDist;
+ std::vector<double> m_TexCoords;
+ std::vector<double> m_EffTexCoords;
+ LineJoin m_LineJoin;
+};
+
+}
+
+#endif
+
diff --git a/src/player/RasterNode.cpp b/src/player/RasterNode.cpp
new file mode 100644
index 0000000..0bf304c
--- /dev/null
+++ b/src/player/RasterNode.cpp
@@ -0,0 +1,646 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "RasterNode.h"
+
+#include "NodeDefinition.h"
+#include "OGLSurface.h"
+#include "FXNode.h"
+
+#include "../graphics/ImagingProjection.h"
+
+#include "../base/MathHelper.h"
+#include "../base/Logger.h"
+#include "../base/XMLHelper.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition RasterNode::createDefinition()
+{
+ return NodeDefinition("rasternode")
+ .extendDefinition(AreaNode::createDefinition())
+ .addArg(Arg<int>("maxtilewidth", -1, false,
+ offsetof(RasterNode, m_MaxTileSize.x)))
+ .addArg(Arg<int>("maxtileheight", -1, false,
+ offsetof(RasterNode, m_MaxTileSize.y)))
+ .addArg(Arg<string>("blendmode", "blend", false,
+ offsetof(RasterNode, m_sBlendMode)))
+ .addArg(Arg<bool>("mipmap", false))
+ .addArg(Arg<UTF8String>("maskhref", "", false, offsetof(RasterNode, m_sMaskHref)))
+ .addArg(Arg<DPoint>("maskpos", DPoint(0,0), false,
+ offsetof(RasterNode, m_MaskPos)))
+ .addArg(Arg<DPoint>("masksize", DPoint(0,0), false,
+ offsetof(RasterNode, m_MaskSize)))
+ .addArg(Arg<DTriple>("gamma", DTriple(1.0,1.0,1.0), false,
+ offsetof(RasterNode, m_Gamma)))
+ .addArg(Arg<DTriple>("contrast", DTriple(1.0,1.0,1.0), false,
+ offsetof(RasterNode, m_Contrast)))
+ .addArg(Arg<DTriple>("intensity", DTriple(1.0,1.0,1.0), false,
+ offsetof(RasterNode, m_Intensity)));
+}
+
+RasterNode::RasterNode()
+ : m_pSurface(0),
+ m_Material(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, false),
+ m_bBound(false),
+ m_TileSize(-1,-1),
+ m_pVertexes(0),
+ m_bFXDirty(true)
+{
+}
+
+RasterNode::~RasterNode()
+{
+ if (m_pSurface) {
+ delete m_pSurface;
+ m_pSurface = 0;
+ }
+}
+
+void RasterNode::setArgs(const ArgList& args)
+{
+ AreaNode::setArgs(args);
+ if ((!ispow2(m_MaxTileSize.x) && m_MaxTileSize.x != -1)
+ || (!ispow2(m_MaxTileSize.y) && m_MaxTileSize.y != -1))
+ {
+ throw Exception(AVG_ERR_OUT_OF_RANGE,
+ "maxtilewidth and maxtileheight must be powers of two.");
+ }
+ bool bMipmap = args.getArgVal<bool>("mipmap");
+ m_Material = MaterialInfo(GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE, bMipmap);
+ m_pSurface = new OGLSurface();
+}
+
+void RasterNode::connectDisplay()
+{
+ checkMaskSupport(m_sMaskHref);
+ AreaNode::connectDisplay();
+
+ m_pSurface->attach();
+ m_bBound = false;
+ if (m_MaxTileSize != IntPoint(-1, -1)) {
+ m_TileSize = m_MaxTileSize;
+ }
+ calcVertexGrid(m_TileVertices);
+ setBlendModeStr(m_sBlendMode);
+ if (m_pMaskBmp) {
+ downloadMask();
+ setMaskCoords();
+ }
+ m_pSurface->setColorParams(m_Gamma, m_Intensity, m_Contrast);
+ setupFX(true);
+}
+
+void RasterNode::disconnect(bool bKill)
+{
+ if (m_pVertexes) {
+ delete m_pVertexes;
+ m_pVertexes = 0;
+ }
+ if (m_pSurface) {
+ m_pSurface->destroy();
+ }
+ m_pFBO = FBOPtr();
+ m_pImagingProjection = ImagingProjectionPtr();
+ if (bKill) {
+ m_pFXNode = FXNodePtr();
+ } else {
+ if (m_pFXNode) {
+ m_pFXNode->disconnect();
+ }
+ }
+ AreaNode::disconnect(bKill);
+}
+
+void RasterNode::checkReload()
+{
+ string sLastMaskFilename = m_sMaskFilename;
+ string sMaskFilename = m_sMaskHref;
+ initFilename(sMaskFilename);
+ if (sLastMaskFilename != sMaskFilename) {
+ m_sMaskFilename = sMaskFilename;
+ try {
+ if (m_sMaskFilename != "") {
+ AVG_TRACE(Logger::MEMORY, "Loading " << m_sMaskFilename);
+ m_pMaskBmp = BitmapPtr(new Bitmap(m_sMaskFilename));
+ if (m_pMaskBmp->getPixelFormat() != I8) {
+ BitmapPtr pTempBmp = m_pMaskBmp;
+ m_pMaskBmp = BitmapPtr(new Bitmap(m_pMaskBmp->getSize(), I8));
+ m_pMaskBmp->copyPixels(*pTempBmp);
+ }
+ setMaskCoords();
+ }
+ } catch (Exception & ex) {
+ if (ex.getCode() == AVG_ERR_VIDEO_GENERAL) {
+ throw;
+ }
+ m_sMaskFilename = "";
+ if (getState() != Node::NS_UNCONNECTED) {
+ AVG_TRACE(Logger::ERROR, ex.getStr());
+ } else {
+ AVG_TRACE(Logger::MEMORY, ex.getStr());
+ }
+ }
+ if (m_sMaskFilename == "") {
+ m_pMaskBmp = BitmapPtr();
+ getSurface()->setMask(GLTexturePtr());
+ }
+ if (getState() == Node::NS_CANRENDER && m_pMaskBmp) {
+ downloadMask();
+ }
+ } else {
+ setMaskCoords();
+ }
+}
+
+VertexGrid RasterNode::getOrigVertexCoords()
+{
+ checkDisplayAvailable("getOrigVertexCoords");
+ if (!m_bBound) {
+ bind();
+ }
+ VertexGrid grid;
+ calcVertexGrid(grid);
+ return grid;
+}
+
+VertexGrid RasterNode::getWarpedVertexCoords()
+{
+ checkDisplayAvailable("getWarpedVertexCoords");
+ if (!m_bBound) {
+ bind();
+ }
+ return m_TileVertices;
+}
+
+void RasterNode::setWarpedVertexCoords(const VertexGrid& grid)
+{
+ checkDisplayAvailable("setWarpedVertexCoords");
+ if (!m_bBound) {
+ bind();
+ }
+ bool bGridOK = true;
+ IntPoint numTiles = getNumTiles();
+ if (grid.size() != (unsigned)(numTiles.y+1)) {
+ bGridOK = false;
+ }
+ for (unsigned i = 0; i < grid.size(); ++i) {
+ if (grid[i].size() != (unsigned)(numTiles.x+1)) {
+ bGridOK = false;
+ }
+ }
+ if (!bGridOK) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE,
+ "setWarpedVertexCoords() called with incorrect grid size.");
+ }
+ m_TileVertices = grid;
+ m_bVertexArrayDirty = true;
+}
+
+int RasterNode::getMaxTileWidth() const
+{
+ return m_MaxTileSize.x;
+}
+
+int RasterNode::getMaxTileHeight() const
+{
+ return m_MaxTileSize.y;
+}
+
+bool RasterNode::getMipmap() const
+{
+ return m_Material.getUseMipmaps();
+}
+
+const std::string& RasterNode::getBlendModeStr() const
+{
+ return m_sBlendMode;
+}
+
+void RasterNode::setBlendModeStr(const string& sBlendMode)
+{
+ m_sBlendMode = sBlendMode;
+ m_BlendMode = GLContext::stringToBlendMode(sBlendMode);
+}
+
+const UTF8String& RasterNode::getMaskHRef() const
+{
+ return m_sMaskHref;
+}
+
+void RasterNode::setMaskHRef(const UTF8String& sHref)
+{
+ if (GLContext::getCurrent()) {
+ checkMaskSupport(sHref);
+ }
+ m_sMaskHref = sHref;
+ checkReload();
+}
+
+const DPoint& RasterNode::getMaskPos() const
+{
+ return m_MaskPos;
+}
+
+void RasterNode::setMaskPos(const DPoint& pos)
+{
+ m_MaskPos = pos;
+ setMaskCoords();
+}
+
+const DPoint& RasterNode::getMaskSize() const
+{
+ return m_MaskSize;
+}
+
+void RasterNode::setMaskSize(const DPoint& size)
+{
+ m_MaskSize = size;
+ setMaskCoords();
+}
+
+void RasterNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ // Node isn't pickable if it's warped.
+ if (m_MaxTileSize == IntPoint(-1, -1)) {
+ AreaNode::getElementsByPos(pos, pElements);
+ }
+}
+
+DTriple RasterNode::getGamma() const
+{
+ return m_Gamma;
+}
+
+void RasterNode::setGamma(const DTriple& gamma)
+{
+ m_Gamma = gamma;
+ if (getState() == Node::NS_CANRENDER) {
+ m_pSurface->setColorParams(m_Gamma, m_Intensity, m_Contrast);
+ }
+}
+
+DTriple RasterNode::getIntensity() const
+{
+ return m_Intensity;
+}
+
+void RasterNode::setIntensity(const DTriple& intensity)
+{
+ m_Intensity = intensity;
+ if (getState() == Node::NS_CANRENDER) {
+ m_pSurface->setColorParams(m_Gamma, m_Intensity, m_Contrast);
+ }
+}
+
+DTriple RasterNode::getContrast() const
+{
+ return m_Contrast;
+}
+
+void RasterNode::setContrast(const DTriple& contrast)
+{
+ m_Contrast = contrast;
+ if (getState() == Node::NS_CANRENDER) {
+ m_pSurface->setColorParams(m_Gamma, m_Intensity, m_Contrast);
+ }
+}
+
+void RasterNode::setEffect(FXNodePtr pFXNode)
+{
+ if (m_pFXNode && m_pFXNode != pFXNode) {
+ m_pFXNode->disconnect();
+ }
+ if (m_pFXNode && !pFXNode) {
+ m_pFBO = FBOPtr();
+ }
+ m_pFXNode = pFXNode;
+ if (getState() == NS_CANRENDER) {
+ setupFX(true);
+ }
+}
+
+void RasterNode::blt32(const DPoint& destSize, double opacity,
+ GLContext::BlendMode mode, bool bPremultipliedAlpha)
+{
+ blt(destSize, mode, opacity, Pixel32(255, 255, 255, 255), bPremultipliedAlpha);
+}
+
+void RasterNode::blta8(const DPoint& destSize, double opacity,
+ const Pixel32& color, GLContext::BlendMode mode)
+{
+ blt(destSize, mode, opacity, color, false);
+}
+
+GLContext::BlendMode RasterNode::getBlendMode() const
+{
+ return m_BlendMode;
+}
+
+OGLSurface * RasterNode::getSurface()
+{
+ return m_pSurface;
+}
+
+const MaterialInfo& RasterNode::getMaterial() const
+{
+ return m_Material;
+}
+
+bool RasterNode::hasMask() const
+{
+ return m_sMaskFilename != "";
+}
+
+void RasterNode::setMaskCoords()
+{
+ if (m_sMaskFilename != "") {
+ calcMaskCoords();
+ }
+}
+
+void RasterNode::calcMaskCoords()
+{
+ DPoint maskSize;
+ DPoint mediaSize = DPoint(getMediaSize());
+ if (m_MaskSize == DPoint(0,0)) {
+ maskSize = DPoint(1,1);
+ } else {
+ maskSize = DPoint(m_MaskSize.x/mediaSize.x, m_MaskSize.y/mediaSize.y);
+ }
+ DPoint maskPos = DPoint(m_MaskPos.x/mediaSize.x, m_MaskPos.y/mediaSize.y);
+ m_pSurface->setMaskCoords(maskPos, maskSize);
+}
+
+void RasterNode::checkMaskSupport(const string& sHref)
+{
+ if (!(GLContext::getCurrent()->isUsingShaders()) && sHref != "") {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Can't use masks - unsupported on this hardware/driver combination.");
+ }
+}
+
+void RasterNode::downloadMask()
+{
+ GLTexturePtr pTex(new GLTexture(m_pMaskBmp->getSize(), I8,
+ m_Material.getUseMipmaps()));
+ pTex->moveBmpToTexture(m_pMaskBmp);
+ m_pSurface->setMask(pTex);
+}
+
+void RasterNode::bind()
+{
+ if (!m_bBound) {
+ calcTexCoords();
+ }
+ m_bBound = true;
+}
+
+static ProfilingZoneID FXProfilingZone("RasterNode::renderFX");
+
+void RasterNode::renderFX(const DPoint& destSize, const Pixel32& color,
+ bool bPremultipliedAlpha)
+{
+ ScopeTimer Timer(FXProfilingZone);
+ setupFX(false);
+ GLContext* pContext = GLContext::getCurrent();
+ pContext->enableGLColorArray(false);
+ pContext->enableTexture(true);
+ if (m_pFXNode && (m_bFXDirty || m_pSurface->isDirty() || m_pFXNode->isDirty())) {
+ if (!m_bBound) {
+ bind();
+ }
+ m_pSurface->activate(getMediaSize());
+
+ m_pFBO->activate();
+ clearGLBuffers(GL_COLOR_BUFFER_BIT);
+
+ glColor4d(double(color.getR())/256, double(color.getG())/256,
+ double(color.getB())/256, 1);
+ if (bPremultipliedAlpha) {
+ glproc::BlendColor(1.0f, 1.0f, 1.0f, 1.0f);
+ }
+ pContext->setBlendMode(GLContext::BLEND_BLEND, bPremultipliedAlpha);
+
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+
+ m_pImagingProjection->activate();
+ m_pImagingProjection->draw();
+
+/*
+ static int i=0;
+ stringstream ss;
+ ss << "foo" << i << ".png";
+ BitmapPtr pBmp = m_pFBO->getImage(0);
+ pBmp->save(ss.str());
+ */
+ m_pFXNode->apply(m_pFBO->getTex());
+
+ glPopMatrix();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "RasterNode::renderFX(): glPopMatrix");
+/*
+ stringstream ss1;
+ ss1 << "bar" << ".png";
+ i++;
+ m_pFXNode->getImage()->save(ss1.str());
+*/
+ glproc::UseProgramObject(0);
+ m_bFXDirty = false;
+ m_pSurface->resetDirty();
+ m_pFXNode->resetDirty();
+ }
+}
+
+void RasterNode::checkDisplayAvailable(std::string sMsg)
+{
+ if (!(getState() == Node::NS_CANRENDER)) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ string(sMsg) + ": cannot access vertex coordinates before node is bound.");
+ }
+ if (!m_pSurface->isCreated()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ string(sMsg) + ": Surface not available.");
+ }
+}
+
+void RasterNode::setupFX(bool bNewFX)
+{
+ if (m_pSurface && m_pSurface->getSize() != IntPoint(-1, -1) && m_pFXNode) {
+ if (!GLContext::getCurrent()->isUsingShaders()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Can't use FX - unsupported on this hardware/driver combination.");
+ }
+ if (bNewFX || !m_pFBO || m_pFBO->getSize() != m_pSurface->getSize()) {
+ m_pFXNode->setSize(m_pSurface->getSize());
+ m_pFXNode->connect();
+ m_bFXDirty = true;
+ }
+ if (!m_pFBO || m_pFBO->getSize() != m_pSurface->getSize()) {
+ m_pFBO = FBOPtr(new FBO(IntPoint(m_pSurface->getSize()), B8G8R8A8, 1, 1,
+ false, getMipmap()));
+ GLTexturePtr pTex = m_pFBO->getTex();
+ pTex->setWrapMode(GL_CLAMP_TO_BORDER, GL_CLAMP_TO_BORDER);
+ m_pImagingProjection = ImagingProjectionPtr(new ImagingProjection(
+ m_pSurface->getSize()));
+ }
+ }
+}
+
+void RasterNode::blt(const DPoint& destSize, GLContext::BlendMode mode,
+ double opacity, const Pixel32& color, bool bPremultipliedAlpha)
+{
+ if (!m_bBound) {
+ bind();
+ }
+ GLContext* pContext = GLContext::getCurrent();
+ pContext->enableGLColorArray(false);
+ pContext->enableTexture(true);
+ DRect destRect;
+ if (m_pFXNode) {
+ m_pFXNode->getTex()->activate(GL_TEXTURE0);
+
+ pContext->setBlendMode(mode, true);
+ glColor4d(1.0, 1.0, 1.0, opacity);
+ DRect relDestRect = m_pFXNode->getRelDestRect();
+ destRect = DRect(relDestRect.tl.x*destSize.x, relDestRect.tl.y*destSize.y,
+ relDestRect.br.x*destSize.x, relDestRect.br.y*destSize.y);
+ } else {
+ m_pSurface->activate(getMediaSize(), bPremultipliedAlpha);
+ pContext->setBlendMode(mode, bPremultipliedAlpha);
+ glColor4d(double(color.getR())/256, double(color.getG())/256,
+ double(color.getB())/256, opacity);
+ destRect = DRect(DPoint(0,0), destSize);
+ }
+ glproc::BlendColor(1.0f, 1.0f, 1.0f, float(opacity));
+ glPushMatrix();
+ glTranslated(destRect.tl.x, destRect.tl.y, 1);
+ glScaled(destRect.size().x, destRect.size().y, 1);
+
+ if (m_bVertexArrayDirty) {
+ m_pVertexes->reset();
+ for (unsigned y = 0; y < m_TileVertices.size()-1; y++) {
+ for (unsigned x = 0; x < m_TileVertices[0].size()-1; x++) {
+ int curVertex = m_pVertexes->getCurVert();
+ m_pVertexes->appendPos(m_TileVertices[y][x], m_TexCoords[y][x]);
+ m_pVertexes->appendPos(m_TileVertices[y][x+1], m_TexCoords[y][x+1]);
+ m_pVertexes->appendPos(m_TileVertices[y+1][x+1], m_TexCoords[y+1][x+1]);
+ m_pVertexes->appendPos(m_TileVertices[y+1][x], m_TexCoords[y+1][x]);
+ m_pVertexes->appendQuadIndexes(
+ curVertex+1, curVertex, curVertex+2, curVertex+3);
+ }
+ }
+ m_bVertexArrayDirty = false;
+ }
+
+ m_pVertexes->draw();
+
+ glPopMatrix();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "RasterNode::blt(): glPopMatrix 2");
+
+ PixelFormat pf = m_pSurface->getPixelFormat();
+ AVG_TRACE(Logger::BLTS, "(" << destSize.x << ", " << destSize.y << ")"
+ << ", m_pf: " << pf);
+}
+
+IntPoint RasterNode::getNumTiles()
+{
+ IntPoint size = m_pSurface->getSize();
+ if (m_TileSize.x == -1) {
+ return IntPoint(1,1);
+ } else {
+ return IntPoint(safeCeil(double(size.x)/m_TileSize.x),
+ safeCeil(double(size.y)/m_TileSize.y));
+ }
+}
+
+void RasterNode::calcVertexGrid(VertexGrid& grid)
+{
+ IntPoint numTiles = getNumTiles();
+ std::vector<DPoint> TileVerticesLine(numTiles.x+1);
+ grid = std::vector<std::vector<DPoint> > (numTiles.y+1, TileVerticesLine);
+ for (unsigned y = 0; y < grid.size(); y++) {
+ for (unsigned x = 0; x < grid[y].size(); x++) {
+ calcTileVertex(x, y, grid[y][x]);
+ }
+ }
+ if (m_pVertexes) {
+ delete m_pVertexes;
+ }
+ m_bVertexArrayDirty = true;
+ m_pVertexes = new VertexArray(numTiles.x*numTiles.y*4, numTiles.x*numTiles.y*6);
+}
+
+void RasterNode::calcTileVertex(int x, int y, DPoint& Vertex)
+{
+ IntPoint numTiles = getNumTiles();
+ if (x < numTiles.x) {
+ Vertex.x = double(m_TileSize.x*x) / m_pSurface->getSize().x;
+ } else {
+ Vertex.x = 1;
+ }
+ if (y < numTiles.y) {
+ Vertex.y = double(m_TileSize.y*y) / m_pSurface->getSize().y;
+ } else {
+ Vertex.y = 1;
+ }
+}
+
+void RasterNode::calcTexCoords()
+{
+ DPoint textureSize = DPoint(m_pSurface->getTextureSize());
+ DPoint imageSize = DPoint(m_pSurface->getSize());
+ DPoint texCoordExtents = DPoint(imageSize.x/textureSize.x,
+ imageSize.y/textureSize.y);
+
+ DPoint texSizePerTile;
+ if (m_TileSize.x == -1) {
+ texSizePerTile = texCoordExtents;
+ } else {
+ texSizePerTile = DPoint(double(m_TileSize.x)/imageSize.x*texCoordExtents.x,
+ double(m_TileSize.y)/imageSize.y*texCoordExtents.y);
+ }
+
+ IntPoint numTiles = getNumTiles();
+ vector<DPoint> texCoordLine(numTiles.x+1);
+ m_TexCoords = std::vector<std::vector<DPoint> >
+ (numTiles.y+1, texCoordLine);
+ for (unsigned y = 0; y < m_TexCoords.size(); y++) {
+ for (unsigned x = 0; x < m_TexCoords[y].size(); x++) {
+ if (y == m_TexCoords.size()-1) {
+ m_TexCoords[y][x].y = texCoordExtents.y;
+ } else {
+ m_TexCoords[y][x].y = texSizePerTile.y*y;
+ }
+ if (x == m_TexCoords[y].size()-1) {
+ m_TexCoords[y][x].x = texCoordExtents.x;
+ } else {
+ m_TexCoords[y][x].x = texSizePerTile.x*x;
+ }
+ }
+ }
+ m_bVertexArrayDirty = true;
+}
+}
diff --git a/src/player/RasterNode.h b/src/player/RasterNode.h
new file mode 100644
index 0000000..92d9ac4
--- /dev/null
+++ b/src/player/RasterNode.h
@@ -0,0 +1,157 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _RasterNode_H_
+#define _RasterNode_H_
+
+#include "../api.h"
+#include "AreaNode.h"
+#include "MaterialInfo.h"
+
+#include "../avgconfigwrapper.h"
+#include "../base/Point.h"
+#include "../base/Triple.h"
+#include "../base/UTF8String.h"
+#include "../graphics/GLContext.h"
+
+#include <string>
+
+namespace avg {
+
+class OGLSurface;
+class ImagingProjection;
+typedef boost::shared_ptr<ImagingProjection> ImagingProjectionPtr;
+class FBO;
+typedef boost::shared_ptr<FBO> FBOPtr;
+class GLTexture;
+typedef boost::shared_ptr<GLTexture> GLTexturePtr;
+class FXNode;
+typedef boost::shared_ptr<FXNode> FXNodePtr;
+
+typedef std::vector<std::vector<DPoint> > VertexGrid;
+
+class AVG_API RasterNode: public AreaNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ virtual ~RasterNode ();
+ virtual void connectDisplay();
+ virtual void setArgs(const ArgList& args);
+ virtual void disconnect(bool bKill);
+ virtual void checkReload();
+
+ // Warping support.
+ VertexGrid getOrigVertexCoords();
+ VertexGrid getWarpedVertexCoords();
+ void setWarpedVertexCoords(const VertexGrid& Grid);
+
+ int getMaxTileWidth() const;
+ int getMaxTileHeight() const;
+ bool getMipmap() const;
+
+ const std::string& getBlendModeStr() const;
+ void setBlendModeStr(const std::string& sBlendMode);
+ GLContext::BlendMode getBlendMode() const;
+
+ const UTF8String& getMaskHRef() const;
+ void setMaskHRef(const UTF8String& sHref);
+
+ const DPoint& getMaskPos() const;
+ void setMaskPos(const DPoint& pos);
+
+ const DPoint& getMaskSize() const;
+ void setMaskSize(const DPoint& size);
+
+ void getElementsByPos(const DPoint& pos, std::vector<NodeWeakPtr>& pElements);
+
+ DTriple getGamma() const;
+ void setGamma(const DTriple& gamma);
+ DTriple getIntensity() const;
+ void setIntensity(const DTriple& intensity);
+ DTriple getContrast() const;
+ void setContrast(const DTriple& contrast);
+
+ void setEffect(FXNodePtr pFXNode);
+
+ protected:
+ RasterNode();
+ void blt32(const DPoint& destSize, double opacity, GLContext::BlendMode mode,
+ bool bPremultipliedAlpha = false);
+ void blta8(const DPoint& destSize, double opacity,
+ const Pixel32& color, GLContext::BlendMode mode);
+
+ virtual OGLSurface * getSurface();
+ const MaterialInfo& getMaterial() const;
+ bool hasMask() const;
+ void setMaskCoords();
+ void bind();
+ void renderFX(const DPoint& destSize, const Pixel32& color,
+ bool bPremultipliedAlpha);
+
+ private:
+ void downloadMask();
+ virtual void calcMaskCoords();
+ void checkMaskSupport(const std::string& sHref);
+ void checkDisplayAvailable(std::string sMsg);
+ void setupFX(bool bNewFX);
+ void blt(const DPoint& destSize, GLContext::BlendMode mode,
+ double opacity, const Pixel32& color, bool bPremultipliedAlpha);
+
+ IntPoint getNumTiles();
+ void calcVertexGrid(VertexGrid& grid);
+ void calcTileVertex(int x, int y, DPoint& Vertex);
+ void calcTexCoords();
+
+ OGLSurface * m_pSurface;
+
+ IntPoint m_MaxTileSize;
+ std::string m_sBlendMode;
+ GLContext::BlendMode m_BlendMode;
+ MaterialInfo m_Material;
+
+ UTF8String m_sMaskHref;
+ std::string m_sMaskFilename;
+ BitmapPtr m_pMaskBmp;
+ DPoint m_MaskPos;
+ DPoint m_MaskSize;
+
+ bool m_bBound;
+
+ IntPoint m_TileSize;
+ VertexGrid m_TileVertices;
+ bool m_bVertexArrayDirty;
+ VertexArray * m_pVertexes;
+ std::vector<std::vector<DPoint> > m_TexCoords;
+
+ DTriple m_Gamma;
+ DTriple m_Intensity;
+ DTriple m_Contrast;
+
+ FBOPtr m_pFBO;
+ FXNodePtr m_pFXNode;
+ bool m_bFXDirty;
+ ImagingProjectionPtr m_pImagingProjection;
+};
+
+}
+
+#endif
diff --git a/src/player/RectNode.cpp b/src/player/RectNode.cpp
new file mode 100644
index 0000000..d7387df
--- /dev/null
+++ b/src/player/RectNode.cpp
@@ -0,0 +1,163 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "RectNode.h"
+
+#include "NodeDefinition.h"
+
+#include "../graphics/VertexArray.h"
+#include "../base/Exception.h"
+#include "../base/MathHelper.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition RectNode::createDefinition()
+{
+ double texCoords[] = {0, 0.25, 0.5, 0.75, 1};
+ return NodeDefinition("rect", Node::buildNode<RectNode>)
+ .extendDefinition(FilledVectorNode::createDefinition())
+ .addArg(Arg<DPoint>("pos", DPoint(0,0), false, offsetof(RectNode, m_Rect.tl)))
+ .addArg(Arg<DPoint>("size", DPoint(0,0)))
+ .addArg(Arg<double>("angle", 0.0, false, offsetof(RectNode, m_Angle)))
+ .addArg(Arg<vector<double> >("texcoords", vectorFromCArray(5, texCoords), false,
+ offsetof(RectNode, m_TexCoords)))
+ ;
+}
+
+RectNode::RectNode(const ArgList& args)
+ : FilledVectorNode(args)
+{
+ args.setMembers(this);
+ setSize(args.getArgVal<DPoint>("size"));
+}
+
+RectNode::~RectNode()
+{
+}
+
+const DPoint& RectNode::getPos() const
+{
+ return m_Rect.tl;
+}
+
+void RectNode::setPos(const DPoint& pt)
+{
+ double w = m_Rect.width();
+ double h = m_Rect.height();
+ m_Rect.tl = pt;
+ m_Rect.setWidth(w);
+ m_Rect.setHeight(h);
+ setDrawNeeded();
+}
+
+DPoint RectNode::getSize() const
+{
+ return m_Rect.size();
+}
+
+void RectNode::setSize(const DPoint& pt)
+{
+ m_Rect.setWidth(pt.x);
+ m_Rect.setHeight(pt.y);
+ setDrawNeeded();
+}
+
+const vector<double>& RectNode::getTexCoords() const
+{
+ return m_TexCoords;
+}
+
+void RectNode::setTexCoords(const vector<double>& coords)
+{
+ if (coords.size() != 5) {
+ throw(Exception(AVG_ERR_OUT_OF_RANGE,
+ "Number of texture coordinates for a rectangle must be 5."));
+ }
+ m_TexCoords = coords;
+ setDrawNeeded();
+}
+
+double RectNode::getAngle() const
+{
+ return m_Angle;
+}
+
+void RectNode::setAngle(double angle)
+{
+ m_Angle = fmod(angle, 2*M_PI);
+ setDrawNeeded();
+}
+
+void RectNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ DPoint pivot = m_Rect.tl+m_Rect.size()/2;
+ DPoint rpos = pos.getRotatedPivot(m_Angle, pivot);
+ if (rpos.x >= m_Rect.tl.x && rpos.y >= m_Rect.tl.y && rpos.x < m_Rect.br.x &&
+ rpos.y < m_Rect.br.y && reactsToMouseEvents())
+ {
+ pElements.push_back(shared_from_this());
+ }
+}
+
+void RectNode::calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ DPoint pivot = m_Rect.tl+m_Rect.size()/2;
+
+ DPoint p1 = m_Rect.tl;
+ DPoint p2(m_Rect.tl.x, m_Rect.br.y);
+ DPoint p3 = m_Rect.br;
+ DPoint p4(m_Rect.br.x, m_Rect.tl.y);
+
+ vector<DPoint> pts;
+ pts.push_back(p1.getRotatedPivot(m_Angle, pivot));
+ pts.push_back(p2.getRotatedPivot(m_Angle, pivot));
+ pts.push_back(p3.getRotatedPivot(m_Angle, pivot));
+ pts.push_back(p4.getRotatedPivot(m_Angle, pivot));
+ calcPolyLine(pts, m_TexCoords, true, LJ_MITER, pVertexArray, color);
+}
+
+void RectNode::calcFillVertexes(VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ DPoint pivot = m_Rect.tl+m_Rect.size()/2;
+
+ DPoint p1 = m_Rect.tl;
+ DPoint p2(m_Rect.tl.x, m_Rect.br.y);
+ DPoint p3 = m_Rect.br;
+ DPoint p4(m_Rect.br.x, m_Rect.tl.y);
+ DPoint rp1 = p1.getRotatedPivot(m_Angle, pivot);
+ DPoint rp2 = p2.getRotatedPivot(m_Angle, pivot);
+ DPoint rp3 = p3.getRotatedPivot(m_Angle, pivot);
+ DPoint rp4 = p4.getRotatedPivot(m_Angle, pivot);
+ pVertexArray->appendPos(rp1, getFillTexCoord1(), color);
+ DPoint blTexCoord = DPoint(getFillTexCoord1().x, getFillTexCoord2().y);
+ pVertexArray->appendPos(rp2, blTexCoord, color);
+ pVertexArray->appendPos(rp3, getFillTexCoord2(), color);
+ DPoint trTexCoord = DPoint(getFillTexCoord2().x, getFillTexCoord1().y);
+ pVertexArray->appendPos(rp4, trTexCoord, color);
+ pVertexArray->appendQuadIndexes(1, 0, 2, 3);
+}
+
+}
diff --git a/src/player/RectNode.h b/src/player/RectNode.h
new file mode 100644
index 0000000..842bf35
--- /dev/null
+++ b/src/player/RectNode.h
@@ -0,0 +1,67 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _RectNode_H_
+#define _RectNode_H_
+
+#include "../api.h"
+#include "FilledVectorNode.h"
+
+#include "../graphics/Pixel32.h"
+
+namespace avg {
+
+class AVG_API RectNode : public FilledVectorNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ RectNode(const ArgList& args);
+ virtual ~RectNode();
+
+ const DPoint& getPos() const;
+ void setPos(const DPoint& pt);
+
+ DPoint getSize() const;
+ void setSize(const DPoint& pt);
+
+ const std::vector<double>& getTexCoords() const;
+ void setTexCoords(const std::vector<double>& coords);
+
+ double getAngle() const;
+ void setAngle(double angle);
+
+ void getElementsByPos(const DPoint& pos, std::vector<NodeWeakPtr>& pElements);
+
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+ virtual void calcFillVertexes(VertexArrayPtr& pVertexArray, Pixel32 color);
+
+ private:
+ DRect m_Rect;
+ std::vector<double> m_TexCoords;
+
+ double m_Angle;
+};
+
+}
+
+#endif
+
diff --git a/src/player/SDLDisplayEngine.cpp b/src/player/SDLDisplayEngine.cpp
new file mode 100644
index 0000000..0b6293f
--- /dev/null
+++ b/src/player/SDLDisplayEngine.cpp
@@ -0,0 +1,1078 @@
+
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+
+#include "SDLDisplayEngine.h"
+#include "../avgconfigwrapper.h"
+
+#ifdef __APPLE__
+#include "SDLMain.h"
+#endif
+
+#include "Shape.h"
+
+#include "Event.h"
+#include "MouseEvent.h"
+#include "KeyEvent.h"
+#if defined(HAVE_XI2_1) || defined(HAVE_XI2_2)
+#include "XInputMTInputDevice.h"
+#endif
+#include "../base/MathHelper.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+#include "../base/OSHelper.h"
+#include "../base/StringHelper.h"
+
+#include "../graphics/GLContext.h"
+#include "../graphics/Filterflip.h"
+#include "../graphics/Filterfliprgb.h"
+#include "../graphics/ShaderRegistry.h"
+
+#include "OGLSurface.h"
+#include "OffscreenCanvas.h"
+
+#include <SDL/SDL.h>
+
+#ifdef __APPLE__
+#include <ApplicationServices/ApplicationServices.h>
+#endif
+#ifdef linux
+#include <SDL/SDL_syswm.h>
+#include <X11/extensions/xf86vmode.h>
+#endif
+
+#ifdef __APPLE__
+#include <OpenGL/OpenGL.h>
+#endif
+
+#ifdef linux
+#include <sys/ioctl.h>
+#include <sys/fcntl.h>
+#endif
+
+#include <signal.h>
+#include <iostream>
+#include <sstream>
+#include <math.h>
+
+#ifdef _WIN32
+#include <windows.h>
+#else
+#include <unistd.h>
+#endif
+
+using namespace std;
+
+namespace avg {
+
+double SDLDisplayEngine::s_RefreshRate = 0.0;
+
+void safeSetAttribute(SDL_GLattr attr, int value)
+{
+ int err = SDL_GL_SetAttribute(attr, value);
+ if (err == -1) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL, SDL_GetError());
+ }
+}
+
+SDLDisplayEngine::SDLDisplayEngine()
+ : IInputDevice(EXTRACT_INPUTDEVICE_CLASSNAME(SDLDisplayEngine)),
+ m_WindowSize(0,0),
+ m_PPMM(0),
+ m_pScreen(0),
+ m_VBMethod(VB_NONE),
+ m_VBMod(0),
+ m_bMouseOverApp(true),
+ m_pLastMouseEvent(new MouseEvent(Event::CURSORMOTION, false, false, false,
+ IntPoint(-1, -1), MouseEvent::NO_BUTTON, DPoint(-1, -1), 0)),
+ m_NumMouseButtonsDown(0)
+{
+#ifdef __APPLE__
+ static bool bSDLInitialized = false;
+ if (!bSDLInitialized) {
+ CustomSDLMain();
+ bSDLInitialized = true;
+ }
+#endif
+ if (SDL_InitSubSystem(SDL_INIT_VIDEO)==-1) {
+ AVG_TRACE(Logger::ERROR, "Can't init SDL display subsystem.");
+ exit(-1);
+ }
+ m_Gamma[0] = 1.0;
+ m_Gamma[1] = 1.0;
+ m_Gamma[2] = 1.0;
+ initTranslationTable();
+}
+
+SDLDisplayEngine::~SDLDisplayEngine()
+{
+#ifndef _WIN32
+ SDL_QuitSubSystem(SDL_INIT_VIDEO);
+#endif
+}
+
+void SDLDisplayEngine::init(const DisplayParams& dp, GLConfig glConfig)
+{
+ calcScreenDimensions(dp.m_DotsPerMM);
+ stringstream ss;
+ if (dp.m_Pos.x != -1) {
+ ss << dp.m_Pos.x << "," << dp.m_Pos.y;
+ setEnv("SDL_VIDEO_WINDOW_POS", ss.str().c_str());
+ }
+#ifdef linux
+ IntPoint oldWindowSize = m_WindowSize;
+#endif
+ double aspectRatio = double(dp.m_Size.x)/double(dp.m_Size.y);
+ if (dp.m_WindowSize == IntPoint(0, 0)) {
+ m_WindowSize = dp.m_Size;
+ } else if (dp.m_WindowSize.x == 0) {
+ m_WindowSize.x = int(dp.m_WindowSize.y*aspectRatio);
+ m_WindowSize.y = dp.m_WindowSize.y;
+ } else {
+ m_WindowSize.x = dp.m_WindowSize.x;
+ m_WindowSize.y = int(dp.m_WindowSize.x/aspectRatio);
+ }
+
+ switch (dp.m_BPP) {
+ case 32:
+ safeSetAttribute(SDL_GL_RED_SIZE, 8);
+ safeSetAttribute(SDL_GL_GREEN_SIZE, 8);
+ safeSetAttribute(SDL_GL_BLUE_SIZE, 8);
+ safeSetAttribute(SDL_GL_BUFFER_SIZE, 32);
+ break;
+ case 24:
+ safeSetAttribute(SDL_GL_RED_SIZE, 8);
+ safeSetAttribute(SDL_GL_GREEN_SIZE, 8);
+ safeSetAttribute(SDL_GL_BLUE_SIZE, 8);
+ safeSetAttribute(SDL_GL_BUFFER_SIZE, 24);
+ break;
+ case 16:
+ safeSetAttribute(SDL_GL_RED_SIZE, 5);
+ safeSetAttribute(SDL_GL_GREEN_SIZE, 6);
+ safeSetAttribute(SDL_GL_BLUE_SIZE, 5);
+ safeSetAttribute(SDL_GL_BUFFER_SIZE, 16);
+ break;
+ case 15:
+ safeSetAttribute(SDL_GL_RED_SIZE, 5);
+ safeSetAttribute(SDL_GL_GREEN_SIZE, 5);
+ safeSetAttribute(SDL_GL_BLUE_SIZE, 5);
+ safeSetAttribute(SDL_GL_BUFFER_SIZE, 15);
+ break;
+ default:
+ AVG_TRACE(Logger::ERROR, "Unsupported bpp " << dp.m_BPP <<
+ "in SDLDisplayEngine::init()");
+ exit(-1);
+ }
+ safeSetAttribute(SDL_GL_DEPTH_SIZE, 24);
+ safeSetAttribute(SDL_GL_STENCIL_SIZE, 8);
+ safeSetAttribute(SDL_GL_DOUBLEBUFFER, 1);
+
+ unsigned int Flags = SDL_OPENGL;
+ if (dp.m_bFullscreen) {
+ Flags |= SDL_FULLSCREEN;
+ }
+ m_bIsFullscreen = dp.m_bFullscreen;
+
+ if (!dp.m_bHasWindowFrame) {
+ Flags |= SDL_NOFRAME;
+ }
+
+ bool bAllMultisampleValuesTested = false;
+ m_pScreen = 0;
+ while (!bAllMultisampleValuesTested && !m_pScreen) {
+ if (glConfig.m_MultiSampleSamples > 1) {
+ safeSetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 1);
+ safeSetAttribute(SDL_GL_MULTISAMPLESAMPLES, glConfig.m_MultiSampleSamples);
+ } else {
+ safeSetAttribute(SDL_GL_MULTISAMPLEBUFFERS, 0);
+ safeSetAttribute(SDL_GL_MULTISAMPLESAMPLES, 0);
+ }
+ m_pScreen = SDL_SetVideoMode(m_WindowSize.x, m_WindowSize.y, dp.m_BPP, Flags);
+ if (!m_pScreen) {
+ switch (glConfig.m_MultiSampleSamples) {
+ case 1:
+ bAllMultisampleValuesTested = true;
+ break;
+ case 2:
+ glConfig.m_MultiSampleSamples = 1;
+ break;
+ case 4:
+ glConfig.m_MultiSampleSamples = 2;
+ break;
+ case 8:
+ glConfig.m_MultiSampleSamples = 4;
+ break;
+ default:
+ glConfig.m_MultiSampleSamples = 8;
+ break;
+ }
+ }
+ }
+ if (!m_pScreen) {
+ throw Exception(AVG_ERR_UNSUPPORTED, string("Setting SDL video mode failed: ")
+ + SDL_GetError() + ". (size=" + toString(m_WindowSize) + ", bpp=" +
+ toString(dp.m_BPP) + ", multisamplesamples=" +
+ toString(glConfig.m_MultiSampleSamples) + ").");
+ }
+ m_pGLContext = GLContextPtr(new GLContext(true, glConfig));
+
+#if defined(HAVE_XI2_1) || defined(HAVE_XI2_2)
+ SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
+ m_pXIMTInputDevice = 0;
+#endif
+ SDL_WM_SetCaption("libavg", 0);
+ calcRefreshRate();
+
+ glEnable(GL_BLEND);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "init: glEnable(GL_BLEND)");
+ glShadeModel(GL_FLAT);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "init: glShadeModel(GL_FLAT)");
+ glDisable(GL_DEPTH_TEST);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "init: glDisable(GL_DEPTH_TEST)");
+ glEnable(GL_STENCIL_TEST);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "init: glEnable(GL_STENCIL_TEST)");
+ glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "init: glTexEnvf()");
+ glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
+ glPixelStorei(GL_PACK_ROW_LENGTH, 0);
+ glPixelStorei(GL_PACK_ALIGNMENT, 1);
+ if (!queryOGLExtension("GL_ARB_vertex_buffer_object")) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Graphics driver lacks vertex buffer support, unable to initialize graphics.");
+ }
+
+ glEnableClientState(GL_VERTEX_ARRAY);
+ glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+ setGamma(dp.m_Gamma[0], dp.m_Gamma[1], dp.m_Gamma[2]);
+ showCursor(dp.m_bShowCursor);
+ if (dp.m_Framerate == 0) {
+ setVBlankRate(dp.m_VBRate);
+ } else {
+ setFramerate(dp.m_Framerate);
+ }
+
+ m_Size = dp.m_Size;
+ // SDL sets up a signal handler we really don't want.
+ signal(SIGSEGV, SIG_DFL);
+ m_pGLContext->logConfig();
+
+ SDL_EnableUNICODE(1);
+ if (m_pGLContext->isUsingShaders()) {
+ OGLSurface::createShader();
+ }
+}
+
+#ifdef _WIN32
+#pragma warning(disable: 4996)
+#endif
+void SDLDisplayEngine::teardown()
+{
+ if (m_pScreen) {
+ if (m_Gamma[0] != 1.0 || m_Gamma[1] != 1.0 || m_Gamma[2] != 1.0) {
+ SDL_SetGamma(1.0, 1.0, 1.0);
+ }
+#ifdef linux
+ // Workaround for broken mouse cursor on exit under Ubuntu 8.04.
+ SDL_ShowCursor(SDL_ENABLE);
+// SDL_SetVideoMode(m_WindowWidth, m_WindowHeight, 24, 0);
+#endif
+ m_pScreen = 0;
+ m_pGLContext = GLContextPtr();
+ }
+}
+
+double SDLDisplayEngine::getRefreshRate()
+{
+ if (s_RefreshRate == 0.0) {
+ calcRefreshRate();
+ }
+ return s_RefreshRate;
+}
+
+void SDLDisplayEngine::setGamma(double red, double green, double blue)
+{
+ if (red > 0) {
+ AVG_TRACE(Logger::CONFIG, "Setting gamma to " << red << ", " << green << ", " << blue);
+ int err = SDL_SetGamma(float(red), float(green), float(blue));
+ m_Gamma[0] = red;
+ m_Gamma[1] = green;
+ m_Gamma[2] = blue;
+ if (err == -1) {
+ AVG_TRACE(Logger::WARNING, "Unable to set display gamma.");
+ }
+ }
+}
+
+void SDLDisplayEngine::setMousePos(const IntPoint& pos)
+{
+ SDL_WarpMouse(pos.x, pos.y);
+}
+
+int SDLDisplayEngine::getKeyModifierState() const
+{
+ return SDL_GetModState();
+}
+
+void SDLDisplayEngine::calcScreenDimensions(double dotsPerMM)
+{
+ if (dotsPerMM != 0) {
+ const SDL_VideoInfo* pInfo = SDL_GetVideoInfo();
+ m_ScreenResolution = IntPoint(pInfo->current_w, pInfo->current_h);
+ m_PPMM = dotsPerMM;
+ }
+
+ if (m_PPMM == 0) {
+ const SDL_VideoInfo* pInfo = SDL_GetVideoInfo();
+ m_ScreenResolution = IntPoint(pInfo->current_w, pInfo->current_h);
+#ifdef WIN32
+ HDC hdc = CreateDC("DISPLAY", NULL, NULL, NULL);
+ m_PPMM = GetDeviceCaps(hdc, LOGPIXELSX)/25.4;
+#else
+ #ifdef linux
+ Display * pDisplay = XOpenDisplay(0);
+ DPoint displayMM(DisplayWidthMM(pDisplay,0), DisplayHeightMM(pDisplay,0));
+ #elif defined __APPLE__
+ CGSize size = CGDisplayScreenSize(CGMainDisplayID());
+ DPoint displayMM(size.width, size.height);
+ #endif
+ // Non-Square pixels cause errors here. We'll fix that when it happens.
+ m_PPMM = m_ScreenResolution.x/displayMM.x;
+#endif
+ }
+}
+
+static ProfilingZoneID SwapBufferProfilingZone("Render - swap buffers");
+
+void SDLDisplayEngine::swapBuffers()
+{
+ ScopeTimer timer(SwapBufferProfilingZone);
+ SDL_GL_SwapBuffers();
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "swapBuffers()");
+ AVG_TRACE(Logger::BLTS, "GL SwapBuffers");
+}
+
+void SDLDisplayEngine::showCursor(bool bShow)
+{
+#ifdef _WIN32
+#define MAX_CORE_POINTERS 6
+ // Hack to fix a pointer issue with fullscreen, SDL and touchscreens
+ // Refer to Mantis bug #140
+ for (int i = 0; i < MAX_CORE_POINTERS; ++i) {
+ ShowCursor(bShow);
+ }
+#else
+ if (bShow) {
+ SDL_ShowCursor(SDL_ENABLE);
+ } else {
+ SDL_ShowCursor(SDL_DISABLE);
+ }
+#endif
+}
+
+BitmapPtr SDLDisplayEngine::screenshot(int buffer)
+{
+ BitmapPtr pBmp (new Bitmap(m_WindowSize, B8G8R8X8, "screenshot"));
+ string sTmp;
+ bool bBroken = getEnv("AVG_BROKEN_READBUFFER", sTmp);
+ GLenum buf = buffer;
+ if (!buffer) {
+ if (bBroken) {
+ // Workaround for buggy GL_FRONT on some machines.
+ buf = GL_BACK;
+ } else {
+ buf = GL_FRONT;
+ }
+ }
+ glReadBuffer(buf);
+ glproc::BindBuffer(GL_PIXEL_PACK_BUFFER_EXT, 0);
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "SDLDisplayEngine::screenshot:glReadBuffer()");
+ glReadPixels(0, 0, m_WindowSize.x, m_WindowSize.y, GL_BGRA, GL_UNSIGNED_BYTE,
+ pBmp->getPixels());
+ OGLErrorCheck(AVG_ERR_VIDEO_GENERAL, "SDLDisplayEngine::screenshot:glReadPixels()");
+ FilterFlip().applyInPlace(pBmp);
+ return pBmp;
+}
+
+IntPoint SDLDisplayEngine::getSize()
+{
+ return m_Size;
+}
+
+void SDLDisplayEngine::initMacVBlank(int rate)
+{
+#ifdef __APPLE__
+ CGLContextObj context = CGLGetCurrentContext();
+ AVG_ASSERT (context);
+#if MAC_OS_X_VERSION_10_5
+ GLint l = rate;
+#else
+ long l = rate;
+#endif
+ if (rate > 1) {
+ AVG_TRACE(Logger::WARNING,
+ "VBlank rate set to " << rate
+ << " but Mac OS X only supports 1. Assuming 1.");
+ l = 1;
+ }
+ CGLError err = CGLSetParameter(context, kCGLCPSwapInterval, &l);
+ AVG_ASSERT(!err);
+#endif
+}
+
+bool SDLDisplayEngine::initVBlank(int rate)
+{
+ if (rate > 0) {
+#ifdef __APPLE__
+ initMacVBlank(rate);
+ m_VBMethod = VB_APPLE;
+#elif defined _WIN32
+ if (queryOGLExtension("WGL_EXT_swap_control")) {
+ glproc::SwapIntervalEXT(rate);
+ m_VBMethod = VB_WIN;
+ } else {
+ AVG_TRACE(Logger::WARNING,
+ "Windows VBlank setup failed: OpenGL Extension not supported.");
+ m_VBMethod = VB_NONE;
+ }
+#else
+ if (getenv("__GL_SYNC_TO_VBLANK") != 0) {
+ AVG_TRACE(Logger::WARNING,
+ "__GL_SYNC_TO_VBLANK set. This interferes with libavg vblank handling.");
+ m_VBMethod = VB_NONE;
+ } else {
+ if (queryGLXExtension("GLX_SGI_swap_control")) {
+ m_VBMethod = VB_SGI;
+ glproc::SwapIntervalSGI(rate);
+
+ } else {
+ AVG_TRACE(Logger::WARNING,
+ "Linux VBlank setup failed: OpenGL Extension not supported.");
+ m_VBMethod = VB_NONE;
+ }
+ }
+#endif
+ } else {
+ switch (m_VBMethod) {
+ case VB_APPLE:
+ initMacVBlank(0);
+ break;
+ case VB_WIN:
+#ifdef _WIN32
+ glproc::SwapIntervalEXT(0);
+#endif
+ break;
+ case VB_SGI:
+#ifdef linux
+ if (queryGLXExtension("GLX_SGI_swap_control")) {
+ glproc::SwapIntervalSGI(rate);
+ }
+#endif
+ break;
+ default:
+ break;
+ }
+ m_VBMethod = VB_NONE;
+ }
+ switch(m_VBMethod) {
+ case VB_SGI:
+ AVG_TRACE(Logger::CONFIG,
+ " Using SGI OpenGL extension for vertical blank support.");
+ break;
+ case VB_APPLE:
+ AVG_TRACE(Logger::CONFIG, " Using Apple GL vertical blank support.");
+ break;
+ case VB_WIN:
+ AVG_TRACE(Logger::CONFIG, " Using Windows GL vertical blank support.");
+ break;
+ case VB_NONE:
+ AVG_TRACE(Logger::CONFIG, " Vertical blank support disabled.");
+ break;
+ default:
+ AVG_TRACE(Logger::WARNING, " Illegal vblank enum value.");
+ }
+ return m_VBMethod != VB_NONE;
+}
+
+bool SDLDisplayEngine::vbWait(int rate)
+{
+ switch(m_VBMethod) {
+ case VB_SGI:
+ case VB_APPLE:
+ case VB_WIN:
+ return true;
+ case VB_NONE:
+ default:
+ AVG_ASSERT(false);
+ return false;
+ }
+}
+
+void SDLDisplayEngine::calcRefreshRate()
+{
+ double lastRefreshRate = s_RefreshRate;
+ s_RefreshRate = 0;
+#ifdef __APPLE__
+ CFDictionaryRef modeInfo = CGDisplayCurrentMode(CGMainDisplayID());
+ if (modeInfo) {
+ CFNumberRef value = (CFNumberRef) CFDictionaryGetValue(modeInfo,
+ kCGDisplayRefreshRate);
+ if (value) {
+ CFNumberGetValue(value, kCFNumberIntType, &s_RefreshRate);
+ if (s_RefreshRate < 1.0) {
+ AVG_TRACE(Logger::CONFIG,
+ "This seems to be a TFT screen, assuming 60 Hz refresh rate.");
+ s_RefreshRate = 60;
+ }
+ } else {
+ AVG_TRACE(Logger::WARNING,
+ "Apple refresh rate calculation (CFDictionaryGetValue) failed");
+ }
+ } else {
+ AVG_TRACE(Logger::WARNING,
+ "Apple refresh rate calculation (CGDisplayCurrentMode) failed");
+ }
+#elif defined _WIN32
+ // This isn't correct for multi-monitor systems.
+ HDC hDC = CreateDC("DISPLAY", NULL, NULL, NULL);
+ s_RefreshRate = GetDeviceCaps(hDC, VREFRESH);
+ if (s_RefreshRate < 2) {
+ s_RefreshRate = 60;
+ }
+ DeleteDC(hDC);
+#else
+ Display * pDisplay = XOpenDisplay(0);
+ int pixelClock;
+ XF86VidModeModeLine modeLine;
+ bool bOK = XF86VidModeGetModeLine (pDisplay, DefaultScreen(pDisplay),
+ &pixelClock, &modeLine);
+ if (!bOK) {
+ AVG_TRACE (Logger::WARNING,
+ "Could not get current refresh rate (XF86VidModeGetModeLine failed).");
+ AVG_TRACE (Logger::WARNING,
+ "Defaulting to 60 Hz refresh rate.");
+ }
+ double HSyncRate = pixelClock*1000.0/modeLine.htotal;
+ s_RefreshRate = HSyncRate/modeLine.vtotal;
+ XCloseDisplay(pDisplay);
+#endif
+ if (s_RefreshRate == 0 || isnan(s_RefreshRate)) {
+ s_RefreshRate = 60;
+ }
+ if (lastRefreshRate != s_RefreshRate) {
+ AVG_TRACE(Logger::CONFIG, "Vertical Refresh Rate: " << s_RefreshRate);
+ }
+
+}
+
+vector<long> SDLDisplayEngine::KeyCodeTranslationTable(SDLK_LAST, key::KEY_UNKNOWN);
+
+const char * getEventTypeName(unsigned char type)
+{
+ switch (type) {
+ case SDL_ACTIVEEVENT:
+ return "SDL_ACTIVEEVENT";
+ case SDL_KEYDOWN:
+ return "SDL_KEYDOWN";
+ case SDL_KEYUP:
+ return "SDL_KEYUP";
+ case SDL_MOUSEMOTION:
+ return "SDL_MOUSEMOTION";
+ case SDL_MOUSEBUTTONDOWN:
+ return "SDL_MOUSEBUTTONDOWN";
+ case SDL_MOUSEBUTTONUP:
+ return "SDL_MOUSEBUTTONUP";
+ case SDL_JOYAXISMOTION:
+ return "SDL_JOYAXISMOTION";
+ case SDL_JOYBUTTONDOWN:
+ return "SDL_JOYBUTTONDOWN";
+ case SDL_JOYBUTTONUP:
+ return "SDL_JOYBUTTONUP";
+ case SDL_VIDEORESIZE:
+ return "SDL_VIDEORESIZE";
+ case SDL_VIDEOEXPOSE:
+ return "SDL_VIDEOEXPOSE";
+ case SDL_QUIT:
+ return "SDL_QUIT";
+ case SDL_USEREVENT:
+ return "SDL_USEREVENT";
+ case SDL_SYSWMEVENT:
+ return "SDL_SYSWMEVENT";
+ default:
+ return "Unknown SDL event type";
+ }
+}
+
+vector<EventPtr> SDLDisplayEngine::pollEvents()
+{
+ SDL_Event sdlEvent;
+ vector<EventPtr> events;
+
+ while (SDL_PollEvent(&sdlEvent)) {
+ EventPtr pNewEvent;
+ switch (sdlEvent.type) {
+ case SDL_MOUSEMOTION:
+ if (m_bMouseOverApp) {
+ pNewEvent = createMouseEvent(Event::CURSORMOTION, sdlEvent,
+ MouseEvent::NO_BUTTON);
+ CursorEventPtr pNewCursorEvent =
+ boost::dynamic_pointer_cast<CursorEvent>(pNewEvent);
+ if (!events.empty()) {
+ CursorEventPtr pLastEvent =
+ boost::dynamic_pointer_cast<CursorEvent>(events.back());
+ if (pLastEvent && *pNewCursorEvent == *pLastEvent) {
+ pNewEvent = EventPtr();
+ }
+ }
+ }
+ break;
+ case SDL_MOUSEBUTTONDOWN:
+ pNewEvent = createMouseButtonEvent(Event::CURSORDOWN, sdlEvent);
+ break;
+ case SDL_MOUSEBUTTONUP:
+ pNewEvent = createMouseButtonEvent(Event::CURSORUP, sdlEvent);
+ break;
+ case SDL_JOYAXISMOTION:
+// pNewEvent = createAxisEvent(sdlEvent));
+ break;
+ case SDL_JOYBUTTONDOWN:
+// pNewEvent = createButtonEvent(Event::BUTTON_DOWN, sdlEvent));
+ break;
+ case SDL_JOYBUTTONUP:
+// pNewEvent = createButtonEvent(Event::BUTTON_UP, sdlEvent));
+ break;
+ case SDL_KEYDOWN:
+ pNewEvent = createKeyEvent(Event::KEYDOWN, sdlEvent);
+ break;
+ case SDL_KEYUP:
+ pNewEvent = createKeyEvent(Event::KEYUP, sdlEvent);
+ break;
+ case SDL_QUIT:
+ pNewEvent = EventPtr(new Event(Event::QUIT, Event::NONE));
+ break;
+ case SDL_VIDEORESIZE:
+ break;
+ case SDL_SYSWMEVENT:
+ {
+#if defined(HAVE_XI2_1) || defined(HAVE_XI2_2)
+ SDL_SysWMmsg* pMsg = sdlEvent.syswm.msg;
+ AVG_ASSERT(pMsg->subsystem == SDL_SYSWM_X11);
+ if (m_pXIMTInputDevice) {
+ m_pXIMTInputDevice->handleXIEvent(pMsg->event.xevent);
+ }
+#endif
+ }
+ break;
+ default:
+ // Ignore unknown events.
+ break;
+ }
+ if (pNewEvent) {
+ events.push_back(pNewEvent);
+ }
+ }
+ return events;
+}
+
+void SDLDisplayEngine::setXIMTInputDevice(XInputMTInputDevice* pInputDevice)
+{
+ AVG_ASSERT(!m_pXIMTInputDevice);
+ m_pXIMTInputDevice = pInputDevice;
+}
+
+EventPtr SDLDisplayEngine::createMouseEvent(Event::Type type, const SDL_Event& sdlEvent,
+ long button)
+{
+ int x, y;
+ Uint8 buttonState = SDL_GetMouseState(&x, &y);
+ x = int((x*m_Size.x)/m_WindowSize.x);
+ y = int((y*m_Size.y)/m_WindowSize.y);
+ DPoint lastMousePos = m_pLastMouseEvent->getPos();
+ DPoint speed;
+ if (lastMousePos.x == -1) {
+ speed = DPoint(0,0);
+ } else {
+ double lastFrameTime = 1000/getEffectiveFramerate();
+ speed = DPoint(x-lastMousePos.x, y-lastMousePos.y)/lastFrameTime;
+ }
+ MouseEventPtr pEvent(new MouseEvent(type, (buttonState & SDL_BUTTON(1)) != 0,
+ (buttonState & SDL_BUTTON(2)) != 0, (buttonState & SDL_BUTTON(3)) != 0,
+ IntPoint(x, y), button, speed));
+
+ m_pLastMouseEvent = pEvent;
+ return pEvent;
+}
+
+EventPtr SDLDisplayEngine::createMouseButtonEvent(Event::Type type,
+ const SDL_Event& sdlEvent)
+{
+ long button = 0;
+ switch (sdlEvent.button.button) {
+ case SDL_BUTTON_LEFT:
+ button = MouseEvent::LEFT_BUTTON;
+ break;
+ case SDL_BUTTON_MIDDLE:
+ button = MouseEvent::MIDDLE_BUTTON;
+ break;
+ case SDL_BUTTON_RIGHT:
+ button = MouseEvent::RIGHT_BUTTON;
+ break;
+ case SDL_BUTTON_WHEELUP:
+ button = MouseEvent::WHEELUP_BUTTON;
+ break;
+ case SDL_BUTTON_WHEELDOWN:
+ button = MouseEvent::WHEELDOWN_BUTTON;
+ break;
+ }
+ return createMouseEvent(type, sdlEvent, button);
+
+}
+
+/*
+EventPtr SDLDisplayEngine::createAxisEvent(const SDL_Event & sdlEvent)
+{
+ return new AxisEvent(sdlEvent.jaxis.which, sdlEvent.jaxis.axis,
+ sdlEvent.jaxis.value);
+}
+
+
+EventPtr SDLDisplayEngine::createButtonEvent
+ (Event::Type type, const SDL_Event & sdlEvent)
+{
+ return new ButtonEvent(type, sdlEvent.jbutton.which,
+ sdlEvent.jbutton.button));
+}
+*/
+
+EventPtr SDLDisplayEngine::createKeyEvent(Event::Type type, const SDL_Event& sdlEvent)
+{
+ long keyCode = KeyCodeTranslationTable[sdlEvent.key.keysym.sym];
+ unsigned int modifiers = key::KEYMOD_NONE;
+
+ if (sdlEvent.key.keysym.mod & KMOD_LSHIFT)
+ { modifiers |= key::KEYMOD_LSHIFT; }
+ if (sdlEvent.key.keysym.mod & KMOD_RSHIFT)
+ { modifiers |= key::KEYMOD_RSHIFT; }
+ if (sdlEvent.key.keysym.mod & KMOD_LCTRL)
+ { modifiers |= key::KEYMOD_LCTRL; }
+ if (sdlEvent.key.keysym.mod & KMOD_RCTRL)
+ { modifiers |= key::KEYMOD_RCTRL; }
+ if (sdlEvent.key.keysym.mod & KMOD_LALT)
+ { modifiers |= key::KEYMOD_LALT; }
+ if (sdlEvent.key.keysym.mod & KMOD_RALT)
+ { modifiers |= key::KEYMOD_RALT; }
+ if (sdlEvent.key.keysym.mod & KMOD_LMETA)
+ { modifiers |= key::KEYMOD_LMETA; }
+ if (sdlEvent.key.keysym.mod & KMOD_RMETA)
+ { modifiers |= key::KEYMOD_RMETA; }
+ if (sdlEvent.key.keysym.mod & KMOD_NUM)
+ { modifiers |= key::KEYMOD_NUM; }
+ if (sdlEvent.key.keysym.mod & KMOD_CAPS)
+ { modifiers |= key::KEYMOD_CAPS; }
+ if (sdlEvent.key.keysym.mod & KMOD_MODE)
+ { modifiers |= key::KEYMOD_MODE; }
+ if (sdlEvent.key.keysym.mod & KMOD_RESERVED)
+ { modifiers |= key::KEYMOD_RESERVED; }
+
+ KeyEventPtr pEvent(new KeyEvent(type,
+ sdlEvent.key.keysym.scancode, keyCode,
+ SDL_GetKeyName(sdlEvent.key.keysym.sym), sdlEvent.key.keysym.unicode, modifiers));
+ return pEvent;
+}
+
+void SDLDisplayEngine::initTranslationTable()
+{
+#define TRANSLATION_ENTRY(x) KeyCodeTranslationTable[SDLK_##x] = key::KEY_##x;
+
+ TRANSLATION_ENTRY(UNKNOWN);
+ TRANSLATION_ENTRY(BACKSPACE);
+ TRANSLATION_ENTRY(TAB);
+ TRANSLATION_ENTRY(CLEAR);
+ TRANSLATION_ENTRY(RETURN);
+ TRANSLATION_ENTRY(PAUSE);
+ TRANSLATION_ENTRY(ESCAPE);
+ TRANSLATION_ENTRY(SPACE);
+ TRANSLATION_ENTRY(EXCLAIM);
+ TRANSLATION_ENTRY(QUOTEDBL);
+ TRANSLATION_ENTRY(HASH);
+ TRANSLATION_ENTRY(DOLLAR);
+ TRANSLATION_ENTRY(AMPERSAND);
+ TRANSLATION_ENTRY(QUOTE);
+ TRANSLATION_ENTRY(LEFTPAREN);
+ TRANSLATION_ENTRY(RIGHTPAREN);
+ TRANSLATION_ENTRY(ASTERISK);
+ TRANSLATION_ENTRY(PLUS);
+ TRANSLATION_ENTRY(COMMA);
+ TRANSLATION_ENTRY(MINUS);
+ TRANSLATION_ENTRY(PERIOD);
+ TRANSLATION_ENTRY(SLASH);
+ TRANSLATION_ENTRY(0);
+ TRANSLATION_ENTRY(1);
+ TRANSLATION_ENTRY(2);
+ TRANSLATION_ENTRY(3);
+ TRANSLATION_ENTRY(4);
+ TRANSLATION_ENTRY(5);
+ TRANSLATION_ENTRY(6);
+ TRANSLATION_ENTRY(7);
+ TRANSLATION_ENTRY(8);
+ TRANSLATION_ENTRY(9);
+ TRANSLATION_ENTRY(COLON);
+ TRANSLATION_ENTRY(SEMICOLON);
+ TRANSLATION_ENTRY(LESS);
+ TRANSLATION_ENTRY(EQUALS);
+ TRANSLATION_ENTRY(GREATER);
+ TRANSLATION_ENTRY(QUESTION);
+ TRANSLATION_ENTRY(AT);
+ TRANSLATION_ENTRY(LEFTBRACKET);
+ TRANSLATION_ENTRY(BACKSLASH);
+ TRANSLATION_ENTRY(RIGHTBRACKET);
+ TRANSLATION_ENTRY(CARET);
+ TRANSLATION_ENTRY(UNDERSCORE);
+ TRANSLATION_ENTRY(BACKQUOTE);
+ TRANSLATION_ENTRY(a);
+ TRANSLATION_ENTRY(b);
+ TRANSLATION_ENTRY(c);
+ TRANSLATION_ENTRY(d);
+ TRANSLATION_ENTRY(e);
+ TRANSLATION_ENTRY(f);
+ TRANSLATION_ENTRY(g);
+ TRANSLATION_ENTRY(h);
+ TRANSLATION_ENTRY(i);
+ TRANSLATION_ENTRY(j);
+ TRANSLATION_ENTRY(k);
+ TRANSLATION_ENTRY(l);
+ TRANSLATION_ENTRY(m);
+ TRANSLATION_ENTRY(n);
+ TRANSLATION_ENTRY(o);
+ TRANSLATION_ENTRY(p);
+ TRANSLATION_ENTRY(q);
+ TRANSLATION_ENTRY(r);
+ TRANSLATION_ENTRY(s);
+ TRANSLATION_ENTRY(t);
+ TRANSLATION_ENTRY(u);
+ TRANSLATION_ENTRY(v);
+ TRANSLATION_ENTRY(w);
+ TRANSLATION_ENTRY(x);
+ TRANSLATION_ENTRY(y);
+ TRANSLATION_ENTRY(z);
+ TRANSLATION_ENTRY(DELETE);
+ TRANSLATION_ENTRY(WORLD_0);
+ TRANSLATION_ENTRY(WORLD_1);
+ TRANSLATION_ENTRY(WORLD_2);
+ TRANSLATION_ENTRY(WORLD_3);
+ TRANSLATION_ENTRY(WORLD_4);
+ TRANSLATION_ENTRY(WORLD_5);
+ TRANSLATION_ENTRY(WORLD_6);
+ TRANSLATION_ENTRY(WORLD_7);
+ TRANSLATION_ENTRY(WORLD_8);
+ TRANSLATION_ENTRY(WORLD_9);
+ TRANSLATION_ENTRY(WORLD_10);
+ TRANSLATION_ENTRY(WORLD_11);
+ TRANSLATION_ENTRY(WORLD_12);
+ TRANSLATION_ENTRY(WORLD_13);
+ TRANSLATION_ENTRY(WORLD_14);
+ TRANSLATION_ENTRY(WORLD_15);
+ TRANSLATION_ENTRY(WORLD_16);
+ TRANSLATION_ENTRY(WORLD_17);
+ TRANSLATION_ENTRY(WORLD_18);
+ TRANSLATION_ENTRY(WORLD_19);
+ TRANSLATION_ENTRY(WORLD_20);
+ TRANSLATION_ENTRY(WORLD_21);
+ TRANSLATION_ENTRY(WORLD_22);
+ TRANSLATION_ENTRY(WORLD_23);
+ TRANSLATION_ENTRY(WORLD_24);
+ TRANSLATION_ENTRY(WORLD_25);
+ TRANSLATION_ENTRY(WORLD_26);
+ TRANSLATION_ENTRY(WORLD_27);
+ TRANSLATION_ENTRY(WORLD_28);
+ TRANSLATION_ENTRY(WORLD_29);
+ TRANSLATION_ENTRY(WORLD_30);
+ TRANSLATION_ENTRY(WORLD_31);
+ TRANSLATION_ENTRY(WORLD_32);
+ TRANSLATION_ENTRY(WORLD_33);
+ TRANSLATION_ENTRY(WORLD_34);
+ TRANSLATION_ENTRY(WORLD_35);
+ TRANSLATION_ENTRY(WORLD_36);
+ TRANSLATION_ENTRY(WORLD_37);
+ TRANSLATION_ENTRY(WORLD_38);
+ TRANSLATION_ENTRY(WORLD_39);
+ TRANSLATION_ENTRY(WORLD_40);
+ TRANSLATION_ENTRY(WORLD_41);
+ TRANSLATION_ENTRY(WORLD_42);
+ TRANSLATION_ENTRY(WORLD_43);
+ TRANSLATION_ENTRY(WORLD_44);
+ TRANSLATION_ENTRY(WORLD_45);
+ TRANSLATION_ENTRY(WORLD_46);
+ TRANSLATION_ENTRY(WORLD_47);
+ TRANSLATION_ENTRY(WORLD_48);
+ TRANSLATION_ENTRY(WORLD_49);
+ TRANSLATION_ENTRY(WORLD_50);
+ TRANSLATION_ENTRY(WORLD_51);
+ TRANSLATION_ENTRY(WORLD_52);
+ TRANSLATION_ENTRY(WORLD_53);
+ TRANSLATION_ENTRY(WORLD_54);
+ TRANSLATION_ENTRY(WORLD_55);
+ TRANSLATION_ENTRY(WORLD_56);
+ TRANSLATION_ENTRY(WORLD_57);
+ TRANSLATION_ENTRY(WORLD_58);
+ TRANSLATION_ENTRY(WORLD_59);
+ TRANSLATION_ENTRY(WORLD_60);
+ TRANSLATION_ENTRY(WORLD_61);
+ TRANSLATION_ENTRY(WORLD_62);
+ TRANSLATION_ENTRY(WORLD_63);
+ TRANSLATION_ENTRY(WORLD_64);
+ TRANSLATION_ENTRY(WORLD_65);
+ TRANSLATION_ENTRY(WORLD_66);
+ TRANSLATION_ENTRY(WORLD_67);
+ TRANSLATION_ENTRY(WORLD_68);
+ TRANSLATION_ENTRY(WORLD_69);
+ TRANSLATION_ENTRY(WORLD_70);
+ TRANSLATION_ENTRY(WORLD_71);
+ TRANSLATION_ENTRY(WORLD_72);
+ TRANSLATION_ENTRY(WORLD_73);
+ TRANSLATION_ENTRY(WORLD_74);
+ TRANSLATION_ENTRY(WORLD_75);
+ TRANSLATION_ENTRY(WORLD_76);
+ TRANSLATION_ENTRY(WORLD_77);
+ TRANSLATION_ENTRY(WORLD_78);
+ TRANSLATION_ENTRY(WORLD_79);
+ TRANSLATION_ENTRY(WORLD_80);
+ TRANSLATION_ENTRY(WORLD_81);
+ TRANSLATION_ENTRY(WORLD_82);
+ TRANSLATION_ENTRY(WORLD_83);
+ TRANSLATION_ENTRY(WORLD_84);
+ TRANSLATION_ENTRY(WORLD_85);
+ TRANSLATION_ENTRY(WORLD_86);
+ TRANSLATION_ENTRY(WORLD_87);
+ TRANSLATION_ENTRY(WORLD_88);
+ TRANSLATION_ENTRY(WORLD_89);
+ TRANSLATION_ENTRY(WORLD_90);
+ TRANSLATION_ENTRY(WORLD_91);
+ TRANSLATION_ENTRY(WORLD_92);
+ TRANSLATION_ENTRY(WORLD_93);
+ TRANSLATION_ENTRY(WORLD_94);
+ TRANSLATION_ENTRY(WORLD_95);
+ TRANSLATION_ENTRY(KP0);
+ TRANSLATION_ENTRY(KP1);
+ TRANSLATION_ENTRY(KP2);
+ TRANSLATION_ENTRY(KP3);
+ TRANSLATION_ENTRY(KP4);
+ TRANSLATION_ENTRY(KP5);
+ TRANSLATION_ENTRY(KP6);
+ TRANSLATION_ENTRY(KP7);
+ TRANSLATION_ENTRY(KP8);
+ TRANSLATION_ENTRY(KP9);
+ TRANSLATION_ENTRY(KP_PERIOD);
+ TRANSLATION_ENTRY(KP_DIVIDE);
+ TRANSLATION_ENTRY(KP_MULTIPLY);
+ TRANSLATION_ENTRY(KP_MINUS);
+ TRANSLATION_ENTRY(KP_PLUS);
+ TRANSLATION_ENTRY(KP_ENTER);
+ TRANSLATION_ENTRY(KP_EQUALS);
+ TRANSLATION_ENTRY(UP);
+ TRANSLATION_ENTRY(DOWN);
+ TRANSLATION_ENTRY(RIGHT);
+ TRANSLATION_ENTRY(LEFT);
+ TRANSLATION_ENTRY(INSERT);
+ TRANSLATION_ENTRY(HOME);
+ TRANSLATION_ENTRY(END);
+ TRANSLATION_ENTRY(PAGEUP);
+ TRANSLATION_ENTRY(PAGEDOWN);
+ TRANSLATION_ENTRY(F1);
+ TRANSLATION_ENTRY(F2);
+ TRANSLATION_ENTRY(F3);
+ TRANSLATION_ENTRY(F4);
+ TRANSLATION_ENTRY(F5);
+ TRANSLATION_ENTRY(F6);
+ TRANSLATION_ENTRY(F7);
+ TRANSLATION_ENTRY(F8);
+ TRANSLATION_ENTRY(F9);
+ TRANSLATION_ENTRY(F10);
+ TRANSLATION_ENTRY(F11);
+ TRANSLATION_ENTRY(F12);
+ TRANSLATION_ENTRY(F13);
+ TRANSLATION_ENTRY(F14);
+ TRANSLATION_ENTRY(F15);
+ TRANSLATION_ENTRY(NUMLOCK);
+ TRANSLATION_ENTRY(CAPSLOCK);
+ TRANSLATION_ENTRY(SCROLLOCK);
+ TRANSLATION_ENTRY(RSHIFT);
+ TRANSLATION_ENTRY(LSHIFT);
+ TRANSLATION_ENTRY(RCTRL);
+ TRANSLATION_ENTRY(LCTRL);
+ TRANSLATION_ENTRY(RALT);
+ TRANSLATION_ENTRY(LALT);
+ TRANSLATION_ENTRY(RMETA);
+ TRANSLATION_ENTRY(LMETA);
+ TRANSLATION_ENTRY(LSUPER);
+ TRANSLATION_ENTRY(RSUPER);
+ TRANSLATION_ENTRY(MODE);
+ TRANSLATION_ENTRY(COMPOSE);
+ TRANSLATION_ENTRY(HELP);
+ TRANSLATION_ENTRY(PRINT);
+ TRANSLATION_ENTRY(SYSREQ);
+ TRANSLATION_ENTRY(BREAK);
+ TRANSLATION_ENTRY(MENU);
+ TRANSLATION_ENTRY(POWER);
+ TRANSLATION_ENTRY(EURO);
+ TRANSLATION_ENTRY(UNDO);
+}
+
+const IntPoint& SDLDisplayEngine::getWindowSize() const
+{
+ return m_WindowSize;
+}
+
+bool SDLDisplayEngine::isFullscreen() const
+{
+ return m_bIsFullscreen;
+}
+
+IntPoint SDLDisplayEngine::getScreenResolution()
+{
+ calcScreenDimensions();
+ return m_ScreenResolution;
+}
+
+double SDLDisplayEngine::getPixelsPerMM()
+{
+ calcScreenDimensions();
+
+ return m_PPMM;
+}
+
+DPoint SDLDisplayEngine::getPhysicalScreenDimensions()
+{
+ calcScreenDimensions();
+ DPoint size;
+ DPoint screenRes = DPoint(getScreenResolution());
+ size.x = screenRes.x/m_PPMM;
+ size.y = screenRes.y/m_PPMM;
+ return size;
+}
+
+void SDLDisplayEngine::assumePixelsPerMM(double ppmm)
+{
+ m_PPMM = ppmm;
+}
+
+}
diff --git a/src/player/SDLDisplayEngine.h b/src/player/SDLDisplayEngine.h
new file mode 100644
index 0000000..7a824cb
--- /dev/null
+++ b/src/player/SDLDisplayEngine.h
@@ -0,0 +1,128 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _SDLDisplayEngine_H_
+#define _SDLDisplayEngine_H_
+
+#include "../api.h"
+#include "IInputDevice.h"
+#include "DisplayEngine.h"
+
+#include "../graphics/GLConfig.h"
+#include "../graphics/Bitmap.h"
+#include "../graphics/Pixel32.h"
+#include "../graphics/OGLHelper.h"
+#include "../graphics/FBO.h"
+
+#include <string>
+#include <vector>
+
+struct SDL_Surface;
+union SDL_Event;
+
+namespace avg {
+
+class XInputMTInputDevice;
+class MouseEvent;
+typedef boost::shared_ptr<class MouseEvent> MouseEventPtr;
+class GLContext;
+typedef boost::shared_ptr<class GLContext> GLContextPtr;
+
+class AVG_API SDLDisplayEngine: public DisplayEngine, public IInputDevice
+{
+ public:
+ SDLDisplayEngine();
+ virtual ~SDLDisplayEngine();
+ virtual void init(const DisplayParams& dp, GLConfig glConfig);
+
+ // From DisplayEngine
+ virtual void teardown();
+ virtual double getRefreshRate();
+ virtual void setGamma(double red, double green, double blue);
+ virtual void setMousePos(const IntPoint& pos);
+ virtual int getKeyModifierState() const;
+
+ virtual IntPoint getSize();
+
+ virtual void showCursor(bool bShow);
+ virtual BitmapPtr screenshot(int buffer=0);
+
+ // From IInputDevice
+ virtual std::vector<EventPtr> pollEvents();
+ void setXIMTInputDevice(XInputMTInputDevice* pInputDevice);
+
+ const IntPoint& getWindowSize() const;
+ bool isFullscreen() const;
+ IntPoint getScreenResolution();
+ double getPixelsPerMM();
+ DPoint getPhysicalScreenDimensions();
+ void assumePixelsPerMM(double ppmm);
+ virtual void swapBuffers();
+
+ private:
+ void initSDL(int width, int height, bool isFullscreen, int bpp);
+ void initTranslationTable();
+ void calcScreenDimensions(double dotsPerMM=0);
+
+ EventPtr createMouseEvent
+ (Event::Type Type, const SDL_Event & SDLEvent, long Button);
+ EventPtr createMouseButtonEvent
+ (Event::Type Type, const SDL_Event & SDLEvent);
+ EventPtr createKeyEvent
+ (Event::Type Type, const SDL_Event & SDLEvent);
+
+ IntPoint m_Size;
+ bool m_bIsFullscreen;
+ IntPoint m_WindowSize;
+ IntPoint m_ScreenResolution;
+ double m_PPMM;
+
+ SDL_Surface * m_pScreen;
+
+ // Vertical blank stuff.
+ virtual bool initVBlank(int rate);
+ void initMacVBlank(int rate);
+ bool vbWait(int rate);
+ enum VBMethod {VB_SGI, VB_APPLE, VB_WIN, VB_NONE};
+ VBMethod m_VBMethod;
+ int m_VBMod;
+ int m_LastVBCount;
+
+ static void calcRefreshRate();
+ static double s_RefreshRate;
+
+ // Event handling.
+ bool m_bMouseOverApp;
+ MouseEventPtr m_pLastMouseEvent;
+ int m_NumMouseButtonsDown;
+ static std::vector<long> KeyCodeTranslationTable;
+ XInputMTInputDevice * m_pXIMTInputDevice;
+
+ GLContextPtr m_pGLContext;
+
+ double m_Gamma[3];
+};
+
+typedef boost::shared_ptr<SDLDisplayEngine> SDLDisplayEnginePtr;
+
+}
+
+#endif
diff --git a/src/player/SDLMain.h b/src/player/SDLMain.h
new file mode 100644
index 0000000..8df5895
--- /dev/null
+++ b/src/player/SDLMain.h
@@ -0,0 +1,14 @@
+
+#ifndef __SDLMain_h__
+#define __SDLMain_h__
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+void CustomSDLMain();
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/player/SDLMain.m b/src/player/SDLMain.m
new file mode 100644
index 0000000..bec828d
--- /dev/null
+++ b/src/player/SDLMain.m
@@ -0,0 +1,32 @@
+#import <SDL/SDL.h>
+#import "SDLMain.h"
+
+#import <Cocoa/Cocoa.h>
+
+/* Portions of CPS.h */
+typedef struct CPSProcessSerNum
+{
+ UInt32 lo;
+ UInt32 hi;
+} CPSProcessSerNum;
+
+extern OSErr CPSGetCurrentProcess( CPSProcessSerNum *psn);
+extern OSErr CPSEnableForegroundOperation( CPSProcessSerNum *psn, UInt32 _arg2, UInt32 _arg3, UInt32 _arg4, UInt32 _arg5);
+extern OSErr CPSSetFrontProcess( CPSProcessSerNum *psn);
+
+void CustomSDLMain()
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ [ NSApplication sharedApplication ];
+ [ NSApp setMainMenu:[[NSMenu alloc] init] ];
+
+ {
+ CPSProcessSerNum PSN;
+ /* Tell the dock about us */
+ if (!CPSGetCurrentProcess(&PSN))
+ if (!CPSEnableForegroundOperation(&PSN,0x03,0x3C,0x2C,0x1103))
+ if (!CPSSetFrontProcess(&PSN))
+ [NSApplication sharedApplication];
+ }
+}
+
diff --git a/src/player/SVG.cpp b/src/player/SVG.cpp
new file mode 100644
index 0000000..2a69560
--- /dev/null
+++ b/src/player/SVG.cpp
@@ -0,0 +1,172 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "SVG.h"
+
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+#include "../base/ScopeTimer.h"
+#include "../base/OSHelper.h"
+#include "../base/StringHelper.h"
+#include "../base/Logger.h"
+
+#include "../graphics/PixelFormat.h"
+#include "../graphics/Filterfill.h"
+#include "../graphics/FilterUnmultiplyAlpha.h"
+
+#include "OGLSurface.h"
+#include "Player.h"
+#include "ImageNode.h"
+
+#include <glib-object.h>
+#include <librsvg/rsvg-cairo.h>
+#include <cairo.h>
+
+#include <iostream>
+
+using namespace boost::python;
+using namespace std;
+
+
+namespace avg {
+
+bool SVG::s_RSVGInitialized = false;
+
+SVG::SVG(const UTF8String& sFilename, bool bUnescapeIllustratorIDs)
+ : m_sFilename(sFilename),
+ m_bUnescapeIllustratorIDs(bUnescapeIllustratorIDs)
+{
+ if (!s_RSVGInitialized) {
+ rsvg_init();
+ s_RSVGInitialized = true;
+ }
+
+ GError* pErr = new GError;
+ m_pRSVG = rsvg_handle_new_from_file(m_sFilename.c_str(), &pErr);
+ if (!m_pRSVG) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ string("Could not open svg file: ") + m_sFilename);
+ }
+ delete pErr;
+}
+
+SVG::~SVG()
+{
+ g_object_unref(m_pRSVG);
+}
+
+BitmapPtr SVG::renderElement(const UTF8String& sElementID)
+{
+ return renderElement(sElementID, 1);
+}
+
+BitmapPtr SVG::renderElement(const UTF8String& sElementID, const DPoint& size)
+{
+ SVGElementPtr pElement = getElement(sElementID);
+ DPoint elementSize = pElement->getSize();
+ return internalRenderElement(pElement, size, elementSize);
+}
+
+BitmapPtr SVG::renderElement(const UTF8String& sElementID, double scale)
+{
+ SVGElementPtr pElement = getElement(sElementID);
+ DPoint size = pElement->getSize();
+ DPoint renderSize = size * scale;
+ return internalRenderElement(pElement, renderSize, size);
+}
+
+NodePtr SVG::createImageNode(const UTF8String& sElementID, const dict& nodeAttrs)
+{
+ BitmapPtr pBmp = renderElement(sElementID);
+ return createImageNodeFromBitmap(pBmp, nodeAttrs);
+}
+
+NodePtr SVG::createImageNode(const UTF8String& sElementID, const dict& nodeAttrs,
+ const DPoint& renderSize)
+{
+ BitmapPtr pBmp = renderElement(sElementID, renderSize);
+ return createImageNodeFromBitmap(pBmp, nodeAttrs);
+}
+
+NodePtr SVG::createImageNode(const UTF8String& sElementID, const dict& nodeAttrs,
+ double scale)
+{
+ BitmapPtr pBmp = renderElement(sElementID, scale);
+ return createImageNodeFromBitmap(pBmp, nodeAttrs);
+}
+
+DPoint SVG::getElementSize(const UTF8String& sElementID)
+{
+ SVGElementPtr pElement = getElement(sElementID);
+ return pElement->getSize();
+}
+
+BitmapPtr SVG::internalRenderElement(const SVGElementPtr& pElement,
+ const DPoint& renderSize, const DPoint& size)
+{
+ DPoint pos = pElement->getPos();
+ DPoint scale(renderSize.x/size.x, renderSize.y/size.y);
+ IntPoint boundingBox = IntPoint(renderSize) +
+ IntPoint(int(scale.x+0.5), int(scale.y+0.5));
+ BitmapPtr pBmp(new Bitmap(boundingBox, B8G8R8A8));
+ FilterFill<Pixel32>(Pixel32(0,0,0,0)).applyInPlace(pBmp);
+
+ cairo_surface_t* pSurface;
+ cairo_t* pCairo;
+ pSurface = cairo_image_surface_create_for_data(pBmp->getPixels(),
+ CAIRO_FORMAT_ARGB32, boundingBox.x, boundingBox.y,
+ pBmp->getStride());
+ pCairo = cairo_create(pSurface);
+ cairo_scale(pCairo, scale.x, scale.y);
+ cairo_translate(pCairo, -pos.x, -pos.y);
+ rsvg_handle_render_cairo_sub(m_pRSVG, pCairo, pElement->getUnescapedID().c_str());
+
+ FilterUnmultiplyAlpha().applyInPlace(pBmp);
+
+ cairo_surface_destroy(pSurface);
+ cairo_destroy(pCairo);
+
+ return pBmp;
+}
+
+NodePtr SVG::createImageNodeFromBitmap(BitmapPtr pBmp, const dict& nodeAttrs)
+{
+ ImageNodePtr pNode = boost::dynamic_pointer_cast<ImageNode>(
+ Player::get()->createNode("image", nodeAttrs));
+ pNode->setBitmap(pBmp);
+ return pNode;
+}
+
+SVGElementPtr SVG::getElement(const UTF8String& sElementID)
+{
+ map<UTF8String, SVGElementPtr>::iterator pos = m_ElementMap.find(sElementID);
+ if (pos == m_ElementMap.end()) {
+ SVGElementPtr pElement(new SVGElement(m_pRSVG, m_sFilename, sElementID,
+ m_bUnescapeIllustratorIDs));
+ m_ElementMap[sElementID] = pElement;
+ return pElement;
+ } else {
+ return pos->second;
+ }
+}
+
+}
+
diff --git a/src/player/SVG.h b/src/player/SVG.h
new file mode 100644
index 0000000..cc38620
--- /dev/null
+++ b/src/player/SVG.h
@@ -0,0 +1,79 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _SVG_H_
+#define _SVG_H_
+
+#include "WrapPython.h"
+
+#include "../api.h"
+
+#include "../base/UTF8String.h"
+#include "../graphics/Bitmap.h"
+#include "BoostPython.h"
+#include "SVGElement.h"
+
+#include <librsvg/rsvg.h>
+#include <boost/shared_ptr.hpp>
+
+#include <string>
+
+namespace avg {
+
+class Node;
+typedef boost::shared_ptr<Node> NodePtr;
+
+class SVG
+{
+public:
+ SVG(const UTF8String& sFilename, bool bUnescapeIllustratorIDs=false);
+ virtual ~SVG();
+
+ BitmapPtr renderElement(const UTF8String& sElementID);
+ BitmapPtr renderElement(const UTF8String& sElementID, const DPoint& size);
+ BitmapPtr renderElement(const UTF8String& sElementID, double scale);
+ NodePtr createImageNode(const UTF8String& sElementID,
+ const boost::python::dict& nodeAttrs);
+ NodePtr createImageNode(const UTF8String& sElementID,
+ const boost::python::dict& nodeAttrs, const DPoint& renderSize);
+ NodePtr createImageNode(const UTF8String& sElementID,
+ const boost::python::dict& nodeAttrs, double scale);
+ DPoint getElementSize(const UTF8String& sElementID);
+
+private:
+ BitmapPtr internalRenderElement(const SVGElementPtr& pElement,
+ const DPoint& renderSize, const DPoint& size);
+ NodePtr createImageNodeFromBitmap(BitmapPtr pBmp,
+ const boost::python::dict& nodeAttrs);
+ SVGElementPtr getElement(const UTF8String& sElementID);
+
+ std::map<UTF8String, SVGElementPtr> m_ElementMap;
+ UTF8String m_sFilename;
+ bool m_bUnescapeIllustratorIDs;
+ RsvgHandle* m_pRSVG;
+
+ static bool s_RSVGInitialized;
+};
+
+}
+
+#endif
+
diff --git a/src/player/SVGElement.cpp b/src/player/SVGElement.cpp
new file mode 100644
index 0000000..6531431
--- /dev/null
+++ b/src/player/SVGElement.cpp
@@ -0,0 +1,115 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "SVGElement.h"
+
+#include "../base/StringHelper.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+using namespace std;
+
+namespace avg {
+
+SVGElement::SVGElement(RsvgHandle* pRSVG, const UTF8String& sFilename,
+ const UTF8String& sElementID, bool bUnescapeIllustratorIDs)
+{
+ m_sUnescapedID = unescapeID(pRSVG, sFilename, sElementID, bUnescapeIllustratorIDs);
+
+ RsvgPositionData pos;
+ rsvg_handle_get_position_sub(pRSVG, &pos, m_sUnescapedID.c_str());
+ m_Pos = DPoint(pos.x, pos.y);
+
+ RsvgDimensionData dim;
+ rsvg_handle_get_dimensions_sub(pRSVG, &dim, m_sUnescapedID.c_str());
+ m_Size = DPoint(dim.width+1, dim.height+1);
+}
+
+const UTF8String& SVGElement::getUnescapedID() const
+{
+ return m_sUnescapedID;
+}
+
+const DPoint& SVGElement::getPos() const
+{
+ return m_Pos;
+}
+
+const DPoint& SVGElement::getSize() const
+{
+ return m_Size;
+}
+
+UTF8String SVGElement::unescapeID(RsvgHandle* pRSVG, const UTF8String& sFilename,
+ const UTF8String& sElementID, bool bUnescapeIllustratorIDs)
+{
+ UTF8String sResult(string("#") + sElementID);
+ if (bUnescapeIllustratorIDs) {
+ vector<string> sPossibleIDs;
+ sPossibleIDs.push_back(sResult);
+ string::size_type pos = sResult.find("_");
+ while (pos != UTF8String::npos) {
+ sResult.replace(pos, 1, "_x5F_");
+ pos = sResult.find("_", pos+5);
+ }
+ // Illustrator adds suffixes to IDs to get rid of duplicates. Even after the
+ // duplicates are removed, the suffixes remain :-(.
+ // We handle two cases here:
+ // 1) If there is only one version with a suffix, we take that version.
+ // 2) If there are duplicate IDs, we warn.
+ sPossibleIDs.push_back(sResult);
+ for (int i=1; i<30; ++i) {
+ string sTempID = sResult + "_" + toString(i) + "_";
+ sPossibleIDs.push_back(sTempID);
+ }
+ int numFound = 0;
+ for (int i=0; i<30; ++i) {
+ string sTempID = sPossibleIDs[i];
+ if (rsvg_handle_has_sub(pRSVG, sTempID.c_str())) {
+ sResult = sTempID;
+ numFound += 1;
+ }
+ }
+ if (numFound == 0) {
+ throwIDNotFound(sFilename, sElementID);
+ }
+ if (numFound > 1) {
+ AVG_TRACE(Logger::WARNING,
+ "svg file '" << sFilename <<
+ "' has more than one element with id '" << sElementID << "'.");
+ }
+ } else {
+ if (!rsvg_handle_has_sub(pRSVG, sResult.c_str())) {
+ throwIDNotFound(sFilename, sElementID);
+ }
+ }
+ return sResult;
+}
+
+void SVGElement::throwIDNotFound(const UTF8String& sFilename,
+ const UTF8String& sElementID)
+{
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ string("svg file '") + sFilename + "' does not have an element with id '" +
+ sElementID + "'.");
+}
+
+}
diff --git a/src/player/SVGElement.h b/src/player/SVGElement.h
new file mode 100644
index 0000000..8eda90d
--- /dev/null
+++ b/src/player/SVGElement.h
@@ -0,0 +1,62 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _SVGElement_H_
+#define _SVGElement_H_
+
+#include "../api.h"
+
+#include "../base/UTF8String.h"
+#include "../base/Point.h"
+
+#include <librsvg/rsvg.h>
+#include <boost/shared_ptr.hpp>
+
+#include <map>
+
+namespace avg {
+
+class SVGElement
+{
+public:
+ SVGElement(RsvgHandle* pRSVG, const UTF8String& sFilename,
+ const UTF8String& sElementID, bool bUnescapeIllustratorIDs);
+
+ const UTF8String& getUnescapedID() const;
+ const DPoint& getPos() const;
+ const DPoint& getSize() const;
+
+private:
+ UTF8String unescapeID(RsvgHandle* pRSVG, const UTF8String& sFilename,
+ const UTF8String& sElementID, bool bUnescapeIllustratorIDs);
+ void throwIDNotFound(const UTF8String& sFilename, const UTF8String& sElementID);
+
+ UTF8String m_sUnescapedID;
+ DPoint m_Pos;
+ DPoint m_Size;
+};
+
+typedef boost::shared_ptr<SVGElement> SVGElementPtr;
+
+}
+
+#endif
+
diff --git a/src/player/ShadowFXNode.cpp b/src/player/ShadowFXNode.cpp
new file mode 100644
index 0000000..703a901
--- /dev/null
+++ b/src/player/ShadowFXNode.cpp
@@ -0,0 +1,141 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "ShadowFXNode.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+#include "../graphics/ShaderRegistry.h"
+
+#include <string>
+
+using namespace std;
+
+namespace avg {
+
+ShadowFXNode::ShadowFXNode()
+ : FXNode(),
+ m_Offset(0,0),
+ m_StdDev(1),
+ m_Opacity(1),
+ m_Color(255,255,255,255)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ if (!GLTexture::isFloatFormatSupported()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "OpenGL configuration doesn't support Shadow (no float textures).");
+ }
+}
+
+ShadowFXNode::~ShadowFXNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void ShadowFXNode::connect()
+{
+ if (!GLTexture::isFloatFormatSupported()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Cannot create ShadowFX: OpenGL configuration doesn't support Blur (no float textures).");
+ }
+ FXNode::connect();
+}
+
+void ShadowFXNode::disconnect()
+{
+ m_pFilter = GPUShadowFilterPtr();
+ FXNode::disconnect();
+}
+
+void ShadowFXNode::setParams(const DPoint& offset, double stdDev, double opacity,
+ const string& sColor)
+{
+ m_Offset = offset;
+ m_StdDev = stdDev;
+ m_Opacity = opacity;
+ m_sColorName = sColor;
+ m_Color = colorStringToColor(sColor);
+ updateFilter();
+}
+
+void ShadowFXNode::setOffset(const DPoint& offset)
+{
+ m_Offset = offset;
+ updateFilter();
+}
+
+DPoint ShadowFXNode::getOffset() const
+{
+ return m_Offset;
+}
+
+void ShadowFXNode::setRadius(double radius)
+{
+ m_StdDev = radius;
+ updateFilter();
+}
+
+double ShadowFXNode::getRadius() const
+{
+ return m_StdDev;
+}
+
+void ShadowFXNode::setOpacity(double opacity)
+{
+ m_Opacity = opacity;
+ updateFilter();
+}
+
+double ShadowFXNode::getOpacity() const
+{
+ return m_Opacity;
+}
+
+void ShadowFXNode::setColor(const std::string& sColor)
+{
+ m_sColorName = sColor;
+ m_Color = colorStringToColor(sColor);
+ updateFilter();
+}
+
+std::string ShadowFXNode::getColor() const
+{
+ return m_sColorName;
+}
+
+GPUFilterPtr ShadowFXNode::createFilter(const IntPoint& size)
+{
+ m_pFilter = GPUShadowFilterPtr(new GPUShadowFilter(size, m_Offset, m_StdDev,
+ m_Opacity, m_Color));
+ setDirty();
+ return m_pFilter;
+}
+
+void ShadowFXNode::updateFilter()
+{
+ if (m_pFilter) {
+ m_pFilter->setParams(m_Offset, m_StdDev, m_Opacity, m_Color);
+ setDirty();
+ }
+}
+
+}
+
diff --git a/src/player/ShadowFXNode.h b/src/player/ShadowFXNode.h
new file mode 100644
index 0000000..bd5a19c
--- /dev/null
+++ b/src/player/ShadowFXNode.h
@@ -0,0 +1,72 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _ShadowFXNode_H_
+#define _ShadowFXNode_H_
+
+#include "../api.h"
+
+#include "FXNode.h"
+#include "../graphics/GPUShadowFilter.h"
+
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+namespace avg {
+
+class AVG_API ShadowFXNode: public FXNode {
+public:
+ ShadowFXNode();
+ virtual ~ShadowFXNode();
+
+ virtual void connect();
+ virtual void disconnect();
+ void setParams(const DPoint& offset, double stdDev, double opacity,
+ const std::string& sColor);
+
+ void setOffset(const DPoint& offset);
+ DPoint getOffset() const;
+ void setRadius(double radius);
+ double getRadius() const;
+ void setOpacity(double opacity);
+ double getOpacity() const;
+ void setColor(const std::string& sColor);
+ std::string getColor() const;
+
+private:
+ virtual GPUFilterPtr createFilter(const IntPoint& size);
+ void updateFilter();
+
+ GPUShadowFilterPtr m_pFilter;
+
+ DPoint m_Offset;
+ double m_StdDev;
+ double m_Opacity;
+ std::string m_sColorName;
+ Pixel32 m_Color;
+};
+
+typedef boost::shared_ptr<ShadowFXNode> ShadowFXNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/Shape.cpp b/src/player/Shape.cpp
new file mode 100644
index 0000000..f93cd6b
--- /dev/null
+++ b/src/player/Shape.cpp
@@ -0,0 +1,121 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Shape.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+
+#include "../graphics/Filterfliprgb.h"
+#include "../graphics/GLContext.h"
+
+#include "OGLSurface.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+
+namespace avg {
+
+Shape::Shape(const MaterialInfo& material)
+{
+ m_pSurface = new OGLSurface();
+ m_pImage = ImagePtr(new Image(m_pSurface, material));
+}
+
+Shape::~Shape()
+{
+ delete m_pSurface;
+}
+
+void Shape::setBitmap(BitmapPtr pBmp)
+{
+ Image::State prevState = m_pImage->getState();
+ if (pBmp) {
+ m_pImage->setBitmap(pBmp);
+ } else {
+ m_pImage->setEmpty();
+ }
+ if (m_pImage->getState() == Image::GPU) {
+ if (prevState != Image::GPU) {
+ // TODO: This shouldn't happen.
+ m_pVertexArray = VertexArrayPtr(new VertexArray());
+ }
+ }
+}
+
+void Shape::moveToGPU()
+{
+ m_pSurface->attach();
+ m_pImage->moveToGPU();
+ m_pVertexArray = VertexArrayPtr(new VertexArray());
+}
+
+void Shape::moveToCPU()
+{
+ m_pVertexArray = VertexArrayPtr();
+ m_pImage->moveToCPU();
+}
+
+ImagePtr Shape::getImage()
+{
+ return m_pImage;
+}
+
+bool Shape::isTextured() const
+{
+ return m_pImage->getSource() != Image::NONE;
+}
+
+VertexArrayPtr Shape::getVertexArray()
+{
+ return m_pVertexArray;
+}
+
+void Shape::draw()
+{
+ bool bIsTextured = isTextured();
+ GLContext* pContext = GLContext::getCurrent();
+ if (bIsTextured) {
+ m_pSurface->activate();
+ } else {
+ if (GLContext::getCurrent()->isUsingShaders()) {
+ glproc::UseProgramObject(0);
+ }
+ for (int i = 1; i < 5; ++i) {
+ glproc::ActiveTexture(GL_TEXTURE0 + i);
+ glDisable(GL_TEXTURE_2D);
+ }
+ glproc::ActiveTexture(GL_TEXTURE0);
+ }
+ pContext->enableTexture(bIsTextured);
+ pContext->enableGLColorArray(!bIsTextured);
+ m_pVertexArray->draw();
+}
+
+void Shape::discard()
+{
+ m_pVertexArray = VertexArrayPtr();
+ m_pImage->discard();
+}
+
+}
diff --git a/src/player/Shape.h b/src/player/Shape.h
new file mode 100644
index 0000000..6502aaa
--- /dev/null
+++ b/src/player/Shape.h
@@ -0,0 +1,68 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Shape_H_
+#define _Shape_H_
+
+#include "../api.h"
+#include "Image.h"
+#include "MaterialInfo.h"
+
+#include "../base/Point.h"
+#include "../graphics/Bitmap.h"
+#include "../graphics/VertexArray.h"
+
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+namespace avg {
+
+class AVG_API Shape
+{
+ public:
+ Shape(const MaterialInfo& material);
+ virtual ~Shape();
+
+ void setBitmap(BitmapPtr pBmp);
+
+ virtual void moveToGPU();
+ virtual void moveToCPU();
+
+ ImagePtr getImage();
+ VertexArrayPtr getVertexArray();
+ void draw();
+
+ void discard();
+
+ private:
+ bool isTextured() const;
+
+ VertexArrayPtr m_pVertexArray;
+ OGLSurface * m_pSurface;
+ ImagePtr m_pImage;
+};
+
+typedef boost::shared_ptr<Shape> ShapePtr;
+
+}
+
+#endif
+
diff --git a/src/player/SoundNode.cpp b/src/player/SoundNode.cpp
new file mode 100644
index 0000000..9d31597
--- /dev/null
+++ b/src/player/SoundNode.cpp
@@ -0,0 +1,333 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#include "SoundNode.h"
+#include "Player.h"
+#include "NodeDefinition.h"
+#include "Canvas.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+#include "../base/XMLHelper.h"
+
+#include "../audio/SDLAudioEngine.h"
+
+#include "../video/AsyncVideoDecoder.h"
+#include "../video/FFMpegDecoder.h"
+
+#include <iostream>
+#include <sstream>
+
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+NodeDefinition SoundNode::createDefinition()
+{
+ return NodeDefinition("sound", Node::buildNode<SoundNode>)
+ .extendDefinition(AreaNode::createDefinition())
+ .addArg(Arg<UTF8String>("href", "", false, offsetof(SoundNode, m_href)))
+ .addArg(Arg<bool>("loop", false, false, offsetof(SoundNode, m_bLoop)))
+ .addArg(Arg<double>("volume", 1.0, false, offsetof(SoundNode, m_Volume)))
+ ;
+}
+
+SoundNode::SoundNode(const ArgList& args)
+ : m_Filename(""),
+ m_pEOFCallback(0),
+ m_pDecoder(0),
+ m_Volume(1.0),
+ m_State(Unloaded)
+{
+ args.setMembers(this);
+ m_Filename = m_href;
+ initFilename(m_Filename);
+ VideoDecoderPtr pSyncDecoder(new FFMpegDecoder());
+ m_pDecoder = new AsyncVideoDecoder(pSyncDecoder, 8);
+
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+SoundNode::~SoundNode()
+{
+ if (m_pDecoder) {
+ delete m_pDecoder;
+ m_pDecoder = 0;
+ }
+ if (m_pEOFCallback) {
+ Py_DECREF(m_pEOFCallback);
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+long long SoundNode::getDuration() const
+{
+ exceptionIfUnloaded("getDuration");
+ return (long long)(m_pDecoder->getVideoInfo().m_Duration*1000);
+}
+
+std::string SoundNode::getAudioCodec() const
+{
+ exceptionIfUnloaded("getAudioCodec");
+ return m_pDecoder->getVideoInfo().m_sACodec;
+}
+
+int SoundNode::getAudioSampleRate() const
+{
+ exceptionIfUnloaded("getAudioSampleRate");
+ return m_pDecoder->getVideoInfo().m_SampleRate;
+}
+
+int SoundNode::getNumAudioChannels() const
+{
+ exceptionIfUnloaded("getNumAudioChannels");
+ return m_pDecoder->getVideoInfo().m_NumAudioChannels;
+}
+
+long long SoundNode::getCurTime() const
+{
+ exceptionIfUnloaded("getCurTime");
+ return (long long)(m_pDecoder->getCurTime(SS_AUDIO)*1000);
+}
+
+void SoundNode::seekToTime(long long Time)
+{
+ exceptionIfUnloaded("seekToTime");
+ seek(Time);
+}
+
+bool SoundNode::getLoop() const
+{
+ return m_bLoop;
+}
+
+void SoundNode::setEOFCallback(PyObject * pEOFCallback)
+{
+ if (m_pEOFCallback) {
+ Py_DECREF(m_pEOFCallback);
+ }
+ Py_INCREF(pEOFCallback);
+ m_pEOFCallback = pEOFCallback;
+}
+
+void SoundNode::connectDisplay()
+{
+ if (!SDLAudioEngine::get()) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "Sound nodes can only be created if audio is not disabled.");
+ }
+ checkReload();
+ AreaNode::connectDisplay();
+ long long curTime = Player::get()->getFrameTime();
+ if (m_State != Unloaded) {
+ startDecoding();
+ m_StartTime = curTime;
+ m_PauseTime = 0;
+ }
+ if (m_State == Paused) {
+ m_PauseStartTime = curTime;
+ }
+}
+
+void SoundNode::connect(CanvasPtr pCanvas)
+{
+ AreaNode::connect(pCanvas);
+ pCanvas->registerFrameEndListener(this);
+}
+
+void SoundNode::disconnect(bool bKill)
+{
+ changeSoundState(Unloaded);
+ getCanvas()->unregisterFrameEndListener(this);
+ if (bKill) {
+ setEOFCallback(Py_None);
+ }
+ AreaNode::disconnect(bKill);
+}
+
+void SoundNode::play()
+{
+ changeSoundState(Playing);
+}
+
+void SoundNode::stop()
+{
+ changeSoundState(Unloaded);
+}
+
+void SoundNode::pause()
+{
+ changeSoundState(Paused);
+}
+
+const UTF8String& SoundNode::getHRef() const
+{
+ return m_href;
+}
+
+void SoundNode::setHRef(const UTF8String& href)
+{
+ m_href = href;
+ checkReload();
+}
+
+double SoundNode::getVolume()
+{
+ return m_Volume;
+}
+
+void SoundNode::setVolume(double volume)
+{
+ if (volume < 0) {
+ volume = 0;
+ }
+ m_Volume = volume;
+ if (m_pDecoder) {
+ m_pDecoder->setVolume(volume);
+ }
+}
+
+void SoundNode::checkReload()
+{
+ string fileName (m_href);
+ if (m_href != "") {
+ initFilename(fileName);
+ if (fileName != m_Filename) {
+ SoundState oldState = m_State;
+ changeSoundState(Unloaded);
+ m_Filename = fileName;
+ if (oldState != Unloaded) {
+ changeSoundState(Paused);
+ }
+ }
+ } else {
+ changeSoundState(Unloaded);
+ m_Filename = "";
+ }
+}
+
+void SoundNode::onFrameEnd()
+{
+ if (m_State == Playing && m_pDecoder->isEOF(SS_AUDIO)) {
+ onEOF();
+ }
+}
+
+int SoundNode::fillAudioBuffer(AudioBufferPtr pBuffer)
+{
+ if (m_State == Playing) {
+ return m_pDecoder->fillAudioBuffer(pBuffer);
+ } else {
+ return 0;
+ }
+}
+
+void SoundNode::changeSoundState(SoundState newSoundState)
+{
+ if (newSoundState == m_State) {
+ return;
+ }
+ if (m_State == Unloaded) {
+ open();
+ }
+ if (newSoundState == Unloaded) {
+ close();
+ }
+ if (getState() == NS_CANRENDER) {
+ long long curTime = Player::get()->getFrameTime();
+ if (m_State == Unloaded) {
+ startDecoding();
+ m_StartTime = curTime;
+ m_PauseTime = 0;
+ }
+ if (newSoundState == Paused) {
+ m_PauseStartTime = curTime;
+ } else if (newSoundState == Playing && m_State == Paused) {
+ m_PauseTime += curTime-m_PauseStartTime;
+ }
+ }
+ m_State = newSoundState;
+}
+
+void SoundNode::seek(long long destTime)
+{
+ m_pDecoder->seek(double(destTime)/1000);
+ m_StartTime = Player::get()->getFrameTime() - destTime;
+ m_PauseTime = 0;
+ m_PauseStartTime = Player::get()->getFrameTime();
+}
+
+void SoundNode::open()
+{
+ m_pDecoder->setVolume(m_Volume);
+ m_pDecoder->open(m_Filename, true);
+ VideoInfo videoInfo = m_pDecoder->getVideoInfo();
+ if (!videoInfo.m_bHasAudio) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ string("SoundNode: Opening "+m_Filename
+ +" failed. No audio stream found."));
+ }
+}
+
+void SoundNode::startDecoding()
+{
+ SDLAudioEngine* pEngine = SDLAudioEngine::get();
+ m_pDecoder->startDecoding(false, pEngine->getParams());
+ pEngine->addSource(this);
+}
+
+void SoundNode::close()
+{
+ SDLAudioEngine::get()->removeSource(this);
+ m_pDecoder->close();
+}
+
+void SoundNode::exceptionIfUnloaded(const std::string& sFuncName) const
+{
+ if (m_State == Unloaded) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ string("SoundNode.")+sFuncName+" failed: video not loaded.");
+ }
+}
+
+void SoundNode::onEOF()
+{
+ seek(0);
+ if (!m_bLoop) {
+ changeSoundState(Paused);
+ }
+ if (m_pEOFCallback) {
+ PyObject * arglist = Py_BuildValue("()");
+ PyObject * result = PyEval_CallObject(m_pEOFCallback, arglist);
+ Py_DECREF(arglist);
+ if (!result) {
+ throw error_already_set();
+ }
+ Py_DECREF(result);
+ }
+}
+
+}
diff --git a/src/player/SoundNode.h b/src/player/SoundNode.h
new file mode 100644
index 0000000..04f927d
--- /dev/null
+++ b/src/player/SoundNode.h
@@ -0,0 +1,102 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _SoundNode_H_
+#define _SoundNode_H_
+
+#include "../api.h"
+
+#include "AreaNode.h"
+
+#include "../base/IFrameEndListener.h"
+#include "../base/UTF8String.h"
+#include "../audio/IAudioSource.h"
+
+namespace avg {
+
+class VideoDecoder;
+
+class AVG_API SoundNode : public AreaNode, IFrameEndListener, IAudioSource
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ SoundNode(const ArgList& args);
+ virtual ~SoundNode();
+
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+
+ void play();
+ void stop();
+ void pause();
+
+ const UTF8String& getHRef() const;
+ void setHRef(const UTF8String& href);
+ double getVolume();
+ void setVolume(double volume);
+ void checkReload();
+
+ long long getDuration() const;
+ std::string getAudioCodec() const;
+ int getAudioSampleRate() const;
+ int getNumAudioChannels() const;
+
+ long long getCurTime() const;
+ void seekToTime(long long Time);
+ bool getLoop() const;
+ void setEOFCallback(PyObject * pEOFCallback);
+
+ virtual void onFrameEnd();
+
+ virtual int fillAudioBuffer(AudioBufferPtr pBuffer);
+
+ private:
+ void seek(long long destTime);
+ void onEOF();
+
+ enum SoundState {Unloaded, Paused, Playing};
+ void changeSoundState(SoundState newSoundState);
+ void open();
+ void startDecoding();
+ void close();
+ void exceptionIfUnloaded(const std::string& sFuncName) const;
+
+ UTF8String m_href;
+ std::string m_Filename;
+ bool m_bLoop;
+ PyObject * m_pEOFCallback;
+ bool m_bAudioEnabled;
+
+ long long m_StartTime;
+ long long m_PauseTime;
+ long long m_PauseStartTime;
+
+ VideoDecoder * m_pDecoder;
+ double m_Volume;
+ SoundState m_State;
+};
+
+}
+
+#endif
+
diff --git a/src/player/TUIOInputDevice.cpp b/src/player/TUIOInputDevice.cpp
new file mode 100644
index 0000000..a722289
--- /dev/null
+++ b/src/player/TUIOInputDevice.cpp
@@ -0,0 +1,216 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TUIOInputDevice.h"
+#include "TouchEvent.h"
+#include "Player.h"
+#include "AVGNode.h"
+#include "TouchStatus.h"
+
+#include "../base/Logger.h"
+#include "../base/StringHelper.h"
+#include "../base/OSHelper.h"
+#include "../base/Point.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+using namespace std;
+using namespace osc;
+
+namespace avg {
+
+#ifndef WIN32
+void* TUIOInputDevice::threadFunc(void* p)
+#else
+DWORD WINAPI TUIOInputDevice::threadFunc(LPVOID p)
+#endif
+{
+ TUIOInputDevice* pThis = (TUIOInputDevice*)p;
+ pThis->m_pSocket->Run();
+ return 0;
+};
+
+TUIOInputDevice::TUIOInputDevice()
+ : m_LastID(0)
+{
+}
+
+TUIOInputDevice::~TUIOInputDevice()
+{
+ if (m_pSocket) {
+ m_pSocket->Break();
+ }
+}
+
+void TUIOInputDevice::start()
+{
+ string sPort("3333");
+ getEnv("AVG_TUIO_PORT", sPort);
+ int port;
+ try {
+ port = stringToInt(sPort);
+ } catch (Exception&) {
+ throw Exception(AVG_ERR_TYPE,
+ string("TUIO event source: AVG_TUIO_PORT set to invalid value '")
+ + sPort + "'");
+ }
+ MultitouchInputDevice::start();
+ try {
+ m_pSocket = new UdpListeningReceiveSocket(IpEndpointName(
+ IpEndpointName::ANY_ADDRESS, port), this);
+ } catch (std::exception &e) {
+ throw Exception(AVG_ERR_MT_INIT,
+ string("TUIO event source: Can't initialize networking. ") + e.what());
+ }
+ if (!m_pSocket->IsBound()) {
+ throw Exception(AVG_ERR_MT_INIT, "TUIO event source: Socket not bound.");
+ }
+ AVG_TRACE(Logger::CONFIG, "TUIO multitouch event source created, listening on port "
+ << port);
+
+#ifndef WIN32
+ pthread_create(&m_Thread, NULL, threadFunc, this);
+#else
+ DWORD threadId;
+ m_Thread = CreateThread(0, 0, threadFunc, this, 0, &threadId);
+#endif
+}
+
+void TUIOInputDevice::ProcessPacket(const char* pData, int size,
+ const IpEndpointName& remoteEndpoint)
+{
+ boost::mutex::scoped_lock lock(getMutex());
+ try {
+ ReceivedPacket packet(pData, size);
+ if (packet.IsBundle()) {
+ processBundle(ReceivedBundle(packet), remoteEndpoint);
+ } else {
+ processMessage(ReceivedMessage(packet), remoteEndpoint);
+ }
+ } catch (MalformedBundleException& e) {
+ AVG_TRACE(Logger::WARNING, "Malformed OSC bundle received: " << e.what());
+ }
+}
+
+void TUIOInputDevice::processBundle(const ReceivedBundle& bundle,
+ const IpEndpointName& remoteEndpoint)
+{
+ try {
+ for (ReceivedBundle::const_iterator it = bundle.ElementsBegin();
+ it != bundle.ElementsEnd(); ++it)
+ {
+ if (it->IsBundle()) {
+ processBundle(ReceivedBundle(*it), remoteEndpoint);
+ } else {
+ processMessage(ReceivedMessage(*it), remoteEndpoint);
+ }
+ }
+ } catch (MalformedBundleException& e) {
+ AVG_TRACE(Logger::WARNING, "Malformed OSC bundle received: " << e.what());
+ }
+}
+
+void TUIOInputDevice::processMessage(const ReceivedMessage& msg,
+ const IpEndpointName& remoteEndpoint)
+{
+// cerr << msg << endl;
+ try {
+ ReceivedMessageArgumentStream args = msg.ArgumentStream();
+
+ if (strcmp(msg.AddressPattern(), "/tuio/2Dcur") == 0) {
+ const char* cmd;
+ args >> cmd;
+
+ if (strcmp(cmd,"set")==0) {
+ processSet(args);
+ } else if (strcmp(cmd,"alive")==0) {
+ processAlive(args);
+ } else if (strcmp(cmd, "fseq") == 0 ) {
+ int32 fseq;
+ args >> fseq;
+ }
+ }
+ } catch (osc::Exception& e) {
+ AVG_TRACE(Logger::WARNING, "Error parsing TUIO message: " << e.what()
+ << ". Message was " << msg);
+ }
+}
+
+void TUIOInputDevice::processSet(ReceivedMessageArgumentStream& args)
+{
+ osc::int32 tuioID;
+ float xpos, ypos;
+ float xspeed, yspeed;
+ float accel;
+ args >> tuioID >> xpos >> ypos >> xspeed >> yspeed >> accel;
+ DPoint pos(xpos, ypos);
+ DPoint speed(xspeed, yspeed);
+// cerr << "Set: ID: " << tuioID << ", pos: " << pos << ", speed: " << speed
+// << ", accel: " << accel << endl;
+ TouchStatusPtr pTouchStatus = getTouchStatus(tuioID);
+ if (!pTouchStatus) {
+ // Down
+ m_LastID++;
+ TouchEventPtr pEvent = createEvent(m_LastID, Event::CURSORDOWN, pos, speed);
+ addTouchStatus((long)tuioID, pEvent);
+ } else {
+ // Move
+ TouchEventPtr pEvent = createEvent(0, Event::CURSORMOTION, pos, speed);
+ pTouchStatus->pushEvent(pEvent);
+ }
+}
+
+void TUIOInputDevice::processAlive(ReceivedMessageArgumentStream& args)
+{
+ m_LiveTUIOIDs.clear();
+ int32 tuioID;
+ while (!args.Eos()) {
+ args >> tuioID;
+ m_LiveTUIOIDs.insert(tuioID);
+ }
+
+ // Create up events for all ids not in live list.
+ set<int> deadTUIOIDs;
+ getDeadIDs(m_LiveTUIOIDs, deadTUIOIDs);
+ set<int>::iterator it;
+ for (it = deadTUIOIDs.begin(); it != deadTUIOIDs.end(); ++it) {
+ int id = *it;
+ TouchStatusPtr pTouchStatus = getTouchStatus(id);
+ TouchEventPtr pOldEvent = pTouchStatus->getLastEvent();
+ TouchEventPtr pUpEvent = boost::dynamic_pointer_cast<TouchEvent>(
+ pOldEvent->cloneAs(Event::CURSORUP));
+ pTouchStatus->pushEvent(pUpEvent);
+ removeTouchStatus(id);
+ }
+}
+
+TouchEventPtr TUIOInputDevice::createEvent(int id, Event::Type type, DPoint pos,
+ DPoint speed)
+{
+ DPoint size = getWindowSize();
+ IntPoint screenPos(int(pos.x*size.x+0.5), int(pos.y*size.y+0.5));
+ DPoint screenSpeed(int(speed.x*size.x+0.5), int(speed.y*size.y+0.5));
+ TouchEventPtr pEvent(new TouchEvent(id, type, screenPos, Event::TOUCH));
+ pEvent->setSpeed(screenSpeed/1000);
+ return pEvent;
+}
+
+}
diff --git a/src/player/TUIOInputDevice.h b/src/player/TUIOInputDevice.h
new file mode 100644
index 0000000..6bd99f1
--- /dev/null
+++ b/src/player/TUIOInputDevice.h
@@ -0,0 +1,80 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TUIOInputDevice_H_
+#define _TUIOInputDevice_H_
+
+#include "../api.h"
+#include "MultitouchInputDevice.h"
+#include "Event.h"
+#include "../oscpack/UdpSocket.h"
+#include "../oscpack/PacketListener.h"
+#include "../oscpack/OscReceivedElements.h"
+#include "../oscpack/OscPrintReceivedElements.h"
+
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+#include <set>
+
+namespace avg {
+
+class AVG_API TUIOInputDevice: public MultitouchInputDevice, PacketListener
+{
+public:
+ TUIOInputDevice();
+ virtual ~TUIOInputDevice();
+ virtual void start();
+
+ virtual void ProcessPacket(const char* pData, int size,
+ const IpEndpointName& remoteEndpoint);
+
+private:
+#ifndef WIN32
+ static void* threadFunc(void* p);
+#else
+ static DWORD WINAPI threadFunc(LPVOID p);
+#endif
+ void processBundle(const osc::ReceivedBundle& bundle,
+ const IpEndpointName& remoteEndpoint);
+ void processMessage(const osc::ReceivedMessage& msg,
+ const IpEndpointName& remoteEndpoint);
+ void processSet(osc::ReceivedMessageArgumentStream& args);
+ void processAlive(osc::ReceivedMessageArgumentStream& args);
+ TouchEventPtr createEvent(int id, Event::Type type, DPoint pos, DPoint speed);
+
+ UdpListeningReceiveSocket* m_pSocket;
+ int m_LastID;
+ std::set<int> m_LiveTUIOIDs;
+#ifndef WIN32
+ pthread_t m_Thread;
+#else
+ HANDLE m_Thread;
+#endif
+};
+
+typedef boost::shared_ptr<TUIOInputDevice> TUIOInputDevicePtr;
+
+}
+
+#endif
+
diff --git a/src/player/TestHelper.cpp b/src/player/TestHelper.cpp
new file mode 100644
index 0000000..c9a3e48
--- /dev/null
+++ b/src/player/TestHelper.cpp
@@ -0,0 +1,147 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TestHelper.h"
+#include "Player.h"
+#include "MouseEvent.h"
+#include "TouchEvent.h"
+#include "KeyEvent.h"
+#include "TouchStatus.h"
+
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include <iostream>
+#ifdef WIN32
+#undef max
+#endif
+#include <limits>
+
+using namespace std;
+
+namespace avg {
+
+TestHelper::TestHelper()
+ : IInputDevice(EXTRACT_INPUTDEVICE_CLASSNAME(TestHelper))
+{
+}
+
+TestHelper::~TestHelper()
+{
+}
+
+void TestHelper::reset()
+{
+ m_Touches.clear();
+}
+
+void TestHelper::fakeMouseEvent(Event::Type eventType,
+ bool leftButtonState, bool middleButtonState,
+ bool rightButtonState,
+ int xPosition, int yPosition, int button)
+{
+ checkEventType(eventType);
+ MouseEventPtr pEvent(new MouseEvent(eventType, leftButtonState,
+ middleButtonState, rightButtonState, IntPoint(xPosition, yPosition), button));
+ m_Events.push_back(pEvent);
+}
+
+void TestHelper::fakeTouchEvent(int id, Event::Type eventType,
+ Event::Source source, const DPoint& pos, const DPoint& speed)
+{
+ checkEventType(eventType);
+ // The id is modified to avoid collisions with real touch events.
+ TouchEventPtr pEvent(new TouchEvent(id+std::numeric_limits<int>::max()/2, eventType,
+ IntPoint(pos), source, speed));
+ map<int, TouchStatusPtr>::iterator it = m_Touches.find(pEvent->getCursorID());
+ switch (pEvent->getType()) {
+ case Event::CURSORDOWN: {
+ AVG_ASSERT(it == m_Touches.end());
+ TouchStatusPtr pTouchStatus(new TouchStatus(pEvent));
+ m_Touches[pEvent->getCursorID()] = pTouchStatus;
+ }
+ break;
+ case Event::CURSORMOTION:
+ case Event::CURSORUP: {
+ if (it == m_Touches.end()) {
+ cerr << "borked: " << pEvent->getCursorID() << ", " <<
+ pEvent->typeStr() << endl;
+ }
+ AVG_ASSERT(it != m_Touches.end());
+ TouchStatusPtr pTouchStatus = (*it).second;
+ pTouchStatus->pushEvent(pEvent);
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ break;
+ }
+}
+
+void TestHelper::fakeKeyEvent(Event::Type eventType,
+ unsigned char scanCode, int keyCode,
+ const string& keyString, int unicode, int modifiers)
+{
+ KeyEventPtr pEvent(new KeyEvent(eventType, scanCode, keyCode,
+ keyString, unicode, modifiers));
+ m_Events.push_back(pEvent);
+}
+
+void TestHelper::dumpObjects()
+{
+ cerr << ObjectCounter::get()->dump();
+}
+
+// From IInputDevice
+std::vector<EventPtr> TestHelper::pollEvents()
+{
+ vector<EventPtr> events = m_Events;
+ map<int, TouchStatusPtr>::iterator it;
+ for (it = m_Touches.begin(); it != m_Touches.end(); ) {
+ TouchStatusPtr pTouchStatus = it->second;
+ CursorEventPtr pEvent = pTouchStatus->pollEvent();
+ if (pEvent) {
+ events.push_back(pEvent);
+ if (pEvent->getType() == Event::CURSORUP) {
+ m_Touches.erase(it++);
+ } else {
+ ++it;
+ }
+ } else {
+ ++it;
+ }
+ }
+
+ m_Events.clear();
+ return events;
+}
+
+void TestHelper::checkEventType(Event::Type eventType)
+{
+ if (eventType == Event::CURSOROVER || eventType == Event::CURSOROUT) {
+ throw Exception(AVG_ERR_UNSUPPORTED, "TestHelper::fakeXxxEvent: Can't send "
+ "CURSOROVER and CURSOROUT events directly. They are generated "
+ "internally.");
+ }
+}
+
+}
+
diff --git a/src/player/TestHelper.h b/src/player/TestHelper.h
new file mode 100644
index 0000000..0461729
--- /dev/null
+++ b/src/player/TestHelper.h
@@ -0,0 +1,74 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TestHelper_H_
+#define _TestHelper_H_
+
+#include "../api.h"
+#include "../graphics/Bitmap.h"
+#include "Event.h"
+#include "IInputDevice.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <vector>
+#include <map>
+
+namespace avg {
+
+class TouchStatus;
+typedef boost::shared_ptr<class TouchStatus> TouchStatusPtr;
+class CursorEvent;
+typedef boost::shared_ptr<class CursorEvent> CursorEventPtr;
+
+class AVG_API TestHelper : public IInputDevice
+{
+ public:
+ TestHelper();
+ virtual ~TestHelper();
+ void reset();
+
+ void fakeMouseEvent(Event::Type eventType,
+ bool leftButtonState, bool middleButtonState,
+ bool rightButtonState,
+ int xPosition, int yPosition, int button);
+ void fakeTouchEvent(int id, Event::Type eventType, Event::Source source,
+ const DPoint& pos, const DPoint& speed=DPoint(0, 0));
+ void fakeKeyEvent(Event::Type eventType,
+ unsigned char scanCode, int keyCode,
+ const std::string& keyString, int unicode, int modifiers);
+ void dumpObjects();
+
+ // From IInputDevice
+ virtual std::vector<EventPtr> pollEvents();
+
+ private:
+ void checkEventType(Event::Type eventType);
+
+ std::vector<EventPtr> m_Events;
+ std::map<int, TouchStatusPtr> m_Touches;
+};
+
+typedef boost::shared_ptr<TestHelper> TestHelperPtr;
+}
+
+#endif
+
diff --git a/src/player/TextEngine.cpp b/src/player/TextEngine.cpp
new file mode 100644
index 0000000..9d89e36
--- /dev/null
+++ b/src/player/TextEngine.cpp
@@ -0,0 +1,301 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TextEngine.h"
+
+#include "../base/Logger.h"
+#include "../base/OSHelper.h"
+#include "../base/Exception.h"
+#include "../base/FileHelper.h"
+#include "../base/StringHelper.h"
+
+#include <algorithm>
+
+namespace avg {
+
+using namespace std;
+
+static void
+text_subst_func_hint(FcPattern *pattern, gpointer data)
+{
+ FcPatternAddBool(pattern, FC_HINTING, true);
+ FcPatternAddInteger(pattern, FC_HINT_STYLE, FC_HINT_MEDIUM);
+ FcPatternAddInteger(pattern, FC_RGBA, FC_RGBA_NONE);
+ FcPatternAddBool(pattern, FC_ANTIALIAS, true);
+}
+
+static void
+text_subst_func_nohint(FcPattern *pattern, gpointer data)
+{
+ FcPatternAddBool(pattern, FC_HINTING, false);
+ FcPatternAddBool(pattern, FC_AUTOHINT, false);
+ FcPatternAddInteger(pattern, FC_HINT_STYLE, FC_HINT_NONE);
+ FcPatternAddInteger(pattern, FC_RGBA, FC_RGBA_NONE);
+ FcPatternAddBool(pattern, FC_ANTIALIAS, true);
+}
+
+TextEngine& TextEngine::get(bool bHint)
+{
+ if (bHint) {
+ static TextEngine s_Instance(true);
+ return s_Instance;
+ } else {
+ static TextEngine s_Instance(false);
+ return s_Instance;
+ }
+}
+
+
+TextEngine::TextEngine(bool bHint)
+ : m_bHint(bHint)
+{
+ m_sFontDirs.push_back("fonts/");
+ init();
+}
+
+TextEngine::~TextEngine()
+{
+ deinit();
+}
+
+void TextEngine::init()
+{
+ g_type_init();
+ m_pFontMap = PANGO_FT2_FONT_MAP(pango_ft2_font_map_new());
+ pango_ft2_font_map_set_resolution(m_pFontMap, 72, 72);
+ if (m_bHint) {
+ pango_ft2_font_map_set_default_substitute(m_pFontMap, text_subst_func_hint,
+ 0, 0);
+ } else {
+ pango_ft2_font_map_set_default_substitute(m_pFontMap, text_subst_func_nohint,
+ 0, 0);
+ }
+ m_pPangoContext = pango_ft2_font_map_create_context(m_pFontMap);
+
+ pango_context_set_language(m_pPangoContext,
+ pango_language_from_string ("en_US"));
+ pango_context_set_base_dir(m_pPangoContext, PANGO_DIRECTION_LTR);
+
+ initFonts();
+
+ string sOldLang = "";
+ getEnv("LC_CTYPE", sOldLang);
+ setEnv("LC_CTYPE", "en-us");
+ pango_font_map_list_families(PANGO_FONT_MAP(m_pFontMap), &m_ppFontFamilies,
+ &m_NumFontFamilies);
+ setEnv("LC_CTYPE", sOldLang);
+ for (int i = 0; i < m_NumFontFamilies; ++i) {
+ m_sFonts.push_back(pango_font_family_get_name(m_ppFontFamilies[i]));
+ }
+ sort(m_sFonts.begin(), m_sFonts.end());
+}
+
+void TextEngine::deinit()
+{
+ g_object_unref(m_pFontMap);
+ g_free(m_ppFontFamilies);
+ g_object_unref(m_pPangoContext);
+ m_sFonts.clear();
+}
+
+void TextEngine::addFontDir(const std::string& sDir)
+{
+ deinit();
+ m_sFontDirs.push_back(sDir);
+ init();
+}
+
+PangoContext * TextEngine::getPangoContext()
+{
+ return m_pPangoContext;
+}
+
+const vector<string>& TextEngine::getFontFamilies()
+{
+ return m_sFonts;
+}
+
+const vector<string>& TextEngine::getFontVariants(const string& sFontName)
+{
+ PangoFontFamily * pCurFamily = getFontFamily(sFontName);
+ PangoFontFace ** ppFaces;
+ int numFaces;
+ pango_font_family_list_faces (pCurFamily, &ppFaces, &numFaces);
+ static vector<string> sVariants;
+ for (int i = 0; i < numFaces; ++i) {
+ sVariants.push_back(pango_font_face_get_face_name(ppFaces[i]));
+ }
+ g_free(ppFaces);
+ return sVariants;
+}
+
+PangoFontDescription * TextEngine::getFontDescription(const string& sFamily,
+ const string& sVariant)
+{
+ PangoFontDescription* pDescription;
+ FontDescriptionCache::iterator it;
+ it = m_FontDescriptionCache.find(pair<string, string>(sFamily, sVariant));
+ if (it == m_FontDescriptionCache.end()) {
+ PangoFontFamily * pFamily;
+ bool bFamilyFound = true;
+ try {
+ pFamily = getFontFamily(sFamily);
+ } catch (Exception&) {
+ if (m_sFontsNotFound.find(sFamily) == m_sFontsNotFound.end()) {
+ AVG_TRACE(Logger::WARNING, "Could not find font face " << sFamily <<
+ ". Using sans instead.");
+ m_sFontsNotFound.insert(sFamily);
+ }
+ bFamilyFound = false;
+ pFamily = getFontFamily("sans");
+ }
+ PangoFontFace ** ppFaces;
+ int numFaces;
+ pango_font_family_list_faces(pFamily, &ppFaces, &numFaces);
+ PangoFontFace * pFace = 0;
+ if (sVariant == "") {
+ pFace = ppFaces[0];
+ } else {
+ for (int i = 0; i < numFaces; ++i) {
+ if (equalIgnoreCase(pango_font_face_get_face_name(ppFaces[i]), sVariant)) {
+ pFace = ppFaces[i];
+ }
+ }
+ }
+ if (!pFace) {
+ pFace = ppFaces[0];
+ if (bFamilyFound) {
+ pair<string, string> variant(sFamily, sVariant);
+ if (m_VariantsNotFound.find(variant) == m_VariantsNotFound.end()) {
+ m_VariantsNotFound.insert(variant);
+ AVG_TRACE(Logger::WARNING, "Could not find font variant "
+ << sFamily << ":" << sVariant << ". Using " <<
+ pango_font_face_get_face_name(pFace) << " instead.");
+ }
+ }
+ }
+ g_free(ppFaces);
+ pDescription = pango_font_face_describe(pFace);
+ m_FontDescriptionCache[pair<string, string>(sFamily, sVariant)] =
+ pDescription;
+ } else {
+ pDescription = it->second;
+ }
+ return pango_font_description_copy(pDescription);
+}
+
+void GLibLogFunc(const gchar *log_domain, GLogLevelFlags log_level,
+ const gchar *message, gpointer unused_data)
+{
+#ifndef WIN32
+ string s = "Pango ";
+ if (log_level & G_LOG_LEVEL_ERROR) {
+ s += "error: ";
+ } else if (log_level & G_LOG_LEVEL_CRITICAL) {
+ s += string("critical: ")+message;
+ AVG_TRACE(Logger::ERROR, s);
+ AVG_ASSERT(false);
+ } else if (log_level & G_LOG_LEVEL_WARNING) {
+ s += "warning: ";
+ } else if (log_level & G_LOG_LEVEL_MESSAGE) {
+ s += "message: ";
+ } else if (log_level & G_LOG_LEVEL_INFO) {
+ s += "info: ";
+ } else if (log_level & G_LOG_LEVEL_DEBUG) {
+ s += "debug: ";
+ }
+ s += message;
+ AVG_TRACE(Logger::WARNING, s);
+#endif
+}
+
+void TextEngine::initFonts()
+{
+ g_type_init();
+
+ std::vector<std::string> fontConfPathPrefixList;
+#ifndef WIN32
+ fontConfPathPrefixList.push_back("/");
+ fontConfPathPrefixList.push_back("/usr/local/");
+ fontConfPathPrefixList.push_back("/opt/local/");
+#endif
+ fontConfPathPrefixList.push_back(getAvgLibPath());
+
+ std::string sFontConfPath;
+ for (size_t i = 0; i < fontConfPathPrefixList.size(); ++i) {
+ sFontConfPath = fontConfPathPrefixList[i] + "etc/fonts/fonts.conf";
+ if (fileExists(sFontConfPath)) {
+ break;
+ }
+ }
+
+ FcConfig * pConfig = FcConfigCreate();
+ int ok = (int)FcConfigParseAndLoad(pConfig,
+ (const FcChar8 *)(sFontConfPath.c_str()), true);
+ checkFontError(ok, string("Font error: could not load config file ")+sFontConfPath);
+ ok = (int)FcConfigBuildFonts(pConfig);
+ checkFontError(ok, string("Font error: FcConfigBuildFonts failed."));
+ ok = (int)FcConfigSetCurrent(pConfig);
+ checkFontError(ok, string("Font error: FcConfigSetCurrent failed."));
+ for(std::vector<std::string>::const_iterator it = m_sFontDirs.begin();
+ it != m_sFontDirs.end(); ++it)
+ {
+ ok = (int)FcConfigAppFontAddDir(pConfig, (const FcChar8 *)it->c_str());
+ checkFontError(ok, string("Font error: FcConfigAppFontAddDir("
+ + *it + ") failed."));
+ }
+ /*
+ FcStrList * pCacheDirs = FcConfigGetCacheDirs(pConfig);
+ FcChar8 * pDir;
+ do {
+ pDir = FcStrListNext(pCacheDirs);
+ if (pDir) {
+ cerr << pDir << endl;
+ }
+ } while (pDir);
+ */
+ g_log_set_default_handler(GLibLogFunc, 0);
+}
+
+PangoFontFamily * TextEngine::getFontFamily(const string& sFamily)
+{
+ PangoFontFamily * pFamily = 0;
+ AVG_ASSERT(m_NumFontFamilies != 0);
+ for (int i=0; i<m_NumFontFamilies; ++i) {
+ if (equalIgnoreCase(pango_font_family_get_name(m_ppFontFamilies[i]), sFamily)) {
+ pFamily = m_ppFontFamilies[i];
+ }
+ }
+ if (!pFamily) {
+ throw(Exception(AVG_ERR_INVALID_ARGS,
+ "getFontFamily: Font family "+sFamily+" not found."));
+ }
+ return pFamily;
+}
+
+void TextEngine::checkFontError(int ok, const string& sMsg)
+{
+ if (ok == 0) {
+ throw Exception(AVG_ERR_FONT_INIT_FAILED, sMsg);
+ }
+}
+
+}
diff --git a/src/player/TextEngine.h b/src/player/TextEngine.h
new file mode 100644
index 0000000..734b2a4
--- /dev/null
+++ b/src/player/TextEngine.h
@@ -0,0 +1,76 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TextEngine_H_
+#define _TextEngine_H_
+
+#include <pango/pango.h>
+#include <pango/pangoft2.h>
+#include <fontconfig/fontconfig.h>
+
+#include <vector>
+#include <string>
+#include <set>
+#include <map>
+
+namespace avg {
+
+class TextEngine {
+public:
+ static TextEngine& get(bool bHint);
+ virtual ~TextEngine();
+
+ PangoContext * getPangoContext();
+
+ const std::vector<std::string>& getFontFamilies();
+ const std::vector<std::string>& getFontVariants(const std::string& sFontName);
+ void addFontDir(const std::string& sDir);
+
+ PangoFontDescription * getFontDescription(const std::string& sFamily,
+ const std::string& sVariant);
+ void FT2SubstituteFunc(FcPattern *pattern, gpointer data);
+
+private:
+ TextEngine(bool bHint);
+ void init();
+ void deinit();
+ void initFonts();
+ PangoFontFamily * getFontFamily(const std::string& sFamily);
+
+ void checkFontError(int Ok, const std::string& sMsg);
+
+ bool m_bHint;
+ PangoContext * m_pPangoContext;
+ PangoFT2FontMap * m_pFontMap;
+ std::set<std::string> m_sFontsNotFound;
+ std::set<std::pair<std::string, std::string> > m_VariantsNotFound;
+ int m_NumFontFamilies;
+ std::vector<std::string> m_sFonts;
+ typedef std::map<std::pair<std::string, std::string>, PangoFontDescription* >
+ FontDescriptionCache;
+ FontDescriptionCache m_FontDescriptionCache;
+ PangoFontFamily** m_ppFontFamilies;
+ std::vector<std::string> m_sFontDirs;
+
+};
+
+}
+#endif
diff --git a/src/player/Timeout.cpp b/src/player/Timeout.cpp
new file mode 100644
index 0000000..48f5e11
--- /dev/null
+++ b/src/player/Timeout.cpp
@@ -0,0 +1,93 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Timeout.h"
+
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include "BoostPython.h"
+
+#include <iostream>
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+int Timeout::s_LastID = 0;
+
+Timeout::Timeout(int time, PyObject * pyfunc, bool isInterval, long long startTime)
+ : m_Interval(time),
+ m_PyFunc(pyfunc),
+ m_IsInterval(isInterval)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ m_NextTimeout = m_Interval+startTime;
+ s_LastID++;
+ m_ID = s_LastID;
+
+ Py_INCREF(m_PyFunc);
+}
+
+Timeout::~Timeout()
+{
+ Py_DECREF(m_PyFunc);
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+bool Timeout::IsReady(long long time) const
+{
+ return m_NextTimeout <= time;
+}
+
+bool Timeout::IsInterval() const
+{
+ return m_IsInterval;
+}
+
+void Timeout::Fire(long long curTime)
+{
+ if (m_IsInterval) {
+ m_NextTimeout = m_Interval + curTime;
+ }
+ PyObject * arglist = Py_BuildValue("()");
+ PyObject * result = PyEval_CallObject(m_PyFunc, arglist);
+ // XXX: After the call to python, this might have been deleted
+ // by a call to clearTimeout()!
+ Py_DECREF(arglist);
+ if (!result) {
+ throw error_already_set();
+ }
+ Py_DECREF(result);
+}
+
+int Timeout::GetID() const
+{
+ return m_ID;
+}
+
+bool Timeout::operator <(const Timeout& other) const
+{
+ return m_NextTimeout < other.m_NextTimeout;
+}
+
+}
diff --git a/src/player/Timeout.h b/src/player/Timeout.h
new file mode 100644
index 0000000..0f73a4e
--- /dev/null
+++ b/src/player/Timeout.h
@@ -0,0 +1,54 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _Timeout_H_
+#define _Timeout_H_
+
+// Python docs say python.h should be included before any standard headers (!)
+#include "WrapPython.h"
+#include "../api.h"
+
+namespace avg {
+
+class AVG_API Timeout
+{
+ public:
+ Timeout (int time, PyObject * pyfunc, bool isInterval, long long startTime);
+ virtual ~Timeout ();
+
+ bool IsReady(long long time) const;
+ bool IsInterval() const;
+ void Fire(long long curTime);
+ int GetID() const;
+ bool operator <(const Timeout& other) const;
+
+ private:
+ long long m_Interval;
+ long long m_NextTimeout;
+ PyObject * m_PyFunc;
+ bool m_IsInterval;
+ int m_ID;
+ static int s_LastID;
+};
+
+}
+
+#endif //_Timeout_H_
diff --git a/src/player/TouchEvent.cpp b/src/player/TouchEvent.cpp
new file mode 100644
index 0000000..17a1f52
--- /dev/null
+++ b/src/player/TouchEvent.cpp
@@ -0,0 +1,202 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "TouchEvent.h"
+
+#include "Player.h"
+#include "AVGNode.h"
+
+#include "../graphics/Bitmap.h"
+#include "../graphics/Filterfill.h"
+#include "../graphics/Pixel8.h"
+#include "../base/Exception.h"
+
+#include "../base/Logger.h"
+
+using namespace std;
+
+namespace avg {
+
+TouchEvent::TouchEvent(int id, Type eventType, BlobPtr pBlob, const IntPoint& pos,
+ Source source, const DPoint& speed)
+ : CursorEvent(id, eventType, pos, source),
+ m_pBlob(pBlob),
+ m_bHasHandOrientation(false)
+{
+ setSpeed(speed);
+ if (pBlob) {
+ m_Orientation = pBlob->getOrientation();
+ m_Area = pBlob->getArea();
+ m_Center = pBlob->getCenter();
+ m_Eccentricity = pBlob->getEccentricity();
+ const DPoint& axis0 = m_pBlob->getScaledBasis(0);
+ const DPoint& axis1 = m_pBlob->getScaledBasis(1);
+ if (axis0.getNorm() > axis1.getNorm()) {
+ m_MajorAxis = axis0;
+ m_MinorAxis = axis1;
+ } else {
+ m_MajorAxis = axis1;
+ m_MinorAxis = axis0;
+ }
+ } else {
+ m_Orientation = 0;
+ m_Area = 20;
+ m_Center = DPoint(0, 0);
+ m_Eccentricity = 0;
+ m_MajorAxis = DPoint(5, 0);
+ m_MinorAxis = DPoint(0, 5);
+ }
+}
+
+TouchEvent::TouchEvent(int id, Type eventType, const IntPoint& pos, Source source,
+ const DPoint& speed, double orientation, double area, double eccentricity,
+ DPoint majorAxis, DPoint minorAxis)
+ : CursorEvent(id, eventType, pos, source),
+ m_Orientation(orientation),
+ m_Area(area),
+ m_Eccentricity(eccentricity),
+ m_MajorAxis(majorAxis),
+ m_MinorAxis(minorAxis)
+{
+ setSpeed(speed);
+}
+
+TouchEvent::TouchEvent(int id, Type eventType, const IntPoint& pos, Source source,
+ const DPoint& speed)
+ : CursorEvent(id, eventType, pos, source),
+ m_Orientation(0),
+ m_Area(20),
+ m_Eccentricity(0),
+ m_MajorAxis(5, 0),
+ m_MinorAxis(0, 5)
+{
+ setSpeed(speed);
+}
+
+TouchEvent::~TouchEvent()
+{
+}
+
+CursorEventPtr TouchEvent::cloneAs(Type eventType) const
+{
+ TouchEventPtr pClone(new TouchEvent(*this));
+ pClone->m_Type = eventType;
+ return pClone;
+}
+
+double TouchEvent::getOrientation() const
+{
+ return m_Orientation;
+}
+
+double TouchEvent::getArea() const
+{
+ return m_Area;
+}
+
+const DPoint & TouchEvent::getCenter() const
+{
+ return m_Center;
+}
+
+double TouchEvent::getEccentricity() const
+{
+ return m_Eccentricity;
+}
+
+const DPoint & TouchEvent::getMajorAxis() const
+{
+ return m_MajorAxis;
+}
+
+const DPoint & TouchEvent::getMinorAxis() const
+{
+ return m_MinorAxis;
+}
+
+const BlobPtr TouchEvent::getBlob() const
+{
+ return m_pBlob;
+}
+
+ContourSeq TouchEvent::getContour()
+{
+ if (m_pBlob) {
+ return m_pBlob->getContour();
+ } else {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "TouchEvent::getContour: No contour available.");
+ }
+}
+
+double TouchEvent::getHandOrientation() const
+{
+ if (getSource() == Event::TOUCH) {
+ if (m_bHasHandOrientation) {
+ return m_HandOrientation;
+ } else {
+ DPoint screenCenter = Player::get()->getRootNode()->getSize()/2;
+ return (getPos()-screenCenter).getAngle();
+ }
+ } else {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "TouchEvent::getHandOrientation: Only supported for touch events.");
+ }
+}
+
+void TouchEvent::addRelatedEvent(TouchEventPtr pEvent)
+{
+ m_RelatedEvents.push_back(pEvent);
+ if (getSource() == Event::TOUCH && m_RelatedEvents.size() == 1) {
+ TouchEventPtr pHandEvent = m_RelatedEvents.begin()->lock();
+ m_HandOrientation = (pHandEvent->getPos()-getPos()).getAngle();
+ m_bHasHandOrientation = true;
+ }
+}
+
+vector<TouchEventPtr> TouchEvent::getRelatedEvents() const
+{
+ vector<TouchEventPtr> pRelatedEvents;
+ vector<TouchEventWeakPtr>::const_iterator it;
+ for (it = m_RelatedEvents.begin(); it != m_RelatedEvents.end(); ++it) {
+ pRelatedEvents.push_back((*it).lock());
+ }
+ return pRelatedEvents;
+}
+
+void TouchEvent::removeBlob()
+{
+ m_pBlob = BlobPtr();
+}
+
+void TouchEvent::trace()
+{
+ CursorEvent::trace();
+ AVG_TRACE(Logger::EVENTS2, "pos: " << getPos()
+ << ", ID: " << getCursorID()
+ << ", Area: " << m_Area
+ << ", Eccentricity: " << m_Eccentricity);
+}
+
+}
+
diff --git a/src/player/TouchEvent.h b/src/player/TouchEvent.h
new file mode 100644
index 0000000..95bbca4
--- /dev/null
+++ b/src/player/TouchEvent.h
@@ -0,0 +1,87 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#ifndef _TouchEvent_H_
+#define _TouchEvent_H_
+
+#include "../api.h"
+#include "CursorEvent.h"
+
+#include "../imaging/Blob.h"
+#include "../base/Point.h"
+
+#include <math.h>
+#include <boost/weak_ptr.hpp>
+
+namespace avg {
+
+class TouchEvent;
+typedef boost::shared_ptr<class TouchEvent> TouchEventPtr;
+typedef boost::weak_ptr<class TouchEvent> TouchEventWeakPtr;
+
+class AVG_API TouchEvent: public CursorEvent
+{
+ public:
+ TouchEvent(int id, Type eventType, BlobPtr pBlob, const IntPoint& pos,
+ Source source, const DPoint& speed=DPoint(0,0));
+ TouchEvent(int id, Type eventType, const IntPoint& pos, Source source,
+ const DPoint& speed, double orientation, double area, double eccentricity,
+ DPoint majorAxis, DPoint minorAxis);
+ TouchEvent(int id, Type eventType, const IntPoint& pos, Source source,
+ const DPoint& speed=DPoint(0, 0));
+ virtual ~TouchEvent();
+ virtual CursorEventPtr cloneAs(Type eventType) const;
+
+ double getOrientation() const;
+ double getArea() const;
+ const DPoint & getCenter() const;
+ double getEccentricity() const;
+ const DPoint & getMajorAxis() const;
+ const DPoint & getMinorAxis() const;
+
+ const BlobPtr getBlob() const;
+ ContourSeq getContour();
+ double getHandOrientation() const;
+
+ void addRelatedEvent(TouchEventPtr pEvent);
+ std::vector<TouchEventPtr> getRelatedEvents() const;
+
+ void removeBlob();
+
+ virtual void trace();
+
+ private:
+ BlobPtr m_pBlob;
+ double m_Orientation;
+ double m_Area;
+ DPoint m_Center;
+ double m_Eccentricity;
+ DPoint m_MajorAxis;
+ DPoint m_MinorAxis;
+ std::vector<TouchEventWeakPtr> m_RelatedEvents;
+ bool m_bHasHandOrientation;
+ double m_HandOrientation;
+};
+
+}
+#endif
diff --git a/src/player/TouchStatus.cpp b/src/player/TouchStatus.cpp
new file mode 100644
index 0000000..66d63bb
--- /dev/null
+++ b/src/player/TouchStatus.cpp
@@ -0,0 +1,109 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TouchStatus.h"
+
+#include "TouchEvent.h"
+#include "BoostPython.h"
+#include "Player.h"
+
+#include "../base/Exception.h"
+#include "../base/StringHelper.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+TouchStatus::TouchStatus(TouchEventPtr pEvent)
+ : m_bFirstFrame(true),
+ m_CursorID(pEvent->getCursorID())
+{
+ m_pNewEvents.push_back(pEvent);
+ m_pLastEvent = pEvent;
+}
+
+TouchStatus::~TouchStatus()
+{
+}
+
+void TouchStatus::pushEvent(TouchEventPtr pEvent, bool bCheckMotion)
+{
+ AVG_ASSERT(pEvent);
+ pEvent->setCursorID(m_CursorID);
+
+ if (m_bFirstFrame) {
+ // Ignore unless cursorup.
+ if (pEvent->getType() == Event::CURSORUP) {
+ // Down and up in the first frame. To avoid inconsistencies, both
+ // messages must be delivered. This is the only time that m_pNewEvents
+ // has more than one entry.
+ m_pNewEvents.push_back(pEvent);
+ }
+ } else {
+ if (bCheckMotion && pEvent->getType() == Event::CURSORMOTION &&
+ getLastEvent()->getPos() == pEvent->getPos())
+ {
+ // Ignore motion events without motion.
+ return;
+ } else {
+ if (m_pNewEvents.empty()) {
+ // No pending events: schedule for delivery.
+ m_pNewEvents.push_back(pEvent);
+ } else {
+ // More than one event per poll: Deliver only the last one.
+ m_pNewEvents[0] = pEvent;
+ }
+ }
+ }
+}
+
+TouchEventPtr TouchStatus::pollEvent()
+{
+ if (m_pNewEvents.empty()) {
+ return TouchEventPtr();
+ } else {
+ TouchEventPtr pEvent = m_pNewEvents[0];
+ m_pNewEvents.erase(m_pNewEvents.begin());
+ m_bFirstFrame = false;
+ m_pLastEvent = pEvent;
+ return pEvent;
+ }
+}
+
+TouchEventPtr TouchStatus::getLastEvent()
+{
+ if (m_pNewEvents.empty()) {
+ AVG_ASSERT(m_pLastEvent);
+ return m_pLastEvent;
+ } else {
+ return m_pNewEvents.back();
+ }
+}
+
+int TouchStatus::getID() const
+{
+ return m_CursorID;
+}
+
+}
+
diff --git a/src/player/TouchStatus.h b/src/player/TouchStatus.h
new file mode 100644
index 0000000..7a4eb5a
--- /dev/null
+++ b/src/player/TouchStatus.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TouchStatus_H_
+#define _TouchStatus_H_
+
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+
+#include <vector>
+
+namespace avg {
+
+class TouchEvent;
+typedef boost::shared_ptr<class TouchEvent> TouchEventPtr;
+
+class AVG_API TouchStatus {
+public:
+ TouchStatus(TouchEventPtr pEvent);
+ virtual ~TouchStatus();
+
+ void pushEvent(TouchEventPtr pEvent, bool bCheckMotion=true);
+ TouchEventPtr pollEvent();
+ TouchEventPtr getLastEvent();
+
+ int getID() const;
+
+private:
+ TouchEventPtr m_pLastEvent;
+ std::vector<TouchEventPtr> m_pNewEvents;
+
+ bool m_bFirstFrame;
+ int m_CursorID;
+};
+
+typedef boost::shared_ptr<class TouchStatus> TouchStatusPtr;
+
+}
+
+#endif
diff --git a/src/player/TrackerCalibrator.cpp b/src/player/TrackerCalibrator.cpp
new file mode 100644
index 0000000..a6a6a58
--- /dev/null
+++ b/src/player/TrackerCalibrator.cpp
@@ -0,0 +1,239 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TrackerCalibrator.h"
+#include "TrackerInputDevice.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include "../imaging/DeDistort.h"
+
+extern "C" {
+#include "../lmfit/lmmin.h"
+#include "../lmfit/lm_eval.h"
+}
+
+using namespace std;
+
+#define NUM_POINTS 4
+#define MIN_DIST_FROM_BORDER 30
+//#define DEBUG_FIT 1
+#define MAX_ITERATIONS 50000
+
+namespace avg {
+
+enum Params { DISPSCALE_X, DISPSCALE_Y, DISPOFFSET_X, DISPOFFSET_Y, DIST_2,
+ ANGLE, TRAPEZ, NUM_PARAMS};
+
+void lm_print_tracker( int n_par, double* p, int m_dat, double* fvec,
+ void *data, int iflag, int iter, int nfev )
+/*
+ * data : for soft control of printout behaviour, add control
+ * variables to the data struct
+ * iflag : 0 (init) 1 (outer loop) 2(inner loop) -1(terminated)
+ * iter : outer loop counter
+ * nfev : number of calls to *evaluate
+ */
+{
+ TrackerCalibrator *mydata;
+ mydata = static_cast<TrackerCalibrator*>(data);
+ mydata->print_tracker(n_par, p, m_dat, fvec, iflag, iter, nfev);
+
+}
+
+void lm_evaluate_tracker(double* p, int m_dat, double* fvec,
+ void *data, int *info)
+{
+ TrackerCalibrator *mydata = static_cast<TrackerCalibrator*>(data);
+ mydata->evaluate_tracker(p, m_dat, fvec, info);
+
+}
+
+TrackerCalibrator::TrackerCalibrator(const IntPoint& CamExtents,
+ const IntPoint& DisplayExtents)
+ : m_CurPoint(0),
+ m_CamExtents(CamExtents),
+ m_DisplayExtents(DisplayExtents),
+ m_bCurPointSet(false)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ IntPoint OffsetPerPoint((DisplayExtents.x-MIN_DIST_FROM_BORDER*2)/(NUM_POINTS-1),
+ (DisplayExtents.y-MIN_DIST_FROM_BORDER*2)/(NUM_POINTS-1));
+ for (int y=0; y<NUM_POINTS; y++) {
+ for (int x=0; x<NUM_POINTS; x++) {
+ m_DisplayPoints.push_back(
+ IntPoint(OffsetPerPoint.x*x+MIN_DIST_FROM_BORDER,
+ OffsetPerPoint.y*y+MIN_DIST_FROM_BORDER));
+ m_CamPoints.push_back(DPoint(0,0));
+ }
+ }
+}
+
+TrackerCalibrator::~TrackerCalibrator()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+
+bool TrackerCalibrator::nextPoint()
+{
+ if (!m_bCurPointSet) {
+ // There is no data for the previous point, so delete it.
+ m_DisplayPoints.erase(m_DisplayPoints.begin()+m_CurPoint);
+ m_CamPoints.erase(m_CamPoints.begin()+m_CurPoint);
+ } else {
+ m_CurPoint++;
+ }
+ m_bCurPointSet = false;
+ if (m_CurPoint < m_DisplayPoints.size()) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+IntPoint TrackerCalibrator::getDisplayPoint()
+{
+ return m_DisplayPoints[m_CurPoint];
+}
+
+void TrackerCalibrator::setCamPoint(const DPoint& pt)
+{
+ m_CamPoints[m_CurPoint] = pt;
+ m_bCurPointSet = true;
+}
+
+DeDistortPtr TrackerCalibrator::makeTransformer()
+{
+ lm_control_type control;
+ lm_initialize_control( &control );
+ control.maxcall=MAX_ITERATIONS;
+ // control.epsilon=1e-8;
+ // control.ftol = 1e-4;
+ // control.xtol = 1e-4;
+ // control.gtol = 1e-4;
+
+ int dat = int(m_DisplayPoints.size());
+ AVG_ASSERT(dat == int(m_CamPoints.size()));
+
+ //fill in reasonable defaults
+ m_DistortParams.clear();
+ m_DistortParams.push_back(0);
+ m_Angle = 0;
+ m_TrapezoidFactor = 0.0;
+ m_DisplayOffset= DPoint(0,0);
+ m_DisplayScale = DPoint(2,2);
+
+ int n_p = NUM_PARAMS;
+ //should really match the Params enum!!!!
+ double p[] = {
+ m_DisplayScale.x,
+ m_DisplayScale.y,
+ m_DisplayOffset.x,
+ m_DisplayOffset.y,
+ m_DistortParams[0],
+ m_Angle,
+ m_TrapezoidFactor
+ };
+ initThisFromDouble(p);
+ lm_minimize(dat, n_p, p, lm_evaluate_tracker, lm_print_tracker,
+ this, &control );
+ initThisFromDouble(p);
+/*
+ for(int i=0;i<NUM_POINTS*NUM_POINTS;i++) {
+ DPoint screenPoint = m_CurrentTrafo->transformBlobToScreen(
+ m_CurrentTrafo->transform_point(m_CamPoints[i]));
+ cerr << "sample value of trafo of (cam) "
+ << m_CamPoints[i]<<" : (transformed) "
+ << screenPoint
+ << "== (display)"
+ << DPoint(m_DisplayPoints[i])
+ << " dist="
+ << calcDist(DPoint(m_DisplayPoints[i]), screenPoint)
+ << endl;
+ }
+ cerr<<" DisplayScale = "<<m_DisplayScale << endl;
+ cerr<<" DisplayOffset= "<<m_DisplayOffset << endl;
+ cerr<<" unDistortionParams = "<<m_DistortParams[0] << ", " << m_DistortParams[1]
+ << ", " << m_DistortParams[2] << endl;
+ cerr<<" Trapezoid = "<<m_TrapezoidFactor << endl;
+ cerr<<" angle = "<<m_Angle << endl;
+*/
+ return m_CurrentTrafo;
+}
+
+void TrackerCalibrator::initThisFromDouble(double *p)
+{
+ m_DisplayOffset.x = p[DISPOFFSET_X];
+ m_DisplayOffset.y = p[DISPOFFSET_Y];
+ m_DisplayScale.x = p[DISPSCALE_X];
+ m_DisplayScale.y = p[DISPSCALE_Y];
+ m_DistortParams.clear();
+ m_DistortParams.push_back( p[DIST_2]);
+ m_Angle = p[ANGLE];
+ m_TrapezoidFactor = p[TRAPEZ];
+ m_CurrentTrafo = DeDistortPtr(
+ new DeDistort(DPoint(m_CamExtents),
+ m_DistortParams,
+ m_Angle,
+ m_TrapezoidFactor,
+ m_DisplayOffset,
+ m_DisplayScale
+ )
+ );
+}
+
+void TrackerCalibrator::evaluate_tracker(double *p, int m_dat, double* fvec, int* info)
+{
+ initThisFromDouble(p);
+
+ for (int i=0; i<m_dat; i++){
+ fvec[i] = calcDist(
+ m_CurrentTrafo->transformBlobToScreen(
+ m_CurrentTrafo->transform_point(m_CamPoints[i])
+ ),
+ DPoint(m_DisplayPoints[i])
+ );
+ }
+ *info = *info; /* to prevent a 'unused variable' warning */
+ /* if <parameters drifted away> { *info = -1; } */
+}
+
+void TrackerCalibrator::print_tracker(int n_par, double *p, int m_dat,
+ double *fvec, int iflag, int iter, int nfev)
+{
+#ifdef DEBUG_FIT
+ initThisFromDouble(p);
+ if (iflag==2) {
+ printf ("trying step in gradient direction\n");
+ } else if (iflag==1) {
+ printf ("determining gradient (iteration %d)\n", iter);
+ } else if (iflag==0) {
+ printf ("starting minimization\n");
+ } else if (iflag==-1) {
+ printf ("terminated after %d evaluations\n", nfev);
+ }
+#endif
+ AVG_ASSERT(n_par == NUM_PARAMS);
+}
+
+}
diff --git a/src/player/TrackerCalibrator.h b/src/player/TrackerCalibrator.h
new file mode 100644
index 0000000..9b31963
--- /dev/null
+++ b/src/player/TrackerCalibrator.h
@@ -0,0 +1,75 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TrackerCalibrator_H_
+#define _TrackerCalibrator_H_
+
+#include "../api.h"
+#include "../imaging/DeDistort.h"
+#include "../base/Point.h"
+
+#include <vector>
+
+namespace avg {
+
+class AVG_API TrackerCalibrator {
+
+public:
+ friend void lm_evaluate_tracker(double* p, int m_dat, double* fvec,
+ void *data, int *info);
+ friend void lm_print_tracker(int n_par, double* p, int m_dat, double* fvec,
+ void *data, int iflag, int iter, int nfev);
+
+ TrackerCalibrator(const IntPoint& CamExtents, const IntPoint& DisplayExtents);
+ virtual ~TrackerCalibrator();
+
+ bool nextPoint();
+ IntPoint getDisplayPoint();
+ void setCamPoint(const DPoint& pt);
+
+ DeDistortPtr makeTransformer();
+
+private:
+ void initThisFromDouble(double *p);
+
+ void evaluate_tracker(double *p, int m_dat, double *fvec, int* info);
+ void print_tracker(int n_par, double *p, int m_dat,
+ double *fvec, int iflag, int iter, int nfev);
+
+ std::vector<double> m_DistortParams;
+ double m_Angle;
+ DPoint m_DisplayScale;
+ DPoint m_DisplayOffset;
+ double m_TrapezoidFactor;
+ DeDistortPtr m_CurrentTrafo;
+ unsigned int m_CurPoint;
+ std::vector<IntPoint> m_DisplayPoints;
+ std::vector<DPoint> m_CamPoints;
+
+ IntPoint m_CamExtents;
+ IntPoint m_DisplayExtents;
+
+ bool m_bCurPointSet;
+};
+
+}
+
+#endif
diff --git a/src/player/TrackerInputDevice.cpp b/src/player/TrackerInputDevice.cpp
new file mode 100644
index 0000000..af85784
--- /dev/null
+++ b/src/player/TrackerInputDevice.cpp
@@ -0,0 +1,491 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is igor@c-base.org
+//
+
+#include "TrackerInputDevice.h"
+#include "TouchEvent.h"
+#include "TrackerTouchStatus.h"
+
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+#include "../base/ScopeTimer.h"
+#include "../base/Exception.h"
+
+#include "../graphics/HistoryPreProcessor.h"
+#include "../graphics/Filterfill.h"
+#include "../graphics/Pixel8.h"
+
+#include "../imaging/DeDistort.h"
+#include "../imaging/CoordTransformer.h"
+
+#include "Player.h"
+#include "AVGNode.h"
+
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include <map>
+#include <list>
+#include <vector>
+#include <queue>
+#include <set>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+TrackerInputDevice::TrackerInputDevice()
+ : IInputDevice(EXTRACT_INPUTDEVICE_CLASSNAME(TrackerInputDevice)),
+ m_pTrackerThread(0),
+ m_bSubtractHistory(true),
+ m_pCalibrator(0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+
+ m_TrackerConfig.load();
+
+ string sDriver = m_TrackerConfig.getParam("/camera/driver/@value");
+ string sDevice = m_TrackerConfig.getParam("/camera/device/@value");
+ bool bFW800 = m_TrackerConfig.getBoolParam("/camera/fw800/@value");
+ IntPoint captureSize(m_TrackerConfig.getPointParam("/camera/size/"));
+ string sCaptureFormat = m_TrackerConfig.getParam("/camera/format/@value");
+ double frameRate = m_TrackerConfig.getDoubleParam("/camera/framerate/@value");
+
+ PixelFormat camPF = stringToPixelFormat(sCaptureFormat);
+ if (camPF == NO_PIXELFORMAT) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Unknown camera pixel format "+sCaptureFormat+".");
+ }
+
+ AVG_TRACE(Logger::CONFIG, "Trying to create a Tracker for " << sDriver
+ << " Camera: " << sDevice << " Size: " << captureSize << "format: "
+ << sCaptureFormat);
+ m_pCamera = createCamera(sDriver, sDevice, -1, bFW800, captureSize, camPF, I8,
+ frameRate);
+ AVG_TRACE(Logger::CONFIG, "Got Camera " << m_pCamera->getDevice() << " from driver: "
+ << m_pCamera->getDriverName());
+
+ IntPoint imgSize = m_pCamera->getImgSize();
+ m_pBitmaps[0] = BitmapPtr(new Bitmap(imgSize, I8));
+ m_pMutex = MutexPtr(new boost::mutex);
+ m_pCmdQueue = TrackerThread::CQueuePtr(new TrackerThread::CQueue);
+ m_pDeDistort = m_TrackerConfig.getTransform();
+ try {
+ m_ActiveDisplaySize = IntPoint(
+ m_TrackerConfig.getPointParam("/transform/activedisplaysize/"));
+ } catch (Exception) {
+ m_ActiveDisplaySize = IntPoint(Player::get()->getRootNode()->getSize());
+ }
+ try {
+ m_DisplayROI = m_TrackerConfig.getRectParam("/transform/displayroi/");
+ } catch (Exception) {
+ m_DisplayROI = DRect(DPoint(0,0), DPoint(m_ActiveDisplaySize));
+ }
+
+ IntRect roi = m_pDeDistort->getActiveBlobArea(m_DisplayROI);
+ if (roi.tl.x < 0 || roi.tl.y < 0 ||
+ roi.br.x > imgSize.x || roi.br.y > imgSize.y)
+ {
+ AVG_TRACE(Logger::ERROR,
+ "Impossible tracker configuration: Region of interest is "
+ << roi << ", camera image size is " << imgSize << ". Aborting.");
+ exit(5);
+ }
+ m_InitialROI = roi;
+ createBitmaps(roi);
+ setDebugImages(false, false);
+
+ try {
+ m_bFindFingertips = m_TrackerConfig.getBoolParam(
+ "/tracker/findfingertips/@value");
+ } catch(Exception) {
+ m_bFindFingertips = false;
+ }
+
+}
+
+TrackerInputDevice::~TrackerInputDevice()
+{
+ m_pCmdQueue->pushCmd(boost::bind(&TrackerThread::stop, _1));
+ if (m_pTrackerThread) {
+ m_pTrackerThread->join();
+ delete m_pTrackerThread;
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void TrackerInputDevice::start()
+{
+ m_pTrackerThread = new boost::thread(
+ TrackerThread(
+ m_InitialROI,
+ m_pCamera,
+ m_pBitmaps,
+ m_pMutex,
+ *m_pCmdQueue,
+ this,
+ m_bSubtractHistory,
+ m_TrackerConfig
+ )
+ );
+ setConfig();
+}
+
+void TrackerInputDevice::setParam(const string& sElement, const string& sValue)
+{
+ string sOldParamVal = m_TrackerConfig.getParam(sElement);
+ m_TrackerConfig.setParam(sElement, sValue);
+
+ // Test if active area is outside camera.
+ DRect area = m_pDeDistort->getActiveBlobArea(m_DisplayROI);
+ DPoint size = m_TrackerConfig.getPointParam("/camera/size/");
+ int prescale = m_TrackerConfig.getIntParam("/tracker/prescale/@value");
+ if (area.br.x > size.x/prescale || area.br.y > size.y/prescale ||
+ area.tl.x < 0 || area.tl.y < 0)
+ {
+ m_TrackerConfig.setParam(sElement, sOldParamVal);
+ } else {
+ setConfig();
+ }
+// m_TrackerConfig.dump();
+}
+
+string TrackerInputDevice::getParam(const string& sElement)
+{
+ return m_TrackerConfig.getParam(sElement);
+}
+
+void TrackerInputDevice::setDebugImages(bool bImg, bool bFinger)
+{
+ m_pCmdQueue->pushCmd(boost::bind(&TrackerThread::setDebugImages, _1, bImg,
+ bFinger));
+}
+
+void TrackerInputDevice::resetHistory()
+{
+ m_pCmdQueue->pushCmd(boost::bind(&TrackerThread::resetHistory, _1));
+}
+
+void TrackerInputDevice::saveConfig()
+{
+ m_TrackerConfig.save();
+}
+
+void TrackerInputDevice::setConfig()
+{
+ m_pDeDistort = m_TrackerConfig.getTransform();
+ DRect area = m_pDeDistort->getActiveBlobArea(m_DisplayROI);
+ createBitmaps(area);
+ m_pCmdQueue->pushCmd(boost::bind(&TrackerThread::setConfig, _1, m_TrackerConfig,
+ area, m_pBitmaps));
+}
+
+void TrackerInputDevice::createBitmaps(const IntRect& area)
+{
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ for (int i=1; i<NUM_TRACKER_IMAGES; i++) {
+ switch (i) {
+ case TRACKER_IMG_HISTOGRAM:
+ m_pBitmaps[TRACKER_IMG_HISTOGRAM] =
+ BitmapPtr(new Bitmap(IntPoint(256, 256), I8));
+ FilterFill<Pixel8>(Pixel8(0)).
+ applyInPlace(m_pBitmaps[TRACKER_IMG_HISTOGRAM]);
+ break;
+ case TRACKER_IMG_FINGERS:
+ m_pBitmaps[TRACKER_IMG_FINGERS] =
+ BitmapPtr(new Bitmap(area.size(), B8G8R8A8));
+ FilterFill<Pixel32>(Pixel32(0,0,0,0)).
+ applyInPlace(m_pBitmaps[TRACKER_IMG_FINGERS]);
+ break;
+ default:
+ m_pBitmaps[i] = BitmapPtr(new Bitmap(area.size(), I8));
+ FilterFill<Pixel8>(Pixel8(0)).applyInPlace(m_pBitmaps[i]);
+ }
+ }
+}
+
+Bitmap * TrackerInputDevice::getImage(TrackerImageID imageID) const
+{
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ return new Bitmap(*m_pBitmaps[imageID]);
+}
+
+DPoint TrackerInputDevice::getDisplayROIPos() const
+{
+ return m_DisplayROI.tl;
+}
+
+DPoint TrackerInputDevice::getDisplayROISize() const
+{
+ return m_DisplayROI.size();
+}
+
+static ProfilingZoneID ProfilingZoneCalcTrack("trackBlobIDs(track)");
+static ProfilingZoneID ProfilingZoneCalcTouch("trackBlobIDs(touch)");
+
+void TrackerInputDevice::update(BlobVectorPtr pTrackBlobs,
+ BlobVectorPtr pTouchBlobs, long long time)
+{
+ if (pTrackBlobs) {
+ ScopeTimer Timer(ProfilingZoneCalcTrack);
+ trackBlobIDs(pTrackBlobs, time, false);
+ }
+ if (pTouchBlobs) {
+ ScopeTimer Timer(ProfilingZoneCalcTouch);
+ trackBlobIDs(pTouchBlobs, time, true);
+ }
+}
+
+// Temporary structure to be put into heap of blob distances. Used only in
+// trackBlobIDs.
+struct BlobDistEntry {
+ BlobDistEntry(double dist, BlobPtr pNewBlob, BlobPtr pOldBlob)
+ : m_Dist(dist),
+ m_pNewBlob(pNewBlob),
+ m_pOldBlob(pOldBlob)
+ {
+ }
+
+ double m_Dist;
+ BlobPtr m_pNewBlob;
+ BlobPtr m_pOldBlob;
+};
+typedef boost::shared_ptr<struct BlobDistEntry> BlobDistEntryPtr;
+
+// The heap is sorted by least distance, so this operator does the
+// _opposite_ of what is expected!
+bool operator < (const BlobDistEntryPtr& e1, const BlobDistEntryPtr& e2)
+{
+ return e1->m_Dist > e2->m_Dist;
+}
+
+void TrackerInputDevice::trackBlobIDs(BlobVectorPtr pNewBlobs, long long time,
+ bool bTouch)
+{
+ TouchStatusMap * pEvents;
+ string sConfigPath;
+ Event::Source source;
+ if (bTouch) {
+ sConfigPath = "/tracker/touch/";
+ pEvents = &m_TouchEvents;
+ source = Event::TOUCH;
+ } else {
+ sConfigPath = "/tracker/track/";
+ pEvents = &m_TrackEvents;
+ source = Event::TRACK;
+ }
+ BlobVector oldBlobs;
+ for (TouchStatusMap::iterator it = pEvents->begin(); it != pEvents->end(); ++it) {
+ (*it).second->setStale();
+ oldBlobs.push_back((*it).first);
+ }
+ // Create a heap that contains all distances of old to new blobs < MaxDist
+ double MaxDist = m_TrackerConfig.getDoubleParam(sConfigPath+"similarity/@value");
+ double MaxDistSquared = MaxDist*MaxDist;
+ priority_queue<BlobDistEntryPtr> distHeap;
+ for (BlobVector::iterator it = pNewBlobs->begin(); it != pNewBlobs->end(); ++it) {
+ BlobPtr pNewBlob = *it;
+ for(BlobVector::iterator it2 = oldBlobs.begin(); it2 != oldBlobs.end(); ++it2) {
+ BlobPtr pOldBlob = *it2;
+ double distSquared = calcDistSquared(pNewBlob->getCenter(),
+ pOldBlob->getEstimatedNextCenter());
+ if (distSquared <= MaxDistSquared) {
+ BlobDistEntryPtr pEntry = BlobDistEntryPtr(
+ new BlobDistEntry(distSquared, pNewBlob, pOldBlob));
+ distHeap.push(pEntry);
+ }
+ }
+ }
+ // Match up the closest blobs.
+ set<BlobPtr> matchedNewBlobs;
+ set<BlobPtr> matchedOldBlobs;
+ int numMatchedBlobs = 0;
+ while (!distHeap.empty()) {
+ BlobDistEntryPtr pEntry = distHeap.top();
+ distHeap.pop();
+ if (matchedNewBlobs.find(pEntry->m_pNewBlob) == matchedNewBlobs.end() &&
+ matchedOldBlobs.find(pEntry->m_pOldBlob) == matchedOldBlobs.end())
+ {
+ // Found a pair of matched blobs.
+ numMatchedBlobs++;
+ BlobPtr pNewBlob = pEntry->m_pNewBlob;
+ BlobPtr pOldBlob = pEntry->m_pOldBlob;
+ matchedNewBlobs.insert(pNewBlob);
+ matchedOldBlobs.insert(pOldBlob);
+ AVG_ASSERT (pEvents->find(pOldBlob) != pEvents->end());
+ TrackerTouchStatusPtr pTouchStatus;
+ pTouchStatus = pEvents->find(pOldBlob)->second;
+ // Make sure we don't discard any events that have related info.
+ bool bKeepAllEvents = pNewBlob->getFirstRelated() && !bTouch;
+ pTouchStatus->blobChanged(pNewBlob, time, bKeepAllEvents);
+ pNewBlob->calcNextCenter(pOldBlob->getCenter());
+ // Update the mapping.
+ (*pEvents)[pNewBlob] = pTouchStatus;
+ pEvents->erase(pOldBlob);
+ }
+ }
+ // Blobs have been matched. Left-overs are new blobs.
+ for (BlobVector::iterator it = pNewBlobs->begin(); it != pNewBlobs->end(); ++it) {
+ if (matchedNewBlobs.find(*it) == matchedNewBlobs.end()) {
+ TrackerTouchStatusPtr pTouchStatus = TrackerTouchStatusPtr(
+ new TrackerTouchStatus(*it, time, m_pDeDistort, m_DisplayROI,
+ source));
+ (*pEvents)[(*it)] = pTouchStatus;
+ }
+ }
+
+ // All event streams that are still stale haven't been updated: blob is gone,
+ // set the sentinel for this.
+ for(TouchStatusMap::iterator it=pEvents->begin(); it!=pEvents->end(); ++it) {
+ if ((*it).second->isStale()) {
+ (*it).second->blobGone();
+ }
+ }
+};
+
+TrackerCalibrator* TrackerInputDevice::startCalibration()
+{
+ AVG_ASSERT(!m_pCalibrator);
+ m_pOldTransformer = m_TrackerConfig.getTransform();
+ m_OldDisplayROI = m_DisplayROI;
+ m_DisplayROI = DRect(DPoint(0,0), DPoint(m_ActiveDisplaySize));
+ m_TrackerConfig.setTransform(DeDistortPtr(new DeDistort(
+ DPoint(m_pBitmaps[0]->getSize()), DPoint(m_ActiveDisplaySize))));
+ setConfig();
+ m_pCalibrator = new TrackerCalibrator(m_pBitmaps[0]->getSize(),
+ m_ActiveDisplaySize);
+ return m_pCalibrator;
+}
+
+void TrackerInputDevice::endCalibration()
+{
+ AVG_ASSERT(m_pCalibrator);
+ m_TrackerConfig.setTransform(m_pCalibrator->makeTransformer());
+ m_DisplayROI = m_OldDisplayROI;
+ DRect area = m_TrackerConfig.getTransform()->getActiveBlobArea(m_DisplayROI);
+ if (area.size().x*area.size().y > 1024*1024*8) {
+ AVG_TRACE(Logger::WARNING, "Ignoring calibration - resulting area would be "
+ << area);
+ m_TrackerConfig.setTransform(m_pOldTransformer);
+ }
+ setConfig();
+ delete m_pCalibrator;
+ m_pCalibrator = 0;
+ m_pOldTransformer = DeDistortPtr();
+}
+
+void TrackerInputDevice::abortCalibration()
+{
+ AVG_ASSERT(m_pCalibrator);
+ m_TrackerConfig.setTransform(m_pOldTransformer);
+ setConfig();
+ m_pOldTransformer = DeDistortPtr();
+ delete m_pCalibrator;
+ m_pCalibrator = 0;
+}
+
+vector<EventPtr> TrackerInputDevice::pollEvents()
+{
+ boost::mutex::scoped_lock lock(*m_pMutex);
+ vector<EventPtr> pTouchEvents;
+ vector<EventPtr> pTrackEvents;
+ pollEventType(pTouchEvents, m_TouchEvents, CursorEvent::TOUCH);
+ pollEventType(pTrackEvents, m_TrackEvents, CursorEvent::TRACK);
+ copyRelatedInfo(pTouchEvents, pTrackEvents);
+ if (m_bFindFingertips) {
+ findFingertips(pTouchEvents);
+ }
+ pTouchEvents.insert(pTouchEvents.end(),
+ pTrackEvents.begin(), pTrackEvents.end());
+ return pTouchEvents;
+}
+
+void TrackerInputDevice::pollEventType(vector<EventPtr>& res, TouchStatusMap& Events,
+ CursorEvent::Source source)
+{
+ EventPtr pEvent;
+ for (TouchStatusMap::iterator it = Events.begin(); it!= Events.end();) {
+ TrackerTouchStatusPtr pTouchStatus = (*it).second;
+ pEvent = pTouchStatus->pollEvent();
+ if (pEvent) {
+ res.push_back(pEvent);
+ if (pEvent->getType() == Event::CURSORUP) {
+ Events.erase(it++);
+ } else {
+ ++it;
+ }
+ } else {
+ ++it;
+ }
+ }
+}
+
+void TrackerInputDevice::copyRelatedInfo(vector<EventPtr> pTouchEvents,
+ vector<EventPtr> pTrackEvents)
+{
+ // Copy related blobs to related events.
+ // Yuck.
+ vector<EventPtr>::iterator it;
+ for (it = pTouchEvents.begin(); it != pTouchEvents.end(); ++it) {
+ TouchEventPtr pTouchEvent = boost::dynamic_pointer_cast<TouchEvent>(*it);
+ BlobPtr pTouchBlob = pTouchEvent->getBlob();
+ BlobPtr pRelatedBlob = pTouchBlob->getFirstRelated();
+ if (pRelatedBlob) {
+ vector<EventPtr>::iterator it2;
+ TouchEventPtr pTrackEvent;
+ BlobPtr pTrackBlob;
+ for (it2 = pTrackEvents.begin();
+ pTrackBlob != pRelatedBlob && it2 != pTrackEvents.end();
+ ++it2)
+ {
+ pTrackEvent = boost::dynamic_pointer_cast<TouchEvent>(*it2);
+ pTrackBlob = pTrackEvent->getBlob();
+ }
+ if (pTrackBlob == pRelatedBlob) {
+ pTouchEvent->addRelatedEvent(pTrackEvent);
+ pTrackEvent->addRelatedEvent(pTouchEvent);
+ }
+ }
+ }
+}
+
+void TrackerInputDevice::findFingertips(std::vector<EventPtr>& pTouchEvents)
+{
+ vector<EventPtr>::iterator it;
+ for (it = pTouchEvents.begin(); it != pTouchEvents.end(); ++it) {
+ TouchEventPtr pTouchEvent = boost::dynamic_pointer_cast<TouchEvent>(*it);
+ vector<TouchEventPtr> pTrackEvents = pTouchEvent->getRelatedEvents();
+ if (pTrackEvents.size() > 0) {
+ double handAngle = pTouchEvent->getHandOrientation();
+ double dist = pTouchEvent->getMajorAxis().getNorm()*2;
+ DPoint tweakVec = DPoint::fromPolar(handAngle, dist);
+ DPoint newPos = pTouchEvent->getPos()-tweakVec;
+ newPos.x = max(0.0, min(newPos.x, double(m_ActiveDisplaySize.x)));
+ newPos.y = max(0.0, min(newPos.y, double(m_ActiveDisplaySize.y)));
+ pTouchEvent->setPos(newPos);
+ }
+ }
+}
+
+}
+
diff --git a/src/player/TrackerInputDevice.h b/src/player/TrackerInputDevice.h
new file mode 100644
index 0000000..b09890b
--- /dev/null
+++ b/src/player/TrackerInputDevice.h
@@ -0,0 +1,122 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TrackerInputDevice_H_
+#define _TrackerInputDevice_H_
+
+#include "../api.h"
+#include "CursorEvent.h"
+#include "IInputDevice.h"
+#include "TrackerCalibrator.h"
+
+#include "../imaging/TrackerThread.h"
+#include "../imaging/Blob.h"
+
+#include "../graphics/Bitmap.h"
+#include "../graphics/Filter.h"
+
+#include "../base/Rect.h"
+
+#include <string>
+#include <map>
+#include <list>
+#include <vector>
+#include <utility>
+
+namespace avg {
+
+class TrackerTouchStatus;
+typedef boost::shared_ptr<TrackerTouchStatus> TrackerTouchStatusPtr;
+
+class AVG_API TrackerInputDevice: public IBlobTarget, public IInputDevice
+{
+ typedef std::map<BlobPtr, TrackerTouchStatusPtr> TouchStatusMap;
+
+ public:
+ TrackerInputDevice();
+ virtual ~TrackerInputDevice();
+ void start();
+
+ void setParam(const std::string& sElement, const std::string& sValue);
+ std::string getParam(const std::string& sElement);
+
+ void resetHistory();
+ void setDebugImages(bool bImg, bool bFinger);
+ void saveConfig();
+ Bitmap * getImage(TrackerImageID imageID) const;
+ DPoint getDisplayROIPos() const;
+ DPoint getDisplayROISize() const;
+
+ std::vector<EventPtr> pollEvents(); //main thread
+
+ // implement IBlobTarget
+ // Called from Tracker Thread!
+ virtual void update(BlobVectorPtr pTrackBlobs, BlobVectorPtr pTouchBlobs,
+ long long time);
+
+ TrackerCalibrator* startCalibration();
+ void endCalibration();
+ void abortCalibration();
+
+ private:
+ void setConfig();
+ void createBitmaps(const IntRect& area);
+
+ boost::thread* m_pTrackerThread;
+
+ // Used by main thread
+ void pollEventType(std::vector<EventPtr>& res, TouchStatusMap& events,
+ CursorEvent::Source source);
+ void copyRelatedInfo(std::vector<EventPtr> pTouchEvents,
+ std::vector<EventPtr> pTrackEvents);
+ void findFingertips(std::vector<EventPtr>& pTouchEvents);
+
+ IntRect m_InitialROI;
+ CameraPtr m_pCamera;
+ bool m_bSubtractHistory;
+ DeDistortPtr m_pDeDistort;
+ DeDistortPtr m_pOldTransformer;
+ IntPoint m_ActiveDisplaySize;
+ DRect m_DisplayROI;
+ DRect m_OldDisplayROI;
+ TrackerCalibrator * m_pCalibrator;
+ bool m_bFindFingertips;
+
+ // Used by tracker thread
+ void trackBlobIDs(BlobVectorPtr new_blobs, long long time, bool bTouch);
+
+ // Used by both threads
+ TouchStatusMap m_TouchEvents;
+ TouchStatusMap m_TrackEvents;
+ TrackerConfig m_TrackerConfig;
+
+ MutexPtr m_pMutex;
+ BitmapPtr m_pBitmaps[NUM_TRACKER_IMAGES];
+
+ TrackerThread::CQueuePtr m_pCmdQueue;
+};
+
+typedef boost::shared_ptr<TrackerInputDevice> TrackerInputDevicePtr;
+
+}
+
+#endif
+
diff --git a/src/player/TrackerTouchStatus.cpp b/src/player/TrackerTouchStatus.cpp
new file mode 100644
index 0000000..2377228
--- /dev/null
+++ b/src/player/TrackerTouchStatus.cpp
@@ -0,0 +1,120 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TrackerTouchStatus.h"
+#include "TouchEvent.h"
+
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include <math.h>
+
+using namespace std;
+
+namespace avg {
+
+int TrackerTouchStatus::s_LastID = 0;
+
+TrackerTouchStatus::TrackerTouchStatus(BlobPtr pFirstBlob, long long time,
+ DeDistortPtr pDeDistort, const DRect& displayROI, Event::Source source)
+ : TouchStatus(createEvent(source, Event::CURSORDOWN, ++s_LastID, pFirstBlob, time,
+ pDeDistort, displayROI)),
+ m_Source(source),
+ m_pDeDistort(pDeDistort),
+ m_DisplayROI(displayROI),
+ m_Stale(false),
+ m_bGone(false),
+ m_ID(s_LastID),
+ m_pBlob(pFirstBlob),
+ m_LastTime(time),
+ m_LastCenter(pFirstBlob->getCenter())
+{
+ AVG_ASSERT(m_Source == Event::TOUCH || m_Source == Event::TRACK);
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+TrackerTouchStatus::~TrackerTouchStatus()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void TrackerTouchStatus::blobChanged(BlobPtr pNewBlob, long long time, bool bKeepEvent)
+{
+ AVG_ASSERT(m_pBlob);
+ AVG_ASSERT(pNewBlob);
+ if (!m_bGone) {
+ DPoint c = pNewBlob->getCenter();
+ bool bPosChanged;
+ if (bKeepEvent) {
+ bPosChanged = true;
+ } else {
+ bPosChanged = (calcDist(c, m_LastCenter) > 1);
+ }
+ if (bPosChanged) {
+ m_LastCenter = pNewBlob->getCenter();
+ TouchEventPtr pEvent = createEvent(Event::CURSORMOTION, pNewBlob, time);
+ pushEvent(pEvent, false);
+ }
+ m_pBlob = pNewBlob;
+ m_Stale = false;
+ m_LastTime = time;
+ }
+};
+
+void TrackerTouchStatus::blobGone()
+{
+ if (!m_bGone) {
+ TouchEventPtr pEvent = createEvent(Event::CURSORUP, m_pBlob, m_LastTime+1);
+ pushEvent(pEvent, false);
+ m_bGone = true;
+ }
+}
+
+void TrackerTouchStatus::setStale()
+{
+ m_Stale = true;
+}
+
+bool TrackerTouchStatus::isStale()
+{
+ return m_Stale;
+}
+
+TouchEventPtr TrackerTouchStatus::createEvent(Event::Source source, Event::Type type,
+ int id, BlobPtr pBlob, long long time, DeDistortPtr pDeDistort,
+ const DRect& displayROI)
+{
+ DPoint blobOffset = pDeDistort->getActiveBlobArea(displayROI).tl;
+ DPoint pt = pBlob->getCenter() + blobOffset;
+ DPoint screenpos = pDeDistort->transformBlobToScreen(pt);
+ IntPoint pos(int(screenpos.x+0.5), int(screenpos.y+0.5));
+
+ return TouchEventPtr(new TouchEvent(id, type, pBlob, pos, source));
+}
+
+TouchEventPtr TrackerTouchStatus::createEvent(Event::Type type, BlobPtr pBlob,
+ long long time)
+{
+ return createEvent(m_Source, type, m_ID, pBlob, time, m_pDeDistort, m_DisplayROI);
+}
+
+}
diff --git a/src/player/TrackerTouchStatus.h b/src/player/TrackerTouchStatus.h
new file mode 100644
index 0000000..53b9e4a
--- /dev/null
+++ b/src/player/TrackerTouchStatus.h
@@ -0,0 +1,70 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _TrackerTouchStatus_H_
+#define _TrackerTouchStatus_H_
+
+#include "../api.h"
+#include "Event.h"
+#include "TouchStatus.h"
+
+#include "../base/Point.h"
+
+#include "../imaging/Blob.h"
+#include "../imaging/DeDistort.h"
+
+#include <string>
+
+namespace avg {
+
+class AVG_API TrackerTouchStatus: public TouchStatus
+{
+ public:
+ TrackerTouchStatus(BlobPtr pFirstBlob, long long time, DeDistortPtr pDeDistort,
+ const DRect& displayROI, Event::Source source);
+ virtual ~TrackerTouchStatus();
+ void blobChanged(BlobPtr pNewBlob, long long time, bool bKeepEvent);
+ void blobGone();
+ void setStale();
+ bool isStale();
+
+ private:
+ TouchEventPtr createEvent(Event::Source source, Event::Type type, int id,
+ BlobPtr pBlob, long long time, DeDistortPtr pDeDistort,
+ const DRect& displayROI);
+ TouchEventPtr createEvent(Event::Type type, BlobPtr pBlob, long long time);
+
+ Event::Source m_Source;
+ DeDistortPtr m_pDeDistort;
+ DRect m_DisplayROI;
+ bool m_Stale;
+ bool m_bGone;
+ int m_ID;
+ BlobPtr m_pBlob;
+ long long m_LastTime;
+ DPoint m_LastCenter;
+
+ static int s_LastID;
+};
+
+}
+
+#endif
diff --git a/src/player/VectorNode.cpp b/src/player/VectorNode.cpp
new file mode 100644
index 0000000..427d637
--- /dev/null
+++ b/src/player/VectorNode.cpp
@@ -0,0 +1,521 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VectorNode.h"
+
+#include "NodeDefinition.h"
+#include "OGLSurface.h"
+#include "Image.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+#include "../base/Exception.h"
+#include "../base/WideLine.h"
+#include "../base/GeomHelper.h"
+#include "../base/Triangle.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/VertexArray.h"
+#include "../graphics/Filterfliprgb.h"
+
+#include <iostream>
+#include <sstream>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+NodeDefinition VectorNode::createDefinition()
+{
+ return NodeDefinition("vector")
+ .extendDefinition(Node::createDefinition())
+ .addArg(Arg<string>("color", "FFFFFF", false, offsetof(VectorNode, m_sColorName)))
+ .addArg(Arg<double>("strokewidth", 1, false, offsetof(VectorNode, m_StrokeWidth)))
+ .addArg(Arg<UTF8String>("texhref", "", false, offsetof(VectorNode, m_TexHRef)))
+ .addArg(Arg<string>("blendmode", "blend", false,
+ offsetof(VectorNode, m_sBlendMode)))
+ ;
+}
+
+VectorNode::VectorNode(const ArgList& args)
+{
+ m_pShape = ShapePtr(createDefaultShape());
+
+ ObjectCounter::get()->incRef(&typeid(*this));
+ m_TexHRef = args.getArgVal<UTF8String>("texhref");
+ setTexHRef(m_TexHRef);
+ m_sColorName = args.getArgVal<string>("color");
+ m_Color = colorStringToColor(m_sColorName);
+}
+
+VectorNode::~VectorNode()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void VectorNode::connectDisplay()
+{
+ setDrawNeeded();
+ m_Color = colorStringToColor(m_sColorName);
+ Node::connectDisplay();
+ m_pShape->moveToGPU();
+ m_OldOpacity = -1;
+ setBlendModeStr(m_sBlendMode);
+}
+
+void VectorNode::connect(CanvasPtr pCanvas)
+{
+ Node::connect(pCanvas);
+ checkReload();
+}
+
+void VectorNode::disconnect(bool bKill)
+{
+ if (bKill) {
+ m_pShape->discard();
+ } else {
+ m_pShape->moveToCPU();
+ }
+ Node::disconnect(bKill);
+}
+
+void VectorNode::checkReload()
+{
+ Node::checkReload(m_TexHRef, m_pShape->getImage());
+ if (getState() == Node::NS_CANRENDER) {
+ m_pShape->moveToGPU();
+ setDrawNeeded();
+ }
+}
+
+const UTF8String& VectorNode::getTexHRef() const
+{
+ return m_TexHRef;
+}
+
+void VectorNode::setTexHRef(const UTF8String& href)
+{
+ m_TexHRef = href;
+ checkReload();
+ setDrawNeeded();
+}
+
+void VectorNode::setBitmap(BitmapPtr pBmp)
+{
+ m_TexHRef = "";
+ m_pShape->setBitmap(pBmp);
+ setDrawNeeded();
+}
+
+const string& VectorNode::getBlendModeStr() const
+{
+ return m_sBlendMode;
+}
+
+void VectorNode::setBlendModeStr(const string& sBlendMode)
+{
+ m_sBlendMode = sBlendMode;
+ m_BlendMode = GLContext::stringToBlendMode(sBlendMode);
+}
+
+static ProfilingZoneID PrerenderProfilingZone("VectorNode::prerender");
+
+void VectorNode::preRender()
+{
+ Node::preRender();
+ double curOpacity = getEffectiveOpacity();
+
+ VertexArrayPtr pVA = m_pShape->getVertexArray();
+ {
+ if (m_bDrawNeeded || curOpacity != m_OldOpacity) {
+ ScopeTimer timer(PrerenderProfilingZone);
+ pVA->reset();
+ Pixel32 color = getColorVal();
+ color.setA((unsigned char)(curOpacity*255));
+ calcVertexes(pVA, color);
+ pVA->update();
+ m_bDrawNeeded = false;
+ m_OldOpacity = curOpacity;
+ }
+ }
+
+}
+
+void VectorNode::maybeRender(const DRect& rect)
+{
+ AVG_ASSERT(getState() == NS_CANRENDER);
+ if (isVisible()) {
+ if (getID() != "") {
+ AVG_TRACE(Logger::BLTS, "Rendering " << getTypeStr() <<
+ " with ID " << getID());
+ } else {
+ AVG_TRACE(Logger::BLTS, "Rendering " << getTypeStr());
+ }
+ GLContext::getCurrent()->setBlendMode(m_BlendMode);
+ render(rect);
+ }
+}
+
+static ProfilingZoneID RenderProfilingZone("VectorNode::render");
+
+void VectorNode::render(const DRect& rect)
+{
+ ScopeTimer timer(RenderProfilingZone);
+// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ double curOpacity = getEffectiveOpacity();
+ glColor4d(1.0, 1.0, 1.0, curOpacity);
+ m_pShape->draw();
+}
+
+void VectorNode::setColor(const string& sColor)
+{
+ if (m_sColorName != sColor) {
+ m_sColorName = sColor;
+ m_Color = colorStringToColor(m_sColorName);
+ m_bDrawNeeded = true;
+ }
+}
+
+const string& VectorNode::getColor() const
+{
+ return m_sColorName;
+}
+
+void VectorNode::setStrokeWidth(double width)
+{
+ if (width != m_StrokeWidth) {
+ m_bDrawNeeded = true;
+ m_StrokeWidth = width;
+ }
+}
+
+double VectorNode::getStrokeWidth() const
+{
+ return m_StrokeWidth;
+}
+
+Pixel32 VectorNode::getColorVal() const
+{
+ return m_Color;
+}
+
+GLContext::BlendMode VectorNode::getBlendMode() const
+{
+ return m_BlendMode;
+}
+
+VectorNode::LineJoin VectorNode::string2LineJoin(const string& s)
+{
+ if (s == "miter") {
+ return LJ_MITER;
+ } else if (s == "bevel") {
+ return LJ_BEVEL;
+ } else {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "Vector linejoin "+s+" not supported."));
+ }
+}
+
+string VectorNode::lineJoin2String(LineJoin lineJoin)
+{
+ switch(lineJoin) {
+ case LJ_MITER:
+ return "miter";
+ case LJ_BEVEL:
+ return "bevel";
+ default:
+ AVG_ASSERT(false);
+ return 0;
+ }
+}
+
+void VectorNode::setDrawNeeded()
+{
+ m_bDrawNeeded = true;
+}
+
+bool VectorNode::isDrawNeeded()
+{
+ return m_bDrawNeeded;
+}
+
+void VectorNode::calcPolyLineCumulDist(vector<double>& cumulDists,
+ const vector<DPoint>& pts, bool bIsClosed)
+{
+ cumulDists.clear();
+ cumulDists.reserve(pts.size());
+ if (!pts.empty()) {
+ vector<double> distances;
+ distances.reserve(pts.size());
+ double totalDist = 0;
+ for (unsigned i = 1; i < pts.size(); ++i) {
+ double dist = calcDist(pts[i], pts[i-1]);
+ distances.push_back(dist);
+ totalDist += dist;
+ }
+ if (bIsClosed) {
+ double dist = calcDist(pts[pts.size()-1], pts[0]);
+ distances.push_back(dist);
+ totalDist += dist;
+ }
+
+ double cumulDist = 0;
+ cumulDists.push_back(0);
+ for (unsigned i = 0; i < distances.size(); ++i) {
+ cumulDist += distances[i]/totalDist;
+ cumulDists.push_back(cumulDist);
+ }
+ }
+}
+
+void VectorNode::calcEffPolyLineTexCoords(vector<double>& effTC,
+ const vector<double>& tc, const vector<double>& cumulDist)
+{
+ if (tc.empty()) {
+ effTC = cumulDist;
+ } else if (tc.size() == cumulDist.size()) {
+ effTC = tc;
+ } else {
+ effTC.reserve(cumulDist.size());
+ effTC = tc;
+ double minGivenTexCoord = tc[0];
+ double maxGivenTexCoord = tc[tc.size()-1];
+ double maxCumulDist = cumulDist[tc.size()-1];
+ int baselineDist = 0;
+ for (unsigned i = tc.size(); i < cumulDist.size(); ++i) {
+ int repeatFactor = int(cumulDist[i]/maxCumulDist);
+ double effCumulDist = fmod(cumulDist[i], maxCumulDist);
+ while (cumulDist[baselineDist+1] < effCumulDist) {
+ baselineDist++;
+ }
+ double ratio = (effCumulDist-cumulDist[baselineDist])/
+ (cumulDist[baselineDist+1]-cumulDist[baselineDist]);
+ double rawTexCoord = (1-ratio)*tc[baselineDist] +ratio*tc[baselineDist+1];
+ double texCoord = rawTexCoord
+ +repeatFactor*(maxGivenTexCoord-minGivenTexCoord);
+ effTC.push_back(texCoord);
+ }
+ }
+}
+
+void VectorNode::calcPolyLine(const vector<DPoint>& origPts,
+ const vector<double>& origTexCoords, bool bIsClosed, LineJoin lineJoin,
+ VertexArrayPtr& pVertexArray, Pixel32 color)
+{
+ vector<DPoint> pts;
+ pts.reserve(origPts.size());
+ vector<double> texCoords;
+ texCoords.reserve(origPts.size());
+
+ pts.push_back(origPts[0]);
+ texCoords.push_back(origTexCoords[0]);
+ for (unsigned i = 1; i < origPts.size(); ++i) {
+ if (calcDistSquared(origPts[i], origPts[i-1]) > 0.1) {
+ pts.push_back(origPts[i]);
+ texCoords.push_back(origTexCoords[i]);
+ }
+ }
+ if (bIsClosed) {
+ texCoords.push_back(origTexCoords[origTexCoords.size()-1]);
+ }
+
+ int numPts = pts.size();
+
+ // Create array of wide lines.
+ vector<WideLine> lines;
+ lines.reserve(numPts-1);
+ for (int i = 0; i < numPts-1; ++i) {
+ lines.push_back(WideLine(pts[i], pts[i+1], m_StrokeWidth));
+ }
+ if (bIsClosed) {
+ lines.push_back(WideLine(pts[numPts-1], pts[0], m_StrokeWidth));
+ }
+ // First points
+ if (bIsClosed) {
+ WideLine lastLine = lines[lines.size()-1];
+ DPoint pli = getLineLineIntersection(lastLine.pl0, lastLine.dir,
+ lines[0].pl0, lines[0].dir);
+ DPoint pri = getLineLineIntersection(lastLine.pr0, lastLine.dir,
+ lines[0].pr0, lines[0].dir);
+ Triangle tri(lastLine.pl1, lines[0].pl0, pri);
+ if (tri.isClockwise()) {
+ if (!DLineSegment(lastLine.pr0, lastLine.pr1).isPointOver(pri) &&
+ !DLineSegment(lines[0].pr0, lines[0].pr1).isPointOver(pri))
+ {
+ pri = lines[0].pr1;
+ }
+ } else {
+ if (!DLineSegment(lastLine.pl0, lastLine.pl1).isPointOver(pli) &&
+ !DLineSegment(lines[0].pl0, lines[0].pl1).isPointOver(pli))
+ {
+ pli = lines[0].pl1;
+ }
+ }
+
+ double curTC = texCoords[0];
+ switch (lineJoin) {
+ case LJ_MITER:
+ pVertexArray->appendPos(pli, DPoint(curTC,1), color);
+ pVertexArray->appendPos(pri, DPoint(curTC,0), color);
+ break;
+ case LJ_BEVEL: {
+ if (tri.isClockwise()) {
+ pVertexArray->appendPos(lines[0].pl0, DPoint(curTC,1), color);
+ pVertexArray->appendPos(pri, DPoint(curTC,0), color);
+ } else {
+ pVertexArray->appendPos(pli, DPoint(curTC,1), color);
+ pVertexArray->appendPos(lines[0].pr0, DPoint(curTC,0), color);
+ }
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ break;
+ }
+ } else {
+ pVertexArray->appendPos(lines[0].pl0, DPoint(texCoords[0],1), color);
+ pVertexArray->appendPos(lines[0].pr0, DPoint(texCoords[0],0), color);
+ }
+
+ // All complete line segments
+ unsigned numNormalSegments;
+ if (bIsClosed) {
+ numNormalSegments = pts.size();
+ } else {
+ numNormalSegments = pts.size()-2;
+ }
+ for (unsigned i = 0; i < numNormalSegments; ++i) {
+ const WideLine* pLine1 = &(lines[i]);
+ const WideLine* pLine2;
+ if (i == pts.size()-1) {
+ pLine2 = &(lines[0]);
+ } else {
+ pLine2 = &(lines[i+1]);
+ }
+ DPoint pli = getLineLineIntersection(pLine1->pl0, pLine1->dir, pLine2->pl0, pLine2->dir);
+ DPoint pri = getLineLineIntersection(pLine1->pr0, pLine1->dir, pLine2->pr0, pLine2->dir);
+ Triangle tri(pLine1->pl1, pLine2->pl0, pri);
+ if (tri.isClockwise()) {
+ if (!DLineSegment(pLine1->pr0, pLine1->pr1).isPointOver(pri) &&
+ !DLineSegment(pLine2->pr0, pLine2->pr1).isPointOver(pri))
+ {
+ pri = pLine2->pr1;
+ }
+ } else {
+ if (!DLineSegment(pLine1->pl0, pLine1->pl1).isPointOver(pli) &&
+ !DLineSegment(pLine2->pl0, pLine2->pl1).isPointOver(pli))
+ {
+ pli = pLine2->pl1;
+ }
+ }
+
+ int curVertex = pVertexArray->getCurVert();
+ double curTC = texCoords[i+1];
+ switch (lineJoin) {
+ case LJ_MITER:
+ pVertexArray->appendPos(pli, DPoint(curTC,1), color);
+ pVertexArray->appendPos(pri, DPoint(curTC,0), color);
+ pVertexArray->appendQuadIndexes(
+ curVertex-1, curVertex-2, curVertex+1, curVertex);
+ break;
+ case LJ_BEVEL:
+ {
+ double TC0;
+ double TC1;
+ if (tri.isClockwise()) {
+ calcBevelTC(*pLine1, *pLine2, true, texCoords, i+1, TC0, TC1);
+ pVertexArray->appendPos(pLine1->pl1, DPoint(TC0,1), color);
+ pVertexArray->appendPos(pLine2->pl0, DPoint(TC1,1), color);
+ pVertexArray->appendPos(pri, DPoint(curTC,0), color);
+ pVertexArray->appendQuadIndexes(
+ curVertex-1, curVertex-2, curVertex+2, curVertex);
+ pVertexArray->appendTriIndexes(
+ curVertex, curVertex+1, curVertex+2);
+ } else {
+ calcBevelTC(*pLine1, *pLine2, false, texCoords, i+1, TC0, TC1);
+ pVertexArray->appendPos(pLine1->pr1, DPoint(TC0,0), color);
+ pVertexArray->appendPos(pli, DPoint(curTC,1), color);
+ pVertexArray->appendPos(pLine2->pr0, DPoint(TC1,0), color);
+ pVertexArray->appendQuadIndexes(
+ curVertex-2, curVertex-1, curVertex+1, curVertex);
+ pVertexArray->appendTriIndexes(
+ curVertex, curVertex+1, curVertex+2);
+ }
+ }
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ }
+
+ // Last segment (PolyLine only)
+ if (!bIsClosed) {
+ int curVertex = pVertexArray->getCurVert();
+ double curTC = texCoords[numPts-1];
+ pVertexArray->appendPos(lines[numPts-2].pl1, DPoint(curTC,1), color);
+ pVertexArray->appendPos(lines[numPts-2].pr1, DPoint(curTC,0), color);
+ pVertexArray->appendQuadIndexes(curVertex-1, curVertex-2, curVertex+1, curVertex);
+ }
+}
+
+void VectorNode::calcBevelTC(const WideLine& line1, const WideLine& line2,
+ bool bIsLeft, const vector<double>& texCoords, unsigned i,
+ double& TC0, double& TC1)
+{
+ double line1Len = line1.getLen();
+ double line2Len = line2.getLen();
+ double triLen;
+ if (bIsLeft) {
+ triLen = calcDist(line1.pl1, line2.pl0);
+ } else {
+ triLen = calcDist(line1.pr1, line2.pr0);
+ }
+ double ratio0 = line1Len/(line1Len+triLen/2);
+ TC0 = (1-ratio0)*texCoords[i-1]+ratio0*texCoords[i];
+ double nextTexCoord;
+ if (i == texCoords.size()-1) {
+ nextTexCoord = texCoords[i];
+ } else {
+ nextTexCoord = texCoords[i+1];
+ }
+ double ratio1 = line2Len/(line2Len+triLen/2);
+ TC1 = ratio1*texCoords[i]+(1-ratio1)*nextTexCoord;
+}
+
+int VectorNode::getNumDifferentPts(const vector<DPoint>& pts)
+{
+ int numPts = pts.size();
+ for (unsigned i=1; i<pts.size(); ++i) {
+ if (calcDistSquared(pts[i], pts[i-1])<0.1) {
+ numPts--;
+ }
+ }
+ return numPts;
+}
+
+Shape* VectorNode::createDefaultShape() const
+{
+ return new Shape(MaterialInfo(GL_REPEAT, GL_CLAMP_TO_EDGE, false));
+}
+
+}
diff --git a/src/player/VectorNode.h b/src/player/VectorNode.h
new file mode 100644
index 0000000..d17c7c4
--- /dev/null
+++ b/src/player/VectorNode.h
@@ -0,0 +1,117 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VectorNode_H_
+#define _VectorNode_H_
+
+#include "../api.h"
+#include "Node.h"
+#include "Shape.h"
+
+#include "../base/UTF8String.h"
+#include "../graphics/Pixel32.h"
+#include "../graphics/VertexArray.h"
+#include "../graphics/GLContext.h"
+
+namespace avg {
+
+struct WideLine;
+
+class AVG_API VectorNode : public Node
+{
+ public:
+ enum LineJoin {LJ_MITER, LJ_BEVEL};
+
+ static NodeDefinition createDefinition();
+
+ VectorNode(const ArgList& args);
+ virtual ~VectorNode();
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+ virtual void checkReload();
+
+ const UTF8String& getTexHRef() const;
+ void setTexHRef(const UTF8String& href);
+ void setBitmap(BitmapPtr pBmp);
+
+ const std::string& getBlendModeStr() const;
+ void setBlendModeStr(const std::string& sBlendMode);
+
+ virtual void preRender();
+ virtual void maybeRender(const DRect& rect);
+ virtual void render(const DRect& rect);
+
+ virtual void calcVertexes(VertexArrayPtr& pVertexArray, Pixel32 color) = 0;
+
+ void setColor(const std::string& sColor);
+ const std::string& getColor() const;
+
+ void setStrokeWidth(double width);
+ double getStrokeWidth() const;
+
+ static LineJoin string2LineJoin(const std::string& s);
+ static std::string lineJoin2String(LineJoin lineJoin);
+
+ protected:
+ Pixel32 getColorVal() const;
+ GLContext::BlendMode getBlendMode() const;
+
+ void setDrawNeeded();
+ bool isDrawNeeded();
+ bool hasVASizeChanged();
+ void calcPolyLineCumulDist(std::vector<double>& cumulDist,
+ const std::vector<DPoint>& pts, bool bIsClosed);
+ void calcEffPolyLineTexCoords(std::vector<double>& effTC,
+ const std::vector<double>& tc, const std::vector<double>& cumulDist);
+
+ void calcPolyLine(const std::vector<DPoint>& origPts,
+ const std::vector<double>& origTexCoords, bool bIsClosed, LineJoin lineJoin,
+ VertexArrayPtr& pVertexArray, Pixel32 color);
+ void calcBevelTC(const WideLine& line1, const WideLine& line2,
+ bool bIsLeft, const std::vector<double>& texCoords, unsigned i,
+ double& TC0, double& TC1);
+ int getNumDifferentPts(const std::vector<DPoint>& pts);
+
+ private:
+ Shape* createDefaultShape() const;
+
+ private:
+ std::string m_sColorName;
+ Pixel32 m_Color;
+ double m_StrokeWidth;
+ UTF8String m_TexHRef;
+ std::string m_sBlendMode;
+
+ bool m_bDrawNeeded;
+ bool m_bVASizeChanged;
+ double m_OldOpacity;
+
+ ShapePtr m_pShape;
+ GLContext::BlendMode m_BlendMode;
+};
+
+typedef boost::shared_ptr<VectorNode> VectorNodePtr;
+
+}
+
+#endif
+
diff --git a/src/player/VideoNode.cpp b/src/player/VideoNode.cpp
new file mode 100644
index 0000000..0df4129
--- /dev/null
+++ b/src/player/VideoNode.cpp
@@ -0,0 +1,782 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#include "VideoNode.h"
+#include "Player.h"
+#include "OGLSurface.h"
+#include "NodeDefinition.h"
+#include "Canvas.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+#include "../base/XMLHelper.h"
+
+#include "../graphics/Filterfill.h"
+#include "../graphics/GLTexture.h"
+#include "../graphics/TextureMover.h"
+
+#include "../audio/SDLAudioEngine.h"
+
+#include "../video/AsyncVideoDecoder.h"
+#include "../video/FFMpegDecoder.h"
+
+#include <iostream>
+#include <sstream>
+
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+
+using namespace boost::python;
+using namespace std;
+
+namespace avg {
+
+NodeDefinition VideoNode::createDefinition()
+{
+ return NodeDefinition("video", Node::buildNode<VideoNode>)
+ .extendDefinition(RasterNode::createDefinition())
+ .addArg(Arg<UTF8String>("href", "", false, offsetof(VideoNode, m_href)))
+ .addArg(Arg<bool>("loop", false, false, offsetof(VideoNode, m_bLoop)))
+ .addArg(Arg<bool>("threaded", true, false, offsetof(VideoNode, m_bThreaded)))
+ .addArg(Arg<double>("fps", 0.0, false, offsetof(VideoNode, m_FPS)))
+ .addArg(Arg<int>("queuelength", 8, false,
+ offsetof(VideoNode, m_QueueLength)))
+ .addArg(Arg<double>("volume", 1.0, false, offsetof(VideoNode, m_Volume)))
+ .addArg(Arg<bool>("accelerated", false, false,
+ offsetof(VideoNode, m_bUsesHardwareAcceleration)))
+ ;
+}
+
+VideoNode::VideoNode(const ArgList& args)
+ : m_VideoState(Unloaded),
+ m_bFrameAvailable(false),
+ m_bFirstFrameDecoded(false),
+ m_Filename(""),
+ m_bEOFPending(false),
+ m_pEOFCallback(0),
+ m_FramesTooLate(0),
+ m_FramesPlayed(0),
+ m_SeekBeforeCanRenderTime(0),
+ m_pDecoder(0),
+ m_Volume(1.0),
+ m_bUsesHardwareAcceleration(false)
+{
+ args.setMembers(this);
+ m_Filename = m_href;
+ initFilename(m_Filename);
+ if (!m_bThreaded && m_QueueLength != 8) {
+ throw Exception(AVG_ERR_INVALID_ARGS,
+ "Can't set queue length for unthreaded videos because there is no decoder queue in this case.");
+ }
+ if (m_bThreaded) {
+ VideoDecoderPtr pSyncDecoder = VideoDecoderPtr(new FFMpegDecoder());
+ m_pDecoder = new AsyncVideoDecoder(pSyncDecoder, m_QueueLength);
+ } else {
+ m_pDecoder = new FFMpegDecoder();
+ }
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+VideoNode::~VideoNode()
+{
+ if (m_pDecoder) {
+ delete m_pDecoder;
+ m_pDecoder = 0;
+ }
+ if (m_pEOFCallback) {
+ Py_DECREF(m_pEOFCallback);
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void VideoNode::connectDisplay()
+{
+ checkReload();
+ RasterNode::connectDisplay();
+ long long CurTime = Player::get()->getFrameTime();
+ if (m_VideoState != Unloaded) {
+ startDecoding();
+ }
+ if (m_VideoState == Paused) {
+ m_PauseStartTime = CurTime;
+ }
+}
+
+void VideoNode::connect(CanvasPtr pCanvas)
+{
+ pCanvas->registerFrameEndListener(this);
+ RasterNode::connect(pCanvas);
+}
+
+void VideoNode::disconnect(bool bKill)
+{
+ getCanvas()->unregisterFrameEndListener(this);
+ if (bKill) {
+ setEOFCallback(Py_None);
+ }
+ changeVideoState(Unloaded);
+ RasterNode::disconnect(bKill);
+}
+
+void VideoNode::play()
+{
+ changeVideoState(Playing);
+}
+
+void VideoNode::stop()
+{
+ changeVideoState(Unloaded);
+}
+
+void VideoNode::pause()
+{
+ changeVideoState(Paused);
+}
+
+int VideoNode::getNumFrames() const
+{
+ exceptionIfUnloaded("getNumFrames");
+ return m_pDecoder->getVideoInfo().m_NumFrames;
+}
+
+int VideoNode::getCurFrame() const
+{
+ exceptionIfUnloaded("getCurFrame");
+ int curFrame = m_pDecoder->getCurFrame();
+ if (curFrame > 0) {
+ return curFrame;
+ } else {
+ return 0;
+ }
+}
+
+int VideoNode::getNumFramesQueued() const
+{
+ exceptionIfUnloaded("getNumFramesQueued");
+ return m_pDecoder->getNumFramesQueued();
+}
+
+void VideoNode::seekToFrame(int frameNum)
+{
+ if (frameNum < 0) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE,
+ "Can't seek to a negative frame in a video.");
+ }
+ exceptionIfUnloaded("seekToFrame");
+ if (getCurFrame() != frameNum) {
+ long long destTime = (long long)(frameNum*1000.0/m_pDecoder->getNominalFPS());
+ seek(destTime);
+ }
+}
+
+std::string VideoNode::getStreamPixelFormat() const
+{
+ exceptionIfUnloaded("getStreamPixelFormat");
+ return m_pDecoder->getVideoInfo().m_sPixelFormat;
+}
+
+long long VideoNode::getDuration() const
+{
+ exceptionIfUnloaded("getDuration");
+ return (long long)(m_pDecoder->getVideoInfo().m_Duration*1000);
+}
+
+int VideoNode::getBitrate() const
+{
+ exceptionIfUnloaded("getBitrate");
+ return m_pDecoder->getVideoInfo().m_Bitrate;
+}
+
+string VideoNode::getVideoCodec() const
+{
+ exceptionIfUnloaded("getVideoCodec");
+ return m_pDecoder->getVideoInfo().m_sVCodec;
+}
+
+std::string VideoNode::getAudioCodec() const
+{
+ exceptionIfNoAudio("getAudioCodec");
+ return m_pDecoder->getVideoInfo().m_sACodec;
+}
+
+int VideoNode::getAudioSampleRate() const
+{
+ exceptionIfNoAudio("getAudioSampleRate");
+ return m_pDecoder->getVideoInfo().m_SampleRate;
+}
+
+int VideoNode::getNumAudioChannels() const
+{
+ exceptionIfNoAudio("getNumAudioChannels");
+ return m_pDecoder->getVideoInfo().m_NumAudioChannels;
+}
+
+long long VideoNode::getCurTime() const
+{
+ if (m_VideoState == Unloaded) {
+ return 0;
+ } else {
+ long long curTime = (long long)(m_pDecoder->getCurTime()*1000);
+ if (curTime > 0) {
+ return curTime;
+ } else {
+ return 0;
+ }
+ }
+}
+
+void VideoNode::seekToTime(long long time)
+{
+ if (time < 0) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE,
+ "Can't seek to a negative time in a video.");
+ }
+ exceptionIfUnloaded("seekToTime");
+ seek(time);
+ m_bSeekPending = true;
+}
+
+bool VideoNode::getLoop() const
+{
+ return m_bLoop;
+}
+
+bool VideoNode::isThreaded() const
+{
+ return m_bThreaded;
+}
+
+bool VideoNode::hasAudio() const
+{
+ exceptionIfUnloaded("hasAudio");
+ return m_pDecoder->getVideoInfo().m_bHasAudio;
+}
+
+bool VideoNode::hasAlpha() const
+{
+ exceptionIfUnloaded("hasAlpha");
+ PixelFormat pf = getPixelFormat();
+ return pixelFormatHasAlpha(pf);
+}
+
+void VideoNode::setEOFCallback(PyObject * pEOFCallback)
+{
+ if (m_pEOFCallback) {
+ Py_DECREF(m_pEOFCallback);
+ }
+ if (pEOFCallback == Py_None) {
+ m_pEOFCallback = 0;
+ } else {
+ Py_INCREF(pEOFCallback);
+ m_pEOFCallback = pEOFCallback;
+ }
+}
+
+bool VideoNode::isAccelerated() const
+{
+ exceptionIfUnloaded("isAccelerated");
+ return m_bUsesHardwareAcceleration;
+}
+
+const UTF8String& VideoNode::getHRef() const
+{
+ return m_href;
+}
+
+void VideoNode::setHRef(const UTF8String& href)
+{
+ m_href = href;
+ checkReload();
+}
+
+double VideoNode::getVolume()
+{
+ return m_Volume;
+}
+
+void VideoNode::setVolume(double Volume)
+{
+ if (Volume < 0) {
+ Volume = 0;
+ }
+ m_Volume = Volume;
+ if (m_VideoState != Unloaded && hasAudio()) {
+ m_pDecoder->setVolume(Volume);
+ }
+}
+
+void VideoNode::checkReload()
+{
+ string fileName (m_href);
+ if (m_href != "") {
+ initFilename(fileName);
+ if (fileName != m_Filename && m_VideoState != Unloaded) {
+ changeVideoState(Unloaded);
+ m_Filename = fileName;
+ changeVideoState(Paused);
+ } else {
+ m_Filename = fileName;
+ }
+ } else {
+ changeVideoState(Unloaded);
+ m_Filename = "";
+ }
+ RasterNode::checkReload();
+}
+
+void VideoNode::onFrameEnd()
+{
+ if (m_bEOFPending) {
+ // If the VideoNode is unlinked by python in onEOF, the following line prevents
+ // the object from being deleted until we return from this function.
+ NodePtr pTempThis = shared_from_this();
+ m_bEOFPending = false;
+ onEOF();
+ }
+}
+
+int VideoNode::fillAudioBuffer(AudioBufferPtr pBuffer)
+{
+ AVG_ASSERT(m_bThreaded);
+ if (m_VideoState == Playing) {
+ return m_pDecoder->fillAudioBuffer(pBuffer);
+ } else {
+ return 0;
+ }
+}
+
+void VideoNode::changeVideoState(VideoState NewVideoState)
+{
+ long long curTime = Player::get()->getFrameTime();
+ if (m_VideoState == NewVideoState) {
+ return;
+ }
+ if (m_VideoState == Unloaded) {
+ m_PauseStartTime = curTime;
+ open();
+ }
+ if (NewVideoState == Unloaded) {
+ close();
+ }
+ if (getState() == NS_CANRENDER) {
+ if (m_VideoState == Unloaded) {
+ startDecoding();
+ }
+ if (NewVideoState == Paused) {
+ m_PauseStartTime = curTime;
+ } else if (NewVideoState == Playing && m_VideoState == Paused) {
+/*
+ cerr << "Play after pause:" << endl;
+ cerr << " getFrameTime()=" << curTime << endl;
+ cerr << " m_PauseStartTime=" << m_PauseStartTime << endl;
+ cerr << " offset=" << (1000.0/m_pDecoder->getFPS()) << endl;
+*/
+ m_PauseTime += (curTime-m_PauseStartTime
+ - (long long)(1000.0/m_pDecoder->getFPS()));
+ }
+ }
+ m_VideoState = NewVideoState;
+}
+
+void VideoNode::seek(long long destTime)
+{
+ if (getState() == NS_CANRENDER) {
+ m_pDecoder->seek(double(destTime)/1000.0);
+ m_StartTime = Player::get()->getFrameTime() - destTime;
+ m_JitterCompensation = 0.5;
+ m_PauseTime = 0;
+ m_PauseStartTime = Player::get()->getFrameTime();
+ m_bFrameAvailable = false;
+ m_bSeekPending = true;
+ } else {
+ // If we get a seek command before decoding has really started, we need to defer
+ // the actual seek until the decoder is ready.
+ m_SeekBeforeCanRenderTime = destTime;
+ }
+}
+
+void VideoNode::open()
+{
+ m_FramesTooLate = 0;
+ m_FramesInRowTooLate = 0;
+ m_FramesPlayed = 0;
+ m_pDecoder->open(m_Filename, m_bThreaded, m_bUsesHardwareAcceleration);
+ m_pDecoder->setVolume(m_Volume);
+ VideoInfo videoInfo = m_pDecoder->getVideoInfo();
+ if (!videoInfo.m_bHasVideo) {
+ m_pDecoder->close();
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ string("Video: Opening "+m_Filename+" failed. No video stream found."));
+ }
+ m_StartTime = Player::get()->getFrameTime();
+ m_JitterCompensation = 0.5;
+ m_PauseTime = 0;
+
+ m_bFirstFrameDecoded = false;
+ m_bFrameAvailable = false;
+ m_bUsesHardwareAcceleration = videoInfo.m_bUsesVDPAU;
+}
+
+void VideoNode::startDecoding()
+{
+ const AudioParams * pAP = 0;
+ SDLAudioEngine* pAudioEngine = SDLAudioEngine::get();
+ if (pAudioEngine) {
+ pAP = pAudioEngine->getParams();
+ }
+ m_pDecoder->startDecoding(GLContext::getCurrent()->isUsingShaders(), pAP);
+ VideoInfo videoInfo = m_pDecoder->getVideoInfo();
+ if (m_FPS != 0.0) {
+ if (videoInfo.m_bHasAudio) {
+ AVG_TRACE(Logger::WARNING,
+ getID() + ": Can't set FPS if video contains audio. Ignored.");
+ } else {
+ m_pDecoder->setFPS(m_FPS);
+ }
+ }
+ if (videoInfo.m_bHasAudio && pAudioEngine) {
+ pAudioEngine->addSource(this);
+ }
+ m_bSeekPending = true;
+
+ setViewport(-32767, -32767, -32767, -32767);
+ createTextures(videoInfo.m_Size);
+
+ if (m_SeekBeforeCanRenderTime != 0) {
+ seek(m_SeekBeforeCanRenderTime);
+ m_SeekBeforeCanRenderTime = 0;
+ }
+}
+
+void VideoNode::createTextures(IntPoint size)
+{
+ PixelFormat pf = getPixelFormat();
+ bool bMipmap = getMaterial().getUseMipmaps();
+ if (pixelFormatIsPlanar(pf)) {
+ m_pTextures[0] = GLTexturePtr(new GLTexture(size, I8, bMipmap));
+ IntPoint halfSize(size.x/2, size.y/2);
+ m_pTextures[1] = GLTexturePtr(new GLTexture(halfSize, I8, bMipmap));
+ m_pTextures[2] = GLTexturePtr(new GLTexture(halfSize, I8, bMipmap));
+ if (pixelFormatHasAlpha(pf)) {
+ m_pTextures[3] = GLTexturePtr(new GLTexture(size, I8, bMipmap));
+ }
+ } else {
+ m_pTextures[0] = GLTexturePtr(new GLTexture(size, pf, bMipmap));
+ }
+ for (unsigned i=0; i<getNumPixelFormatPlanes(pf); ++i) {
+ m_pTextures[i]->enableStreaming();
+ }
+ if (pf == B8G8R8X8 || pf == B8G8R8A8) {
+ FilterFill<Pixel32> Filter(Pixel32(0,0,0,255));
+ BitmapPtr pBmp = m_pTextures[0]->lockStreamingBmp();
+ Filter.applyInPlace(pBmp);
+ m_pTextures[0]->unlockStreamingBmp(true);
+ }
+ if (pixelFormatIsPlanar(pf)) {
+ if (pixelFormatHasAlpha(pf)) {
+ getSurface()->create(pf, m_pTextures[0], m_pTextures[1], m_pTextures[2],
+ m_pTextures[3]);
+ } else {
+ getSurface()->create(pf, m_pTextures[0], m_pTextures[1], m_pTextures[2]);
+ }
+ } else {
+ getSurface()->create(pf, m_pTextures[0]);
+ }
+}
+
+void VideoNode::close()
+{
+ SDLAudioEngine* pAudioEngine = SDLAudioEngine::get();
+ if (hasAudio() && pAudioEngine) {
+ pAudioEngine->removeSource(this);
+ }
+ m_pDecoder->close();
+ if (m_FramesTooLate > 0) {
+ string sID;
+ if (getID() == "") {
+ sID = m_href;
+ } else {
+ sID = getID();
+ }
+ AVG_TRACE(Logger::PROFILE_VIDEO, "Missed video frames for '" << sID << "': "
+ << m_FramesTooLate << " of " << m_FramesPlayed);
+ m_FramesTooLate = 0;
+ }
+}
+
+PixelFormat VideoNode::getPixelFormat() const
+{
+ return m_pDecoder->getPixelFormat();
+}
+
+IntPoint VideoNode::getMediaSize()
+{
+ if (m_pDecoder && m_pDecoder->getState() != VideoDecoder::CLOSED) {
+ return m_pDecoder->getSize();
+ } else {
+ return IntPoint(0,0);
+ }
+}
+
+double VideoNode::getFPS() const
+{
+ return m_pDecoder->getFPS();
+}
+
+int VideoNode::getQueueLength() const
+{
+ return m_QueueLength;
+}
+
+long long VideoNode::getNextFrameTime() const
+{
+ switch (m_VideoState) {
+ case Unloaded:
+ return 0;
+ case Paused:
+ return m_PauseStartTime-m_StartTime;
+ case Playing:
+ {
+ if (Player::get()->getFrameTime()-m_StartTime-m_PauseTime < 0) {
+ cerr << "getNextFrameTime < 0" << endl;
+ cerr << "getFrameTime(): " << Player::get()->getFrameTime() << endl;
+ cerr << "m_StartTime: " << m_StartTime << endl;
+ cerr << "m_PauseTime: " << m_PauseTime << endl;
+ }
+ long long nextFrameTime = Player::get()->getFrameTime()-m_StartTime
+ -m_PauseTime
+ -(long long)(m_JitterCompensation*1000.0/
+ Player::get()->getFramerate());
+ if (nextFrameTime < 0) {
+ nextFrameTime = 0;
+ }
+ return nextFrameTime;
+ }
+ default:
+ AVG_ASSERT(false);
+ return 0;
+ }
+}
+
+void VideoNode::exceptionIfNoAudio(const std::string& sFuncName) const
+{
+ exceptionIfUnloaded(sFuncName);
+ if (!hasAudio()) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ string("VideoNode.")+sFuncName+" failed: no audio stream.");
+ }
+}
+
+void VideoNode::exceptionIfUnloaded(const std::string& sFuncName) const
+{
+ if (m_VideoState == Unloaded) {
+ throw Exception(AVG_ERR_VIDEO_GENERAL,
+ string("VideoNode.")+sFuncName+" failed: video not loaded.");
+ }
+}
+
+static ProfilingZoneID PrerenderProfilingZone("VideoNode::prerender");
+
+void VideoNode::preRender()
+{
+ ScopeTimer timer(PrerenderProfilingZone);
+ Node::preRender();
+ if (isVisible()) {
+ if (m_VideoState != Unloaded) {
+ if (m_VideoState == Playing) {
+ bool bNewFrame = renderFrame();
+ m_bFrameAvailable |= bNewFrame;
+ } else { // Paused
+ if (!m_bFrameAvailable) {
+ m_bFrameAvailable = renderFrame();
+ }
+ }
+ m_bFirstFrameDecoded |= m_bFrameAvailable;
+ if (m_bFirstFrameDecoded) {
+ renderFX(getSize(), Pixel32(255, 255, 255, 255), false);
+ }
+ }
+ } else {
+ if (m_bSeekPending && m_bFirstFrameDecoded && m_VideoState != Unloaded) {
+ renderFrame();
+ }
+ if (m_VideoState == Playing) {
+ // Throw away frames that are not visible to make sure the video
+ // stays in sync.
+ m_pDecoder->throwAwayFrame(getNextFrameTime()/1000.0);
+
+ if (m_pDecoder->isEOF()) {
+ updateStatusDueToDecoderEOF();
+ }
+ }
+ }
+}
+
+static ProfilingZoneID RenderProfilingZone("VideoNode::render");
+
+void VideoNode::render(const DRect& rect)
+{
+ ScopeTimer timer(RenderProfilingZone);
+ if (m_VideoState != Unloaded && m_bFirstFrameDecoded) {
+ blt32(getSize(), getEffectiveOpacity(), getBlendMode());
+ }
+}
+
+VideoNode::VideoAccelType VideoNode::getVideoAccelConfig()
+{
+#ifdef AVG_ENABLE_VDPAU
+ if (VDPAU::isAvailable()) {
+ return VDPAU;
+ }
+#endif
+ return NONE;
+}
+
+bool VideoNode::renderFrame()
+{
+ FrameAvailableCode frameAvailable = renderToSurface();
+ if (m_pDecoder->isEOF()) {
+// AVG_TRACE(Logger::PROFILE, "------------------ EOF -----------------");
+ updateStatusDueToDecoderEOF();
+ if (m_bLoop) {
+ frameAvailable = renderToSurface();
+ }
+ }
+
+ switch (frameAvailable) {
+ case FA_NEW_FRAME:
+ m_FramesPlayed++;
+ m_FramesInRowTooLate = 0;
+ bind();
+ m_bSeekPending = false;
+ setMaskCoords();
+// AVG_TRACE(Logger::PROFILE, "New frame.");
+ break;
+ case FA_STILL_DECODING:
+ {
+ m_FramesPlayed++;
+ m_FramesTooLate++;
+ m_FramesInRowTooLate++;
+ double framerate = Player::get()->getEffectiveFramerate();
+ long long frameTime = Player::get()->getFrameTime();
+ if (m_VideoState == Playing) {
+ if (m_FramesInRowTooLate > 3 && framerate != 0) {
+ // Heuristic: If we've missed more than 3 frames in a row, we stop
+ // advancing movie time until the decoder has caught up.
+ m_PauseTime += (long long)(1000/framerate);
+ }
+ if (m_bSeekPending) {
+ // The movie time also stays still while waiting for a seek to
+ // complete.
+ m_PauseTime = frameTime-m_PauseStartTime;
+ }
+ long long curMovieTime =
+ Player::get()->getFrameTime()-m_StartTime-m_PauseTime;
+ if (curMovieTime < 0) {
+ cerr << "----------- curTime < 0 -------------" << endl;
+ cerr << "FramesPlayed=" << m_FramesPlayed << endl;
+ cerr << "getFrameTime()=" << Player::get()->getFrameTime()
+ << endl;
+ cerr << "m_StartTime=" << m_StartTime << endl;
+ cerr << "m_PauseTime=" << m_PauseTime << endl;
+ m_PauseTime = Player::get()->getFrameTime()-m_StartTime;
+ }
+ }
+ }
+// AVG_TRACE(Logger::PROFILE, "Missed video frame.");
+ break;
+ case FA_USE_LAST_FRAME:
+ m_FramesInRowTooLate = 0;
+ m_bSeekPending = false;
+// AVG_TRACE(Logger::PROFILE, "Video frame reused.");
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+
+ return (frameAvailable == FA_NEW_FRAME);
+ return false;
+}
+
+FrameAvailableCode VideoNode::renderToSurface()
+{
+ FrameAvailableCode frameAvailable;
+ PixelFormat pf = m_pDecoder->getPixelFormat();
+ std::vector<BitmapPtr> pBmps;
+ for (unsigned i=0; i<getNumPixelFormatPlanes(pf); ++i) {
+ pBmps.push_back(m_pTextures[i]->lockStreamingBmp());
+ }
+ if (pixelFormatIsPlanar(pf)) {
+ frameAvailable = m_pDecoder->renderToBmps(pBmps, getNextFrameTime()/1000.0);
+ } else {
+ frameAvailable = m_pDecoder->renderToBmp(pBmps[0], getNextFrameTime()/1000.0);
+ }
+ for (unsigned i=0; i<getNumPixelFormatPlanes(pf); ++i) {
+ m_pTextures[i]->unlockStreamingBmp(frameAvailable == FA_NEW_FRAME);
+ }
+
+ // Even with vsync, frame duration has a bit of jitter. If the video frames rendered
+ // are at the border of a frame's time, this can cause irregular display times.
+ // So, if we detect this condition, we adjust the frame time by a small fraction
+ // to move it towards the center of the time slot.
+ long long jitter = (long long)(getNextFrameTime()-m_pDecoder->getCurTime()*1000);
+ if (jitter > (long long)(0.4*(1000/m_pDecoder->getFPS()))) {
+ m_JitterCompensation += 0.05;
+ if (m_JitterCompensation > 1) {
+ m_JitterCompensation -= 1;
+ }
+ }
+ return frameAvailable;
+}
+
+void VideoNode::onEOF()
+{
+ if (m_pEOFCallback) {
+ PyObject * arglist = Py_BuildValue("()");
+ PyObject * result = PyEval_CallObject(m_pEOFCallback, arglist);
+ Py_DECREF(arglist);
+ if (!result) {
+ throw error_already_set();
+ }
+ Py_DECREF(result);
+ }
+}
+
+
+void VideoNode::updateStatusDueToDecoderEOF()
+{
+ m_bEOFPending = true;
+ if (m_bLoop) {
+ m_StartTime = Player::get()->getFrameTime();
+ m_JitterCompensation = 0.5;
+ m_PauseTime = 0;
+ m_FramesInRowTooLate = 0;
+ m_bFrameAvailable = false;
+ m_pDecoder->loop();
+ } else {
+ changeVideoState(Paused);
+ }
+}
+
+
+}
+
diff --git a/src/player/VideoNode.h b/src/player/VideoNode.h
new file mode 100644
index 0000000..e625e03
--- /dev/null
+++ b/src/player/VideoNode.h
@@ -0,0 +1,154 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoNode_H_
+#define _VideoNode_H_
+
+// Python docs say python.h should be included before any standard headers (!)
+#include "../api.h"
+#include "WrapPython.h"
+
+#include "Node.h"
+#include "RasterNode.h"
+
+#include "../base/Point.h"
+#include "../base/IFrameEndListener.h"
+#include "../base/UTF8String.h"
+
+#include "../audio/IAudioSource.h"
+#include "../video/VideoDecoder.h"
+
+namespace avg {
+
+class VideoDecoder;
+class TextureMover;
+typedef boost::shared_ptr<TextureMover> TextureMoverPtr;
+
+class AVG_API VideoNode: public RasterNode, IFrameEndListener, IAudioSource
+{
+ public:
+ enum VideoAccelType {NONE, VDPAU};
+
+ static NodeDefinition createDefinition();
+
+ VideoNode(const ArgList& args);
+ virtual ~VideoNode();
+
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+
+ void play();
+ void stop();
+ void pause();
+
+ const UTF8String& getHRef() const;
+ void setHRef(const UTF8String& href);
+ double getVolume();
+ void setVolume(double volume);
+ double getFPS() const;
+ int getQueueLength() const;
+ void checkReload();
+
+ int getNumFrames() const;
+ int getCurFrame() const;
+ int getNumFramesQueued() const;
+ void seekToFrame(int frameNum);
+ std::string getStreamPixelFormat() const;
+ long long getDuration() const;
+ int getBitrate() const;
+ std::string getVideoCodec() const;
+ std::string getAudioCodec() const;
+ int getAudioSampleRate() const;
+ int getNumAudioChannels() const;
+
+ long long getCurTime() const;
+ void seekToTime(long long time);
+ bool getLoop() const;
+ bool isThreaded() const;
+ bool hasAudio() const;
+ bool hasAlpha() const;
+ void setEOFCallback(PyObject * pEOFCallback);
+ bool isAccelerated() const;
+
+ virtual void render(const DRect& rect);
+ virtual void preRender();
+ virtual void onFrameEnd();
+
+ virtual int fillAudioBuffer(AudioBufferPtr pBuffer);
+ virtual IntPoint getMediaSize();
+
+ static VideoAccelType getVideoAccelConfig();
+
+ private:
+ bool renderFrame();
+ FrameAvailableCode renderToSurface();
+ void seek(long long destTime);
+ void onEOF();
+ void updateStatusDueToDecoderEOF();
+ void dumpFramesTooLate();
+
+ void open();
+ void startDecoding();
+ void createTextures(IntPoint size);
+ void close();
+ enum VideoState {Unloaded, Paused, Playing};
+ void changeVideoState(VideoState NewVideoState);
+ PixelFormat getPixelFormat() const;
+ long long getNextFrameTime() const;
+ void exceptionIfNoAudio(const std::string& sFuncName) const;
+ void exceptionIfUnloaded(const std::string& sFuncName) const;
+
+ VideoState m_VideoState;
+
+ bool m_bFrameAvailable;
+ bool m_bFirstFrameDecoded;
+
+ UTF8String m_href;
+ std::string m_Filename;
+ bool m_bLoop;
+ bool m_bThreaded;
+ double m_FPS;
+ int m_QueueLength;
+ bool m_bEOFPending;
+ PyObject * m_pEOFCallback;
+ int m_FramesTooLate;
+ int m_FramesInRowTooLate;
+ int m_FramesPlayed;
+ bool m_bSeekPending;
+ long long m_SeekBeforeCanRenderTime;
+
+ long long m_StartTime;
+ long long m_PauseTime;
+ long long m_PauseStartTime;
+ double m_JitterCompensation;
+
+ VideoDecoder * m_pDecoder;
+ double m_Volume;
+ bool m_bUsesHardwareAcceleration;
+
+ GLTexturePtr m_pTextures[4];
+};
+
+}
+
+#endif
+
diff --git a/src/player/VideoWriter.cpp b/src/player/VideoWriter.cpp
new file mode 100644
index 0000000..c2c39e9
--- /dev/null
+++ b/src/player/VideoWriter.cpp
@@ -0,0 +1,255 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VideoWriter.h"
+#include "OffscreenCanvas.h"
+#include "Player.h"
+#include "SDLDisplayEngine.h"
+
+#include "../graphics/FBO.h"
+#include "../graphics/GPURGB2YUVFilter.h"
+#include "../graphics/Filterfill.h"
+#include "../base/StringHelper.h"
+
+#include <boost/bind.hpp>
+
+#include <fcntl.h>
+#include <stdio.h>
+
+using namespace std;
+using namespace boost;
+
+namespace avg {
+
+VideoWriter::VideoWriter(CanvasPtr pCanvas, const string& sOutFileName, int frameRate,
+ int qMin, int qMax, bool bSyncToPlayback)
+ : m_pCanvas(pCanvas),
+ m_sOutFileName(sOutFileName),
+ m_FrameRate(frameRate),
+ m_QMin(qMin),
+ m_QMax(qMax),
+ m_bHasValidData(false),
+ m_bSyncToPlayback(bSyncToPlayback),
+ m_bPaused(false),
+ m_PauseTime(0),
+ m_bStopped(false),
+ m_CurFrame(0),
+ m_StartTime(-1),
+ m_bFramePending(false)
+{
+ m_FrameSize = m_pCanvas->getSize();
+#ifdef WIN32
+ int fd = _open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, _S_IREAD | _S_IWRITE);
+#elif defined linux
+ int fd = open64(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
+#else
+ int fd = open(m_sOutFileName.c_str(), O_RDWR | O_CREAT, S_IRWXU);
+#endif
+ if (fd == -1) {
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ string("Could not open output file '") + m_sOutFileName + "'. Reason: " +
+ strerror(errno));
+ }
+#ifdef WIN32
+ _close(fd);
+#else
+ close(fd);
+#endif
+ remove(m_sOutFileName.c_str());
+ CanvasPtr pMainCanvas = Player::get()->getMainCanvas();
+ if (pMainCanvas != m_pCanvas) {
+ m_pFBO = dynamic_pointer_cast<OffscreenCanvas>(m_pCanvas)->getFBO();
+ m_pCanvas->registerPreRenderListener(this);
+ if (GLContext::getCurrent()->isUsingShaders()) {
+ m_pFilter = GPURGB2YUVFilterPtr(new GPURGB2YUVFilter(m_FrameSize));
+ }
+ }
+ VideoWriterThread writer(m_CmdQueue, m_sOutFileName, m_FrameSize, m_FrameRate,
+ qMin, qMax);
+ m_pThread = new boost::thread(writer);
+ m_pCanvas->registerPlaybackEndListener(this);
+ m_pCanvas->registerFrameEndListener(this);
+}
+
+VideoWriter::~VideoWriter()
+{
+ stop();
+ m_pThread->join();
+ delete m_pThread;
+}
+
+void VideoWriter::stop()
+{
+ if (!m_bStopped) {
+ getFrameFromPBO();
+ if (!m_bHasValidData) {
+ writeDummyFrame();
+ }
+
+ m_bStopped = true;
+ m_CmdQueue.pushCmd(boost::bind(&VideoWriterThread::stop, _1));
+
+ m_pCanvas->unregisterFrameEndListener(this);
+ m_pCanvas->unregisterPlaybackEndListener(this);
+ if (m_pFBO) {
+ m_pCanvas->unregisterPreRenderListener(this);
+ }
+ }
+}
+
+void VideoWriter::pause()
+{
+ if (m_bPaused) {
+ throw Exception(AVG_ERR_UNSUPPORTED, "VideoWriter::pause() called when paused.");
+ }
+ if (m_bStopped) {
+ throw Exception(AVG_ERR_UNSUPPORTED, "VideoWriter::pause() called when stopped.");
+ }
+ m_bPaused = true;
+ m_PauseStartTime = Player::get()->getFrameTime();
+}
+
+void VideoWriter::play()
+{
+ if (!m_bPaused) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "VideoWriter::play() called when not paused.");
+ }
+ m_bPaused = false;
+ m_PauseTime += (Player::get()->getFrameTime() - m_PauseStartTime);
+}
+
+std::string VideoWriter::getFileName() const
+{
+ return m_sOutFileName;
+}
+
+int VideoWriter::getFramerate() const
+{
+ return m_FrameRate;
+}
+
+int VideoWriter::getQMin() const
+{
+ return m_QMin;
+}
+
+int VideoWriter::getQMax() const
+{
+ return m_QMax;
+}
+
+void VideoWriter::onFrameEnd()
+{
+ // The VideoWriter handles OffscreenCanvas and MainCanvas differently:
+ // For MainCanvas, it simply does a screenshot onFrameEnd and sends that to the
+ // VideoWriterThread immediately.
+ // For OffscreenCanvas, an asynchronous PBO readback is started in onFrameEnd.
+ // In the next frame's onPreRender, the data is read into a bitmap and sent to
+ // the VideoWriterThread.
+ if (m_StartTime == -1) {
+ m_StartTime = Player::get()->getFrameTime();
+ }
+ if (!m_bPaused) {
+ if (m_bSyncToPlayback) {
+ getFrameFromFBO();
+ } else {
+ long long movieTime = Player::get()->getFrameTime() - m_StartTime
+ - m_PauseTime;
+ double timePerFrame = 1000./m_FrameRate;
+ int wantedFrame = int(movieTime/timePerFrame+0.1);
+ if (wantedFrame > m_CurFrame) {
+ getFrameFromFBO();
+ if (wantedFrame > m_CurFrame + 1) {
+ m_CurFrame = wantedFrame - 1;
+ }
+ }
+ }
+ }
+
+ if (!m_pFBO) {
+ getFrameFromPBO();
+ }
+}
+
+void VideoWriter::onPreRender()
+{
+ getFrameFromPBO();
+}
+
+void VideoWriter::getFrameFromFBO()
+{
+ if (m_pFBO) {
+ if (m_pFilter) {
+ glMatrixMode(GL_MODELVIEW);
+ glPushMatrix();
+ m_pFilter->apply(m_pFBO->getTex());
+ FBOPtr pYUVFBO = m_pFilter->getFBO();
+ pYUVFBO->moveToPBO();
+ glPopMatrix();
+ } else {
+ m_pFBO->moveToPBO();
+ }
+ m_bFramePending = true;
+ } else {
+ BitmapPtr pBmp = Player::get()->getDisplayEngine()->screenshot(GL_BACK);
+ sendFrameToEncoder(pBmp);
+ }
+}
+
+void VideoWriter::getFrameFromPBO()
+{
+ if (m_bFramePending) {
+ BitmapPtr pBmp;
+ if (m_pFilter) {
+ pBmp = m_pFilter->getFBO()->getImageFromPBO();
+ } else {
+ pBmp = m_pFBO->getImageFromPBO();
+ }
+ sendFrameToEncoder(pBmp);
+ m_bFramePending = false;
+ }
+}
+
+void VideoWriter::sendFrameToEncoder(BitmapPtr pBitmap)
+{
+ m_CurFrame++;
+ m_bHasValidData = true;
+ if (m_pFilter) {
+ m_CmdQueue.pushCmd(boost::bind(&VideoWriterThread::encodeYUVFrame, _1, pBitmap));
+ } else {
+ m_CmdQueue.pushCmd(boost::bind(&VideoWriterThread::encodeFrame, _1, pBitmap));
+ }
+}
+
+void VideoWriter::onPlaybackEnd()
+{
+ stop();
+}
+
+void VideoWriter::writeDummyFrame()
+{
+ BitmapPtr pBmp = BitmapPtr(new Bitmap(m_FrameSize, B8G8R8X8));
+ FilterFill<Pixel32>(Pixel32(0,0,0,255)).applyInPlace(pBmp);
+ sendFrameToEncoder(pBmp);
+}
+
+}
diff --git a/src/player/VideoWriter.h b/src/player/VideoWriter.h
new file mode 100644
index 0000000..c372991
--- /dev/null
+++ b/src/player/VideoWriter.h
@@ -0,0 +1,102 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoWriter_H_
+#define _VideoWriter_H_
+
+#include "../api.h"
+
+#include "VideoWriterThread.h"
+
+#include "../base/IFrameEndListener.h"
+#include "../base/IPlaybackEndListener.h"
+#include "../base/IPreRenderListener.h"
+#include "../base/Point.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
+#include <string>
+
+namespace avg {
+
+class Canvas;
+typedef boost::shared_ptr<Canvas> CanvasPtr;
+class FBO;
+typedef boost::shared_ptr<FBO> FBOPtr;
+class GPURGB2YUVFilter;
+typedef boost::shared_ptr<GPURGB2YUVFilter> GPURGB2YUVFilterPtr;
+
+class AVG_API VideoWriter : public IFrameEndListener, IPreRenderListener,
+ IPlaybackEndListener
+{
+ public:
+ VideoWriter(CanvasPtr pCanvas, const std::string& sOutFileName,
+ int frameRate=30, int qMin=3, int qMax=5, bool bSyncToPlayback=true);
+ virtual ~VideoWriter();
+ void stop();
+ void pause();
+ void play();
+
+ std::string getFileName() const;
+ int getFramerate() const;
+ int getQMin() const;
+ int getQMax() const;
+
+ virtual void onFrameEnd();
+ virtual void onPreRender();
+ virtual void onPlaybackEnd();
+
+ private:
+ void getFrameFromFBO();
+ void getFrameFromPBO();
+
+ void sendFrameToEncoder(BitmapPtr pBitmap);
+ void writeDummyFrame();
+
+ CanvasPtr m_pCanvas;
+ FBOPtr m_pFBO;
+ GPURGB2YUVFilterPtr m_pFilter;
+ std::string m_sOutFileName;
+ int m_FrameRate;
+ int m_QMin;
+ int m_QMax;
+ IntPoint m_FrameSize;
+
+ bool m_bHasValidData;
+
+ VideoWriterThread::CQueue m_CmdQueue;
+ boost::thread* m_pThread;
+ bool m_bSyncToPlayback;
+
+ bool m_bPaused;
+ long long m_PauseStartTime;
+ long long m_PauseTime;
+
+ bool m_bStopped;
+
+ int m_CurFrame;
+ long long m_StartTime;
+ bool m_bFramePending;
+};
+
+}
+#endif
diff --git a/src/player/VideoWriterThread.cpp b/src/player/VideoWriterThread.cpp
new file mode 100644
index 0000000..3bb9a32
--- /dev/null
+++ b/src/player/VideoWriterThread.cpp
@@ -0,0 +1,326 @@
+
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VideoWriterThread.h"
+
+#include "../base/ProfilingZone.h"
+#include "../base/ScopeTimer.h"
+#include "../base/StringHelper.h"
+
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+#include <libavutil/mathematics.h>
+#endif
+
+using namespace std;
+
+namespace avg {
+
+const unsigned int VIDEO_BUFFER_SIZE = 400000;
+const ::PixelFormat STREAM_PIXEL_FORMAT = ::PIX_FMT_YUVJ420P;
+
+VideoWriterThread::VideoWriterThread(CQueue& CmdQueue, const string& sFilename,
+ IntPoint size, int frameRate, int qMin, int qMax)
+ : WorkerThread<VideoWriterThread>(sFilename, CmdQueue, Logger::PROFILE),
+ m_sFilename(sFilename),
+ m_Size(size),
+ m_FrameRate(frameRate),
+ m_QMin(qMin),
+ m_QMax(qMax),
+ m_pOutputFormatContext()
+{
+}
+
+VideoWriterThread::~VideoWriterThread()
+{
+}
+
+static ProfilingZoneID ProfilingZoneEncodeFrame("Encode frame");
+
+void VideoWriterThread::encodeYUVFrame(BitmapPtr pBmp)
+{
+ ScopeTimer timer(ProfilingZoneEncodeFrame);
+ convertYUVImage(pBmp);
+ writeFrame(m_pConvertedFrame);
+ ThreadProfiler::get()->reset();
+}
+
+void VideoWriterThread::encodeFrame(BitmapPtr pBmp)
+{
+ ScopeTimer timer(ProfilingZoneEncodeFrame);
+ convertRGBImage(pBmp);
+ writeFrame(m_pConvertedFrame);
+ ThreadProfiler::get()->reset();
+}
+
+void VideoWriterThread::close()
+{
+ if (m_pOutputFormatContext) {
+ av_write_trailer(m_pOutputFormatContext);
+ avcodec_close(m_pVideoStream->codec);
+
+ for (unsigned int i=0; i<m_pOutputFormatContext->nb_streams; i++) {
+ AVStream* pStream = m_pOutputFormatContext->streams[i];
+
+ pStream->discard = AVDISCARD_ALL;
+ av_freep(&m_pOutputFormatContext->streams[i]->codec);
+ av_freep(&m_pOutputFormatContext->streams[i]);
+ }
+
+ if (!(m_pOutputFormat->flags & AVFMT_NOFILE)) {
+ url_fclose(m_pOutputFormatContext->pb);
+ }
+
+ av_free(m_pOutputFormatContext);
+ av_free(m_pVideoBuffer);
+ av_free(m_pConvertedFrame);
+ av_free(m_pPictureBuffer);
+ sws_freeContext(m_pFrameConversionContext);
+ m_pOutputFormatContext = 0;
+ }
+}
+
+bool VideoWriterThread::init()
+{
+ open();
+ return true;
+}
+
+bool VideoWriterThread::work()
+{
+ waitForCommand();
+ return true;
+}
+
+void VideoWriterThread::deinit()
+{
+ close();
+}
+
+void VideoWriterThread::open()
+{
+ av_register_all(); // TODO: make sure this is only done once.
+// av_log_set_level(AV_LOG_DEBUG);
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ m_pOutputFormat = av_guess_format("mov", NULL, NULL);
+#else
+ m_pOutputFormat = guess_format("mov", NULL, NULL);
+#endif
+ m_pOutputFormat->video_codec = CODEC_ID_MJPEG;
+
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 24, 0)
+ m_pOutputFormatContext = avformat_alloc_context();
+#else
+ m_pOutputFormatContext = av_alloc_format_context();
+#endif
+ m_pOutputFormatContext->oformat = m_pOutputFormat;
+
+ strncpy(m_pOutputFormatContext->filename, m_sFilename.c_str(),
+ sizeof(m_pOutputFormatContext->filename));
+
+ if (m_pOutputFormat->video_codec != CODEC_ID_NONE) {
+ setupVideoStream();
+ }
+#if LIBAVFORMAT_VERSION_MAJOR < 52
+ av_set_parameters(m_pOutputFormatContext, NULL);
+#endif
+
+ double muxPreload = 0.5;
+ double muxMaxDelay = 0.7;
+ m_pOutputFormatContext->preload = int(muxPreload * AV_TIME_BASE);
+ m_pOutputFormatContext->max_delay = int(muxMaxDelay * AV_TIME_BASE);
+
+// av_dump_format(m_pOutputFormatContext, 0, m_sFilename.c_str(), 1);
+
+ openVideoCodec();
+
+ m_pVideoBuffer = NULL;
+ if (!(m_pOutputFormatContext->oformat->flags & AVFMT_RAWPICTURE)) {
+ m_pVideoBuffer = (unsigned char*)(av_malloc(VIDEO_BUFFER_SIZE));
+ }
+
+ if (!(m_pOutputFormat->flags & AVFMT_NOFILE)) {
+ int retVal = url_fopen(&m_pOutputFormatContext->pb, m_sFilename.c_str(),
+ URL_WRONLY);
+ if (retVal < 0) {
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ string("Could not open output file: '") + m_sFilename + "'");
+ }
+ }
+
+ m_pFrameConversionContext = sws_getContext(m_Size.x, m_Size.y,
+ ::PIX_FMT_RGB32, m_Size.x, m_Size.y, STREAM_PIXEL_FORMAT,
+ SWS_BILINEAR, NULL, NULL, NULL);
+
+ m_pConvertedFrame = createFrame(STREAM_PIXEL_FORMAT, m_Size);
+
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ avformat_write_header(m_pOutputFormatContext, 0);
+#else
+ av_write_header(m_pOutputFormatContext);
+#endif
+}
+
+void VideoWriterThread::setupVideoStream()
+{
+ m_pVideoStream = av_new_stream(m_pOutputFormatContext, 0);
+
+ AVCodecContext* pCodecContext = m_pVideoStream->codec;
+ pCodecContext->codec_id = static_cast<CodecID>(m_pOutputFormat->video_codec);
+ pCodecContext->codec_type = AVMEDIA_TYPE_VIDEO;
+
+ /* put sample parameters */
+ pCodecContext->bit_rate = 400000;
+ /* resolution must be a multiple of two */
+ pCodecContext->width = m_Size.x;
+ pCodecContext->height = m_Size.y;
+ /* time base: this is the fundamental unit of time (in seconds) in terms
+ of which frame timestamps are represented. for fixed-fps content,
+ timebase should be 1/framerate and timestamp increments should be
+ identically 1. */
+ pCodecContext->time_base.den = m_FrameRate;
+ pCodecContext->time_base.num = 1;
+// pCodecContext->gop_size = 12; /* emit one intra frame every twelve frames at most */
+ pCodecContext->pix_fmt = STREAM_PIXEL_FORMAT;
+ // Quality of quantization
+ pCodecContext->qmin = m_QMin;
+ pCodecContext->qmax = m_QMax;
+ // some formats want stream headers to be separate
+ if (m_pOutputFormatContext->oformat->flags & AVFMT_GLOBALHEADER) {
+ pCodecContext->flags |= CODEC_FLAG_GLOBAL_HEADER;
+ }
+ m_FramesWritten = 0;
+}
+
+void VideoWriterThread::openVideoCodec()
+{
+ AVCodec* videoCodec = avcodec_find_encoder(m_pVideoStream->codec->codec_id);
+ AVG_ASSERT(videoCodec);
+
+ int rc = avcodec_open(m_pVideoStream->codec, videoCodec);
+ AVG_ASSERT(rc == 0);
+}
+
+AVFrame* VideoWriterThread::createFrame(::PixelFormat pixelFormat, IntPoint size)
+{
+ AVFrame* pPicture;
+
+ pPicture = avcodec_alloc_frame();
+
+ int memNeeded = avpicture_get_size(pixelFormat, size.x, size.y);
+ m_pPictureBuffer = static_cast<unsigned char*>(av_malloc(memNeeded));
+ avpicture_fill(reinterpret_cast<AVPicture*>(pPicture),
+ m_pPictureBuffer, pixelFormat, size.x, size.y);
+
+ return pPicture;
+}
+
+static ProfilingZoneID ProfilingZoneConvertImage(" Convert image");
+
+void VideoWriterThread::convertRGBImage(BitmapPtr pSrcBmp)
+{
+ ScopeTimer timer(ProfilingZoneConvertImage);
+ unsigned char* rgbData[3] = {pSrcBmp->getPixels(), NULL, NULL};
+ int rgbStride[3] = {pSrcBmp->getLineLen(), 0, 0};
+
+ sws_scale(m_pFrameConversionContext, rgbData, rgbStride,
+ 0, m_Size.y, m_pConvertedFrame->data, m_pConvertedFrame->linesize);
+}
+
+void VideoWriterThread::convertYUVImage(BitmapPtr pSrcBmp)
+{
+ ScopeTimer timer(ProfilingZoneConvertImage);
+ IntPoint size = pSrcBmp->getSize();
+ BitmapPtr pYBmp(new Bitmap(size, I8, m_pConvertedFrame->data[0],
+ m_pConvertedFrame->linesize[0], false));
+ BitmapPtr pUBmp(new Bitmap(size/2, I8, m_pConvertedFrame->data[1],
+ m_pConvertedFrame->linesize[1], false));
+ BitmapPtr pVBmp(new Bitmap(size/2, I8, m_pConvertedFrame->data[2],
+ m_pConvertedFrame->linesize[2], false));
+ for (int y=0; y<size.y/2; ++y) {
+ int srcStride = pSrcBmp->getStride();
+ const unsigned char * pSrc = pSrcBmp->getPixels() + y*srcStride*2;
+ int yStride = pYBmp->getStride();
+ unsigned char * pYDest = pYBmp->getPixels() + y*yStride*2;
+ unsigned char * pUDest = pUBmp->getPixels() + y*pUBmp->getStride();
+ unsigned char * pVDest = pVBmp->getPixels() + y*pVBmp->getStride();
+ for (int x=0; x<size.x/2; ++x) {
+ *pYDest = *pSrc;
+ *(pYDest+1) = *(pSrc+4);
+ *(pYDest+yStride) = *(pSrc+srcStride);
+ *(pYDest+yStride+1) = *(pSrc+srcStride+4);
+
+ *pUDest = ((int)*(pSrc+1) + *(pSrc+5) +
+ *(pSrc+srcStride+1) + *(pSrc+srcStride+5) + 2)/4;
+
+ *pVDest = ((int)*(pSrc+2) + *(pSrc+6) +
+ *(pSrc+srcStride+2) + *(pSrc+srcStride+6) + 2)/4;
+
+ pSrc += 8;
+ pYDest += 2;
+ pUDest += 1;
+ pVDest += 1;
+ }
+ }
+// pSrcBmp->save("src"+toString(m_FramesWritten)+".png");
+// pUBmp->save("foo"+toString(m_FramesWritten)+".png");
+}
+
+static ProfilingZoneID ProfilingZoneWriteFrame(" Write frame");
+
+void VideoWriterThread::writeFrame(AVFrame* pFrame)
+{
+ ScopeTimer timer(ProfilingZoneWriteFrame);
+ m_FramesWritten++;
+ AVCodecContext* pCodecContext = m_pVideoStream->codec;
+ int out_size = avcodec_encode_video(pCodecContext, m_pVideoBuffer,
+ VIDEO_BUFFER_SIZE, pFrame);
+
+ /* if zero size, it means the image was buffered */
+ if (out_size > 0) {
+ AVPacket packet;
+ av_init_packet(&packet);
+
+ if ((unsigned long long)(pCodecContext->coded_frame->pts) != AV_NOPTS_VALUE) {
+ packet.pts = av_rescale_q(pCodecContext->coded_frame->pts,
+ pCodecContext->time_base, m_pVideoStream->time_base);
+ }
+
+ if (pCodecContext->coded_frame->key_frame) {
+#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 31, 0)
+ packet.flags |= AV_PKT_FLAG_KEY;
+#else
+ packet.flags |= PKT_FLAG_KEY;
+#endif
+ }
+ packet.stream_index = m_pVideoStream->index;
+ packet.data = m_pVideoBuffer;
+ packet.size = out_size;
+
+ /* write the compressed frame in the media file */
+ int ret = av_interleaved_write_frame(m_pOutputFormatContext, &packet);
+ AVG_ASSERT(ret == 0);
+ }
+
+}
+
+}
+
diff --git a/src/player/VideoWriterThread.h b/src/player/VideoWriterThread.h
new file mode 100644
index 0000000..6d61c6d
--- /dev/null
+++ b/src/player/VideoWriterThread.h
@@ -0,0 +1,85 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoWriterThread_H_
+#define _VideoWriterThread_H_
+
+#include "../api.h"
+
+#include "../base/WorkerThread.h"
+#include "../graphics/Bitmap.h"
+#include "../video/WrapFFMpeg.h"
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
+
+#include <string>
+
+namespace avg {
+
+class AVG_API VideoWriterThread : public WorkerThread<VideoWriterThread> {
+ public:
+ VideoWriterThread(CQueue& CmdQueue, const std::string& sFilename, IntPoint size,
+ int frameRate, int qMin, int qMax);
+ virtual ~VideoWriterThread();
+
+ void encodeYUVFrame(BitmapPtr pBmp);
+ void encodeFrame(BitmapPtr pBmp);
+ void close();
+
+ private:
+ bool init();
+ void open();
+
+ // Called by base class
+ virtual bool work();
+ virtual void deinit();
+
+ void setupVideoStream();
+ void openVideoCodec();
+
+ AVFrame* createFrame(::PixelFormat pixelFormat, IntPoint size);
+
+ void convertRGBImage(BitmapPtr pSrcBmp);
+ void convertYUVImage(BitmapPtr pSrcBmp);
+ void writeFrame(AVFrame* pFrame);
+
+ std::string m_sFilename;
+ IntPoint m_Size;
+ int m_FrameRate;
+ int m_QMin;
+ int m_QMax;
+
+ AVOutputFormat* m_pOutputFormat;
+ AVFormatContext* m_pOutputFormatContext;
+ AVStream* m_pVideoStream;
+ SwsContext* m_pFrameConversionContext;
+ AVFrame* m_pConvertedFrame;
+ unsigned char* m_pPictureBuffer;
+ unsigned char* m_pVideoBuffer;
+ int m_VideoBufferSize;
+ PixelFormat m_StreamPixelFormat;
+ int m_FramesWritten;
+};
+
+}
+#endif
diff --git a/src/player/WordsNode.cpp b/src/player/WordsNode.cpp
new file mode 100644
index 0000000..be20edb
--- /dev/null
+++ b/src/player/WordsNode.cpp
@@ -0,0 +1,851 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WordsNode.h"
+#include "OGLSurface.h"
+#include "NodeDefinition.h"
+#include "TextEngine.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../base/XMLHelper.h"
+#include "../base/StringHelper.h"
+#include "../base/MathHelper.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/Filterfill.h"
+#include "../graphics/GLContext.h"
+#include "../graphics/GLTexture.h"
+#include "../graphics/TextureMover.h"
+
+#include <pango/pangoft2.h>
+
+#include <iostream>
+#include <algorithm>
+
+using namespace std;
+
+namespace avg {
+
+NodeDefinition WordsNode::createDefinition()
+{
+ static const string sDTDElements =
+ "<!ELEMENT span (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ATTLIST span\n"
+ " font_desc CDATA #IMPLIED\n"
+ " font_family CDATA #IMPLIED\n"
+ " face CDATA #IMPLIED\n"
+ " size CDATA #IMPLIED\n"
+ " style CDATA #IMPLIED\n"
+ " weight CDATA #IMPLIED\n"
+ " variant CDATA #IMPLIED\n"
+ " stretch CDATA #IMPLIED\n"
+ " foreground CDATA #IMPLIED\n"
+ " background CDATA #IMPLIED\n"
+ " underline CDATA #IMPLIED\n"
+ " rise CDATA #IMPLIED\n"
+ " strikethrough CDATA #IMPLIED\n"
+ " fallback CDATA #IMPLIED\n"
+ " lang CDATA #IMPLIED\n"
+ " letter_spacing CDATA #IMPLIED\n"
+ " rawtextmode CDATA #IMPLIED >\n"
+
+ "<!ELEMENT b (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT big (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT i (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT s (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT sub (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT sup (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT small (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT tt (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT u (#PCDATA|span|b|big|i|s|sub|sup|small|tt|u)*>\n"
+ "<!ELEMENT br (#PCDATA)*>\n";
+
+ string sChildArray[] = {"#PCDATA", "span", "b", "big", "i", "s", "sup", "sub",
+ "small", "tt", "u", "br"};
+ vector<string> sChildren = vectorFromCArray(sizeof(sChildArray)/sizeof(*sChildArray),
+ sChildArray);
+ return NodeDefinition("words", Node::buildNode<WordsNode>)
+ .extendDefinition(RasterNode::createDefinition())
+ .addChildren(sChildren)
+ .addDTDElements(sDTDElements)
+ .addArg(Arg<string>("font", "arial", false, offsetof(WordsNode, m_sFontName)))
+ .addArg(Arg<string>("variant", "", false, offsetof(WordsNode, m_sFontVariant)))
+ .addArg(Arg<UTF8String>("text", ""))
+ .addArg(Arg<string>("color", "FFFFFF", false, offsetof(WordsNode, m_sColorName)))
+ .addArg(Arg<double>("fontsize", 15, false, offsetof(WordsNode, m_FontSize)))
+ .addArg(Arg<int>("indent", 0, false, offsetof(WordsNode, m_Indent)))
+ .addArg(Arg<double>("linespacing", -1, false, offsetof(WordsNode, m_LineSpacing)))
+ .addArg(Arg<string>("alignment", "left"))
+ .addArg(Arg<string>("wrapmode", "word"))
+ .addArg(Arg<bool>("justify", false, false, offsetof(WordsNode, m_bJustify)))
+ .addArg(Arg<bool>("rawtextmode", false, false,
+ offsetof(WordsNode, m_bRawTextMode)))
+ .addArg(Arg<double>("letterspacing", 0, false,
+ offsetof(WordsNode, m_LetterSpacing)))
+ .addArg(Arg<bool>("hint", true, false, offsetof(WordsNode, m_bHint)))
+ ;
+}
+
+WordsNode::WordsNode(const ArgList& args)
+ : m_LogicalSize(0,0),
+ m_pFontDescription(0),
+ m_pLayout(0),
+ m_RedrawState(FONT_CHANGED)
+{
+ m_bParsedText = false;
+
+ args.setMembers(this);
+ setAlignment(args.getArgVal<string>("alignment"));
+ setWrapMode(args.getArgVal<string>("wrapmode"));
+ setText(args.getArgVal<UTF8String>("text"));
+ m_Color = colorStringToColor(m_sColorName);
+ setViewport(-32767, -32767, -32767, -32767);
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+WordsNode::~WordsNode()
+{
+ if (m_pFontDescription) {
+ pango_font_description_free(m_pFontDescription);
+ }
+ if (m_pLayout) {
+ g_object_unref(m_pLayout);
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void WordsNode::setTextFromNodeValue(const string& sText)
+{
+ // Gives priority to Node Values only if they aren't empty
+ UTF8String sTemp = removeExcessSpaces(sText);
+ if (sTemp.length() != 0) {
+ setText(sText);
+ }
+}
+
+void WordsNode::connectDisplay()
+{
+ RasterNode::connectDisplay();
+ setDirty(FONT_CHANGED);
+}
+
+void WordsNode::connect(CanvasPtr pCanvas)
+{
+ RasterNode::connect(pCanvas);
+ checkReload();
+}
+
+void WordsNode::disconnect(bool bKill)
+{
+ if (m_pFontDescription) {
+ pango_font_description_free(m_pFontDescription);
+ m_pFontDescription = 0;
+ setDirty(FONT_CHANGED);
+ }
+ RasterNode::disconnect(bKill);
+}
+
+string WordsNode::getAlignment() const
+{
+ switch(m_Alignment) {
+ case PANGO_ALIGN_LEFT:
+ return "left";
+ case PANGO_ALIGN_CENTER:
+ return "center";
+ case PANGO_ALIGN_RIGHT:
+ return "right";
+ default:
+ AVG_ASSERT(false);
+ return "";
+ }
+}
+
+void WordsNode::setAlignment(const string& sAlign)
+{
+ if (sAlign == "left") {
+ m_Alignment = PANGO_ALIGN_LEFT;
+ } else if (sAlign == "center") {
+ m_Alignment = PANGO_ALIGN_CENTER;
+ } else if (sAlign == "right") {
+ m_Alignment = PANGO_ALIGN_RIGHT;
+ } else {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "WordsNode alignment "+sAlign+" not supported."));
+ }
+
+ setDirty(LAYOUT_CHANGED);
+}
+
+bool WordsNode::getJustify() const
+{
+ return m_bJustify;
+}
+
+void WordsNode::setJustify(bool bJustify)
+{
+ m_bJustify = bJustify;
+ setDirty(LAYOUT_CHANGED);
+}
+
+double WordsNode::getLetterSpacing() const
+{
+ return m_LetterSpacing;
+}
+
+void WordsNode::setLetterSpacing(double letterSpacing)
+{
+ m_LetterSpacing = letterSpacing;
+ setDirty(LAYOUT_CHANGED);
+}
+
+bool WordsNode::getHint() const
+{
+ return m_bHint;
+}
+
+void WordsNode::setHint(bool bHint)
+{
+ setDirty(LAYOUT_CHANGED);
+ m_bHint = bHint;
+}
+
+double WordsNode::getWidth() const
+{
+ const_cast<WordsNode*>(this)->updateLayout();
+ return AreaNode::getWidth();
+}
+
+void WordsNode::setWidth(double width)
+{
+ setDirty(LAYOUT_CHANGED);
+ AreaNode::setWidth(width);
+}
+
+double WordsNode::getHeight() const
+{
+ const_cast<WordsNode*>(this)->updateLayout();
+ return AreaNode::getHeight();
+}
+
+void WordsNode::setHeight(double width)
+{
+ setDirty(LAYOUT_CHANGED);
+ AreaNode::setHeight(width);
+}
+
+DPoint WordsNode::getSize() const
+{
+ const_cast<WordsNode*>(this)->updateLayout();
+ return AreaNode::getSize();
+}
+
+void WordsNode::setSize(const DPoint& pt)
+{
+ setDirty(LAYOUT_CHANGED);
+ AreaNode::setSize(pt);
+}
+
+void WordsNode::getElementsByPos(const DPoint& pos, vector<NodeWeakPtr>& pElements)
+{
+ updateLayout();
+ DPoint relPos = pos-DPoint(m_AlignOffset, 0);
+ AreaNode::getElementsByPos(relPos, pElements);
+}
+
+const std::string& WordsNode::getFont() const
+{
+ return m_sFontName;
+}
+
+void WordsNode::setFont(const std::string& sName)
+{
+ m_sFontName = sName;
+ setDirty(FONT_CHANGED);
+}
+
+const std::string& WordsNode::getFontVariant() const
+{
+ return m_sFontVariant;
+}
+
+void WordsNode::addFontDir(const std::string& sDir)
+{
+ TextEngine::get(true).addFontDir(sDir);
+ TextEngine::get(false).addFontDir(sDir);
+}
+
+void WordsNode::setFontVariant(const std::string& sVariant)
+{
+ m_sFontVariant = sVariant;
+ setDirty(FONT_CHANGED);
+}
+
+const UTF8String& WordsNode::getText() const
+{
+ return m_sRawText;
+}
+
+void WordsNode::setText(const UTF8String& sText)
+{
+ if (sText.length() > 32767) {
+ throw(Exception(AVG_ERR_INVALID_ARGS,
+ string("WordsNode::setText: string too long (")
+ + toString(sText.length()) + ")"));
+ }
+ if (m_sRawText != sText) {
+ m_sRawText = sText;
+ m_sText = m_sRawText;
+ if (m_bRawTextMode) {
+ m_bParsedText = false;
+ } else {
+ setParsedText(sText);
+ }
+ setDirty(LAYOUT_CHANGED);
+ }
+}
+
+const std::string& WordsNode::getColor() const
+{
+ return m_sColorName;
+}
+
+void WordsNode::setColor(const string& sColor)
+{
+ m_sColorName = sColor;
+ m_Color = colorStringToColor(m_sColorName);
+ setDirty(RENDER_NEEDED);
+}
+
+double WordsNode::getFontSize() const
+{
+ return m_FontSize;
+}
+
+void WordsNode::setFontSize(double size)
+{
+ if (size <= 1) {
+ throw Exception(AVG_ERR_INVALID_ARGS, "Words node: Font size < 1 is illegal.");
+ }
+ m_FontSize = size;
+ setDirty(FONT_CHANGED);
+}
+
+int WordsNode::getIndent() const
+{
+ return m_Indent;
+}
+
+void WordsNode::setIndent(int indent)
+{
+ m_Indent = indent;
+ setDirty(LAYOUT_CHANGED);
+}
+
+double WordsNode::getLineSpacing() const
+{
+ return m_LineSpacing;
+}
+
+void WordsNode::setLineSpacing(double lineSpacing)
+{
+ m_LineSpacing = lineSpacing;
+ setDirty(LAYOUT_CHANGED);
+}
+
+bool WordsNode::getRawTextMode() const
+{
+ return m_bRawTextMode;
+}
+
+void WordsNode::setRawTextMode(bool rawTextMode)
+{
+ if (rawTextMode != m_bRawTextMode) {
+ m_sText = m_sRawText;
+ if (rawTextMode) {
+ m_bParsedText = false;
+ } else {
+ setParsedText(m_sText);
+ }
+ m_bRawTextMode = rawTextMode;
+ setDirty(LAYOUT_CHANGED);
+ }
+}
+
+DPoint WordsNode::getGlyphPos(int i)
+{
+ PangoRectangle rect = getGlyphRect(i);
+ return DPoint(double(rect.x)/PANGO_SCALE, double(rect.y)/PANGO_SCALE);
+}
+
+DPoint WordsNode::getGlyphSize(int i)
+{
+ PangoRectangle rect = getGlyphRect(i);
+ return DPoint(double(rect.width)/PANGO_SCALE, double(rect.height)/PANGO_SCALE);
+}
+
+int WordsNode::getNumLines()
+{
+ updateLayout();
+ return pango_layout_get_line_count(m_pLayout);
+}
+
+PyObject* WordsNode::getCharIndexFromPos(DPoint p)
+{
+ int index;
+ int trailing;
+ updateLayout();
+ gboolean bXyToIndex = pango_layout_xy_to_index(m_pLayout,
+ int(p.x*PANGO_SCALE), int(p.y*PANGO_SCALE), &index, &trailing);
+ if (bXyToIndex) {
+ const char* pText = pango_layout_get_text(m_pLayout);
+ return Py_BuildValue("l",(g_utf8_pointer_to_offset(pText,pText+index)));
+ } else {
+ return Py_BuildValue("");
+ }
+}
+
+std::string WordsNode::getTextAsDisplayed()
+{
+ updateLayout();
+ return pango_layout_get_text(m_pLayout);
+}
+
+DPoint WordsNode::getLineExtents(int line)
+{
+ if(line < 0 || line >= getNumLines()) {
+ throw Exception(AVG_ERR_OUT_OF_RANGE, "WordsNode.getLineExtents: line index "
+ +toString(line)+" is out of range.");
+ }
+ updateLayout();
+ PangoRectangle logical_rect;
+ PangoRectangle ink_rect;
+ PangoLayoutLine *layoutLine = pango_layout_get_line_readonly(m_pLayout, line);
+ pango_layout_line_get_pixel_extents(layoutLine, &ink_rect, &logical_rect);
+ return DPoint(double(logical_rect.width), double(logical_rect.height));
+}
+
+void WordsNode::setWrapMode(const string& sWrapMode)
+{
+ if (sWrapMode == "word") {
+ m_WrapMode = PANGO_WRAP_WORD;
+ } else if (sWrapMode == "char") {
+ m_WrapMode = PANGO_WRAP_CHAR;
+ } else if (sWrapMode == "wordchar") {
+ m_WrapMode = PANGO_WRAP_WORD_CHAR;
+ } else {
+ throw(Exception(AVG_ERR_UNSUPPORTED,
+ "WordsNode wrapping mode "+sWrapMode+" not supported."));
+ }
+ setDirty(LAYOUT_CHANGED);
+}
+
+string WordsNode::getWrapMode() const
+{
+ switch(m_WrapMode) {
+ case PANGO_WRAP_WORD:
+ return "word";
+ case PANGO_WRAP_CHAR:
+ return "char";
+ case PANGO_WRAP_WORD_CHAR:
+ return "wordchar";
+ default:
+ AVG_ASSERT(false);
+ return "";
+ }
+}
+
+void WordsNode::parseString(PangoAttrList** ppAttrList, char** ppText)
+{
+ UTF8String sTextWithoutBreaks = applyBR(m_sText);
+ bool bOk;
+ GError * pError = 0;
+ bOk = (pango_parse_markup(sTextWithoutBreaks.c_str(),
+ int(sTextWithoutBreaks.length()), 0,
+ ppAttrList, ppText, 0, &pError) != 0);
+ if (!bOk) {
+ string sError;
+ if (getID() != "") {
+ sError = string("Can't parse string in node with id '")+getID()+"' ("
+ +pError->message+")";
+ } else {
+ sError = string("Can't parse string '")+m_sRawText+"' ("+pError->message+")";
+ }
+ throw Exception(AVG_ERR_CANT_PARSE_STRING, sError);
+ }
+
+}
+
+void WordsNode::calcMaskCoords()
+{
+ updateLayout();
+
+ // Calculate texture coordinates for the mask texture, normalized to
+ // the extents of the text.
+ DPoint normMaskSize;
+ DPoint normMaskPos;
+ DPoint mediaSize = DPoint(getMediaSize());
+ DPoint effMaskPos = getMaskPos()-DPoint(m_InkOffset);
+ DPoint maskSize = getMaskSize();
+ switch (m_Alignment) {
+ case PANGO_ALIGN_LEFT:
+ break;
+ case PANGO_ALIGN_CENTER:
+ effMaskPos.x -= m_AlignOffset+getSize().x/2;
+ break;
+ case PANGO_ALIGN_RIGHT:
+ effMaskPos.x -= m_AlignOffset+getSize().x;
+ break;
+ }
+ if (maskSize == DPoint(0,0)) {
+ normMaskSize = DPoint(getSize().x/mediaSize.x, getSize().y/mediaSize.y);
+ normMaskPos = DPoint(effMaskPos.x/getSize().x, effMaskPos.y/getSize().y);
+ } else {
+ normMaskSize = DPoint(maskSize.x/mediaSize.x, maskSize.y/mediaSize.y);
+ normMaskPos = DPoint(effMaskPos.x/getMaskSize().x, effMaskPos.y/getMaskSize().y);
+ }
+/*
+ cerr << "calcMaskCoords" << endl;
+ cerr << " mediaSize: " << getMediaSize() << endl;
+ cerr << " effMaskPos: " << effMaskPos << endl;
+ cerr << " m_AlignOffset: " << m_AlignOffset << endl;
+ cerr << " maskSize: " << maskSize << endl;
+ cerr << " normMaskSize: " << normMaskSize << endl;
+ cerr << " normMaskPos: " << normMaskPos << endl;
+*/
+ getSurface()->setMaskCoords(normMaskPos, normMaskSize);
+}
+
+void WordsNode::setDirty(RedrawState newState)
+{
+ if (newState < m_RedrawState) {
+ m_RedrawState = newState;
+ }
+}
+
+static ProfilingZoneID UpdateFontProfilingZone("WordsNode: Update font");
+
+void WordsNode::updateFont()
+{
+ if (m_RedrawState == FONT_CHANGED) {
+ ScopeTimer timer(UpdateFontProfilingZone);
+
+ if (m_pFontDescription) {
+ pango_font_description_free(m_pFontDescription);
+ }
+ m_pFontDescription = TextEngine::get(m_bHint).getFontDescription(m_sFontName,
+ m_sFontVariant);
+ pango_font_description_set_absolute_size(m_pFontDescription,
+ (int)(m_FontSize * PANGO_SCALE));
+
+ m_RedrawState = LAYOUT_CHANGED;
+ }
+}
+
+static ProfilingZoneID UpdateLayoutProfilingZone("WordsNode: Update layout");
+
+void WordsNode::updateLayout()
+{
+ updateFont();
+ if (m_RedrawState == LAYOUT_CHANGED) {
+ ScopeTimer timer(UpdateLayoutProfilingZone);
+
+ if (m_sText.length() == 0) {
+ m_LogicalSize = IntPoint(0,0);
+ m_RedrawState = RENDER_NEEDED;
+ } else {
+ PangoContext* pContext = TextEngine::get(m_bHint).getPangoContext();
+ pango_context_set_font_description(pContext, m_pFontDescription);
+
+ if (m_pLayout) {
+ g_object_unref(m_pLayout);
+ }
+ m_pLayout = pango_layout_new(pContext);
+
+ PangoAttrList * pAttrList = 0;
+#if PANGO_VERSION > PANGO_VERSION_ENCODE(1,18,2)
+ PangoAttribute * pLetterSpacing = pango_attr_letter_spacing_new
+ (int(m_LetterSpacing*1024));
+#endif
+ if (m_bParsedText) {
+ char * pText = 0;
+ parseString(&pAttrList, &pText);
+#if PANGO_VERSION > PANGO_VERSION_ENCODE(1,18,2)
+ // Workaround for pango bug.
+ pango_attr_list_insert_before(pAttrList, pLetterSpacing);
+#endif
+ pango_layout_set_text(m_pLayout, pText, -1);
+ g_free (pText);
+ } else {
+ pAttrList = pango_attr_list_new();
+#if PANGO_VERSION > PANGO_VERSION_ENCODE(1,18,2)
+ pango_attr_list_insert_before(pAttrList, pLetterSpacing);
+#endif
+ pango_layout_set_text(m_pLayout, m_sText.c_str(), -1);
+ }
+ pango_layout_set_attributes(m_pLayout, pAttrList);
+ pango_attr_list_unref(pAttrList);
+
+ pango_layout_set_wrap(m_pLayout, m_WrapMode);
+ pango_layout_set_alignment(m_pLayout, m_Alignment);
+ pango_layout_set_justify(m_pLayout, m_bJustify);
+ if (getUserSize().x != 0) {
+ pango_layout_set_width(m_pLayout, int(getUserSize().x * PANGO_SCALE));
+ }
+ pango_layout_set_indent(m_pLayout, m_Indent * PANGO_SCALE);
+ if (m_Indent < 0) {
+ // For hanging indentation, we add a tabstop to support lists
+ PangoTabArray* pTabs = pango_tab_array_new_with_positions(1, false,
+ PANGO_TAB_LEFT, -m_Indent * PANGO_SCALE);
+ pango_layout_set_tabs(m_pLayout, pTabs);
+ pango_tab_array_free(pTabs);
+ }
+ if (m_LineSpacing != -1) {
+ pango_layout_set_spacing(m_pLayout, (int)(m_LineSpacing*PANGO_SCALE));
+ }
+ PangoRectangle logical_rect;
+ PangoRectangle ink_rect;
+ pango_layout_get_pixel_extents(m_pLayout, &ink_rect, &logical_rect);
+
+ /*
+ cerr << getID() << endl;
+ cerr << "Ink: " << ink_rect.x << ", " << ink_rect.y << ", "
+ << ink_rect.width << ", " << ink_rect.height << endl;
+ cerr << "Logical: " << logical_rect.x << ", " << logical_rect.y << ", "
+ << logical_rect.width << ", " << logical_rect.height << endl;
+ cerr << "User Size: " << getUserSize() << endl;
+ */
+ m_InkSize.y = ink_rect.height;
+ if (getUserSize().x == 0) {
+ m_InkSize.x = ink_rect.width;
+ } else {
+ m_InkSize.x = int(getUserSize().x);
+ }
+ if (m_InkSize.x == 0) {
+ m_InkSize.x = 1;
+ }
+ if (m_InkSize.y == 0) {
+ m_InkSize.y = 1;
+ }
+ m_LogicalSize.y = logical_rect.height;
+ m_LogicalSize.x = logical_rect.width;
+ m_InkOffset = IntPoint(ink_rect.x-logical_rect.x, ink_rect.y-logical_rect.y);
+ if (m_LineSpacing == -1) {
+ m_LineSpacing = pango_layout_get_spacing(m_pLayout)/PANGO_SCALE;
+ }
+ m_RedrawState = RENDER_NEEDED;
+ setViewport(-32767, -32767, -32767, -32767);
+ }
+ }
+}
+
+static ProfilingZoneID RenderTextProfilingZone("WordsNode: render text");
+
+void WordsNode::renderText()
+{
+ AVG_ASSERT(m_RedrawState == RENDER_NEEDED || m_RedrawState == CLEAN);
+
+ if (!(getState() == NS_CANRENDER)) {
+ return;
+ }
+ if (m_RedrawState == RENDER_NEEDED) {
+ if (m_sText.length() != 0) {
+ ScopeTimer timer(RenderTextProfilingZone);
+ int maxTexSize = GLContext::getCurrent()->getMaxTexSize();
+ if (m_InkSize.x > maxTexSize || m_InkSize.y > maxTexSize) {
+ throw Exception(AVG_ERR_UNSUPPORTED,
+ "WordsNode size exceeded maximum (Size="
+ + toString(m_InkSize) + ", max=" + toString(maxTexSize) + ")");
+ }
+ GLTexturePtr pTex(new GLTexture(m_InkSize, A8));
+ getSurface()->create(A8, pTex);
+ TextureMoverPtr pMover = TextureMover::create(m_InkSize, A8, GL_DYNAMIC_DRAW);
+
+ BitmapPtr pBmp = pMover->lock();
+ FilterFill<unsigned char>(0).applyInPlace(pBmp);
+ FT_Bitmap bitmap;
+ bitmap.rows = m_InkSize.y;
+ bitmap.width = m_InkSize.x;
+ unsigned char * pLines = pBmp->getPixels();
+ bitmap.pitch = pBmp->getStride();
+ bitmap.buffer = pLines;
+ bitmap.num_grays = 256;
+ bitmap.pixel_mode = ft_pixel_mode_grays;
+
+ PangoRectangle logical_rect;
+ PangoRectangle ink_rect;
+ pango_layout_get_pixel_extents(m_pLayout, &ink_rect, &logical_rect);
+ pango_ft2_render_layout(&bitmap, m_pLayout, -ink_rect.x, -ink_rect.y);
+ switch (m_Alignment) {
+ case PANGO_ALIGN_LEFT:
+ m_AlignOffset = 0;
+ break;
+ case PANGO_ALIGN_CENTER:
+ m_AlignOffset = -logical_rect.width/2;
+ break;
+ case PANGO_ALIGN_RIGHT:
+ m_AlignOffset = -logical_rect.width;
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+
+ pMover->unlock();
+ pMover->moveToTexture(*pTex);
+
+ bind();
+ }
+ m_RedrawState = CLEAN;
+ }
+}
+
+void WordsNode::redraw()
+{
+ AVG_ASSERT(m_sText.length() < 32767);
+
+ updateLayout();
+ renderText();
+}
+
+void WordsNode::preRender()
+{
+ Node::preRender();
+ if (isVisible()) {
+ redraw();
+ } else {
+ updateLayout();
+ }
+ if (m_sText.length() != 0 && isVisible()) {
+ renderFX(getSize(), m_Color, false);
+ }
+}
+
+static ProfilingZoneID RenderProfilingZone("WordsNode::render");
+
+void WordsNode::render(const DRect& rect)
+{
+ ScopeTimer timer(RenderProfilingZone);
+ if (m_sText.length() != 0 && isVisible()) {
+ IntPoint offset = m_InkOffset + IntPoint(m_AlignOffset, 0);
+ GLContext* pContext = GLContext::getCurrent();
+ if (offset != IntPoint(0,0)) {
+ pContext->pushTransform(DPoint(offset), 0, DPoint(0,0));
+ }
+ blta8(DPoint(getSurface()->getSize()), getEffectiveOpacity(), m_Color,
+ getBlendMode());
+ if (offset != IntPoint(0,0)) {
+ pContext->popTransform();
+ }
+ }
+}
+
+IntPoint WordsNode::getMediaSize()
+{
+ updateLayout();
+ return m_LogicalSize;
+}
+
+const vector<string>& WordsNode::getFontFamilies()
+{
+ return TextEngine::get(true).getFontFamilies();
+}
+
+const vector<string>& WordsNode::getFontVariants(const string& sFontName)
+{
+ return TextEngine::get(true).getFontVariants(sFontName);
+}
+
+string WordsNode::removeExcessSpaces(const string & sText)
+{
+ string s = sText;
+ string::size_type lastPos = s.npos;
+ string::size_type pos = s.find_first_of(" \n\r");
+ while (pos != s.npos) {
+ s[pos] = ' ';
+ if (pos == lastPos+1) {
+ s.erase(pos, 1);
+ pos--;
+ }
+ lastPos = pos;
+ pos = s.find_first_of(" \n\r", pos+1);
+ }
+ return s;
+}
+
+PangoRectangle WordsNode::getGlyphRect(int i)
+{
+
+ if (i >= int(g_utf8_strlen(m_sText.c_str(), -1)) || i < 0) {
+ throw(Exception(AVG_ERR_INVALID_ARGS,
+ string("getGlyphRect: Index ") + toString(i) + " out of range."));
+ }
+ updateLayout();
+ const char* pText = pango_layout_get_text(m_pLayout);
+ char * pChar = g_utf8_offset_to_pointer(pText, i);
+ int byteOffset = pChar-pText;
+ PangoRectangle rect;
+
+ if (m_pLayout) {
+ pango_layout_index_to_pos(m_pLayout, byteOffset, &rect);
+ } else {
+ rect.x = 0;
+ rect.y = 0;
+ rect.width = 0;
+ rect.height = 0;
+ }
+ return rect;
+}
+
+void WordsNode::setParsedText(const UTF8String& sText)
+{
+ m_sText = removeExcessSpaces(sText);
+ setDirty(LAYOUT_CHANGED);
+
+ // This just does a syntax check and throws an exception if appropriate.
+ // The results are discarded.
+ PangoAttrList * pAttrList = 0;
+ char * pText = 0;
+ parseString(&pAttrList, &pText);
+ pango_attr_list_unref (pAttrList);
+ g_free (pText);
+ m_bParsedText = true;
+}
+
+UTF8String WordsNode::applyBR(const UTF8String& sText)
+{
+ UTF8String sResult(sText);
+ UTF8String sLowerText = toLowerCase(sResult);
+ string::size_type pos=sLowerText.find("<br/>");
+ while (pos != string::npos) {
+ sResult.replace(pos, 5, "\n");
+ sLowerText.replace(pos, 5, "\n");
+ if (sLowerText[pos+1] == ' ') {
+ sLowerText.erase(pos+1, 1);
+ sResult.erase(pos+1, 1);
+ }
+ pos=sLowerText.find("<br/>");
+ }
+ return sResult;
+}
+
+}
+
diff --git a/src/player/WordsNode.h b/src/player/WordsNode.h
new file mode 100644
index 0000000..23c225c
--- /dev/null
+++ b/src/player/WordsNode.h
@@ -0,0 +1,162 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _WordsNode_H_
+#define _WordsNode_H_
+
+#include "../api.h"
+#include "RasterNode.h"
+#include "../graphics/Pixel32.h"
+#include "../base/UTF8String.h"
+
+#include <pango/pango.h>
+
+#include <string>
+#include <vector>
+
+namespace avg {
+
+class AVG_API WordsNode : public RasterNode
+{
+ public:
+ static NodeDefinition createDefinition();
+
+ WordsNode(const ArgList& args);
+ virtual ~WordsNode();
+
+ virtual void connectDisplay();
+ virtual void connect(CanvasPtr pCanvas);
+ virtual void disconnect(bool bKill);
+ virtual void preRender();
+ virtual void render(const DRect& rect);
+
+ virtual double getWidth() const;
+ virtual void setWidth(double width);
+
+ virtual double getHeight() const;
+ virtual void setHeight(double width);
+
+ virtual DPoint getSize() const;
+ virtual void setSize(const DPoint& pt);
+
+ void getElementsByPos(const DPoint& pos, std::vector<NodeWeakPtr>& pElements);
+ void setTextFromNodeValue(const std::string& sText);
+
+ const std::string& getFont() const;
+ void setFont(const std::string& sName);
+
+ const std::string& getFontVariant() const;
+ void setFontVariant(const std::string& sVariant);
+
+ const UTF8String& getText() const;
+ void setText(const UTF8String& sText);
+
+ const std::string& getColor() const;
+ void setColor(const std::string& sColor);
+
+ double getFontSize() const;
+ void setFontSize(double size);
+
+ int getIndent() const;
+ void setIndent(int indent);
+
+ double getLineSpacing() const;
+ void setLineSpacing(double lineSpacing);
+
+ bool getRawTextMode() const;
+ void setRawTextMode(bool rawTextMode);
+
+ std::string getAlignment() const;
+ void setAlignment(const std::string& sAlignment);
+
+ std::string getWrapMode() const;
+ void setWrapMode(const std::string& sWrapMode);
+
+ bool getJustify() const;
+ void setJustify(bool bJustify);
+
+ double getLetterSpacing() const;
+ void setLetterSpacing(double letterSpacing);
+
+ bool getHint() const;
+ void setHint(bool bHint);
+
+ DPoint getGlyphPos(int i);
+ DPoint getGlyphSize(int i);
+ virtual IntPoint getMediaSize();
+
+ int getNumLines();
+ PyObject* getCharIndexFromPos(DPoint p);
+ std::string getTextAsDisplayed();
+ DPoint getLineExtents(int line);
+
+ static const std::vector<std::string>& getFontFamilies();
+ static const std::vector<std::string>& getFontVariants(
+ const std::string& sFontName);
+ static void addFontDir(const std::string& sDir);
+
+ private:
+ enum RedrawState {FONT_CHANGED, LAYOUT_CHANGED, RENDER_NEEDED, CLEAN};
+
+ virtual void calcMaskCoords();
+ void setDirty(RedrawState newState);
+ void updateFont();
+ void updateLayout();
+ void renderText();
+ void redraw();
+ void parseString(PangoAttrList** ppAttrList, char** ppText);
+ void setParsedText(const UTF8String& sText);
+ UTF8String applyBR(const UTF8String& sText);
+ std::string removeExcessSpaces(const std::string & sText);
+ PangoRectangle getGlyphRect(int i);
+
+ // Exposed Attributes
+ std::string m_sFontName;
+ std::string m_sFontVariant;
+ UTF8String m_sText;
+ UTF8String m_sRawText;
+ std::string m_sColorName;
+ Pixel32 m_Color;
+ double m_FontSize;
+ int m_Indent;
+ double m_LineSpacing;
+ PangoAlignment m_Alignment;
+ PangoWrapMode m_WrapMode;
+ bool m_bJustify;
+ double m_LetterSpacing;
+ bool m_bHint;
+
+ bool m_bParsedText;
+ bool m_bRawTextMode;
+ IntPoint m_LogicalSize;
+ IntPoint m_InkOffset;
+ IntPoint m_InkSize;
+ int m_AlignOffset;
+ PangoFontDescription * m_pFontDescription;
+ PangoLayout * m_pLayout;
+
+ RedrawState m_RedrawState;
+};
+
+}
+
+#endif
+
diff --git a/src/player/WrapPython.h b/src/player/WrapPython.h
new file mode 100644
index 0000000..b81b4eb
--- /dev/null
+++ b/src/player/WrapPython.h
@@ -0,0 +1,49 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "../api.h"
+
+#ifdef _DEBUG
+# undef _DEBUG // Don't let Python force the debug library just because we're debugging.
+# define DEBUG_UNDEFINED_FROM_WRAPPYTHON_H
+#endif
+
+// libstdc++ and python headers both define _XOPEN_SOURCE (Ubuntu 9.10, gcc 4.4,
+// python 2.6.4)
+#undef _POSIX_C_SOURCE
+#undef _XOPEN_SOURCE
+#include <Python.h>
+#include <string>
+
+#undef HAVE_STAT
+#undef HAVE_TEMPNAM
+#undef PACKAGE
+#undef PACKAGE_BUGREPORT
+#undef PACKAGE_NAME
+#undef PACKAGE_STRING
+#undef PACKAGE_TARNAME
+#undef PACKAGE_VERSION
+
+#ifdef DEBUG_UNDEFINED_FROM_WRAPPYTHON_H
+# undef DEBUG_UNDEFINED_FROM_WRAPPYTHON_H
+# define _DEBUG
+#endif
+
diff --git a/src/player/XInputMTInputDevice.cpp b/src/player/XInputMTInputDevice.cpp
new file mode 100644
index 0000000..0e042c2
--- /dev/null
+++ b/src/player/XInputMTInputDevice.cpp
@@ -0,0 +1,372 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "XInputMTInputDevice.h"
+
+#include "TouchEvent.h"
+#include "Player.h"
+#include "AVGNode.h"
+#include "TouchStatus.h"
+#include "SDLDisplayEngine.h"
+
+#include "../base/Logger.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+#include "../base/OSHelper.h"
+#include "../base/StringHelper.h"
+
+#include <SDL/SDL_syswm.h>
+#include <SDL/SDL.h>
+
+#include <X11/extensions/XInput.h>
+#include <X11/extensions/XInput2.h>
+
+using namespace std;
+
+namespace avg {
+
+Display* XInputMTInputDevice::s_pDisplay = 0;
+
+const char* cookieTypeToName(int evtype);
+string xEventTypeToName(int evtype);
+
+XInputMTInputDevice::XInputMTInputDevice()
+ : m_LastID(0),
+ m_DeviceID(-1)
+{
+}
+
+XInputMTInputDevice::~XInputMTInputDevice()
+{
+ if (m_DeviceID != -1 && m_OldMasterDeviceID != -1) {
+ XIAttachSlaveInfo atInfo;
+ atInfo.type = XIAttachSlave;
+ atInfo.deviceid = m_DeviceID;
+ atInfo.new_master = m_OldMasterDeviceID;
+ XIChangeHierarchy(s_pDisplay, (XIAnyHierarchyChangeInfo *)&atInfo, 1);
+ }
+}
+
+void XInputMTInputDevice::start()
+{
+ Status status;
+ SDLDisplayEngine * pEngine = Player::get()->getDisplayEngine();
+
+ SDL_SysWMinfo info;
+ SDL_VERSION(&info.version);
+ int rc = SDL_GetWMInfo(&info);
+ AVG_ASSERT(rc != -1);
+ s_pDisplay = info.info.x11.display;
+ m_SDLLockFunc = info.info.x11.lock_func;
+ m_SDLUnlockFunc = info.info.x11.unlock_func;
+
+ m_SDLLockFunc();
+ // XInput Extension available?
+ int event, error;
+ bool bOk = XQueryExtension(s_pDisplay, "XInputExtension", &m_XIOpcode,
+ &event, &error);
+ if (!bOk) {
+ throw Exception(AVG_ERR_MT_INIT,
+ "XInput multitouch event source: X Input extension not available.");
+ }
+
+ // Which version of XI2?
+ int major;
+ int minor;
+ status = XIQueryVersion(s_pDisplay, &major, &minor);
+ if (status == BadRequest) {
+ throw Exception(AVG_ERR_MT_INIT,
+ "XInput 2.1 multitouch event source: Server does not support XI2");
+ }
+ if (major < 2 || minor < 1) {
+ throw Exception(AVG_ERR_MT_INIT,
+ "XInput multitouch event source: Supported version is "
+ +toString(major)+"."+toString(minor)+". At least 2.1 is needed.");
+ }
+ findMTDevice();
+
+ // SDL grabs the pointer in full screen mode. This breaks touchscreen usage.
+ // Can't use SDL_WM_GrabInput(SDL_GRAB_OFF) because it doesn't work in full
+ // screen mode. Get the display connection and do it manually.
+ XUngrabPointer(info.info.x11.display, CurrentTime);
+
+ XIEventMask mask;
+ mask.deviceid = m_DeviceID;
+ mask.mask_len = XIMaskLen(XI_LASTEVENT);
+ mask.mask = (unsigned char *)calloc(mask.mask_len, sizeof(char));
+ memset(mask.mask, 0, mask.mask_len);
+ XISetMask(mask.mask, XI_TouchBegin);
+ XISetMask(mask.mask, XI_TouchUpdate);
+ XISetMask(mask.mask, XI_TouchEnd);
+
+ status = XISelectEvents(s_pDisplay, info.info.x11.window, &mask, 1);
+ AVG_ASSERT(status == Success);
+
+ m_SDLUnlockFunc();
+
+ SDL_SetEventFilter(XInputMTInputDevice::filterEvent);
+
+
+ XIDetachSlaveInfo detInfo;
+ detInfo.type = XIDetachSlave;
+ detInfo.deviceid = m_DeviceID;
+ XIChangeHierarchy(s_pDisplay, (XIAnyHierarchyChangeInfo *)&detInfo, 1);
+
+ pEngine->setXIMTInputDevice(this);
+ MultitouchInputDevice::start();
+ AVG_TRACE(Logger::CONFIG, "XInput Multitouch event source created.");
+}
+
+void XInputMTInputDevice::handleXIEvent(const XEvent& xEvent)
+{
+ m_SDLLockFunc();
+ XGenericEventCookie* pCookie = (XGenericEventCookie*)&xEvent.xcookie;
+ if (pCookie->type == GenericEvent && pCookie->extension == m_XIOpcode) {
+ XIDeviceEvent* pDevEvent = (XIDeviceEvent*)(pCookie->data);
+ IntPoint pos(pDevEvent->event_x, pDevEvent->event_y);
+ int xid = pDevEvent->detail;
+ switch (pCookie->evtype) {
+ case XI_TouchBegin:
+ {
+// cerr << "TouchBegin " << xid << ", " << pos << endl;
+ m_LastID++;
+ TouchEventPtr pEvent = createEvent(m_LastID, Event::CURSORDOWN, pos);
+ addTouchStatus(xid, pEvent);
+ }
+ break;
+ case XI_TouchUpdate:
+ {
+// cerr << "TouchUpdate " << xid << ", " << pos << endl;
+ TouchEventPtr pEvent = createEvent(0, Event::CURSORMOTION, pos);
+ TouchStatusPtr pTouchStatus = getTouchStatus(xid);
+ AVG_ASSERT(pTouchStatus);
+ pTouchStatus->pushEvent(pEvent);
+ }
+ break;
+ case XI_TouchEnd:
+ {
+// cerr << "TouchEnd " << xid << ", " << pos << endl;
+ TouchStatusPtr pTouchStatus = getTouchStatus(xid);
+ AVG_ASSERT(pTouchStatus);
+ TouchEventPtr pEvent = createEvent(0, Event::CURSORUP, pos);
+ pTouchStatus->pushEvent(pEvent);
+ }
+ break;
+ default:
+ ;
+// cerr << "Unhandled XInput event, type: "
+// << cookieTypeToName(pCookie->evtype) << endl;
+ }
+ } else {
+// cerr << "Unhandled X11 Event: " << xEvent.type << endl;
+ }
+
+ XFreeEventData(s_pDisplay, pCookie);
+ m_SDLUnlockFunc();
+}
+
+std::vector<EventPtr> XInputMTInputDevice::pollEvents()
+{
+
+ return MultitouchInputDevice::pollEvents();
+}
+
+void XInputMTInputDevice::findMTDevice()
+{
+ int ndevices;
+ XIDeviceInfo* pDevices;
+ XIDeviceInfo* pDevice;
+
+ pDevices = XIQueryDevice(s_pDisplay, XIAllDevices, &ndevices);
+
+ XITouchClassInfo* pTouchClass = 0;
+ int maxTouches;
+ for (int i = 0; i < ndevices && !pTouchClass; ++i) {
+ pDevice = &pDevices[i];
+// cerr << "Device " << pDevice->name << "(id: " << pDevice->deviceid << ")."
+// << endl;
+ if (pDevice->use == XISlavePointer || pDevice->use == XIFloatingSlave) {
+ for (int j = 0; j < pDevice->num_classes; ++j) {
+ XIAnyClassInfo * pClass = pDevice->classes[j];
+ if (pClass->type == XITouchClass) {
+ XITouchClassInfo* pTempTouchClass = (XITouchClassInfo *)pClass;
+ if (pTempTouchClass->mode == XIDirectTouch) {
+ pTouchClass = pTempTouchClass;
+ m_sDeviceName = pDevice->name;
+ m_DeviceID = pDevice->deviceid;
+ if (pDevice->use == XISlavePointer) {
+ m_OldMasterDeviceID = pDevice->attachment;
+ } else {
+ m_OldMasterDeviceID = -1;
+ }
+ maxTouches = pTouchClass->num_touches;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (pTouchClass) {
+ AVG_TRACE(Logger::CONFIG, "Using multitouch input device " << m_sDeviceName
+ << ", max touches: " << maxTouches);
+ } else {
+ throw Exception(AVG_ERR_MT_INIT,
+ "XInput multitouch event source: No multitouch device found.");
+ }
+ XIFreeDeviceInfo(pDevices);
+}
+
+TouchEventPtr XInputMTInputDevice::createEvent(int id, Event::Type type, IntPoint pos)
+{
+ return TouchEventPtr(new TouchEvent(id, type, pos, Event::TOUCH));
+}
+
+int XInputMTInputDevice::filterEvent(const SDL_Event * pEvent)
+{
+ // This is a hook into libsdl event processing. Since libsdl doesn't know about
+ // XInput 2, it doesn't call XGetEventData either. By the time the event arrives
+ // in handleXIEvent(), other events may have arrived and XGetEventData can't be
+ // called anymore. Hence this function, which calls XGetEventData for each event
+ // that has a cookie.
+ if (pEvent->type == SDL_SYSWMEVENT) {
+ SDL_SysWMmsg* pMsg = pEvent->syswm.msg;
+ AVG_ASSERT(pMsg->subsystem == SDL_SYSWM_X11);
+ XEvent* pXEvent = &pMsg->event.xevent;
+ XGenericEventCookie* pCookie = (XGenericEventCookie*)&(pXEvent->xcookie);
+// cerr << "---- filter xinput event: " << xEventTypeToName(pXEvent->type) << ", "
+// << cookieTypeToName(pCookie->evtype) << endl;
+ XGetEventData(s_pDisplay, pCookie);
+ } else {
+// cerr << "---- filter: " << int(pEvent->type) << endl;
+ }
+ return 1;
+}
+
+// From xinput/test_xi2.c
+const char* cookieTypeToName(int evtype)
+{
+ const char *name;
+ switch(evtype) {
+ case XI_DeviceChanged: name = "DeviceChanged"; break;
+ case XI_KeyPress: name = "KeyPress"; break;
+ case XI_KeyRelease: name = "KeyRelease"; break;
+ case XI_ButtonPress: name = "ButtonPress"; break;
+ case XI_ButtonRelease: name = "ButtonRelease"; break;
+ case XI_Motion: name = "Motion"; break;
+ case XI_Enter: name = "Enter"; break;
+ case XI_Leave: name = "Leave"; break;
+ case XI_FocusIn: name = "FocusIn"; break;
+ case XI_FocusOut: name = "FocusOut"; break;
+ case XI_HierarchyChanged: name = "HierarchyChanged"; break;
+ case XI_PropertyEvent: name = "PropertyEvent"; break;
+ case XI_RawKeyPress: name = "RawKeyPress"; break;
+ case XI_RawKeyRelease: name = "RawKeyRelease"; break;
+ case XI_RawButtonPress: name = "RawButtonPress"; break;
+ case XI_RawButtonRelease: name = "RawButtonRelease"; break;
+ case XI_RawMotion: name = "RawMotion"; break;
+ case XI_TouchBegin: name = "TouchBegin"; break;
+ case XI_TouchEnd: name = "TouchEnd"; break;
+ case XI_TouchUpdate: name = "TouchUpdate"; break;
+#ifdef HAVE_XI2_1
+ case XI_TouchUpdateUnowned: name = "TouchUpdateUnowned"; break;
+#endif
+ default: name = "unknown event type"; break;
+ }
+ return name;
+}
+
+string xEventTypeToName(int evtype)
+{
+ switch(evtype) {
+ case KeyPress:
+ return "KeyPress";
+ case KeyRelease:
+ return "KeyRelease";
+ case ButtonPress:
+ return "ButtonPress";
+ case ButtonRelease:
+ return "ButtonRelease";
+ case MotionNotify:
+ return "MotionNotify";
+ case EnterNotify:
+ return "EnterNotify";
+ case LeaveNotify:
+ return "LeaveNotify";
+ case FocusIn:
+ return "FocusIn";
+ case FocusOut:
+ return "FocusOut";
+ case KeymapNotify:
+ return "KeymapNotify";
+ case Expose:
+ return "Expose";
+ case GraphicsExpose:
+ return "GraphicsExpose";
+ case NoExpose:
+ return "NoExpose";
+ case VisibilityNotify:
+ return "VisibilityNotify";
+ case CreateNotify:
+ return "CreateNotify";
+ case DestroyNotify:
+ return "DestroyNotify";
+ case UnmapNotify:
+ return "UnmapNotify";
+ case MapNotify:
+ return "MapNotify";
+ case MapRequest:
+ return "MapRequest";
+ case ReparentNotify:
+ return "ReparentNotify";
+ case ConfigureNotify:
+ return "ConfigureNotify";
+ case ConfigureRequest:
+ return "ConfigureRequest";
+ case GravityNotify:
+ return "GravityNotify";
+ case ResizeRequest:
+ return "ResizeRequest";
+ case CirculateNotify:
+ return "CirculateNotify";
+ case CirculateRequest:
+ return "CirculateRequest";
+ case PropertyNotify:
+ return "PropertyNotify";
+ case SelectionClear:
+ return "SelectionClear";
+ case SelectionRequest:
+ return "SelectionRequest";
+ case SelectionNotify:
+ return "SelectionNotify";
+ case ColormapNotify:
+ return "ColormapNotify";
+ case ClientMessage:
+ return "ClientMessage";
+ case MappingNotify:
+ return "MappingNotify";
+ case GenericEvent:
+ return "GenericEvent";
+ default:
+ return "Unknown event type";
+ }
+}
+
+}
diff --git a/src/player/XInputMTInputDevice.h b/src/player/XInputMTInputDevice.h
new file mode 100644
index 0000000..af10249
--- /dev/null
+++ b/src/player/XInputMTInputDevice.h
@@ -0,0 +1,76 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _XInputMTInputDevice_H_
+#define _XInputMTInputDevice_H_
+
+#include "../api.h"
+#include "../avgconfig.h"
+
+#include "MultitouchInputDevice.h"
+#include "Event.h"
+
+#include "../base/Point.h"
+
+#include <X11/Xlib.h>
+#include <vector>
+#include <string>
+
+union SDL_Event;
+
+namespace avg {
+
+class AVG_API XInputMTInputDevice: public MultitouchInputDevice
+{
+public:
+ XInputMTInputDevice();
+ virtual ~XInputMTInputDevice();
+ virtual void start();
+
+ void handleXIEvent(const XEvent& xEvent);
+ std::vector<EventPtr> pollEvents();
+
+private:
+ void findMTDevice();
+ TouchEventPtr createEvent(int id, Event::Type type, IntPoint pos);
+
+ static int filterEvent(const SDL_Event * pEvent);
+
+ int m_LastID;
+
+ static Display* s_pDisplay;
+ void (*m_SDLLockFunc)(void);
+ void (*m_SDLUnlockFunc)(void);
+
+ int m_XIOpcode;
+
+ std::string m_sDeviceName;
+ int m_DeviceID;
+
+ int m_OldMasterDeviceID;
+};
+
+typedef boost::shared_ptr<XInputMTInputDevice> XInputMTInputDevicePtr;
+
+}
+
+#endif
+
diff --git a/src/player/testcalibrator.cpp b/src/player/testcalibrator.cpp
new file mode 100644
index 0000000..175488f
--- /dev/null
+++ b/src/player/testcalibrator.cpp
@@ -0,0 +1,119 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "TrackerCalibrator.h"
+
+#include "../base/Point.h"
+
+#include "../base/TestSuite.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+using namespace avg;
+using namespace std;
+
+class CalibratorTest: public Test {
+public:
+ CalibratorTest()
+ : Test("CalibratorTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ DeDistortPtr pTrafo;
+ {
+ TrackerCalibrator calibrator(IntPoint(640, 480), IntPoint(640,480));
+ bool bDone = false;
+ while (!bDone) {
+ IntPoint displayPoint(calibrator.getDisplayPoint());
+ calibrator.setCamPoint(DPoint(displayPoint));
+ bDone = !calibrator.nextPoint();
+ }
+ pTrafo = calibrator.makeTransformer();
+ TEST( calcDist(pTrafo->transformBlobToScreen( DPoint(1.00,1.00) ) , DPoint(1.00,1.00))<1);
+// cerr << "scale: " << scale << ", offset: " << offset << endl;
+ TEST(checkTransform(pTrafo, DPoint(0,0), DPoint(0,0)));
+ TEST(checkTransform(pTrafo, DPoint(640, 480), DPoint(640, 480)));
+ }
+ {
+ TrackerCalibrator calibrator(IntPoint(640, 480), IntPoint(1280,720));
+ bool bDone = false;
+ while (!bDone) {
+ IntPoint displayPoint(calibrator.getDisplayPoint());
+ calibrator.setCamPoint(DPoint(displayPoint.x/2, displayPoint.y/1.5));
+ bDone = !calibrator.nextPoint();
+ }
+ pTrafo = calibrator.makeTransformer();
+ TEST( calcDist( pTrafo->transformBlobToScreen( DPoint(1.00,1.00) ), DPoint(2.00,1.50)) <1 );
+// cerr << "scale: " << scale << ", offset: " << offset << endl;
+ TEST(checkTransform(pTrafo, DPoint(0,0), DPoint(0,0)));
+ TEST(checkTransform(pTrafo, DPoint(640, 480), DPoint(640, 480)));
+ TEST(checkBlobToScreen(pTrafo, DPoint(0,0), DPoint(0,0)));
+ TEST(checkBlobToScreen(pTrafo, DPoint(640, 480), DPoint(1280, 720)));
+ }
+ }
+
+ bool checkTransform(CoordTransformerPtr pTrafo, const DPoint& srcPt,
+ const DPoint& destPt)
+ {
+ DPoint ResultPt = pTrafo->transform_point(srcPt);
+// cerr << srcPt << " -> " << ResultPt << ", expected " << destPt << endl;
+ return ((fabs(ResultPt.x-destPt.x) < 0.1) && (fabs(ResultPt.y-destPt.y) < 0.1));
+ }
+
+ bool checkBlobToScreen(DeDistortPtr pTrafo,
+ const DPoint& srcPt, const DPoint& destPt)
+ {
+ DPoint ResultPt = pTrafo->transformBlobToScreen(pTrafo->transform_point(srcPt));
+// cerr << srcPt << " -> " << ResultPt << ", expected " << destPt << endl;
+ return ((fabs(ResultPt.x-destPt.x) < 1) && (fabs(ResultPt.y-destPt.y) < 1));
+ }
+
+};
+
+class CalibratorTestSuite: public TestSuite {
+public:
+ CalibratorTestSuite()
+ : TestSuite("CalibratorTestSuite")
+ {
+ addTest(TestPtr(new CalibratorTest));
+ }
+};
+
+
+int main(int nargs, char** args)
+{
+ CalibratorTestSuite suite;
+ suite.runTests();
+ bool bOK = suite.isOk();
+
+ if (bOK) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
diff --git a/src/player/testplayer.cpp b/src/player/testplayer.cpp
new file mode 100644
index 0000000..342a2c4
--- /dev/null
+++ b/src/player/testplayer.cpp
@@ -0,0 +1,88 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "Player.h"
+
+#include "../base/TestSuite.h"
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <string>
+
+using namespace avg;
+using namespace std;
+
+class PlayerTest: public Test {
+public:
+ PlayerTest()
+ : Test("PlayerTest", 2)
+ {
+ }
+
+ void runTests()
+ {
+ Player player;
+ player.loadString(
+ " <?xml version=\"1.0\"?>"
+ " <avg width=\"160\" height=\"120\">"
+ " <words text=\"foo\"/>"
+ " </avg>"
+ );
+ player.disablePython();
+ if (!getenv("AVG_CONSOLE_TEST")) {
+ player.initPlayback();
+ player.doFrame(false);
+ player.cleanup();
+ }
+ try {
+ throw bad_cast();
+ } catch (bad_cast&) {
+
+ }
+ }
+};
+
+class PlayerTestSuite: public TestSuite {
+public:
+ PlayerTestSuite()
+ : TestSuite("PlayerTestSuite")
+ {
+ addTest(TestPtr(new PlayerTest));
+ }
+};
+
+
+int main(int nargs, char** args)
+{
+ PlayerTestSuite suite;
+ suite.runTests();
+ bool bOK = suite.isOk();
+
+ if (bOK) {
+ return 0;
+ } else {
+ return 1;
+ }
+}
+
diff --git a/src/python/Makefile.am b/src/python/Makefile.am
new file mode 100644
index 0000000..92fede9
--- /dev/null
+++ b/src/python/Makefile.am
@@ -0,0 +1,6 @@
+SUBDIRS = ui data
+pkgpyexec_PYTHON = anim.py draggable.py camcalibrator.py textarea.py\
+ clusteredEventList.py eventList.py gameapp.py grabbable.py \
+ mathutil.py app.py appstarter.py utils.py \
+ trackerhelper.py mtemu.py geom.py parsecamargs.py apphelpers.py \
+ statemachine.py coordcalibrator.py graph.py __init__.py
diff --git a/src/python/Makefile.in b/src/python/Makefile.in
new file mode 100644
index 0000000..c2bcb3e
--- /dev/null
+++ b/src/python/Makefile.in
@@ -0,0 +1,703 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/python
+DIST_COMMON = $(pkgpyexec_PYTHON) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkgpyexecdir)"
+py_compile = $(top_srcdir)/py-compile
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = ui data
+pkgpyexec_PYTHON = anim.py draggable.py camcalibrator.py textarea.py\
+ clusteredEventList.py eventList.py gameapp.py grabbable.py \
+ mathutil.py app.py appstarter.py utils.py \
+ trackerhelper.py mtemu.py geom.py parsecamargs.py apphelpers.py \
+ statemachine.py coordcalibrator.py graph.py __init__.py
+
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/python/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/python/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-pkgpyexecPYTHON: $(pkgpyexec_PYTHON)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgpyexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgpyexecdir)"
+ @list='$(pkgpyexec_PYTHON)'; dlist=; list2=; test -n "$(pkgpyexecdir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
+ if test -f $$b$$p; then \
+ $(am__strip_dir) \
+ dlist="$$dlist $$f"; \
+ list2="$$list2 $$b$$p"; \
+ else :; fi; \
+ done; \
+ for file in $$list2; do echo $$file; done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgpyexecdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgpyexecdir)" || exit $$?; \
+ done || exit $$?; \
+ if test -n "$$dlist"; then \
+ if test -z "$(DESTDIR)"; then \
+ PYTHON=$(PYTHON) $(py_compile) --basedir "$(pkgpyexecdir)" $$dlist; \
+ else \
+ PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(pkgpyexecdir)" $$dlist; \
+ fi; \
+ else :; fi
+
+uninstall-pkgpyexecPYTHON:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgpyexec_PYTHON)'; test -n "$(pkgpyexecdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ filesc=`echo "$$files" | sed 's|$$|c|'`; \
+ fileso=`echo "$$files" | sed 's|$$|o|'`; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$files || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$filesc ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$filesc || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$fileso ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$fileso
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @fail= failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @fail= failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(pkgpyexecdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-pkgpyexecPYTHON
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-pkgpyexecPYTHON
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+ install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-am clean clean-generic clean-libtool \
+ ctags ctags-recursive distclean distclean-generic \
+ distclean-libtool distclean-tags distdir dvi dvi-am html \
+ html-am info info-am install install-am install-data \
+ install-data-am install-dvi install-dvi-am install-exec \
+ install-exec-am install-html install-html-am install-info \
+ install-info-am install-man install-pdf install-pdf-am \
+ install-pkgpyexecPYTHON install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs installdirs-am \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags tags-recursive uninstall uninstall-am \
+ uninstall-pkgpyexecPYTHON
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/python/__init__.py b/src/python/__init__.py
new file mode 100644
index 0000000..de2addb
--- /dev/null
+++ b/src/python/__init__.py
@@ -0,0 +1,19 @@
+# Work around libstdc++ Mesa bug
+# (https://bugs.launchpad.net/ubuntu/+source/mesa/+bug/259219)
+from platform import system
+if system() == 'Linux':
+ from ctypes import cdll
+ cdll.LoadLibrary("libpixman-1.so.0")
+ cdll.LoadLibrary("libstdc++.so.6")
+del system
+
+from avg import *
+import anim
+import draggable
+import textarea
+import statemachine
+from grabbable import Grabbable
+from app import AVGApp, App
+from appstarter import AVGAppStarter, AVGMTAppStarter, AppStarter
+import utils
+import gameapp
diff --git a/src/python/anim.py b/src/python/anim.py
new file mode 100644
index 0000000..1e70916
--- /dev/null
+++ b/src/python/anim.py
@@ -0,0 +1,487 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+"""
+Deprecated framework for time-based animations - there is a better
+framework in the avg module.
+"""
+
+import math
+from libavg import avg
+
+g_Player = None
+
+# Map of all active SimpleAnimations: (node, attribute)->SimpleAnimation
+g_ActiveAnimations = {}
+
+def getNumRunningAnims():
+ return len(g_ActiveAnimations)
+
+def abortAnim(node, attrName):
+ global g_ActiveAnimations
+ if g_ActiveAnimations.has_key((node, attrName)):
+ curAnim = g_ActiveAnimations.get((node, attrName))
+ curAnim._remove()
+
+g_DeprecationWarned = False
+
+def deprecationWarning():
+ global g_DeprecationWarned
+ if not(g_DeprecationWarned):
+ g_DeprecationWarned = True
+ print "The anim package is deprecated and will be removed in the next release; use the anim classes in the avg namespace instead."
+
+class SimpleAnim:
+ """
+ Deprecated.
+ Base class for animations that change libavg node attributes by interpolating
+ over a set amount of time. Constructing an animation object starts the
+ animation. If abort() isn't needed, there is no need to hold on to the object -
+ it will exist exactly as long as the animation lasts and then disappear.
+
+ The animation framework makes sure that only one animation per attribute of a
+ node runs at any given time. If a second one is started, the first one is
+ silently aborted.
+ """
+ def __init__(self, node, attrName, duration, useInt, onStop, onStart):
+ global g_Player
+ global g_ActiveAnimations
+
+ deprecationWarning()
+ g_Player = avg.Player.get()
+ self.node = node
+ self.attrName = attrName
+ self.duration = duration
+ self.onStart = onStart
+ self.onStop = onStop
+ self.onAbort = lambda: None
+ self.useInt = useInt
+
+ def setHandler(self, onStop, onAbort):
+ self.onStop = onStop
+ self.onAbort = onAbort
+
+ def start(self, keepAttr=False):
+ abortAnim(self.node, self.attrName)
+ g_ActiveAnimations[(self.node, self.attrName)] = self
+ if keepAttr:
+ self._calcStartTime()
+ else:
+ self.startTime = g_Player.getFrameTime()
+ self.__interval = g_Player.setOnFrameHandler(self._step)
+ self.__done = False
+ if self.onStart:
+ self.onStart()
+ if self.duration == 0:
+ self._regularStop()
+ elif self.duration:
+ self.__stopTimeout = g_Player.setTimeout(self.duration, self._regularStop)
+ self._step()
+
+ def abort(self):
+ """
+ Stops the animation. Does not call onStop()
+ """
+ if not(self.isDone()):
+ self._remove()
+ if self.onAbort:
+ self.onAbort()
+
+ def isDone(self):
+ """
+ Returns True if the animation has run its course.
+ """
+ return self.__done
+
+ def _remove(self):
+ global g_ActiveAnimations
+ self.__done = True
+ g_ActiveAnimations.pop((self.node, self.attrName))
+ g_Player.clearInterval(self.__interval)
+ if self.duration:
+ g_Player.clearInterval(self.__stopTimeout)
+
+
+class LinearAnim(SimpleAnim):
+ """
+ Deprecated.
+ Class that animates an attribute of a libavg node by interpolating linearly
+ between start and end values.
+ """
+ def __init__(self, node, attrName, duration, startValue, endValue, useInt=False,
+ onStop=None, onStart=None):
+ """
+ @param node: The libavg node object to animate.
+ @param attrName: The name of the attribute to change. Must be a numeric
+ attribute.
+ @param duration: The length of the animation in milliseconds.
+ @param startValue: Initial value of the attribute.
+ @param endValue: Value of the attribute after duration has elapsed.
+ @param useInt: If True, the attribute is always set to an integer value.
+ @param onStop: Python callable to invoke when duration has elapsed and
+ the animation has finished. This can be used to chain
+ animations together by using lambda to create a second animation.
+ """
+ self.__startValue = startValue
+ self.__endValue = endValue
+ SimpleAnim.__init__(self, node, attrName, duration, useInt, onStop, onStart)
+
+ def _step(self):
+ if not(self.isDone()):
+ part = ((float(g_Player.getFrameTime())-self.startTime)/self.duration)
+ if part > 1.0:
+ part = 1.0
+ curValue = self.__startValue+(self.__endValue-self.__startValue)*part
+ if self.useInt:
+ curValue = int(curValue+0.5)
+ setattr(self.node, self.attrName, curValue)
+
+ def _regularStop(self):
+ setattr(self.node, self.attrName, self.__endValue)
+ self._remove()
+ if self.onStop != None:
+ self.onStop()
+
+ def _calcStartTime(self):
+ curVal = getattr(self.node, self.attrName)
+ part = float(curVal-self.__startValue)/(self.__endValue-self.__startValue)
+ self.startTime = g_Player.getFrameTime()-part*self.duration
+
+
+class EaseInOutAnim(SimpleAnim):
+ def __init__(self, node, attrName, duration, startValue, endValue,
+ easeInDuration, easeOutDuration, useInt=False, onStop=None,
+ onStart=None):
+ self.__startValue = startValue
+ self.__endValue = endValue
+ self.__easeInDuration = float(easeInDuration)/duration
+ self.__easeOutDuration = float(easeOutDuration)/duration
+ SimpleAnim.__init__(self, node, attrName, duration, useInt, onStop, onStart)
+
+ def _step(self):
+ if not(self.isDone()):
+ t = (float(g_Player.getFrameTime())-self.startTime)/self.duration;
+ part = self.__ease(t, self.__easeInDuration, self.__easeOutDuration)
+ curValue = self.__startValue+(self.__endValue-self.__startValue)*part
+ if self.useInt:
+ curValue = int(curValue+0.5)
+ setattr(self.node, self.attrName, curValue)
+
+ def _regularStop(self):
+ setattr(self.node, self.attrName, self.__endValue)
+ self._remove()
+ if self.onStop != None:
+ self.onStop()
+
+ def _calcStartTime(self):
+ #XXX: This calculates an inaccurate start time
+ curVal = getattr(self.node, self.attrName)
+ part = float(curVal-self.__startValue)/(self.__endValue-self.__startValue)
+ self.startTime = g_Player.getFrameTime()-part*self.duration
+
+ def __ease(self, t, easeInDuration, easeOutDuration):
+ # All times here are normalized to be between 0 and 1
+ if t > 1:
+ t=1
+ accelDist = easeInDuration*2/math.pi
+ decelDist = easeOutDuration*2/math.pi
+ if t<easeInDuration:
+ # Acceleration stage
+ nt=t/easeInDuration
+ s=math.sin(-math.pi/2+nt*math.pi/2)+1;
+ dist=s*accelDist;
+ elif t > 1-easeOutDuration:
+ # Deceleration stage
+ nt = (t-(1-easeOutDuration))/easeOutDuration
+ s = math.sin(nt*math.pi/2)
+ dist = accelDist+(1-easeInDuration-easeOutDuration)+s*decelDist
+ else:
+ # Linear stage
+ dist = accelDist+t-easeInDuration
+ return dist/(accelDist+(1-easeInDuration-easeOutDuration)+decelDist)
+
+
+class SplineAnim(SimpleAnim):
+ """
+ Deprecated.
+ Class that animates an attribute of a libavg node by interpolating
+ between start and end values using a cubic spline.
+ """
+ def __init__(self, node, attrName, duration, startValue, startSpeed, endValue,
+ endSpeed, useInt=False, onStop=None, onStart=None):
+ """
+ @param node: The libavg node object to animate.
+ @param attrName: The name of the attribute to change. Must be a numeric
+ attribute.
+ @param duration: The length of the animation in milliseconds.
+ @param startValue: Initial value of the attribute.
+ @param startSpeed: Initial speed of the animation.
+ @param endValue: Value of the attribute after duration has elapsed.
+ @param endSpeed: Final speed of the animation.
+ @param useInt: If True, the attribute is always set to an integer value.
+ @param onStop: Python callable to invoke when duration has elapsed and
+ the animation has finished. This can be used to chain
+ animations together by using lambda to create a second animation.
+ """
+ self.__startValue = startValue+0.0
+ self.__startSpeed = startSpeed
+ self.__endValue = endValue
+ self.__endSpeed = endSpeed
+ self.__a = -2*(self.__endValue-self.__startValue)+self.__startSpeed+self.__endSpeed
+ self.__b = 3*(self.__endValue-self.__startValue)-2*self.__startSpeed-self.__endSpeed
+ self.__c = self.__startSpeed
+ self.__d = self.__startValue
+ SimpleAnim.__init__(self, node, attrName, duration, useInt, onStop, onStart)
+
+ def _step(self):
+ if not(self.isDone()):
+ part = ((float(g_Player.getFrameTime())-self.startTime)/self.duration)
+ if part > 1.0:
+ part = 1.0
+ curValue = ((self.__a*part+self.__b)*part+self.__c)*part+self.__d
+ if self.useInt:
+ curValue = int(curValue+0.5)
+ setattr(self.node, self.attrName, curValue)
+
+ def _regularStop(self):
+ setattr(self.node, self.attrName, self.__endValue)
+ self._remove()
+ if self.onStop != None:
+ self.onStop()
+
+ def _calcStartTime(self):
+ #XXX: This calculates an inaccurate start time
+ curVal = getattr(self.node, self.attrName)
+ part = float(curVal-self.__startValue)/(self.__endValue-self.__startValue)
+ self.startTime = g_Player.getFrameTime()-part*self.duration
+
+
+def fadeOut(node, duration, onStop = None):
+ """
+ Deprecated.
+ Fades the opacity of a node to zero.
+ @param node: The node to fade.
+ @param duration: Length of the fade in milliseconds.
+ """
+ fader = LinearAnim(node, "opacity", duration, node.opacity, 0, onStop = onStop)
+ fader.start()
+ return fader
+
+def fadeIn(node, duration, max=1.0, onStop = None):
+ """
+ Deprecated.
+ Fades the opacity of a node.
+ @param node: The node to fade.
+ @param duration: Length of the fade in milliseconds.
+ @param max: The opacity of the node at the end of the fade.
+ """
+ fader = LinearAnim(node, "opacity", duration, node.opacity, max, onStop = onStop)
+ fader.start()
+ return fader
+
+
+class ContinuousAnim(SimpleAnim):
+ """
+ Deprecated.
+ Class that animates an attribute of a libavg node continuously and
+ linearly. The animation will not stop until the abort() method is called.
+ A possible use case is the continuous rotation of an object.
+ """
+ def __init__(self, node, attrName, startValue, speed, useInt=False,
+ onStart=None):
+ """
+ @param node: The libavg node object to animate.
+ @param attrName: The name of the attribute to change. Must be a numeric
+ attribute.
+ @param startValue: Initial value of the attribute.
+ @param speed: Animation speed, value to be added per second.
+ @param useInt: If True, the attribute is always set to an integer value.
+ """
+ self.__startValue = startValue
+ self.__speed = speed
+ SimpleAnim.__init__(self, node, attrName, None, useInt, None, onStart)
+
+ def _step(self):
+ time = (float(g_Player.getFrameTime())-self.startTime)/1000
+ curValue = self.__startValue+time*self.__speed
+ if self.useInt:
+ curValue = int(curValue+0.5)
+ setattr(self.node, self.attrName, curValue)
+
+ def _calcStartTime(self):
+ curVal = getattr(self.node, self.attrName)
+ self.__startValue = curVal
+
+
+class WaitAnim:
+ def __init__(self, duration=None, onStop=None, onStart=None):
+ self.__duration = duration
+ self.onStart = onStart
+ self.onStop = onStop
+ self.onAbort = None
+ self.__isDone = True
+
+ def setHandler(self, onStop, onAbort):
+ self.onStop = onStop
+ self.onAbort = onAbort
+
+ def start(self, keepAttr=False):
+ self.__isDone = False
+ if self.onStart:
+ self.onStart()
+ if self.__duration:
+ self.__stopTimeout = g_Player.setTimeout(self.__duration, self.__regularStop)
+ else:
+ self.__stopTimeout = None
+
+ def abort(self):
+ if self.__stopTimeout:
+ g_Player.clearInterval(self.__stopTimeout)
+ if not(self.__isDone):
+ self.__isDone = True
+ if self.onAbort:
+ self.onAbort()
+
+ def isDone(self):
+ return self.__isDone
+
+ def _calcStartTime(self):
+ pass
+
+ def __regularStop(self):
+ g_Player.clearInterval(self.__stopTimeout)
+ self.__isDone = True
+ self.onStop()
+
+
+class ParallelAnim:
+ def __init__(self, anims, onStop=None, onStart=None, maxAge=None):
+ self.__anims = anims
+ self.onStart = onStart
+ self.onStop = onStop
+ self.__maxAge = maxAge
+ self.__isDone = False
+
+ def setHandler(self, onStop, onAbort):
+ self.onStop = onStop
+ self.onAbort = onAbort
+
+ def start(self, keepAttr=False):
+ self.__isDone = False
+ if self.onStart:
+ self.onStart()
+ self.__runningAnims = self.__anims[:]
+ if self.__maxAge:
+ self.__maxAgeTimeout = g_Player.setTimeout(self.__maxAge,
+ self.__maxAgeReached)
+ for anim in self.__runningAnims:
+ stopHandler = lambda anim=anim: self.__animStopped(anim)
+ anim.setHandler(onStop = stopHandler, onAbort = stopHandler)
+ anim.start(keepAttr)
+
+ def abort(self):
+ if not(self.__isDone):
+ self.__isDone = True
+ for anim in self.__runningAnims:
+ anim.abort()
+ if self.onAbort:
+ self.onAbort()
+ if self.__maxAge:
+ g_Player.clearInterval(self.__maxAgeTimeout)
+
+ def isDone(self):
+ return self.__isDone
+
+ def __maxAgeReached(self):
+ if not(self.__isDone):
+ for anim in self.__runningAnims:
+ anim.abort()
+ self.onStop()
+ self.__isDone = True
+
+ def __animStopped(self, anim):
+ self.__runningAnims.remove(anim)
+ if len(self.__runningAnims) == 0 and not(self.__isDone):
+ self.onStop()
+ self.__isDone = True
+ if self.__maxAge:
+ g_Player.clearInterval(self.__maxAgeTimeout)
+
+
+class StateAnim:
+ def __init__(self, states, transitions, initialState=None):
+ self.__states = states
+ for name in states:
+ states[name].setHandler(self.__onStateDone, None)
+ self.__transitions = transitions
+ self.__curState = None
+ self.__debug = False
+ if initialState:
+ self.setState(initialState)
+
+ def delete(self):
+ if self.__debug:
+ print self, " delete"
+ self.setState(None)
+
+ def setState(self, stateName, keepAttr=False):
+ if self.__debug:
+ print self, " setState: ", self.__curState, "-->", stateName
+ if self.__curState == stateName:
+ return
+ if self.__curState:
+ self.__states[self.__curState].abort()
+ self.__curState = stateName
+ if stateName:
+ self.__states[stateName].start(keepAttr)
+
+ def getState(self):
+ return self.__curState
+
+ def setDebug(self, debug):
+ self.__debug = debug
+
+ def __onStateDone(self):
+ if self.__curState in self.__transitions:
+ transition = self.__transitions[self.__curState]
+ if transition.callback:
+ transition.callback()
+ stateName = transition.nextAnimName
+ if self.__debug:
+ print self, " StateDone: ", self.__curState, "-->", stateName
+ self.__curState = stateName
+ self.__states[stateName].start()
+ else:
+ if self.__debug:
+ print self, " StateDone: ", self.__curState, "--> None"
+ self.__curState = None
+
+
+class AnimTransition:
+ def __init__(self, nextAnimName, callback = None):
+ self.nextAnimName = nextAnimName
+ self.callback = callback
+
+
+def init(g_avg):
+ global avg
+ global g_ActiveAnimations
+ avg = g_avg
+ g_ActiveAnimations = {}
diff --git a/src/python/app.py b/src/python/app.py
new file mode 100644
index 0000000..0961d90
--- /dev/null
+++ b/src/python/app.py
@@ -0,0 +1,144 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Martin Heistermann <mh at sponc dot de>
+#
+
+from libavg import avg
+from appstarter import AppStarter
+
+g_Player = avg.Player.get()
+g_Log = avg.Logger.get()
+
+class App(object):
+ _instances = {}
+
+ def __init__(self, parentNode):
+ '''
+ Initialization before Player.play()
+ Use this only when needed, e.g. for
+ WordsNode.addFontDir(). Do not forget to call
+ super(YourApp, self).__init__(parentNode)
+ '''
+
+ appname = self.__class__.__name__
+ if appname in AVGApp._instances:
+ raise RuntimeError('App %s already setup' % appname)
+
+ AVGApp._instances[appname] = self
+
+ self.__isRunning = False
+ self._parentNode = parentNode
+ self._starter = None
+
+ if 'onKey' in dir(self):
+ raise DeprecationWarning, \
+ 'AVGApp.onKey() has been renamed to AVGApp.onKeyDown().'
+
+ @classmethod
+ def get(cls):
+ '''
+ Get the Application instance
+
+ Note: this class method has to be called from the top-level app class:
+
+ >>> class MyApp(libavg.AVGApp):
+ ... pass
+ >>> instance = MyApp.get()
+ '''
+ return cls._instances.get(cls.__name__, None)
+
+ @classmethod
+ def start(cls, appStarter=AppStarter, **kwargs):
+ appStarter(appClass=cls, **kwargs)
+
+ def init(self):
+ """main initialization
+ build node hierarchy under self.__parentNode."""
+ pass
+
+ def exit(self):
+ """Deinitialization
+ Called after player.play() returns. End of program run."""
+ pass
+
+ def _enter(self):
+ """enter the application, internal interface.
+ override this and start all animations, intervals
+ etc. here"""
+ pass
+
+ def _leave(self):
+ """leave the application, internal interface.
+ override this and stop all animations, intervals
+ etc. Take care your application does not use any
+ non-needed resources after this."""
+ pass
+
+ def enter(self, onLeave = lambda: None):
+ """enter the application, external interface.
+ Do not override this."""
+ self.__isRunning = True
+ self._onLeave = onLeave
+ self._enter()
+
+ def leave(self):
+ """leave the application, external interface.
+ Do not override this."""
+ self.__isRunning = False
+ self._onLeave()
+ self._leave()
+
+ def onKeyDown(self, event):
+ """returns bool indicating if the event was handled
+ by the application """
+ return False
+
+ def onKeyUp(self, event):
+ """returns bool indicating if the event was handled
+ by the application """
+ return False
+
+ def isRunning(self):
+ return self.__isRunning
+
+ def setStarter(self, starter):
+ self._starter = starter
+
+ def getStarter(self):
+ return self._starter
+
+
+class AVGApp(App):
+ '''Backward compatibility class'''
+ multitouch = False
+ fakeFullscreen = False
+
+ @classmethod
+ def start(cls, **kwargs):
+ # TODO: deprecation warning
+ if cls.multitouch:
+ from appstarter import AVGMTAppStarter
+ starter = AVGMTAppStarter
+ else:
+ from appstarter import AVGAppStarter
+ starter = AVGAppStarter
+
+ super(AVGApp, cls).start(appStarter=starter,
+ fakeFullscreen=cls.fakeFullscreen, **kwargs)
diff --git a/src/python/apphelpers.py b/src/python/apphelpers.py
new file mode 100644
index 0000000..65e9f1e
--- /dev/null
+++ b/src/python/apphelpers.py
@@ -0,0 +1,367 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import os
+
+from libavg import avg
+
+g_Player = avg.Player.get()
+
+
+class BaseTouchVisualization(avg.DivNode):
+
+ def __init__(self, event, **kwargs):
+ avg.DivNode.__init__(self, **kwargs)
+ self.contact = event.contact
+ self.listenerid = event.contact.connectListener(self._onMotion, self._onUp)
+ self.pos = avg.Point2D(event.pos)
+ self._fingerSize = 7*g_Player.getPixelsPerMM() # Assume 14mm width for a finger.
+ self._radius = max(self._fingerSize, event.majoraxis.getNorm())
+
+ def _abort(self):
+ self.contact.disconnectListener(self.listenerid)
+ self.contact = None
+
+ def _onMotion(self, event):
+ self.pos = event.pos
+ self._radius = max(self._fingerSize, event.majoraxis.getNorm())
+
+ def _onUp(self, event):
+ self.unlink(True)
+ self.contact = None
+ del self
+
+
+class DebugTouchVisualization(BaseTouchVisualization):
+
+ def __init__(self, event, **kwargs):
+ BaseTouchVisualization.__init__(self, event, **kwargs)
+ self.positions = [event.pos]
+
+ if event.source == avg.TOUCH:
+ color = 'e5d8d8'
+ else:
+ color = 'd8e5e5'
+ self.opacity = 0.5
+
+ self.__transparentCircle = avg.CircleNode(r=self._radius+20, fillcolor=color,
+ fillopacity=0.2, opacity=0.0, strokewidth=1, sensitive=False, parent=self)
+ self.__pulsecircle = avg.CircleNode(r=self._radius, fillcolor=color, color=color,
+ fillopacity=0.5, opacity=0.5, strokewidth=1,
+ sensitive=False, parent=self)
+ self.__majorAxis = avg.LineNode(pos1=(0,0), pos2=event.majoraxis,
+ color='FFFFFF', sensitive=False, parent=self)
+ self.__minorAxis = avg.LineNode(pos1=(0,0), pos2=event.minoraxis,
+ color='FFFFFF', sensitive=False, parent=self)
+ if event.source == avg.TOUCH:
+ self.__handAxis = avg.LineNode(pos1=(0,0), pos2=self.__getHandVector(event),
+ opacity=0.5, color='A0FFA0', sensitive=False, parent=self)
+ fontPos = avg.Point2D(self.__pulsecircle.r, 0)
+ avg.WordsNode(pos=fontPos, text=str(event.cursorid), parent=self)
+ self.motionPath = avg.PolyLineNode(pos=self.positions,
+ opacity=0.7, color=color, parent=kwargs['parent'])
+ self.motionVector = avg.LineNode(pos1=(0,0) , pos2=-event.contact.motionvec,
+ opacity=0.4, parent=self)
+ pulseCircleAnim = avg.LinearAnim(self.__pulsecircle, 'r', 200, 50, self._radius)
+ pulseCircleAnim.start()
+
+ def __del__(self):
+ self.motionPath.unlink(True)
+
+ def _onMotion(self, event):
+ BaseTouchVisualization._onMotion(self, event)
+ self.positions.append(event.pos)
+ if len(self.positions) > 100:
+ self.positions.pop(0)
+
+ self.__pulsecircle.r = self._radius
+ self.__majorAxis.pos2 = event.majoraxis
+ self.__minorAxis.pos2 = event.minoraxis
+ self.motionVector.pos2 = -event.contact.motionvec
+ if event.source == avg.TOUCH:
+ self.__handAxis.pos2 = self.__getHandVector(event)
+ self.motionPath.pos = self.positions
+
+ def __getHandVector(self, event):
+ return -avg.Point2D.fromPolar(event.handorientation, 30)
+
+
+class TouchVisualization(BaseTouchVisualization):
+
+ mediadir = os.path.join(os.path.dirname(__file__), 'data')
+ bmp = avg.Bitmap(mediadir+"/TouchFeedback.png")
+
+ def __init__(self, event, **kwargs):
+ BaseTouchVisualization.__init__(self, event, **kwargs)
+
+ if event.source == avg.TOUCH:
+ self.__circle = avg.ImageNode(parent=self)
+ self.__circle.setBitmap(TouchVisualization.bmp)
+ self.__setRadius(self._radius)
+ avg.LinearAnim(self.__circle, "opacity", 200, 0.7, 0.4).start()
+ else:
+ self.unlink(True)
+ self._abort()
+
+ def _onMotion(self, event):
+ BaseTouchVisualization._onMotion(self, event)
+ self.__setRadius(self._radius)
+
+ def _onUp(self, event):
+
+ def gone(self):
+ BaseTouchVisualization._onUp(self, event)
+ self.unlink(True)
+ del self
+
+ avg.fadeIn(self.__circle, 100, 1)
+ avg.LinearAnim(self.__circle, "size", 100, self.__circle.size, (4,4)).start()
+ avg.LinearAnim(self.__circle, "pos", 100, self.__circle.pos, (-2,-2)).start()
+ g_Player.setTimeout(100, lambda: gone(self))
+
+ def __setRadius(self, radius):
+ self.__circle.pos = (-radius, -radius)
+ self.__circle.size = (radius*2,radius*2)
+
+
+class TouchVisualizationOverlay(avg.DivNode):
+ def __init__(self, isDebug, visClass, **kwargs):
+ super(TouchVisualizationOverlay, self).__init__(**kwargs)
+ self.sensitive = False
+ self.visClass = visClass
+
+ rootNode = g_Player.getRootNode()
+ if isDebug:
+ self.elementoutlinecolor='FFFFAA'
+ avg.RectNode(parent=self, size=self.size, fillopacity=0.2, fillcolor='000000')
+ rootNode.connectEventHandler(avg.CURSORDOWN, avg.TOUCH | avg.TRACK,
+ self, self.__onTouchDown)
+
+ def deinit(self):
+ rootNode = g_Player.getRootNode()
+ rootNode.disconnectEventHandler(self, self.__onTouchDown)
+
+ def __onTouchDown(self, event):
+ self.visClass(event, parent=self)
+
+
+class KeysCaptionNode(avg.DivNode):
+ def __init__(self, **kwargs):
+ super(KeysCaptionNode, self).__init__(**kwargs)
+ self.sensitive = False
+ self.opacity = 0
+
+ self.__background = avg.RectNode(fillcolor='000000', fillopacity=0.6,
+ opacity=0, size=(450, 450), parent=self)
+
+ self.__keysNode = avg.WordsNode(pos=(10, 10), fontsize=18,
+ color='DDDDDD', parent=self)
+
+ self.__isShown = False
+
+ def toggleHelp(self):
+ self.__isShown = not self.__isShown
+
+ keys = g_KbManager.getActiveKeyBindings()
+
+ if self.__isShown:
+ helpText = '<span><b> ACTIVE KEYS </b><br/></span>'
+
+ for keyObj in sorted(keys, key=lambda ko: ko.key):
+ if keyObj.state == 'up':
+ stateAddition = ' (up)'
+ else:
+ stateAddition = ''
+
+ helpText += ('<span><b>%s</b> '
+ '<small>%s%s</small></span><br/>' % (keyObj.key,
+ keyObj.description, stateAddition))
+
+ self.__keysNode.text = helpText
+ self.opacity = 1
+ self.__background.size = self.__keysNode.getMediaSize()
+
+ self.getParent().reorderChild(
+ self.getParent().indexOf(self),
+ self.getParent().getNumChildren()-1)
+ else:
+ self.__keysNode.text = ''
+ self.opacity = 0
+
+
+class KeyBinding(object):
+ def __init__(self, key, description, state, callback):
+ if not isinstance(key, unicode) and not isinstance(key, str):
+ raise TypeError('KeyBinding key should be either a string or unicode object')
+
+ self.__key = key
+ self.__description = description
+ self.__state = state
+ self.__callback = callback
+
+ def __repr__(self):
+ return '<%s key=%s (%s) state=%s>' % (self.__class__.__name__,
+ self.__key, self.__description, self.__state)
+
+ @property
+ def key(self):
+ return self.__key
+
+ @property
+ def description(self):
+ return self.__description
+
+ @property
+ def state(self):
+ return self.__state
+
+ def checkKey(self, key, state):
+ if state is not None and self.__state != state:
+ return False
+
+ return self.__key == key
+
+ def checkEvent(self, event, state):
+ if self.__state != state:
+ return False
+
+ if isinstance(self.__key, unicode):
+ return self.__key == unichr(event.unicode)
+ else:
+ return self.__key == event.keystring
+
+ def executeCallback(self):
+ self.__callback()
+
+
+class KeyboardManager(object):
+ _instance = None
+ TOGGLE_HELP_UNICODE = 63
+
+ def __init__(self):
+ if self._instance is not None:
+ raise RuntimeError('KeyboardManager has been already instantiated')
+
+ self.__keyBindings = []
+ self.__keyBindingsStack = []
+
+ self.__onKeyDownCb = lambda e: False
+ self.__onKeyUpCb = lambda e: False
+
+ self.__keyCaptionsNode = None
+
+ KeyboardManager._instance = self
+
+ @classmethod
+ def get(cls):
+ if cls._instance is None:
+ cls()
+
+ return cls._instance
+
+ def setup(self, onKeyDownCb, onKeyUpCb):
+ rootNode = g_Player.getRootNode()
+ rootNode.setEventHandler(avg.KEYDOWN, avg.NONE, self.__onKeyDown)
+ rootNode.setEventHandler(avg.KEYUP, avg.NONE, self.__onKeyUp)
+
+ self.__onKeyDownCb = onKeyDownCb
+ self.__onKeyUpCb = onKeyUpCb
+
+ self.__keyCaptionsNode = KeysCaptionNode(pos=(5,5), parent=rootNode)
+
+ def teardown(self):
+ self.__keyBindings = []
+
+ self.__keyCaptionsNode.unlink(True)
+ del self.__keyCaptionsNode
+ self.__keyCaptionsNode = None
+
+ def push(self):
+ self.__keyBindingsStack.append(self.__keyBindings)
+ self.__keyBindings = []
+
+ def pop(self):
+ if not self.__keyBindingsStack:
+ raise RuntimeError('Empty stack')
+
+ self.__keyBindings = self.__keyBindingsStack.pop()
+
+ def getActiveKeyBindings(self):
+ return self.__keyBindings
+
+ def bindKey(self, key, func, funcName, state='down'):
+ if isinstance(key, unicode) and state != 'down':
+ raise RuntimeError('bindKey() with unicode keys '
+ 'can be used only with state=down')
+
+ if key == unichr(self.TOGGLE_HELP_UNICODE):
+ raise RuntimeError('%s key is reserved')
+
+ keyObj = self.__findKeyByKeystring(key, state)
+ if keyObj is not None:
+ raise RuntimeError('Key %s has already been bound (%s)' % (key, keyObj))
+
+ self.__keyBindings.append(KeyBinding(key, funcName, state, func))
+
+ def unbindKey(self, key):
+ keyObj = self.__findKeyByKeystring(key)
+
+ if keyObj is not None:
+ self.__keyBindings.remove(keyObj)
+ else:
+ raise KeyError('Key %s not found' % key)
+
+ def bindUnicode(self, key, func, funcName, state='down'):
+ raise DeprecationWarning('Use bindKey() passing an unicode object as keystring')
+
+ def __findKeyByEvent(self, event, state):
+ for keyObj in self.__keyBindings:
+ if keyObj.checkEvent(event, state):
+ return keyObj
+
+ return None
+
+ def __findKeyByKeystring(self, key, state=None):
+ for keyObj in self.__keyBindings:
+ if keyObj.checkKey(key, state):
+ return keyObj
+
+ return None
+
+ def __onKeyDown(self, event):
+ if self.__onKeyDownCb(event):
+ return
+ elif event.unicode == self.TOGGLE_HELP_UNICODE:
+ self.__keyCaptionsNode.toggleHelp()
+ else:
+ keyObj = self.__findKeyByEvent(event, 'down')
+ if keyObj is not None:
+ keyObj.executeCallback()
+
+ def __onKeyUp(self, event):
+ if self.__onKeyUpCb(event):
+ return
+ else:
+ keyObj = self.__findKeyByEvent(event, 'up')
+ if keyObj is not None:
+ keyObj.executeCallback()
+
+
+g_KbManager = KeyboardManager.get()
diff --git a/src/python/appstarter.py b/src/python/appstarter.py
new file mode 100644
index 0000000..89f8258
--- /dev/null
+++ b/src/python/appstarter.py
@@ -0,0 +1,373 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Martin Heistermann <mh at sponc dot de>
+#
+
+import os
+import gc
+import math
+
+from libavg import avg, Point2D
+import graph
+from mtemu import MTemu
+import apphelpers
+
+
+DEFAULT_RESOLUTION = (640, 480)
+
+g_Player = avg.Player.get()
+g_Log = avg.Logger.get()
+g_KbManager = apphelpers.KeyboardManager.get()
+
+
+class AppStarter(object):
+ '''Starts an AVGApp'''
+ def __init__(self, appClass, resolution=DEFAULT_RESOLUTION,
+ debugWindowSize=None, fakeFullscreen=False):
+ resolution = Point2D(resolution)
+ testMode = not 'AVG_DEPLOY' in os.environ
+
+ if testMode and debugWindowSize is not None:
+ debugWindowSize = Point2D(debugWindowSize)
+ else:
+ debugWindowSize = Point2D(0, 0)
+
+ self._setupBaseDivs(resolution)
+
+ g_Player.showCursor(testMode)
+
+ if fakeFullscreen:
+ if os.name != 'nt':
+ raise RuntimeError('Fakefullscreen is supported only on windows')
+ elif not testMode:
+ self.__enableFakeFullscreen()
+
+ fullscreen = False
+ else:
+ fullscreen = not testMode
+
+ g_Player.setResolution(
+ fullscreen,
+ int(debugWindowSize.x), int(debugWindowSize.y),
+ 0 # color depth
+ )
+
+ self._startApp(appClass)
+
+ def _startApp(self, appClass):
+ self._onBeforePlay()
+ g_Player.setTimeout(0, self._onStart)
+ self._appInstance = appClass(self._appNode)
+ g_KbManager.setup(
+ self._appInstance.onKeyDown,
+ self._appInstance.onKeyUp)
+
+ self._setupDefaultKeys()
+
+ self._appInstance.setStarter(self)
+ g_Player.play()
+ self._appInstance.exit()
+ g_KbManager.teardown()
+
+ def _setupBaseDivs(self, resolution):
+ g_Player.loadString('''
+<?xml version="1.0"?>
+<!DOCTYPE avg SYSTEM "../../libavg/doc/avg.dtd">
+<avg width="%s" height="%s">
+</avg>''' % (resolution.x, resolution.y))
+
+ rootNode = g_Player.getRootNode()
+ self._appNode = avg.DivNode(opacity=0, sensitive=False,
+ size=rootNode.size, parent=rootNode)
+
+ def _setupDefaultKeys(self):
+ pass
+
+ def _onBeforePlay(self):
+ pass
+
+ def _onStart(self):
+ self._appInstance.init()
+ self._appNode.opacity = 1
+ self._appNode.sensitive = True
+ self._activeApp = self._appInstance
+ self._appInstance.enter()
+
+ def __enableFakeFullscreen(self):
+ g_Player.setWindowPos(0, 0)
+ g_Player.setWindowFrame(False)
+
+
+class AVGAppStarter(AppStarter):
+ def __init__(self, *args, **kwargs):
+ self.__graphs = 0
+ self._mtEmu = None
+ self.__showingMemGraph = False
+ self.__showingFrGraph = False
+ self.__notifyNode = None
+ self.__debugTouchVisOverlay = None
+
+ super(AVGAppStarter, self).__init__(*args, **kwargs)
+
+ def _setupDefaultKeys(self):
+ super(AVGAppStarter, self)._setupDefaultKeys()
+ g_KbManager.bindKey('o', self.__dumpObjects, 'Dump objects')
+ g_KbManager.bindKey('m', self.showMemoryUsage, 'Show memory usage')
+ g_KbManager.bindKey('f', self.showFrameRate, 'Show frameTime usage')
+ g_KbManager.bindKey('t', self.__switchMtemu, 'Activate multitouch emulation')
+ g_KbManager.bindKey('e', self.__switchShowMTEvents, 'Show multitouch events')
+ g_KbManager.bindKey('s', self.__screenshot, 'Take screenshot')
+
+ def __dumpObjects(self):
+ gc.collect()
+ testHelper = g_Player.getTestHelper()
+ testHelper.dumpObjects()
+ print 'Num anims: ', avg.getNumRunningAnims()
+ print 'Num python objects: ', len(gc.get_objects())
+
+ def showMemoryUsage(self):
+ if self.__showingMemGraph:
+ self.__memGraph.delete()
+ self.__memGraph = None
+ self.__graphs = self.__graphs -1
+ if(self.__graphs == 1 ):
+ self.__frGraph.setYpos(10)
+ else:
+ self.__memGraph = graph.MemGraph('Memory Graph',
+ getValue = avg.getMemoryUsage)
+ self.__graphs = self.__graphs +1
+ if(self.__graphs > 1 ):
+ self.__memGraph.setYpos(190)
+ self.__showingMemGraph = not(self.__showingMemGraph)
+
+ def showFrameRate(self):
+ if self.__showingFrGraph:
+ self.__frGraph.delete()
+ self.__frGraph = None
+ self.__graphs = self.__graphs -1
+ if(self.__graphs == 1 ):
+ self.__memGraph.setYpos(10)
+ else:
+ self.__frGraph = graph.FrameRateGraph('FrameTime Graph',
+ getValue = g_Player.getFrameTime)
+ self.__graphs = self.__graphs +1
+ if(self.__graphs >1):
+ self.__frGraph.setYpos(190)
+ self.__showingFrGraph = not(self.__showingFrGraph)
+
+ def __switchMtemu(self):
+ if self._mtEmu is None:
+ self._mtEmu = MTemu()
+ g_KbManager.bindKey('left shift', self._mtEmu.toggleDualTouch,
+ 'Toggle Multitouch Emulation')
+ g_KbManager.bindKey('right shift', self._mtEmu.toggleDualTouch,
+ 'Toggle Multitouch Emulation')
+ g_KbManager.bindKey('left ctrl', self._mtEmu.toggleSource,
+ 'Toggle Touch Source')
+ g_KbManager.bindKey('right ctrl', self._mtEmu.toggleSource,
+ 'Toggle Touch Source')
+ else:
+ self._mtEmu.deinit()
+ g_KbManager.unbindKey('left ctrl')
+ g_KbManager.unbindKey('right ctrl')
+ g_KbManager.unbindKey('left shift')
+ g_KbManager.unbindKey('right shift')
+
+ del self._mtEmu
+ self._mtEmu = None
+
+ def __switchShowMTEvents(self):
+ if self.__debugTouchVisOverlay is None:
+ rootNode = g_Player.getRootNode()
+ self.__debugTouchVisOverlay = apphelpers.TouchVisualizationOverlay(
+ isDebug=True, visClass=apphelpers.DebugTouchVisualization,
+ size=self._appNode.size, parent=rootNode)
+ else:
+ self.__debugTouchVisOverlay.deinit()
+ self.__debugTouchVisOverlay.unlink(True)
+ del self.__debugTouchVisOverlay
+ self.__debugTouchVisOverlay = None
+
+ def __killNotifyNode(self):
+ if self.__notifyNode:
+ self.__notifyNode.unlink()
+ self.__notifyNode = None
+
+ def __screenshot(self):
+ fnum = 0
+ fnameTemplate = 'screenshot-%03d.png'
+ while os.path.exists(fnameTemplate % fnum):
+ fnum += 1
+
+ try:
+ g_Player.screenshot().save('screenshot-%03d.png' % fnum)
+ except RuntimeError:
+ text = 'Cannot save snapshot file'
+ else:
+ text = 'Screenshot saved as ' + fnameTemplate % fnum
+
+ self.__killNotifyNode()
+
+ self.__notifyNode = avg.WordsNode(
+ text=text, x=g_Player.getRootNode().width - 50,
+ y=g_Player.getRootNode().height - 50, alignment='right', fontsize=20,
+ sensitive=False, parent=g_Player.getRootNode())
+
+ g_Player.setTimeout(2000, self.__killNotifyNode)
+
+
+class AVGMTAppStarter(AVGAppStarter):
+
+ def __init__(self, *args, **kwargs):
+ self.__touchVisOverlay = None
+ super(AVGMTAppStarter, self).__init__(*args, **kwargs)
+
+ def setTouchVisualization(self, visClass):
+ if not(self.__touchVisOverlay is None):
+ self.__touchVisOverlay.deinit()
+ self.__touchVisOverlay.unlink(True)
+ del self.__touchVisOverlay
+ self.__touchVisOverlay = None
+ if not(visClass is None):
+ rootNode = g_Player.getRootNode()
+ self.__touchVisOverlay = apphelpers.TouchVisualizationOverlay(
+ isDebug=False, visClass=visClass, size=self._appNode.size,
+ parent=rootNode)
+
+ def toggleTrackerImage(self):
+ if self.__showTrackerImage:
+ self.hideTrackerImage()
+ else:
+ self.showTrackerImage()
+
+ def showTrackerImage(self):
+ if self.__showTrackerImage:
+ return
+ self.__showTrackerImage = True
+ self.__updateTrackerImageInterval = \
+ g_Player.setOnFrameHandler(self.__updateTrackerImage)
+ self.__trackerImageNode.opacity = 1
+ self.tracker.setDebugImages(False, True)
+
+ def hideTrackerImage(self):
+ if not self.__showTrackerImage:
+ return
+ self.__showTrackerImage = False
+ if self.__updateTrackerImageInterval:
+ g_Player.clearInterval(self.__updateTrackerImageInterval)
+ self.__updateTrackerImageInterval = None
+ self.__trackerImageNode.opacity = 0
+ self.tracker.setDebugImages(False, False)
+
+ def __updateTrackerImage(self):
+ def transformPos((x,y)):
+ if self.trackerFlipX:
+ x = 1 - x
+ if self.trackerFlipY:
+ y = 1 - y
+ return (x, y)
+
+ fingerBitmap = self.tracker.getImage(avg.IMG_FINGERS)
+ node = self.__trackerImageNode
+ node.setBitmap(fingerBitmap)
+ node.pos = self.tracker.getDisplayROIPos()
+ node.size = self.tracker.getDisplayROISize()
+
+ grid = node.getOrigVertexCoords()
+ grid = [ [ transformPos(pos) for pos in line ] for line in grid]
+ node.setWarpedVertexCoords(grid)
+
+ def _onStart(self):
+ from camcalibrator import Calibrator
+
+ # we must add the tracker first, calibrator depends on it
+ try:
+ g_Player.enableMultitouch()
+ except RuntimeError, err:
+ g_Log.trace(g_Log.WARNING, str(err))
+
+ self.tracker = g_Player.getTracker()
+
+ if self.tracker:
+ if Calibrator:
+ self.__calibratorNode = g_Player.createNode('div',{
+ 'opacity': 0,
+ 'active': False,
+ })
+ rootNode = g_Player.getRootNode()
+ rootNode.appendChild(self.__calibratorNode)
+ self.__calibratorNode.size = rootNode.size
+ self.__calibrator = Calibrator(self.__calibratorNode, appStarter=self)
+ self.__calibrator.setOnCalibrationSuccess(self.__onCalibrationSuccess)
+ self.__calibrator.init()
+ else:
+ self.__calibrator = None
+
+ self.__showTrackerImage = False
+ self.__updateTrackerImageInterval = None
+ self.__trackerImageNode = g_Player.createNode('image', {'sensitive': False})
+ g_Player.getRootNode().appendChild(self.__trackerImageNode)
+
+ self.__updateTrackerImageFixup()
+
+ g_KbManager.bindKey('h', self.tracker.resetHistory, 'RESET tracker history')
+ g_KbManager.bindKey('d', self.toggleTrackerImage, 'toggle tracker image')
+
+ if self.__calibrator:
+ g_KbManager.bindKey('c', self.__enterCalibrator, 'enter calibrator')
+ AVGAppStarter._onStart(self)
+
+ def __updateTrackerImageFixup(self):
+ # finger bitmap might need to be rotated/flipped
+ trackerAngle = float(self.tracker.getParam('/transform/angle/@value'))
+ angle = round(trackerAngle/math.pi) * math.pi
+ self.__trackerImageNode.angle = angle
+ self.trackerFlipX = (float(self.tracker.getParam('/transform/displayscale/@x'))
+ < 0)
+ self.trackerFlipY = (float(self.tracker.getParam('/transform/displayscale/@y'))
+ < 0)
+
+ def __onCalibrationSuccess(self):
+ self.__updateTrackerImageFixup()
+
+ def __enterCalibrator(self):
+
+ def leaveCalibrator():
+ g_KbManager.unbindKey('e')
+ self._activeApp = self._appInstance
+ self._appInstance.enter()
+ self.__calibrator.leave()
+ self._appNode.opacity = 1
+ self._appNode.active = True
+ self.__calibratorNode.opacity = 0
+ self.__calibratorNode.active = False
+
+ if self.__calibrator.isRunning():
+ print "calibrator already running!"
+ return
+
+ self._activeApp = self.__calibrator
+ self.__calibrator.enter()
+ g_KbManager.bindKey('e', leaveCalibrator, 'leave Calibrator')
+ self._appInstance.leave()
+ self.__calibratorNode.opacity = 1
+ self.__calibratorNode.active = True
+ self._appNode.opacity = 0
+ self._appNode.active = False
diff --git a/src/python/camcalibrator.py b/src/python/camcalibrator.py
new file mode 100644
index 0000000..784048d
--- /dev/null
+++ b/src/python/camcalibrator.py
@@ -0,0 +1,474 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is igor <igor (at) c-base (dot) org>
+#
+
+import sys, os
+from libavg import avg, AVGApp, AVGAppStarter
+
+import coordcalibrator
+import apphelpers
+
+mediadir = os.path.join(os.path.dirname(__file__), 'data')
+g_Player = avg.Player.get()
+g_Log = avg.Logger.get()
+g_KbManager = apphelpers.KeyboardManager.get()
+
+
+def camera_setup(CameraType):
+ if CameraType == "Fire-i":
+ paramList = [
+ {'Name':"Brightness",
+ 'path':"/camera/brightness/@value",
+ 'min':128, 'max':383, 'increment':1, 'precision':0},
+ {'Name':"Exposure",
+ 'path':"/camera/exposure/@value",
+ 'min':-1, 'max':511, 'increment':1, 'precision':0},
+ {'Name':"Shutter",
+ 'path':"/camera/shutter/@value",
+ 'min':0, 'max':7, 'increment':1, 'precision':0},
+ {'Name':"Gain",
+ 'path':"/camera/gain/@value",
+ 'min':0, 'max':255, 'increment':1, 'precision':0},
+ ]
+ elif CameraType == "FireFly":
+ paramList = [
+ {'Name':"Brightness",
+ 'path':"/camera/brightness/@value",
+ 'min':1, 'max':255, 'increment':1, 'precision':0},
+ {'Name':"Shutter",
+ 'path':"/camera/shutter/@value",
+ 'min':1, 'max':533, 'increment':1, 'precision':0},
+ {'Name':"Gain",
+ 'path':"/camera/gain/@value",
+ 'min':16, 'max':64, 'increment':1, 'precision':0},
+ {'Name':"Gamma",
+ 'path':"/camera/gamma/@value",
+ 'min':0, 'max':1, 'increment':1, 'precision':0},
+ ]
+ elif CameraType == "DragonFly":
+ paramList = [
+ {'Name':"Brightness",
+ 'path':"/camera/brightness/@value",
+ 'min':1, 'max':255, 'increment':1, 'precision':0},
+ {'Name':"Gamma",
+ 'path':"/camera/gamma/@value",
+ 'min':512, 'max':4095, 'increment':5, 'precision':0},
+ {'Name':"Shutter",
+ 'path':"/camera/shutter/@value",
+ 'min':0, 'max':709, 'increment':2, 'precision':0},
+ {'Name':"Gain",
+ 'path':"/camera/gain/@value",
+ 'min':16, 'max':683, 'increment':2, 'precision':0},
+ ]
+ else:
+ g_Log.trace(g_Log.ERROR, "Unknown CameraType %s" % CameraType)
+ sys.exit()
+
+ paramList.extend([
+ # Touch
+ {'Name':"Threshold",
+ 'path':"/tracker/touch/threshold/@value",
+ 'min':1, 'max':255, 'increment':1, 'precision':0},
+ {'Name':"Similarity",
+ 'path':"/tracker/touch/similarity/@value",
+ 'min':1, 'max':300, 'increment':1, 'precision':1},
+
+ {'Name':"Min Area",
+ 'path':"/tracker/touch/areabounds/@min",
+ 'min':1, 'max':1000000, 'increment':3, 'precision':0},
+ {'Name':"Max Area",
+ 'path':"/tracker/touch/areabounds/@max",
+ 'min':20, 'max':1000000, 'increment':10, 'precision':0},
+
+ {'Name':"Ecc. Min",
+ 'path':"/tracker/touch/eccentricitybounds/@min",
+ 'min':1, 'max':30, 'increment':1, 'precision':1},
+ {'Name':"Ecc. Max",
+ 'path':"/tracker/touch/eccentricitybounds/@max",
+ 'min':1, 'max':2000, 'increment':1, 'precision':1},
+
+ {'Name':"Bandpass Min",
+ 'path':"/tracker/touch/bandpass/@min",
+ 'min':0, 'max':15, 'increment':.1, 'precision':1},
+ {'Name':"Bandpass Max",
+ 'path':"/tracker/touch/bandpass/@max",
+ 'min':0, 'max':15, 'increment':.1, 'precision':1},
+ {'Name':"Bandpass Postmult",
+ 'path':"/tracker/touch/bandpasspostmult/@value",
+ 'min':0, 'max':30, 'increment':.1, 'precision':1},
+
+ # Track
+ {'Name':"Threshold",
+ 'path':"/tracker/track/threshold/@value",
+ 'min':1, 'max':255, 'increment':1, 'precision':0},
+
+ {'Name':"Min Area",
+ 'path':"/tracker/track/areabounds/@min",
+ 'min':1, 'max':1000000, 'increment':3, 'precision':0},
+ {'Name':"Max Area",
+ 'path':"/tracker/track/areabounds/@max",
+ 'min':20, 'max':1000000, 'increment':10, 'precision':0},
+
+ {'Name':"Ecc. Min",
+ 'path':"/tracker/track/eccentricitybounds/@min",
+ 'min':1, 'max':30, 'increment':1, 'precision':1},
+ {'Name':"Ecc. Max",
+ 'path':"/tracker/track/eccentricitybounds/@max",
+ 'min':1, 'max':2000, 'increment':1, 'precision':1},
+
+ # Transform
+ {'Name':"p2",
+ 'path':"/transform/distortionparams/@p2",
+ 'min':-3, 'max':3, 'increment':0.001, 'precision':3},
+ {'Name':"Trapezoid",
+ 'path':"/transform/trapezoid/@value",
+ 'min':-3, 'max':3, 'increment':0.0001, 'precision':4},
+ {'Name':"Angle",
+ 'path':"/transform/angle/@value",
+ 'min':-3.15, 'max':3.15, 'increment':0.01, 'precision':2},
+ {'Name':"Displ. x",
+ 'path':"/transform/displaydisplacement/@x",
+ 'min':-5000, 'max':0, 'increment':1, 'precision':0},
+ {'Name':"Displ. y",
+ 'path':"/transform/displaydisplacement/@y",
+ 'min':-5000, 'max':0, 'increment':1, 'precision':0},
+ {'Name':"Scale x",
+ 'path':"/transform/displayscale/@x",
+ 'min':-3, 'max':8, 'increment':0.01, 'precision':2},
+ {'Name':"Scale y",
+ 'path':"/transform/displayscale/@y",
+ 'min':-3, 'max':8, 'increment':0.01, 'precision':2},
+ ])
+ return paramList
+
+class Calibrator(AVGApp):
+ def __init__(self, parentNode, CameraType = "FireFly", appStarter = None):
+ super(Calibrator, self).__init__(parentNode)
+ self.paramList = camera_setup(CameraType)
+ self.parentNode=parentNode
+ self.appStarter = appStarter
+ self.mainNode = g_Player.createNode(
+ """
+ <div active="False" opacity="0">
+ <image width="1280" height="800" href="black.png"/>
+ <image id="cal_distorted" x="0" y="0" width="1280" height="800"
+ sensitive="false" opacity="1"/>
+ <words id="cal_fps" x="30" y="30" color="00FF00" text=""/>
+ <words id="cal_notification" x="390" y="390" width="500" fontsize="18"
+ font="Zurich Ex BT" color="ff3333" alignment="center" />
+ <div id="cal_gui" x="30" y="540">
+ <image id="cal_shadow" x="0" y="13" width="500" height="150"
+ href="black.png" opacity="0.6"/>
+
+ <words x="2" y="13" text="camera" fontsize="16" font="Zurich Ex BT"
+ color="00FF00"/>
+ <image x="2" y="32" href="CamImgBorder.png"/>
+ <image id="cal_camera" x="4" y="34" width="160" height="120"/>
+
+ <words x="168" y="13" text="nohistory" fontsize="16" font="Zurich Ex BT"
+ color="00FF00"/>
+ <image x="168" y="32" href="CamImgBorder.png"/>
+ <image id="cal_nohistory" x="170" y="34" width="160" height="120"/>
+
+ <words x="334" y="13" text="histogram" fontsize="16" font="Zurich Ex BT"
+ color="00FF00"/>
+ <image x="334" y="32" href="CamImgBorder.png"/>
+ <image id="cal_histogram" x="336" y="34" width="160" height="120"/>
+
+ <div id="cal_params" y="170" opacity="0.9">
+ <image id="cal_shadow2" width="750" height="65" href="black.png" opacity="0.6"/>
+ <div id="cal_paramdiv0" x="2">
+ <words text="camera" y="0" fontsize="10" font="Zurich Ex BT" color="00ff00" />
+ <words id="cal_param0" y="12" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param1" y="24" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param2" y="36" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param3" y="48" fontsize="10" font="Zurich Ex BT" />
+ </div>
+ <div id="cal_paramdiv1" x="80">
+ <words text="touch" y="0" fontsize="10" font="Zurich Ex BT" color="00ff00" />
+ <words id="cal_param4" y="12" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param5" y="24" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param6" y="36" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param7" y="48" fontsize="10" font="Zurich Ex BT" />
+ </div>
+ <div id="cal_paramdiv2" x="200">
+ <words id="cal_param8" y="0" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param9" y="12" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param10" y="24" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param11" y="36" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param12" y="48" fontsize="10" font="Zurich Ex BT" />
+ </div>
+ <div id="cal_paramdiv3" x="350">
+ <words text="track" y="0" fontsize="10" font="Zurich Ex BT" color="00ff00" />
+ <words id="cal_param13" y="12" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param14" y="24" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param15" y="36" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param16" y="48" fontsize="10" font="Zurich Ex BT" />
+ </div>
+ <div id="cal_paramdiv4" x="500">
+ <words id="cal_param17" y="0" fontsize="10" font="Zurich Ex BT" />
+ <words text="distort" y="12" fontsize="10" font="Zurich Ex BT" color="00ff00" />
+ <words id="cal_param18" y="24" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param19" y="36" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param20" y="48" fontsize="10" font="Zurich Ex BT" />
+ </div>
+ <div id="cal_paramdiv5" x="650">
+ <words id="cal_param21" y="0" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param22" y="12" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param23" y="24" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param24" y="36" fontsize="10" font="Zurich Ex BT" />
+ <words id="cal_param25" y="48" fontsize="10" font="Zurich Ex BT" />
+ </div>
+ </div>
+ </div>
+ <div id="cal_coordcalibrator" opacity="0" active="false">
+ <image x="0" y="0" width="1280" height="800" href="border.png"/>
+ <div id="cal_messages" x="100" y="100"/>
+ <image id="cal_crosshair" href="crosshair.png"/>
+ <image id="cal_feedback" href="Feedback.png"/>
+ </div>
+ </div>
+ """)
+ self.mainNode.mediadir=mediadir
+ parentNode.insertChild(self.mainNode, 0)
+
+ self.coordCal = None
+ self.tracker = g_Player.getTracker()
+ self.curParam = 0
+ self.saveIndex = 0
+ self.hideMainNodeTimeout = None
+ self.video = []
+ self.__guiOpacity = 1
+ self.__showBigCamImage = False
+ self.__notificationTimer = None
+ self.__onCalibrationSuccess = None
+
+
+
+ def _enter(self):
+
+ g_KbManager.push()
+
+ g_KbManager.bindKey('d', self.__trackerSetDebugImages, 'tracker set debug images')
+ g_KbManager.bindKey('b', self.__bigCamImage, 'big cam image')
+ g_KbManager.bindKey('up', self.__keyFuncUP, 'select parameter up')
+ g_KbManager.bindKey('down', self.__keyFuncDOWN, 'select parameter down')
+ g_KbManager.bindKey('left', self.__keyFuncLEFT, 'value up')
+ g_KbManager.bindKey('right', self.__keyFuncRIGHT, 'value down')
+ g_KbManager.bindKey('page up', self.__keyFuncPAGEUp, 'value up * 10')
+ g_KbManager.bindKey('page down', self.__keyFuncPAGEDown, 'value down * 10')
+ g_KbManager.bindKey('s', self.__trackerSaveConfig, 'save configuration')
+ g_KbManager.bindKey('g', self.__toggleGUI, 'toggle GUI')
+ g_KbManager.bindKey('c', self.__startCoordCalibration,
+ 'start geometry calibration')
+ g_KbManager.bindKey('w', self.__saveTrackerIMG, 'SAVE trager image')
+ g_KbManager.bindKey('h', self.appStarter.tracker.resetHistory, 'RESET history')
+
+ self.appStarter.showTrackerImage()
+ self.mainNode.active=True
+ self.tracker.setDebugImages(True, True)
+ avg.fadeIn(self.mainNode, 400, 1)
+ Bitmap = self.tracker.getImage(avg.IMG_DISTORTED) # Why is this needed?
+ self.__onFrameID=g_Player.setOnFrameHandler(self.__onFrame)
+ #grandparent = self.parentNode.getParent()
+ #if grandparent:
+ # grandparent.reorderChild(grandparent.indexOf(self.parentNode), grandparent.getNumChildren()-1)
+ self.displayParams()
+ if self.hideMainNodeTimeout:
+ g_Player.clearInterval(self.hideMainNodeTimeout)
+
+ def _leave(self):
+ #unbind all calibrator keys - bind old keys
+ g_KbManager.pop()
+
+ def hideMainNode():
+ self.mainNode.opacity=0
+ self.mainNode.active = False
+ self.appStarter.hideTrackerImage()
+ #grandparent = self.parentNode.getParent()
+ #if grandparent:
+ # grandparent.reorderChild(grandparent.indexOf(self.parentNode), 0)
+ self.hideMainNodeTimeout = g_Player.setTimeout(400, hideMainNode)
+ g_Player.clearInterval(self.__onFrameID)
+
+ def reparent(self, newParent):
+ """reparents the calibrator node; returns the old(!) parent node"""
+ oldParent = self.mainNode.getParent()
+ self.mainNode.unlink()
+ newParent.appendChild(self.mainNode)
+ return oldParent
+
+ def __deferredRefreshCB(self):
+ self.displayParams()
+ self.tracker.resetHistory()
+ self.setNotification('')
+ g_KbManager.pop()
+ g_Player.getElementByID('cal_params').opacity = 0.9
+
+ def __clearNotification(self):
+ self.__notificationTimer = None
+ self.setNotification('')
+
+ def __toggleGUI(self):
+ self.__guiOpacity = 1 - self.__guiOpacity
+ g_Player.getElementByID('cal_gui').opacity = self.__guiOpacity
+
+ def __onFrame(self):
+ def showTrackerImage(trackerImageID, nodeID, size, pos=(0,0)):
+ bitmap = self.tracker.getImage(trackerImageID)
+ node = g_Player.getElementByID(nodeID)
+ node.setBitmap(bitmap)
+ node.size = size
+ if pos != (0,0):
+ node.pos = pos
+
+ # flip:
+ grid = node.getOrigVertexCoords()
+ grid = [ [ (1-pos[0], pos[1]) for pos in line ] for line in grid]
+ node.setWarpedVertexCoords(grid)
+
+ if self.__showBigCamImage:
+ showTrackerImage(avg.IMG_CAMERA, "cal_distorted", (1280, 960))
+ else:
+ pos = self.tracker.getDisplayROIPos()
+ size = self.tracker.getDisplayROISize()
+ showTrackerImage(avg.IMG_DISTORTED, "cal_distorted", pos = pos, size = size)
+ showTrackerImage(avg.IMG_CAMERA, "cal_camera", (160, 120))
+ showTrackerImage(avg.IMG_NOHISTORY, "cal_nohistory", (160, 120))
+ showTrackerImage(avg.IMG_HISTOGRAM, "cal_histogram", (160, 120))
+ fps = g_Player.getEffectiveFramerate()
+ g_Player.getElementByID("cal_fps").text = '%(val).2f' % {'val': fps}
+
+ def __trackerSetDebugImages(self):
+ self.appStarter.toggleTrackerImage()
+ # toggleTrackerImage() will influence setDebugImages status, so we have to reset it:
+ self.tracker.setDebugImages(True, True)
+
+ def __bigCamImage(self):
+ self.__showBigCamImage = not(self.__showBigCamImage)
+
+ def __keyFuncUP(self):
+ if self.curParam > 0:
+ self.curParam -= 1
+ self.displayParams()
+
+ def __keyFuncDOWN(self):
+ if self.curParam < len(self.paramList)-1:
+ self.curParam += 1
+ self.displayParams()
+
+ def __keyFuncLEFT(self):
+ self.changeParam(-1)
+ self.displayParams()
+
+ def __keyFuncRIGHT(self):
+ self.changeParam(1)
+ self.displayParams()
+
+ def __keyFuncPAGEUp(self):
+ self.changeParam(10)
+ self.displayParams()
+
+ def __keyFuncPAGEDown(self):
+ self.changeParam(-10)
+ self.displayParams()
+
+ def __trackerSaveConfig(self):
+ self.tracker.saveConfig()
+ self.setNotification('Tracker configuration saved', 2000)
+ g_Log.trace(g_Log.APP, "Tracker configuration saved.")
+
+ def __saveTrackerIMG(self):
+ def saveTrackerImage(id, name):
+ self.tracker.getImage(id).save("img"+str(self.saveIndex)+"_"+name+".png")
+
+ self.saveIndex += 1
+ saveTrackerImage(avg.IMG_CAMERA, "camera")
+ saveTrackerImage(avg.IMG_DISTORTED, "distorted")
+ saveTrackerImage(avg.IMG_NOHISTORY, "nohistory")
+ saveTrackerImage(avg.IMG_HIGHPASS, "highpass")
+ saveTrackerImage(avg.IMG_FINGERS, "fingers")
+ saveTrackerImage(avg.IMG_HISTOGRAM, "histogram")
+ self.setNotification('Tracker images dumped', 2000)
+ g_Log.trace(g_Log.APP, "Tracker images saved.")
+
+ def __startCoordCalibration(self):
+ assert(not self.coordCal)
+
+ self.__savedShutter = self.tracker.getParam("/camera/shutter/@value")
+ self.tracker.setParam("/camera/shutter/@value", "8")
+ self.__savedGain = self.tracker.getParam("/camera/gain/@value")
+ self.tracker.setParam("/camera/gain/@value", "16")
+ self.__savedStrobe = self.tracker.getParam("/camera/strobeduration/@value")
+ self.tracker.setParam("/camera/strobeduration/@value", "-1")
+ self.coordCal = coordcalibrator.CoordCalibrator(self.__onCalibrationTerminated)
+
+ def __onCalibrationTerminated(self, isSuccessful):
+ self.coordCal = None
+ self.tracker.setParam("/camera/shutter/@value", self.__savedShutter)
+ self.tracker.setParam("/camera/gain/@value", self.__savedGain)
+ self.tracker.setParam("/camera/strobeduration/@value", self.__savedStrobe)
+ self.deferredRefresh()
+
+ def setOnCalibrationSuccess(self, callback):
+ self.__onCalibrationSuccess = callback
+
+ def deferredRefresh(self):
+ g_Player.setTimeout(1500, self.__deferredRefreshCB)
+ self.setNotification('Please wait for settlement')
+ g_KbManager.push()
+ g_Player.getElementByID('cal_params').opacity = 0.3
+
+ def setNotification(self, text, timeout=0):
+ g_Player.getElementByID('cal_notification').text = text
+ if timeout:
+ if self.__notificationTimer is not None:
+ g_Player.clearInterval(self.__notificationTimer)
+
+ self.__notificationTimer = g_Player.setTimeout(timeout,
+ self.__clearNotification)
+
+ def displayParams(self):
+ i = 0
+ for Param in self.paramList:
+ Node = g_Player.getElementByID("cal_param"+str(i))
+ Path = Param['path']
+ Val = float(self.tracker.getParam(Path))
+ Node.text = (Param['Name']+": "
+ +('%(val).'+str(Param['precision'])+'f') % {'val': Val})
+ if self.curParam == i:
+ Node.color = "FFFFFF"
+ else:
+ Node.color = "A0A0FF"
+ i += 1
+
+ def changeParam(self, Change):
+ param = self.paramList[self.curParam]
+ if param['increment'] >= 1:
+ Val = int(float(self.tracker.getParam(param['path'])))
+ else:
+ Val = float(self.tracker.getParam(param['path']))
+ Val += Change*param['increment']
+ if Val < param['min']:
+ Val = param['min']
+ if Val > param['max']:
+ Val = param['max']
+ self.tracker.setParam(param['path'], str(Val))
diff --git a/src/python/clusteredEventList.py b/src/python/clusteredEventList.py
new file mode 100644
index 0000000..d75ac99
--- /dev/null
+++ b/src/python/clusteredEventList.py
@@ -0,0 +1,257 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Martin Heistermann <mh at sponc dot de>
+#
+
+from libavg import avg, Point2D
+from eventList import EventList, Cursor
+from mathutil import getDistSquared
+
+g_Log = avg.Logger.get()
+
+MAX_ITERATIONS=50
+
+class Centroid (Cursor):
+ def __init__(self):
+ super(Centroid, self).__init__()
+ self.__members = []
+
+ def isBroken(self):
+ return len(self.__members)==0
+
+ def reposition (self):
+ if len(self.__members) == 0:
+ return
+ pointSum = Point2D(0,0)
+ for point in self.__members:
+ pointSum += point.getPos()
+ center = pointSum / len(self.__members)
+ oldPos = self._pos
+ self.setPos(center)
+ return oldPos != self._pos
+
+ def removeMember (self, member):
+ self.__members.remove(member)
+ self.reposition()
+ self.resetMotion()
+
+ def addMember (self, member):
+ self.__members.append(member)
+ self.reposition()
+ self.resetMotion()
+
+ def hasMember (self, member):
+ return member in self.__members
+
+ def __len__(self):
+ return len(self.__members)
+
+ def __repr__(self):
+ return "centroid at %s, startpos %s, members %s" % (self._pos, self._startPos, self.__members)
+
+
+class ClusteredEventList:
+ """ implements a variant of k-means.
+ same API as EventList, with the difference that ClusteredEventList
+ will simulate a maximum of 2 cursors (if more actual cursors are
+ on the node, they are clustered.
+ In contrast to EventList, the callbacks provide no EventCursors.
+ """
+ def __init__(self,
+ node,
+ source,
+ onDown = lambda x: None,
+ onUp = lambda x: None,
+ onMotion = lambda x: None,
+ resetMotion = lambda: None,
+ captureEvents = True):
+ self.__centroids = []
+ self.__centroidByEvent = {}
+ self.__doNewMotion = False
+
+ self.__callback = {
+ 'onDown': onDown,
+ 'onUp': onUp,
+ 'onMotion': onMotion,
+ 'resetMotion': resetMotion,
+ }
+ self.__eventList = EventList(
+ node = node,
+ source = source,
+ onDown = self.__onDown,
+ onUp = self.__onUp,
+ onMotion = self.__onMotion,
+ resetMotion = self.__resetMotion,
+ captureEvents = captureEvents)
+
+ def handleInitialDown(self,event):
+ self.__eventList.handleInitialDown(event)
+
+ def __onDown(self, eventCursor):
+ #self.__callback['onDown'](eventCursor)
+ centroids = list(self.__centroids) # copy
+ self.calcClusters()
+ self.__resetMotion()
+ if len(centroids) != len(self.__centroids):
+ if len(centroids) and self.__centroids[0] == centroids[0]:
+ newCentroid = self.__centroids[1]
+ else:
+ newCentroid = self.__centroids[0]
+ self.__callback['onDown']()
+
+ def __onUp(self, eventCursor):
+ assert eventCursor in self.__centroidByEvent
+ centroid = self.__centroidByEvent[eventCursor]
+ centroid.removeMember(eventCursor)
+ del self.__centroidByEvent[eventCursor]
+
+ self.calcClusters()
+ self.__resetMotion()
+
+ if len(centroid) == 0:
+ self.__callback['onUp']()
+
+ def __onMotion(self, eventCursor):
+ oldPositions = {}
+ for centroid in self.__centroids:
+ oldPositions[centroid] = centroid.getPos()
+ self.calcClusters()
+ self.__callback['onMotion']()
+
+ def __resetMotion(self):
+ for centroid in self.__centroids:
+ centroid.resetMotion()
+ self.__callback['resetMotion']()
+
+ def delete(self):
+ self.__centroids = []
+ self.__centroidByEvent = {}
+ self.__eventList.delete()
+ self.__callback = {
+ 'onDown': lambda x: None,
+ 'onUp': lambda x: None,
+ 'onMotion': lambda x: None,
+ 'resetMotion': lambda x: None,
+ }
+
+ def __calcMemberships (self):
+ """ returns True if a membership changed, else False."""
+ changed = False
+ if not len(self.__centroids):
+ return changed
+ for point in self.__eventList.getCursors():
+ closestCentroid = self.__centroids[0]
+ minDist = getDistSquared(point.getPos(), closestCentroid.getPos())
+ for centroid in self.__centroids:
+ distance = getDistSquared (point.getPos(), centroid.getPos())
+ if distance < minDist:
+ minDist = distance
+ closestCentroid = centroid
+ if not closestCentroid.hasMember(point):
+ self.__doNewMotion = True
+ if point in self.__centroidByEvent:
+ self.__centroidByEvent[point].removeMember(point)
+ self.__centroidByEvent[point] = closestCentroid
+ closestCentroid.addMember(point)
+ changed = True
+ return changed
+
+ def __tryCalcClusters (self):
+ def __calcInitialCentroids():
+ self.__centroidByEvent = {}
+ self.__centroids = []
+ def createCentroid(point):
+ centroid = Centroid()
+ centroid.addMember(point)
+ self.__centroidByEvent[point] = centroid
+ self.__centroids.append(centroid)
+
+ maxDist = 0
+ points = None
+ if len(self.__eventList)>1:
+ cursors = self.__eventList.getCursors()
+ for p in cursors:
+ for q in cursors:
+ dist = getDistSquared(p.getPos(),q.getPos())
+ if dist >= maxDist and p != q:
+ points = p,q
+ maxDist = dist
+
+ assert(points)
+ for point in points:
+ createCentroid(point)
+ elif len(self.__eventList) == 1:
+ createCentroid(self.__eventList.getCursors()[0])
+
+ def __setCentroids():
+ changed = False
+ for centroid in self.__centroids:
+ if centroid.reposition():
+ changed = True
+ return changed
+
+ if not len(self.__centroids):
+ __calcInitialCentroids()
+ self.__calcMemberships()
+
+ changed = True
+ iterations = 0
+ while changed:
+ changed = False
+ if __setCentroids():
+ changed = True
+ if self.__calcMemberships():
+ changed = True
+ iterations+=1
+ if iterations>MAX_ITERATIONS:
+ #print "too many iterations(%u), aborting" % iterations
+ __setCentroids()
+ break
+
+ def calcClusters (self):
+ def __hasBrokenCentroids():
+ if len(self.__eventList)>1 and len(self.__centroids)!=2:
+ return True
+ for centroid in self.__centroids:
+ if centroid.isBroken():
+ return True
+ if len(self.__centroids)==2:
+ if self.__centroids[0].getPos() == self.__centroids[1].getPos():
+ return True
+ return False
+
+ self.__tryCalcClusters()
+
+ if __hasBrokenCentroids():
+ self.__centroids=[]
+ self.__tryCalcClusters()
+# if __hasBrokenCentroids():
+# g_Log.trace(g_Log.APP,
+# "Cannot fix broken centroids: %s" % self.__centroids)
+ if self.__doNewMotion:
+ self.__doNewMotion = False
+ self.__resetMotion()
+
+ def getCursors (self):
+ return self.__centroids
+
+ def __len__(self):
+ return min(len(self.__eventList), len(self.__centroids))
+
diff --git a/src/python/coordcalibrator.py b/src/python/coordcalibrator.py
new file mode 100644
index 0000000..8dda84b
--- /dev/null
+++ b/src/python/coordcalibrator.py
@@ -0,0 +1,134 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Released with permission from Archimedes-Solutions GmbH
+
+from libavg import avg
+
+import apphelpers
+
+g_KbManager = apphelpers.KeyboardManager.get()
+
+g_Player = avg.Player.get()
+
+class CoordCalibrator:
+ def __init__(self, calibrationTerminatedCb):
+ self.__calibrationTerminatedCb = calibrationTerminatedCb
+ self.__CurPointIndex = 0
+ self.__CPPCal = g_Player.getTracker().startCalibration()
+ self.__LastCenter = None
+ self.__NumMessages = 0
+ self._mycursor = None
+ mainNode = g_Player.getElementByID("cal_coordcalibrator")
+ mainNode.active = True
+ mainNode.opacity = 1
+ mainNode.setEventHandler(avg.CURSORDOWN, avg.TOUCH, self.__onTouchDown)
+ mainNode.setEventHandler(avg.CURSORMOTION, avg.TOUCH, self.__onTouchMove)
+ mainNode.setEventHandler(avg.CURSORUP, avg.TOUCH, self.__onTouchUp)
+ self.__crosshair = g_Player.getElementByID("cal_crosshair")
+ self.__feedback = g_Player.getElementByID("cal_feedback")
+ self.__feedback.opacity = 0
+ self.__addMessage("Starting calibration.")
+ self.__moveMarker()
+
+ g_KbManager.push()
+ g_KbManager.bindKey('space', self.__nextPoint, 'sample next point')
+ g_KbManager.bindKey('a', self.__abortCalibration, 'abort calibration')
+
+ def __endCalibration(self, isSuccessful):
+ g_Player.getElementByID("cal_coordcalibrator").active = False
+ g_Player.getElementByID("cal_coordcalibrator").opacity = 0
+ MsgsNode = g_Player.getElementByID("cal_messages")
+ for i in range(0, MsgsNode.getNumChildren()):
+ MsgsNode.removeChild(0)
+
+ g_KbManager.pop()
+ self.__calibrationTerminatedCb(isSuccessful)
+
+ def __nextPoint(self):
+ if self.__LastCenter:
+ self.__CPPCal.setCamPoint(self.__LastCenter)
+ self.__addMessage (" Using: %(x).2f, %(y).2f" %
+ { "x": self.__LastCenter[0], "y": self.__LastCenter[1]})
+ self._mycursor = None
+ self.__LastCenter = None
+
+ hasNextPoint = self.__CPPCal.nextPoint()
+
+ if not hasNextPoint:
+ # Note: may raise RuntimeError. A rollback doesn't appear to be possible,
+ # which means crashing here is safer than handling the exception
+ g_Player.getTracker().endCalibration()
+ self.__endCalibration(True)
+ else:
+ self.__CurPointIndex += 1
+ self.__moveMarker()
+
+ def __abortCalibration(self):
+ g_Player.getTracker().abortCalibration()
+ self.__endCalibration(False)
+
+ def __moveMarker(self):
+ self.__crosshair.x, self.__crosshair.y = self.__CPPCal.getDisplayPoint()
+ self.__crosshair.x, self.__crosshair.y = self.__feedback.x, self.__feedback.y = \
+ (self.__crosshair.x-7, self.__crosshair.y-7)
+ self.__addMessage("Calibrating point "+str(self.__CurPointIndex))
+
+ def __addMessage(self, text):
+ MsgsNode = g_Player.getElementByID("cal_messages")
+ if self.__NumMessages > 38:
+ for i in range(0, MsgsNode.getNumChildren()-1):
+ MsgsNode.getChild(i).text = MsgsNode.getChild(i+1).text
+ MsgsNode.removeChild(MsgsNode.getNumChildren()-1)
+ else:
+ self.__NumMessages += 1
+ Node = g_Player.createNode(
+ "<words fontsize='10' font='Eurostile' color='00FF00'/>")
+ Node.x = 0
+ Node.y = self.__NumMessages*13
+ Node.text = text
+ MsgsNode.appendChild(Node)
+
+ def __onTouchDown(self, Event):
+ if Event.source != avg.TOUCH:
+ return
+ if not self._mycursor:
+ self._mycursor = Event.cursorid
+ else:
+ return
+ self.__LastCenter = Event.center
+ self.__addMessage(" Touch at %(x).2f, %(y).2f" % {
+ "x": Event.center[0], "y": Event.center[1]})
+ self.__feedback.opacity = 1
+
+ def __onTouchMove(self,Event):
+ if Event.source != avg.TOUCH:
+ return
+ if self._mycursor == Event.cursorid:
+ self.__LastCenter = Event.center
+
+ def __onTouchUp(self, Event):
+ if Event.source != avg.TOUCH:
+ return
+ self.__addMessage("touchup")
+ self.__feedback.opacity = 0
+ if self._mycursor:
+ self._mycursor = None
+ else:
+ return
diff --git a/src/python/data/CamImgBorder.png b/src/python/data/CamImgBorder.png
new file mode 100644
index 0000000..4bc1a37
--- /dev/null
+++ b/src/python/data/CamImgBorder.png
Binary files differ
diff --git a/src/python/data/Feedback.png b/src/python/data/Feedback.png
new file mode 100644
index 0000000..3c71f9c
--- /dev/null
+++ b/src/python/data/Feedback.png
Binary files differ
diff --git a/src/python/data/Makefile.am b/src/python/data/Makefile.am
new file mode 100644
index 0000000..c0496ed
--- /dev/null
+++ b/src/python/data/Makefile.am
@@ -0,0 +1,4 @@
+EXTRA_DIST = $(wildcard *.png) $(wildcard *.avg)
+datadir = $(pkgpyexecdir)/data
+data_DATA = CamImgBorder.png border.png camcalibrator.avg crosshair.png black.png \
+ Feedback.png TouchFeedback.png
diff --git a/src/python/data/Makefile.in b/src/python/data/Makefile.in
new file mode 100644
index 0000000..796c2b5
--- /dev/null
+++ b/src/python/data/Makefile.in
@@ -0,0 +1,480 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/python/data
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(datadir)"
+DATA = $(data_DATA)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = $(pkgpyexecdir)/data
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = $(wildcard *.png) $(wildcard *.avg)
+data_DATA = CamImgBorder.png border.png camcalibrator.avg crosshair.png black.png \
+ Feedback.png TouchFeedback.png
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/python/data/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/python/data/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-dataDATA: $(data_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(datadir)" || $(MKDIR_P) "$(DESTDIR)$(datadir)"
+ @list='$(data_DATA)'; test -n "$(datadir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(datadir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(datadir)" || exit $$?; \
+ done
+
+uninstall-dataDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(data_DATA)'; test -n "$(datadir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(datadir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(datadir)" && rm -f $$files
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(datadir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-dataDATA
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-dataDATA
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dataDATA install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ uninstall uninstall-am uninstall-dataDATA
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/python/data/TouchFeedback.png b/src/python/data/TouchFeedback.png
new file mode 100644
index 0000000..9f5dcda
--- /dev/null
+++ b/src/python/data/TouchFeedback.png
Binary files differ
diff --git a/src/python/data/black.png b/src/python/data/black.png
new file mode 100644
index 0000000..23bd512
--- /dev/null
+++ b/src/python/data/black.png
Binary files differ
diff --git a/src/python/data/border.png b/src/python/data/border.png
new file mode 100644
index 0000000..447a3e6
--- /dev/null
+++ b/src/python/data/border.png
Binary files differ
diff --git a/src/python/data/camcalibrator.avg b/src/python/data/camcalibrator.avg
new file mode 100644
index 0000000..3c77962
--- /dev/null
+++ b/src/python/data/camcalibrator.avg
@@ -0,0 +1,27 @@
+<div>
+ <image href="border.png"/>
+ <image id="bkgnd" width="1280" height="720" />
+ <div id="tracking" x="300" y="32">
+ <words x="0" y="13" text="camera" fontsize="16" />
+ <image x="0" y="32" href="CamImgBorder.png"/>
+ <image id="camera" x="2" y="34" width="160" height="120" />
+
+ <words x="166" y="13" text="distorted" fontsize="16" />
+ <image x="166" y="32" href="CamImgBorder.png"/>
+ <image id="distorted" x="168" y="34" width="160" height="120" />
+
+ <words x="332" y="13" text="history" fontsize="16" />
+ <image x="332" y="32" href="CamImgBorder.png"/>
+ <image id="nohistory" x="334" y="34" width="160" height="120" />
+
+ <image x="498" y="32" href="CamImgBorder.png"/>
+ <image id="histogram" x="500" y="34" width="160" height="120" />
+
+ <words id="param0" x="0" y="162" fontsize="13" />
+ <words id="param1" x="0" y="178" fontsize="13" />
+ <words id="param2" x="0" y="194" fontsize="13" />
+ <words id="param3" x="166" y="162" fontsize="13" />
+ <words id="param4" x="166" y="178" fontsize="13" />
+ </div>
+ <div id="coordcalibrator" width="1280" height="720" />
+</div>
diff --git a/src/python/data/crosshair.png b/src/python/data/crosshair.png
new file mode 100644
index 0000000..be025b1
--- /dev/null
+++ b/src/python/data/crosshair.png
Binary files differ
diff --git a/src/python/draggable.py b/src/python/draggable.py
new file mode 100644
index 0000000..4bc4cd0
--- /dev/null
+++ b/src/python/draggable.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+g_Player = None
+
+from libavg import avg
+
+
+class Draggable:
+ def __init__(self, node, onDragStart=None, onDragEnd=None, onDragMove=None):
+ global g_Player
+ g_Player = avg.Player.get()
+ self.__node = node
+ self.__onDragStart = onDragStart
+ self.__onDragEnd = onDragEnd
+ self.__onDragMove = onDragMove
+ self.__isDragging = False
+
+ def enable(self):
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.MOUSE | avg.TOUCH, self.__onStart)
+
+ def disable(self):
+ if self.__isDragging:
+ self.__stop()
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.MOUSE | avg.TOUCH, None)
+ self.__node.setEventHandler(avg.CURSORMOTION, avg.MOUSE | avg.TOUCH, None)
+ self.__node.setEventHandler(avg.CURSORUP, avg.MOUSE | avg.TOUCH, None)
+
+ def startDrag(self, event):
+ self.__onStart(event)
+
+ def isDragging(self):
+ return self.__isDragging
+
+ def __onStart(self, event):
+ self.__cursorID = event.cursorid
+ self.__isDragging = True
+ self.__lastDownPos = event.pos
+ groupsNode = self.__node.getParent()
+ groupsNode.reorderChild(groupsNode.indexOf(self.__node),
+ groupsNode.getNumChildren()-1)
+ self.__node.setEventCapture(event.cursorid)
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.MOUSE | avg.TOUCH, None)
+ self.__node.setEventHandler(avg.CURSORMOTION, avg.MOUSE | avg.TOUCH,
+ self.__onMove)
+ self.__node.setEventHandler(avg.CURSORUP, avg.MOUSE | avg.TOUCH, self.__onStop)
+ stopBubble = False
+ if self.__onDragStart:
+ stopBubble = self.__onDragStart(event)
+ if stopBubble == None:
+ stopBubble = False
+ self.__startDragPos = self.__node.pos
+ return stopBubble
+
+ def __onMove(self, event):
+ if event.cursorid == self.__cursorID:
+ self.__node.pos = (self.__startDragPos[0]+event.x-self.__lastDownPos[0],
+ self.__startDragPos[1]+event.y-self.__lastDownPos[1])
+ stopBubble = False
+ if self.__onDragMove:
+ stopBubble = self.__onDragMove(event)
+ if stopBubble == None:
+ stopBubble = False
+ return stopBubble
+
+ def __onStop(self, event):
+ if event.cursorid == self.__cursorID:
+ self.__onMove(event)
+ self.__stop()
+ stopBubble = False
+ if self.__onDragEnd:
+ stopBubble = self.__onDragEnd(event)
+ if stopBubble == None:
+ stopBubble = False
+ return stopBubble
+
+ def __stop(self):
+ self.__isDragging = False
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.MOUSE | avg.TOUCH, self.__onStart)
+ self.__node.setEventHandler(avg.CURSORMOTION, avg.MOUSE | avg.TOUCH, None)
+ self.__node.setEventHandler(avg.CURSORUP, avg.MOUSE | avg.TOUCH, None)
+ self.__node.releaseEventCapture(self.__cursorID)
+
+
+def init(g_avg):
+ global avg
+ avg = g_avg
diff --git a/src/python/eventList.py b/src/python/eventList.py
new file mode 100644
index 0000000..ebc4205
--- /dev/null
+++ b/src/python/eventList.py
@@ -0,0 +1,174 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Martin Heistermann <mh at sponc dot de>
+#
+
+from libavg import avg
+
+class Cursor(object):
+ def __init__(self):
+ self._pos = None
+ self.resetMotion()
+
+ def resetMotion(self):
+ self._startPos = self._pos
+
+ def getDelta (self):
+ return self._pos - self._startPos
+
+ def getStartPos (self):
+ return self._startPos
+
+ def getPos (self):
+ return self._pos
+
+ def setPos (self, newPos):
+ self._pos = newPos
+ if not self._startPos:
+ self._startPos = self._pos
+
+ def getX(self):
+ return self._pos.x
+ x = property(getX)
+
+ def getY(self):
+ return self._pos.y
+ y = property(getY)
+
+ def __unicode__ (self):
+ print "cursor %s->%s" % (self.getStartPos(), self.getPos())
+
+class EventCursor(Cursor):
+ def __init__(self, event):
+ super(EventCursor, self).__init__()
+ self.__cursorid = event.cursorid
+ self.update (event)
+
+ def update (self, event):
+ assert event.cursorid == self.__cursorid
+ self.setPos(event.pos)
+ self.__speed = event.speed
+
+ def getSpeed (self):
+ return self.__speed
+
+ def getCursorID (self):
+ return self.__cursorid
+
+class EventList:
+ """Keep track of cursors pressed on a Node"""
+ def __init__(self,
+ node,
+ source,
+ onDown = lambda x: None,
+ onUp = lambda x: None,
+ onMotion = lambda x: None,
+ resetMotion = lambda: None,
+ maxEvents = None,
+ captureEvents = True):
+
+ self.__node = node
+ self.__source = source
+ self.__callback = {
+ 'onDown': onDown,
+ 'onUp': onUp,
+ 'onMotion': onMotion,
+ 'resetMotion': resetMotion,
+ }
+
+ self.__maxEvents = maxEvents
+ self.__captureEvents = captureEvents
+
+ self.__capturedCursors = []
+ self.__node.setEventHandler (avg.CURSORDOWN, self.__source, self.__onDown)
+ self.__node.setEventHandler (avg.CURSORUP, self.__source, self.__onUp)
+ self.__node.setEventHandler (avg.CURSORMOTION, self.__source, self.__onMotion)
+
+ self.__eventCursors = []
+
+ def handleInitialDown(self, event):
+ self.__onDown(event)
+
+ def delete(self):
+ for cursorid in self.__capturedCursors:
+ self.__node.releaseEventCapture (cursorid)
+ self.__capturedCursors = []
+
+ for type_ in avg.CURSORDOWN, avg.CURSORMOTION, avg.CURSORUP:
+ self.__node.setEventHandler(type_, self.__source, None)
+ self.__node = None
+
+ def __setitem__(self, key, val):
+ raise Exception
+
+ def __findEventCursor(self, event):
+ found = filter (lambda ec: ec.getCursorID() == event.cursorid, self.__eventCursors)
+ return found[0] if found else None
+
+ def __resetMotion(self):
+ map(EventCursor.resetMotion, self.__eventCursors)
+ self.__callback['resetMotion']()
+
+ def __onUp(self, event):
+ def __removeCursor (cursor):
+ def __releaseCapture (cursorid):
+ if cursorid in self.__capturedCursors:
+ try:
+ self.__node.releaseEventCapture (cursorid)
+ self.__capturedCursors.remove (cursorid)
+ except RuntimeError: # XXX
+ print "warning: could not release event capture for cursor %u" % cursorid
+
+ __releaseCapture (cursor.getCursorID())
+ self.__eventCursors.remove (cursor)
+ self.__resetMotion ()
+ ec = self.__findEventCursor (event)
+ if ec:
+ ec.update (event)
+ __removeCursor (ec)
+ self.__callback['onUp'](ec)
+
+ def __onDown(self, event):
+ if self.__maxEvents and len(self.__eventCursors) >= self.__maxEvents:
+ return
+
+ if self.__captureEvents:
+ try:
+ self.__node.setEventCapture(event.cursorid)
+ self.__capturedCursors.append(event.cursorid)
+ except RuntimeError:
+ print "warning: could capture events for cursor %u" % event.cursorid
+
+ ec = EventCursor (event)
+ self.__eventCursors.append (ec)
+ self.__resetMotion ()
+ self.__callback['onDown'](ec)
+
+ def __onMotion(self, event):
+ ec = self.__findEventCursor (event)
+ if ec:
+ ec.update (event)
+ self.__callback['onMotion'](ec)
+
+ def getCursors(self):
+ return self.__eventCursors
+
+ def __len__(self):
+ return len(self.__eventCursors)
diff --git a/src/python/gameapp.py b/src/python/gameapp.py
new file mode 100644
index 0000000..350a7ec
--- /dev/null
+++ b/src/python/gameapp.py
@@ -0,0 +1,327 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is OXullo Intersecans <x@brainrapers.org>
+#
+
+'''
+Transitional class to fulfill some of the missing features of AVGApp,
+currently needed for multitouch games.
+'''
+
+from __future__ import with_statement
+import os
+import sys
+import cPickle as pickle
+
+import libavg
+from libavg import avg
+
+g_Player = avg.Player.get()
+g_Log = avg.Logger.get()
+
+
+class Datastore(object):
+ '''
+ General purpose persistent object (state in self.data)
+
+ Even if it's possible to use Datastore independently from GameApp, the suggested
+ use is described with the following case (given MyApp a subclass of GameApp):
+
+ >>> from mypackage.app import MyApp
+ >>> g_App = MyApp.get()
+
+ >>> def validate(data):
+ >>> return type(data) == list and isinstance(data[2], Bar)
+
+ >>> myInitialData = [1, 'foo', Bar(12)]
+ >>> myDs = g_App.initDatastore('hiscore', myInitialData, validate)
+ >>> myDs.data[2].foobarize(1)
+ >>> myDs.data[0] = 2
+ >>> myDs.commit()
+
+ >>> againMyDs = g_App.getDatastore('hiscore')
+ '''
+
+ def __init__(self, dumpFile, initialData, validator, autoCommit):
+ '''
+ dumpFile: path to a file which is used for storing and retrieving data
+ initialData: a callable (class, method) or an instance that is used to initialize
+ the datastore when the dumpfile either doesn't exist, it's corrupted, or
+ cannot be accessed or when the loaded data don't comply with the optional
+ validator. Defaults to an empty dict.
+ validator: a callable to which stored data are passed and that is able to
+ determine if the data format is expected. If the call returns True, the
+ proposed data are accepted and set. With False as return value the
+ Datastore uses initialData instead.
+ autoCommit: if True, the datastore sync itself when the program exits (uses
+ atexit). It's always possible to commit() manually.
+ '''
+ self.__dumpFile = dumpFile
+
+ if hasattr(initialData, '__call__'):
+ initialData = initialData()
+ elif initialData is None:
+ initialData = dict()
+
+ if os.path.exists(self.__dumpFile):
+ if not os.path.isfile:
+ raise RuntimeError('%s dump file '
+ 'is not a plain file' % self)
+ elif not os.access(self.__dumpFile, os.R_OK | os.W_OK):
+ raise RuntimeError('%s dump file'
+ 'cannot be accessed with r/w permissions' % self)
+
+ try:
+ f = open(self.__dumpFile)
+ except IOError:
+ g_Log.trace(g_Log.APP, 'Initializing %s' % self)
+ self.data = initialData
+ self.commit()
+ else:
+ try:
+ self.data = pickle.load(f)
+ except:
+ f.close()
+ g_Log.trace(g_Log.ERROR, 'Datastore %s is corrupted, '
+ 'reinitializing' % self)
+ self.data = initialData
+ self.commit()
+ else:
+ f.close()
+ if not validator(self.data):
+ g_Log.trace(g_Log.ERROR, 'Sanity check failed for %s: '
+ 'reinitializing' % self)
+ self.data = initialData
+ self.commit()
+ else:
+ g_Log.trace(g_Log.APP, '%s successfully '
+ 'loaded' % self)
+
+ if autoCommit:
+ import atexit
+ atexit.register(self.commit)
+
+ def commit(self):
+ '''
+ Dump Datastore data to disk
+ '''
+ import time
+
+ tempFile = self.__dumpFile + '.tmp.' + str(int(time.time() * 1000))
+
+ try:
+ with open(tempFile, 'wb') as f:
+ pickle.dump(self.data, f)
+ except Exception, e:
+ g_Log.trace(g_Log.ERROR, 'Cannot save '
+ '%s (%s)' % (self.__dumpFile, str(e)))
+ return False
+ else:
+ if os.path.exists(self.__dumpFile):
+ try:
+ os.remove(self.__dumpFile)
+ except Exception, e:
+ g_Log.trace(g_Log.ERROR, 'Cannot overwrite '
+ 'dump file %s (%s)' % (self, str(e)))
+ return False
+ try:
+ os.rename(tempFile, self.__dumpFile)
+ except Exception, e:
+ g_Log.trace(g_Log.ERROR, 'Cannot save '
+ '%s (%s)' % (self, str(e)))
+ os.remove(tempFile)
+ return False
+ else:
+ g_Log.trace(g_Log.APP, '%s saved' % self)
+ return True
+
+ def __repr__(self):
+ return '<%s %s>' % (self.__class__.__name__, self.__dumpFile)
+
+
+class GameApp(libavg.AVGApp):
+ '''
+ Derivation from this class adds a command line parser, which can be used to
+ define fullscreen behavior and resolution. It defaults to fullscreen and
+ sets the resolution as the current desktop's one.
+ Multitouch is enabled by default.
+ '''
+ multitouch = True
+ instances = {}
+
+ def __init__(self, *args, **kwargs):
+ appname = self.__class__.__name__
+ if appname in GameApp.instances:
+ raise RuntimeError('App %s already setup' % appname)
+
+ GameApp.instances[appname] = self
+
+ super(GameApp, self).__init__(*args, **kwargs)
+
+ self.__datastores = {}
+
+ pkgpath = self._getPackagePath()
+ if pkgpath is not None:
+ avg.WordsNode.addFontDir(libavg.utils.getMediaDir(pkgpath, 'fonts'))
+ self._parentNode.mediadir = libavg.utils.getMediaDir(pkgpath)
+
+ @classmethod
+ def get(cls):
+ '''
+ Get the Application instance
+
+ Note: this class method has to be called from the top-level app class:
+
+ >>> class MyApp(gameapp.GameApp):
+ ... pass
+ >>> instance = MyApp.get()
+ '''
+ return cls.instances.get(cls.__name__, None)
+
+ @classmethod
+ def start(cls, *args, **kwargs):
+ import optparse
+
+ parser = optparse.OptionParser()
+ parser.add_option('-r', '--resolution', dest='resolution',
+ default=None, help='set an explicit resolution', metavar='WIDTHxHEIGHT')
+ parser.add_option('-w', '--window', dest='window', action='store_true',
+ default=False, help='run the game in a window')
+
+ (options, args) = parser.parse_args()
+
+ if options.resolution is not None:
+ import re
+
+ m = re.match('^(\d+)x(\d+)$', options.resolution)
+
+ if m is None:
+ sys.stderr.write('\n** ERROR: invalid resolution '
+ 'specification %s\n\n' % options.resolution)
+ parser.print_help()
+ sys.exit(1)
+ else:
+ kwargs['resolution'] = map(int, m.groups())
+ elif not 'resolution' in kwargs:
+ kwargs['resolution'] = g_Player.getScreenResolution()
+
+ if options.window:
+ if options.resolution is None:
+ sys.stderr.write('\n** ERROR: in window mode the resolution '
+ 'must be set\n\n')
+ parser.print_help()
+ sys.exit(1)
+ else:
+ if 'AVG_DEPLOY' in os.environ:
+ del os.environ['AVG_DEPLOY']
+ else:
+ os.environ['AVG_DEPLOY'] = '1'
+
+ g_Log.trace(g_Log.APP, 'Setting resolution to: %s' % str(kwargs['resolution']))
+
+ super(GameApp, cls).start(*args, **kwargs)
+
+ def quit(self):
+ '''
+ Quit the application
+ The player is stopped if the application has been started by its own
+ (eg: no appchooser)
+ '''
+ self.leave()
+ if self.getStarter() is not None:
+ g_Player.get().stop()
+
+ def getUserdataPath(self, fname):
+ '''
+ Return a path which is platform dependent and that points to a directory
+ which can be used to store games data.
+ These data will belong to the current user and are not meant for system-wide
+ settings.
+ The path is constructed using the name of the app's class and it is created
+ if it doesn't exist.
+ '''
+ if os.name == 'posix':
+ path = os.path.join(os.environ['HOME'], '.avg',
+ self.__class__.__name__.lower())
+ elif os.name == 'nt':
+ path = os.path.join(os.environ['APPDATA'], 'Avg',
+ self.__class__.__name__.lower())
+ else:
+ raise RuntimeError('Unsupported system %s' % os.name)
+
+ try:
+ os.makedirs(path)
+ except OSError, e:
+ import errno
+ if e.errno != errno.EEXIST:
+ raise
+
+ return os.path.join(path, fname)
+
+ def initDatastore(self, tag, initialData=None, validator=lambda ds: True,
+ autoCommit=True):
+ '''
+ Initialize and return a Datastore instance
+
+ tag: a string that references the datastore. Such tags are uniques within
+ the application's scope and may be retrieved from different parts of
+ the game's package with getDatastore() method.
+
+ See the documentation on Datastore class for the rest of the parameters.
+
+ >>> myDs = MyApp.get().initDatastore('hiscore', [])
+ >>> myDs.data.append(ScoreEntry(12321, 'oxi'))
+ >>> myDs.commit()
+ '''
+
+ if type(tag) != str:
+ raise TypeError('Tag must be a string instead of %s' % type(tag))
+
+ if tag in self.__datastores:
+ raise RuntimeError('Datastore %s already initialized')
+
+ ds = Datastore(self.getUserdataPath(tag + '.pkl'), initialData, validator,
+ autoCommit)
+
+ self.__datastores[tag] = ds
+
+ return ds
+
+ def getDatastore(self, tag):
+ '''
+ Return an initialized Datastore instance given its tag
+ '''
+ return self.__datastores.get(tag, None)
+
+ def _getPackagePath(self):
+ '''
+ Overload this method in your App class if you want to get 'media' and 'fonts'
+ easily set up (respectively as mediadir for App._parentNode and for local font
+ path).
+ This method should return a relative (to CWD) or absolute path. It can be a file
+ path as well.
+ Eg:
+
+ def _getPackagePath(self):
+ return __file__
+ '''
+ return None
+
+
diff --git a/src/python/geom.py b/src/python/geom.py
new file mode 100644
index 0000000..c7d5fd8
--- /dev/null
+++ b/src/python/geom.py
@@ -0,0 +1,206 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg
+g_Player = None
+
+class RoundedRect(avg.PolygonNode):
+ def __init__(self, size, radius, pos=(0,0), parent=None, **kwargs):
+ avg.PolygonNode.__init__(self, **kwargs)
+ self.__pos = avg.Point2D(pos)
+ self.__size = avg.Point2D(size)
+ self.__radius = radius
+ self.__calcPolygon()
+ if parent:
+ parent.appendChild(self)
+
+ def getPos(self):
+ return self.__pos
+
+ def setPos(self, pos):
+ self.__pos = avg.Point2D(pos)
+ self.__calcPolygon()
+ polyPos = avg.PolygonNode.pos
+ pos = property(getPos, setPos)
+
+ def getSize(self):
+ return self.__size
+
+ def setSize(self, size):
+ self.__size = avg.Point2D(size)
+ self.__calcPolygon()
+ size = property(getSize, setSize)
+
+ def getRadius(self):
+ return self.__radius
+
+ def setRadius(self, radius):
+ self.__radius = radius
+ self.__calcPolygon()
+ radius = property(getRadius, setRadius)
+
+ def __calcPolygon(self):
+ def calcQuarterCircle(center, r, startAngle):
+ pos = []
+ for i in xrange(int(r)+1):
+ angle = i*(1.57/r)+startAngle
+ p = avg.Point2D(center)+avg.Point2D.fromPolar(angle, r)
+ pos.append(p)
+ return pos
+
+ if self.__size.x < self.__radius*2:
+ self.__radius = self.__size.x/2
+ if self.__size.y < self.__radius*2:
+ self.__radius = self.__size.y/2
+ if self.__radius == 0:
+ self.__radius = 0.01
+ pos = []
+ r = self.__radius
+ size = self.__size
+ pos.extend(calcQuarterCircle(self.pos+(size.x-r,r), r, -1.57))
+ pos.extend(calcQuarterCircle(self.pos+(size.x-r,size.y-r), r, 0))
+ pos.extend(calcQuarterCircle(self.pos+(r,size.y-r), r, 1.57))
+ pos.extend(calcQuarterCircle(self.pos+(r,r), r, 3.14))
+ self.polyPos = pos
+
+
+class PieSlice(avg.PolygonNode):
+ def __init__(self, radius, startangle, endangle, pos=(0,0), parent=None,
+ **kwargs):
+ avg.PolygonNode.__init__(self, **kwargs)
+ self.__pos = avg.Point2D(pos)
+ self.__radius = radius
+ self.__startangle = startangle
+ self.__endangle = endangle
+ self.__calcPolygon()
+ if parent:
+ parent.appendChild(self)
+
+ def getPos(self):
+ return self.__pos
+
+ def setPos(self, pos):
+ self.__pos = avg.Point2D(pos)
+ self.__calcPolygon()
+ polyPos = avg.PolygonNode.pos
+ pos = property(getPos, setPos)
+
+ def getRadius(self):
+ return self.__radius
+
+ def setRadius(self, radius):
+ self.__radius = radius
+ self.__calcPolygon()
+ radius = property(getRadius, setRadius)
+
+ def getStartAngle(self):
+ return self.__startangle
+
+ def setStartAngle(self, startangle):
+ self.__startangle = startangle
+ self.__calcPolygon()
+ startangle = property(getStartAngle, setStartAngle)
+
+ def getEndAngle(self):
+ return self.__endangle
+
+ def setEndAngle(self, endangle):
+ self.__endangle = endangle
+ self.__calcPolygon()
+ endangle = property(getEndAngle, setEndAngle)
+
+ def __calcPolygon(self):
+
+ def getCirclePoint(i):
+ angle = self.__startangle + (self.__endangle-self.__startangle)*i
+ return avg.Point2D(self.__pos)+avg.Point2D.fromPolar(angle, self.__radius)
+
+ pos = []
+ circlePart = (self.__endangle - self.__startangle)/6.28
+ numPoints = self.__radius*2.*circlePart
+ if numPoints < 4:
+ numPoints = 4
+ for i in xrange(0, int(numPoints)):
+ pos.append(getCirclePoint(i/numPoints))
+ pos.append(getCirclePoint(1))
+ pos.append(self.__pos)
+ self.polyPos = pos
+
+
+class Arc(avg.PolyLineNode):
+ # TODO: Code duplication with PieSlice
+ def __init__(self, radius, startangle, endangle, pos=(0,0), parent=None,
+ **kwargs):
+ avg.PolyLineNode.__init__(self, **kwargs)
+ self.__pos = avg.Point2D(pos)
+ self.__radius = radius
+ self.__startangle = startangle
+ self.__endangle = endangle
+ self.__calcPolygon()
+ if parent:
+ parent.appendChild(self)
+
+ def getPos(self):
+ return self.__pos
+
+ def setPos(self, pos):
+ self.__pos = avg.Point2D(pos)
+ self.__calcPolygon()
+ polyPos = avg.PolyLineNode.pos
+ pos = property(getPos, setPos)
+
+ def getRadius(self):
+ return self.__radius
+
+ def setRadius(self, radius):
+ self.__radius = radius
+ self.__calcPolygon()
+ radius = property(getRadius, setRadius)
+
+ def getStartAngle(self):
+ return self.__startangle
+
+ def setStartAngle(self, startangle):
+ self.__startangle = startangle
+ self.__calcPolygon()
+ startangle = property(getStartAngle, setStartAngle)
+
+ def getEndAngle(self):
+ return self.__endangle
+
+ def setEndAngle(self, endangle):
+ self.__endangle = endangle
+ self.__calcPolygon()
+ endangle = property(getEndAngle, setEndAngle)
+
+ def __calcPolygon(self):
+
+ def getCirclePoint(i):
+ angle = self.__startangle + (self.__endangle-self.__startangle)*i
+ return avg.Point2D(self.__pos)+avg.Point2D.fromPolar(angle, self.__radius)
+
+ pos = []
+ circlePart = (self.__endangle - self.__startangle)/6.28
+ numPoints = self.__radius*2.*circlePart
+ for i in xrange(0, int(numPoints)):
+ pos.append(getCirclePoint(i/numPoints))
+ pos.append(getCirclePoint(1))
+ self.polyPos = pos
+
diff --git a/src/python/grabbable.py b/src/python/grabbable.py
new file mode 100644
index 0000000..800e73b
--- /dev/null
+++ b/src/python/grabbable.py
@@ -0,0 +1,320 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Martin Heistermann <mh at sponc dot de>
+#
+
+import math
+
+from libavg import avg, Point2D
+from clusteredEventList import ClusteredEventList
+from mathutil import solveEquationMatrix, EquationSingular, EquationNotSolvable
+from mathutil import getAngle, getDistance, getScaledDim, getOffsetForMovedPivot
+
+
+NUM_SPEEDS = 5
+
+g_Player = avg.Player.get()
+
+def getRelPos(pos, nodePos, angle, pivot):
+ return (pos - nodePos).getRotated(-angle, pivot)
+
+def getAbsPos(pos, nodePos, angle, pivot):
+ return Point2D(pos).getRotated(angle, Point2D(pivot)) + Point2D(nodePos)
+
+
+class Grabbable:
+ """Helper for multitouch object movement.
+ Grabbable will add the well-known multitouch gestures
+ to a node, i.e. moving with one finger, rotating,
+ resizing and moving with 2 fingers.
+ It also works with many more cursors/fingers, clustering
+ them.
+ """
+ def __init__(self,
+ node,
+ source = avg.TOUCH | avg.MOUSE,
+ maxSize = None, minSize = None,
+ onResize = lambda: None,
+ onDrop = lambda: None,
+ onStop = lambda: None,
+ onAction = lambda: None,
+ onMotion = lambda pos, size, angle, pivot: None,
+ onResetMotion = lambda: None,
+ onDragStart = lambda: None,
+ initialDown = None,
+ inertia = 0.95,
+ torque = 0.95,
+ moveNode = True):
+
+ global g_Player
+ self.__inertia = inertia
+ self.__torque = torque
+ self.__node = node
+ self.__minSize = minSize
+ self.__maxSize = maxSize
+ self.__moveNode = moveNode
+ self.__callback = {
+ 'onResize': onResize,
+ 'onDrop': onDrop,
+ 'onStop': onStop,
+ 'onAction': onAction,
+ 'onMotion': onMotion,
+ 'onResetMotion': onResetMotion,
+ 'onDragStart': onDragStart,
+ }
+
+ self.__stopInertia()
+ #self.__oldAngle = 0.0
+ self.__lastFixPoint = None
+ self.__lastNumFingers = 0
+ self.__onFrameHandler = g_Player.setOnFrameHandler(self.__onFrame)
+
+ self.__eventList = ClusteredEventList (self.__node,
+ source = source,
+ onMotion = self.__onMotion,
+ onUp = self.__onUp,
+ onDown = self.__onDown,
+ resetMotion = self.__resetMotion
+ )
+ if initialDown:
+ self.__eventList.handleInitialDown (initialDown)
+ self.__lastPos = None
+ self.__stopped = True
+
+ def isDragging(self):
+ return len(self.__eventList) > 0
+
+ def getSpeed(self):
+ return self.__speed
+
+ def getAngle(self):
+ return self.__angle
+
+ def delete(self):
+ global g_Player
+ g_Player.clearInterval(self.__onFrameHandler)
+ self.__eventList.delete()
+ self.__node = None
+
+ def __onFrame(self):
+ global g_Player
+ if len (self.__eventList) == 0:
+ # inertia
+ if self.__speed.getNorm() < 1:
+ if not self.__stopped:
+ pos = Point2D(round(self.__node.pos.x), round(self.__node.pos.y))
+ size = Point2D(round(self.__node.size.x), round(self.__node.size.y))
+ self.__callback['onMotion'](pos, size, self.__node.angle,
+ self.__node.pivot)
+ self.__stopped = True
+ self.__callback['onStop']()
+ self.__stopInertia()
+ return
+
+ pos = self.__node.pos + self.__speed
+ angle = self.__node.angle + self.__rotSpeed
+ size = self.__node.size
+ pivot = self.__node.pivot
+
+ if self.__moveNode:
+ self.__node.pos = pos
+ self.__node.size = size
+ self.__node.angle = angle
+ self.__node.pivot = pivot
+
+ self.__callback['onMotion'](pos, size, angle, pivot)
+
+ self.__speed *= self.__inertia
+ self.__rotSpeed *= self.__torque
+ else:
+ self.__stopped = False
+ # save current speed for inertia
+ pos = self.__node.pos
+ angle = self.__node.angle
+ if self.__lastPos:
+ speed = pos - self.__lastPos
+ rotSpeed = angle - self.__lastAngle
+ # use minimal angle to avoid extreme rotation:
+ if rotSpeed < -math.pi/2:
+ rotSpeed += math.pi*2
+ if rotSpeed > math.pi/2:
+ rotSpeed -= math.pi*2
+ self.__speeds = (self.__speeds + [speed])[-NUM_SPEEDS:]
+ self.__rotSpeeds = (self.__rotSpeeds + [rotSpeed])[-NUM_SPEEDS:]
+ self.__lastPos = pos
+ self.__lastAngle = angle
+
+ def __stopInertia (self):
+ self.__speed = Point2D(0,0)
+ self.__rotSpeed = 0
+ self.__speeds = [Point2D(0,0)]
+ self.__rotSpeeds = [0.0]
+ self.__lastPos = None
+
+ def __onDown(self):
+ def __gotoTopLayer():
+ parent = self.__node.getParent()
+ numChildren = parent.getNumChildren()
+ parent.reorderChild(self.__node, numChildren - 1)
+
+ self.__stopInertia()
+ self.__reshape()
+ if len(self.__eventList) == 1: # first finger down
+ if self.__moveNode:
+ __gotoTopLayer()
+ self.__callback['onDragStart']()
+ self.__callback['onAction']()
+
+ def __onMotion(self):
+ self.__reshape()
+ self.__callback['onAction']()
+
+ def __drop(self):
+ self.__speed = sum(self.__speeds, Point2D(0,0)) / len(self.__speeds)
+ self.__rotSpeed = sum(self.__rotSpeeds, 0.0) / len(self.__rotSpeeds)
+ self.__callback['onDrop']()
+
+ def __onUp(self):
+ if len(self.__eventList) == 0:
+ self.__drop()
+ self.__callback['onAction']()
+
+ def __reshape (self):
+ def applyAffineTransformation (parameters, p):
+ """apply transformation to point:
+ M: v:
+ P' = P * (m -n) + (v0)
+ (n m) (v1) """
+ m, n, v0, v1 = parameters
+ nx = p[0] * m - p[1] * n + v0
+ ny = p[0] * n + p[1] * m + v1
+ return Point2D(nx, ny)
+
+ clusters = self.__eventList.getCursors()
+
+ if len(clusters) == 1:
+ cursor = self.__eventList.getCursors()[0]
+
+ pos = self.__oldpos + cursor.getDelta()
+ size = self.__node.size
+ angle = self.__node.angle
+ pivot = self.__node.pivot
+
+ elif len(clusters) == 2:
+ # calculate an affine transformation which describes cluster movement
+ # TODO: explain used maths
+ cursor1, cursor2 = clusters
+ equationMatrix = (
+ ((cursor1.getStartPos().x, -cursor1.getStartPos().y, 1, 0), cursor1.getPos().x),
+ ((cursor1.getStartPos().y, cursor1.getStartPos().x, 0, 1), cursor1.getPos().y),
+ ((cursor2.getStartPos().x, -cursor2.getStartPos().y, 1, 0), cursor2.getPos().x),
+ ((cursor2.getStartPos().y, cursor2.getStartPos().x, 0, 1), cursor2.getPos().y),
+ )
+ try:
+ param = solveEquationMatrix (equationMatrix)
+ except (EquationSingular, EquationNotSolvable):
+# g_Log.trace(g_Log.APP,
+# "Grabbable: cannot solve equation, skipping movement")
+ return False
+
+ absTouchCenter = cursor2.getPos() + (cursor1.getPos() - cursor2.getPos()) / 2
+
+ n_tl = applyAffineTransformation (param, self.o_tl)
+ n_bl = applyAffineTransformation (param, self.o_bl)
+ n_tr = applyAffineTransformation (param, self.o_tr)
+
+ pos = n_tl
+ if pos.x > 1e6 and pos.x > self.o_tl.x:
+ pos = self.o_tl
+ if pos.y > 1e6 and pos.y > self.o_tl.y:
+ pos = self.o_tl
+ if pos.x < -1e6 and pos.x < self.o_tl.x:
+ pos = self.o_tl
+ if pos.y < -1e6 and pos.y < self.o_tl.y:
+ pos = self.o_tl
+
+ size = Point2D(getDistance (n_tl, n_tr), getDistance (n_tl, n_bl))
+ if size.x<=0.1:
+ size.x=0.1
+ if size.y<=0.1:
+ size.y=0.1
+ angle = getAngle(n_tl, n_tr) # pivot for this rotation is 0,0 (rel. to node)
+
+ # get middle of touches relative to the node
+ relTouchCenter = getRelPos(absTouchCenter, pos, angle, Point2D(0,0))
+ pos += getOffsetForMovedPivot(
+ oldPivot = Point2D(0,0),
+ newPivot = relTouchCenter,
+ angle = angle)
+ pivot = relTouchCenter
+
+ # the absolute position of the pivot should change when
+ # resizing, so we track and revert absolute pivot movement
+ oldAbsPivot = getAbsPos(pivot, pos, angle, pivot)
+
+ newSize = getScaledDim (size,
+ max = self.__maxSize,
+ min = self.__minSize)
+
+ ratio = newSize.x / size.x
+ newPivot = pivot * ratio
+
+ pos += getOffsetForMovedPivot(
+ oldPivot = pivot,
+ newPivot = newPivot,
+ angle = angle)
+ oldPivot = pivot
+ pivot = newPivot
+
+ size = newSize
+
+ newAbsPivot = getAbsPos(pivot, pos, angle, pivot)
+
+ # move node to revert absolute pivot position
+ pos -= (newAbsPivot - oldAbsPivot)
+
+ else: # more than 2 clusters
+ assert False
+
+ if self.__moveNode:
+ self.__node.angle = angle
+ self.__node.size = size
+ self.__node.pos = pos
+ self.__node.pivot = pivot
+ self.__callback['onResize']()
+
+ self.__callback['onMotion'](pos, size, angle, pivot)
+
+ def __resetMotion (self):
+ """ sets a new movement start point """
+ # store absolute position at the beginning of the movement
+ # for 2-finger-movements:
+ def getPos(pos):
+ return getAbsPos(pos, self.__node.pos, self.__node.angle, self.__node.pivot)
+ self.o_tl = getPos((0, 0))
+ self.o_bl = getPos((0, self.__node.height))
+ self.o_tr = getPos((self.__node.width, 0))
+
+ # for 1-finger-movements:
+ self.__oldpos = self.__node.pos
+
+ self.__lastFixPoint = None
+ self.__callback['onResetMotion']()
+
diff --git a/src/python/graph.py b/src/python/graph.py
new file mode 100644
index 0000000..c59cc2b
--- /dev/null
+++ b/src/python/graph.py
@@ -0,0 +1,169 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+
+import time
+
+from libavg import avg
+
+g_Player = avg.Player.get()
+
+class Graph(object):
+ def __init__(self, graph, getValue):
+ self._getValue = getValue
+ self._xSkip = 2
+ self._memGraphStartTime = g_Player.getFrameTime()
+ self._curUsage = 0
+
+ self._rootNode = g_Player.getRootNode()
+ size = avg.Point2D(self._rootNode.width-20, self._rootNode.height/6)
+
+ self._node = g_Player.createNode("""
+ <div opacity="0" sensitive="False" x="10" y="10" size="%(size)s">
+ <rect strokewidth="0" fillopacity="0.6" fillcolor="FFFFFF"
+ size="%(size)s"/>
+ <words x="10" y="%(wordsheight0)i" color="000080"/>
+ <words x="10" y="%(wordsheight1)i" color="000080"/>
+ <polyline color="008000"/>
+ <polyline color="000080"/>
+ <words x="10" y="0" color="000080"/>
+ </div>"""
+ % {'size': str(size), 'wordsheight0':size.y-22, 'wordsheight1':size.y-39})
+
+ self._graphSize = size-avg.Point2D(20, 20)
+ self._rootNode.appendChild(self._node)
+ self._textNode0 = self._node.getChild(1)
+ self._textNode1 = self._node.getChild(2)
+ self._maxLineNode = self._node.getChild(3)
+ self._lineNode = self._node.getChild(4)
+ self.__graphText = self._node.getChild(5)
+ self.__graphText.text = graph
+
+ self._setup()
+ avg.fadeIn(self._node, 300)
+
+ def _setup(self):
+ raise RuntimeError, 'Please overload _setup() function'
+
+ def setYpos(self,ypos):
+ self._node.y = ypos
+
+ def delete(self):
+ def kill():
+ self._node.unlink()
+ avg.LinearAnim(self._node, "opacity", 300, 1, 0, None, kill).start()
+ g_Player.clearInterval(self._interval)
+ self._interval = None
+
+
+class MemGraph(Graph):
+ def _setup(self):
+ self._interval = g_Player.setInterval(1000, self._nextMemSample)
+ self._memSampleNum = 0
+ self._usage = [0]
+ self._maxUsage = [0]
+ self._minutesUsage = [0]
+ self._minutesMaxUsage = [0]
+
+ def _nextMemSample(self):
+ curUsage = self._getValue()
+ self._usage.append(curUsage)
+ maxUsage = self._maxUsage[-1]
+
+ if curUsage>maxUsage:
+ maxUsage = curUsage
+ lastMaxChangeTime = time.time()
+ self._textNode1.text = ("Last increase in maximum: "
+ +time.strftime("%d.%m.%Y %H:%M:%S",
+ time.localtime(lastMaxChangeTime)))
+ self._maxUsage.append(maxUsage)
+ self._memSampleNum += 1
+
+ if self._memSampleNum % 60 == 0:
+ lastMinuteAverage = sum(self._usage[-60:])/60
+ self._minutesUsage.append(lastMinuteAverage)
+ self._minutesMaxUsage.append(maxUsage)
+
+ if self._memSampleNum < 60*60:
+ self._plotLine(self._usage, self._lineNode, maxUsage)
+ self._plotLine(self._maxUsage, self._maxLineNode, maxUsage)
+ else:
+ self._plotLine(self._minutesUsage, self._lineNode, maxUsage)
+ self._plotLine(self._minutesMaxUsage, self._maxLineNode, maxUsage)
+
+ self._textNode0.text = ("Max. memory usage: %(size).2f MB"
+ %{"size":maxUsage/(1024*1024.)})
+
+ if self._memSampleNum % 3600 == 0:
+ del self._usage[0:3600]
+ del self._maxUsage[0:3599]
+ if self._memSampleNum == 604800:
+ self._memSampleNum == 0
+
+ def _plotLine(self, data, node, maxy):
+ yfactor = self._graphSize.y/float(maxy)
+ xfactor = self._graphSize.x/float(len(data)-1)
+ node.pos = [(pos[0]*xfactor+10, (maxy-pos[1])*yfactor+10)
+ for pos in enumerate(data)]
+
+
+class FrameRateGraph(Graph):
+ def _setup(self):
+ self._interval = g_Player.setOnFrameHandler(self._nextFrameTimeSample)
+ self._sampleNum = 0
+ self._memSampleNum = 0
+ self._lastCurUsage = 0
+ self._maxFrameTime = 0
+ self._values = []
+
+ def _nextFrameTimeSample(self):
+ val = self._frameTimeSample()
+ self._appendValue(val)
+ self._sampleNum += 1
+
+ def _appendValue(self,value):
+ y = value + self._rootNode.height/6
+ numValues = int(self._rootNode.width/self._xSkip)-10
+ self._values = (self._values + [y])[-numValues:]
+ self._plotGraph()
+
+ def _frameTimeSample(self):
+ frameTime = self._getValue()
+ diff = frameTime - self._lastCurUsage
+ #if(self._sampleNum % 1800 == 0):
+ # self._maxFrameTime = 0
+ if self._sampleNum < 2:
+ self._maxFrameTime = 0
+ if diff > self._maxFrameTime:
+ lastMaxChangeTime = time.time()
+ self._maxFrameTime = diff
+ self._textNode0.text = ("Max FrameTime: %.f" %self._maxFrameTime + " ms" +
+ " Time: " +time.strftime("%d.%m.%Y %H:%M:%S",
+ time.localtime(lastMaxChangeTime)))
+ if diff > self._node.y-1:
+ y = self._node.y-1
+
+ self._lastCurUsage = frameTime
+ self._textNode1.text = ("Current FrameTime: %.f" %diff + " ms" )
+ return -diff
+
+ def _plotGraph(self):
+ self._lineNode.pos = self._getCoords()
+
+ def _getCoords(self):
+ return zip(xrange(10,len(self._values)*self._xSkip, self._xSkip), self._values)
diff --git a/src/python/mathutil.py b/src/python/mathutil.py
new file mode 100644
index 0000000..caa9968
--- /dev/null
+++ b/src/python/mathutil.py
@@ -0,0 +1,168 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Martin Heistermann <mh at sponc dot de>
+#
+
+# TODO: Some of this stuff is duplicated - either in Point2D or in MathHelper.h/.cpp.
+# Clean that up.
+
+import math
+from libavg import Point2D
+
+def getAngle(p1, p2):
+ vec = p2 - p1
+ res = math.atan2(vec.y, vec.x)
+ if res < 0:
+ res += math.pi * 2
+ return res
+
+def getDistance (p, q):
+ return math.sqrt((p.x-q.x)**2 + (p.y-q.y)**2)
+
+def getDistSquared (p, q):
+ return (p.x-q.x)**2 + (p.y-q.y)**2
+
+def getScaleToSize ((width, height), (max_width, max_height)):
+ if width < max_width:
+ height = height * (float(max_width) / width)
+ width = max_width
+ elif height > max_height:
+ width = width * (float(max_height) / height)
+ height = max_height
+ return getScaledDim((width, height), (max_width, max_height))
+
+def getScaledDim (size, max = None, min = None):
+ width, height = size
+ if width == 0 or height == 0:
+ return size
+
+ if max:
+ max = Point2D(max)
+ assert (max.x > 0 and max.y > 0)
+ if width > max.x:
+ height = height * (max.x / width)
+ width = max.x
+ if height > max.y:
+ width = width * (max.y / height)
+ height = max.y
+
+ if min:
+ min = Point2D(min)
+ assert (min.x > 0 and min.y > 0)
+ if width < min.x:
+ height = height * (min.x / width)
+ width = min.x
+ if height < min.y:
+ width = width * (min.y / height)
+ height = min.y
+
+ return Point2D(width, height)
+
+
+class EquationNotSolvable (Exception):
+ pass
+class EquationSingular (Exception):
+ pass
+
+def gauss_jordan(m, eps = 1.0/(10**10)):
+ """Puts given matrix (2D array) into the Reduced Row Echelon Form.
+ Returns True if successful, False if 'm' is singular.
+ NOTE: make sure all the matrix items support fractions! Int matrix will NOT work!
+ Written by Jarno Elonen in April 2005, released into Public Domain
+ http://elonen.iki.fi/code/misc-notes/affine-fit/index.html"""
+ (h, w) = (len(m), len(m[0]))
+ for y in range(0,h):
+ maxrow = y
+ for y2 in range(y+1, h): # Find max pivot
+ if abs(m[y2][y]) > abs(m[maxrow][y]):
+ maxrow = y2
+ (m[y], m[maxrow]) = (m[maxrow], m[y])
+ if abs(m[y][y]) <= eps: # Singular?
+ raise EquationSingular
+ for y2 in range(y+1, h): # Eliminate column y
+ c = m[y2][y] / m[y][y]
+ for x in range(y, w):
+ m[y2][x] -= m[y][x] * c
+ for y in range(h-1, 0-1, -1): # Backsubstitute
+ c = m[y][y]
+ for y2 in range(0,y):
+ for x in range(w-1, y-1, -1):
+ m[y2][x] -= m[y][x] * m[y2][y] / c
+ m[y][y] /= c
+ for x in range(h, w): # Normalize row y
+ m[y][x] /= c
+ return m
+
+
+def solveEquationMatrix(_matrix, eps = 1.0/(10**10)):
+ matrix=[]
+ for coefficients, res in _matrix:
+ newrow = map(float, coefficients + (res,))
+ matrix.append(newrow)
+ matrix = gauss_jordan (matrix)
+ res=[]
+ for col in xrange(len(matrix[0])-1):
+ rows = filter(lambda row: row[col] >= eps, matrix)
+ if len(rows)!=1:
+ raise EquationNotSolvable
+ res.append (rows[0][-1])
+
+ return res
+
+
+def getOffsetForMovedPivot(oldPivot, newPivot, angle):
+ oldPos = Point2D(0,0).getRotated(angle, oldPivot)
+ newPos = Point2D(0,0).getRotated(angle, newPivot)
+ return oldPos - newPos
+
+def isNaN(x):
+ return (not(x<=0) and not(x>=0))
+
+def sgn (x):
+ if x<0:
+ return -1
+ elif x==0:
+ return 0
+ else:
+ return 1
+
+class MovingAverage:
+ """
+ Moving average implementation.
+ Example:
+ ma = MovingAverage(20)
+ print ma(2)
+ print ma(3)
+ print ma(10)
+ """
+ def __init__(self, points):
+ self.__points = points
+ self.__values = []
+
+ def __appendValue(self, value):
+ self.__values = (self.__values + [value])[-self.__points:]
+
+ def __getAverage(self):
+ sum = reduce(lambda a,b:a+b, self.__values)
+ return float(sum) / len(self.__values)
+
+ def __call__(self, value):
+ self.__appendValue(value)
+ return self.__getAverage()
diff --git a/src/python/mtemu.py b/src/python/mtemu.py
new file mode 100644
index 0000000..9171051
--- /dev/null
+++ b/src/python/mtemu.py
@@ -0,0 +1,154 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+# Original author of this file is Sebastian Maulbeck
+# <sm (at) archimedes-solutions (dot) de>
+
+'''
+this class provides a test to emulate one or two TOUCH/TRACK events.
+by pressing "ctrl left/right" the TOUCH events will be switched into TRACK events and the
+other way around.
+by pressing "shift left/right" a second event is created whenever the mousebutton (left)
+is clicked.
+
+Note: remove any mouse event handling from your application to avoid emulation issues
+
+For example:
+
+1) avg.MOUSE | avg.TOUCH filters can be safely reduced to avg.TOUCH
+2) the current libavg button module breaks the emulation
+3) the current libavg Grabbable class breaks the emulation, unless is created with
+source = avg.TOUCH parameter
+'''
+
+from libavg import avg, Point2D
+
+g_Player = avg.Player.get()
+
+class MTemu(object):
+
+ mouseState = 'Up'
+ cursorID = 0
+ dualTouch = False
+ secondTouch = False
+ source = avg.TOUCH
+
+ def __init__(self):
+ self.__rootNode = g_Player.getRootNode()
+ self.__rootNode.connectEventHandler(avg.CURSORUP, avg.MOUSE,
+ self, self.__onMouseUp)
+ self.__rootNode.connectEventHandler(avg.CURSORDOWN, avg.MOUSE,
+ self, self.__onMouseDown)
+ self.__rootNode.connectEventHandler(avg.CURSORMOTION, avg.MOUSE,
+ self, self.__onMouseMotion)
+ posX = self.__rootNode.size.x - 15
+ posY = self.__rootNode.size.y - 20
+
+ self.__layer = avg.WordsNode(text='Multitouch emulation active',
+ pos=(posX, posY),
+ alignment = 'right',
+ color='DDDDDD',
+ sensitive=False,
+ fontsize=18,
+ parent=self.__rootNode)
+
+ def deinit(self):
+ self.__rootNode.disconnectEventHandler(self)
+ self.__rootNode = None
+ self.__layer.unlink()
+ if self.mouseState == 'Down':
+ self.__releaseTouch(self.cursorID)
+ if self.secondTouch:
+ self.__releaseTouch(self.cursorID+1)
+
+ def toggleSource(self):
+ '''
+ Switch between avg.TOUCH and avg.TRACK - source
+ '''
+ if self.mouseState == 'Down':
+ self.__releaseTouch(self.cursorID)
+ if self.secondTouch:
+ self.__releaseTouch(self.cursorID+1)
+ self.mouseState = 'Up'
+ self.secondTouch = False
+ self.source = avg.TOUCH if self.source == avg.TRACK else avg.TRACK
+
+ def toggleDualTouch(self):
+ self.dualTouch = not(self.dualTouch)
+ if self.mouseState == 'Down':
+ if self.secondTouch:
+ self.__releaseTouch(self.cursorID+1)
+ else:
+ self.__sendFakeTouch(self.cursorID+1, Point2D(0,0),
+ avg.CURSORDOWN, mirror=True)
+ self.secondTouch = not(self.secondTouch)
+
+ def __onMouseDown(self, event):
+ self._initialPos = event.pos
+ if self.mouseState == 'Up' and event.button == 1:
+ self.__sendFakeTouch(self.cursorID, event.pos, event.type)
+ if self.dualTouch and not self.secondTouch:
+ self.__sendFakeTouch(self.cursorID+1, event.pos, event.type,
+ True)
+ self.secondTouch = True
+ self.mouseState = 'Down'
+
+ def __onMouseMotion(self, event):
+ if self.mouseState == 'Down':
+ self.__sendFakeTouch(self.cursorID, event.pos, event.type)
+ if self.dualTouch and self.secondTouch:
+ self.__sendFakeTouch(self.cursorID+1, event.pos,
+ event.type, True)
+
+ def __onMouseUp(self, event):
+ if self.mouseState == 'Down' and event.button == 1:
+ self.__sendFakeTouch(self.cursorID, event.pos, event.type)
+ if self.dualTouch and self.secondTouch:
+ self.__sendFakeTouch(self.cursorID+1, event.pos,
+ event.type, True)
+ self.secondTouch = False
+ self.mouseState = 'Up'
+ self.cursorID += 2 #Even for left uneven for right touch
+
+ def __sendFakeTouch(self, cursorID, pos, touchType, mirror=False):
+ offset = Point2D(0,0)
+ if self.dualTouch:
+ offset = Point2D(40, 0)
+ if mirror:
+ pos = 2*(self._initialPos)-pos
+ offset = -offset
+ g_Player.getTestHelper().fakeTouchEvent(cursorID,
+ touchType, self.source, self.__clampPos(pos+offset))
+
+ def __releaseTouch(self, cursorID):
+ self.__sendFakeTouch(cursorID, Point2D(0,0), avg.CURSORUP)
+
+ def __clampPos(self, pos):
+ if pos[0] < 0:
+ pos[0] = 0
+ if pos[1] < 0:
+ pos[1] = 0
+ if pos[0] >= g_Player.getRootNode().size[0]:
+ pos[0] = g_Player.getRootNode().size[0]-1
+ if pos[1] >= g_Player.getRootNode().size[1]:
+ pos[1] = g_Player.getRootNode().size[1]-1
+ return pos
+
diff --git a/src/python/parsecamargs.py b/src/python/parsecamargs.py
new file mode 100644
index 0000000..805ae14
--- /dev/null
+++ b/src/python/parsecamargs.py
@@ -0,0 +1,47 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import optparse
+
+validPixFmt = ('I8', 'I16', 'YUV411', 'YUV422', 'YUYV422', 'RGB', 'BGR', 'BAYER8')
+validDrivers = ('firewire', 'video4linux', 'directshow')
+
+def addOptions(parser):
+ parser.add_option("-t", "--driver", action="store", dest="driver",
+ choices=validDrivers,
+ help="camera drivers (one of: %s)" %', '.join(validDrivers))
+ parser.add_option("-d", "--device", action = "store", dest = "device", default = "",
+ help = "camera device identifier (may be GUID or device path)")
+ parser.add_option("-u", "--unit", action="store", dest="unit", default="-1",
+ type="int", help="unit number")
+ parser.add_option("-w", "--width", dest="width", default="640", type="int",
+ help="capture width in pixels")
+ parser.add_option("-e", "--height", dest="height", default="480", type="int",
+ help="capture height in pixels")
+ parser.add_option("-p", "--pixformat", dest="pixelFormat", default="RGB",
+ choices=validPixFmt,
+ help="camera frame pixel format (one of: %s)" %', '.join(validPixFmt))
+ parser.add_option("-f", "--framerate", dest="framerate", default="15", type="float",
+ help="capture frame rate")
+ parser.add_option("-8", "--fw800", dest="fw800", action="store_true", default=False,
+ help="set firewire bus speed to s800 (if applicable)")
diff --git a/src/python/statemachine.py b/src/python/statemachine.py
new file mode 100644
index 0000000..3bc92c1
--- /dev/null
+++ b/src/python/statemachine.py
@@ -0,0 +1,100 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import utils
+
+class State:
+ def __init__(self, transitions, enterFunc, leaveFunc):
+ self.transitions = {}
+ for destState, transfunc in transitions.items():
+ ref = utils.methodref(transfunc)
+ self.transitions[destState] = ref
+ self.enterFunc = utils.methodref(enterFunc)
+ self.leaveFunc = utils.methodref(leaveFunc)
+
+class StateMachine:
+ def __init__(self, name, startState):
+ self.__states = {}
+ self.__name = name
+ self.__curState = startState
+ self.__trace = False
+ self.__initDone = False
+
+ def addState(self, state, transitions, enterFunc=None, leaveFunc=None):
+ if self.__initDone:
+ raise RuntimeError(
+ "StateMachine: Can't add new states after calling changeState")
+ if self.__states.has_key(state):
+ raise RuntimeError("StateMachine: Duplicate state " + state + ".")
+
+ if isinstance(transitions, (list, tuple)):
+ transitions = dict.fromkeys(transitions)
+ self.__states[state] = State(transitions, enterFunc, leaveFunc)
+
+ def changeState(self, newState):
+ if not(self.__initDone):
+ self.__initDone = True
+ self.__doSanityCheck()
+
+ if self.__trace:
+ print self.__name, ":", self.__curState, "-->", newState
+
+ if not(newState in self.__states):
+ raise RuntimeError('StateMachine: Attempt to change to nonexistent state '+
+ newState+'.')
+ assert(self.__curState in self.__states)
+ state = self.__states[self.__curState]
+ if newState in state.transitions:
+ if state.leaveFunc() != None:
+ state.leaveFunc()()
+ transitionFunc = state.transitions[newState]()
+ if transitionFunc != None:
+ try:
+ transitionFunc(self.__curState, newState)
+ except TypeError:
+ transitionFunc()
+ self.__curState = newState
+ enterFunc = self.__states[self.__curState].enterFunc()
+ if enterFunc != None:
+ enterFunc()
+ else:
+ raise RuntimeError('StateMachine: State change from '+self.__curState+' to '+
+ newState+' not allowed.')
+
+ def traceChanges(self, trace):
+ self.__trace = trace
+
+ @property
+ def state(self):
+ return self.__curState
+
+ def dump(self):
+ for oldState, transitions in self.__states.iteritems():
+ print oldState, ":"
+ for newState, func in transitions.iteritems():
+ print " -->", newState, ":", func.__name__
+ print "Current state:", self.__curState
+
+ def __doSanityCheck(self):
+ for stateName, state in self.__states.iteritems():
+ for transitionName in state.transitions.iterkeys():
+ if not(self.__states.has_key(transitionName)):
+ raise RuntimeError("StateMachine: transition " + stateName + " -> " +
+ transitionName + " has an unknown destination state.")
diff --git a/src/python/textarea.py b/src/python/textarea.py
new file mode 100644
index 0000000..4ff1a8b
--- /dev/null
+++ b/src/python/textarea.py
@@ -0,0 +1,643 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this module is Marco Fagiolini <mfx at archi-me-des dot de>
+#
+
+"""
+Single/Multi-Line editable text field widget for libavg
+
+textarea module provides two classes:
+
+1. TextArea
+ This is the implementation of the widget. Every instantiated TextArea
+ represents an editable text field, which can be set up with several styles
+ and behaviors.
+
+2. FocusContext
+ This helps to easily route the events that comes from keyboards to an
+ appropriate TextArea instance, cycling focuses and dispatching events on
+ the selected field.
+
+"""
+
+g_Player = None
+g_FocusContext = None
+g_LastKeyEvent = None
+g_activityCallback = None
+g_LastKeyRepeated = 0
+g_RepeatDelay = 0.2
+g_CharDelay = 0.1
+
+KEYCODE_TAB = 9
+KEYCODE_LINEFEED = 13
+KEYCODE_SHTAB = 25
+KEYCODE_FORMFEED = 12
+KEYCODE_CRS_UP = 63232
+KEYCODE_CRS_DOWN = 63233
+KEYCODE_CRS_LEFT = 63234
+KEYCODE_CRS_RIGHT = 63235
+KEYCODES_BACKSPACE = (8,127)
+KEYCODES_DEL = 63272
+
+CURSOR_PADDING_PCT = 15
+CURSOR_WIDTH_PCT = 4
+CURSOR_SPACING_PCT = 4
+CURSOR_FLASHING_DELAY = 600
+CURSOR_FLASH_AFTER_INACTIVITY = 200
+
+DEFAULT_BLUR_OPACITY = 0.3
+
+import time
+
+from libavg import avg
+from avg import Point2D
+
+
+class FocusContext:
+ """
+ This class helps to group TextArea elements
+
+ TextArea elements that belong to the same FocusContext cycle focus among
+ themselves. There can be several FocusContextes but only one active at once
+ ( using the global function setActiveFocusContext() )
+ """
+ def __init__(self):
+ self.__elements = []
+ self.__isActive = False
+
+ def isActive(self):
+ """
+ Test if this FocusContext is currently active
+ """
+ return self.__isActive
+
+ def register(self, taElement):
+ """
+ Register a floating textarea on this FocusContext
+
+ @param taElement: a TextArea instance
+ """
+ self.__elements.append(taElement)
+
+ def getFocused(self):
+ """
+ Query the TextArea element that currently has focus
+
+ @return: TextArea instance or None
+ """
+ for ob in self.__elements:
+ if ob.hasFocus():
+ return ob
+ return None
+
+ def keyCharPressed(self, kchar):
+ """
+ Inject an utf-8 encoded characted into the flow
+
+ Shift a character (Unicode keycode) into the active (w/focus) TextArea
+ @type kchar: string
+ @param kchar: a single character (if more than one, the following are ignored)
+ """
+ uch = unicode(kchar, 'utf-8')
+ self.keyUCodePressed(ord(uch[0]))
+
+ def keyUCodePressed(self, keycode):
+ """
+ Inject an Unicode code point into the flow
+
+ Shift a character (Unicode keycode) into the active (w/focus) TextArea
+ @type keycode: int
+ @param keycode: unicode code point of the character
+ """
+ # TAB key cycles focus through textareas
+ if keycode == KEYCODE_TAB:
+ self.cycleFocus()
+ return
+ # Shift-TAB key cycles focus through textareas backwards
+ if keycode == KEYCODE_SHTAB:
+ self.cycleFocus(True)
+ return
+
+ for ob in self.__elements:
+ if ob.hasFocus():
+ ob.onKeyDown(keycode)
+
+ def backspace(self):
+ """
+ Emulate a backspace character keypress
+ """
+ self.keyUCodePressed(KEYCODES_BACKSPACE[0])
+
+ def delete(self):
+ """
+ Emulate a delete character keypress
+ """
+ self.keyUCodePressed(KEYCODE_DEL)
+
+ def clear(self):
+ """
+ Clear the active textarea, emulating the press of FF character
+ """
+ self.keyUCodePressed(KEYCODE_FORMFEED)
+
+ def resetFocuses(self):
+ """
+ Blur every TextArea registered within this FocusContext
+ """
+ for ob in self.__elements:
+ ob.clearFocus()
+
+ def cycleFocus(self, backwards=False):
+ """
+ Force a focus cycle among instantiated textareas
+
+ TAB/Sh-TAB keypress is what is translated in a focus cycle.
+ @param backwards: as default, the method cycles following the order
+ that has been followed during the registration of TextArea
+ instances. Setting this to True, the order is inverted.
+ """
+
+ els = []
+ els.extend(self.__elements)
+
+ if len(els) == 0:
+ return
+
+ if backwards:
+ els.reverse()
+
+ elected = 0
+ for ob in els:
+ if not ob.hasFocus():
+ elected = elected + 1
+ else:
+ break
+
+ # elects the first if no ta are in focus or if the
+ # last one has it
+ if elected in (len(els), len(els)-1):
+ elected = 0
+ else:
+ elected = elected + 1
+
+ for ob in els:
+ ob.setFocus(False)
+
+ els[elected].setFocus(True)
+
+ def getRegistered(self):
+ """
+ Returns a list of TextArea currently registered within this FocusContext
+ @return: a list of registered TextArea instances
+ """
+ return self.__elements
+
+ def _switchActive(self, active):
+ if active:
+ self.resetFocuses()
+ self.cycleFocus()
+ else:
+ self.resetFocuses()
+
+ self.__isActive = active
+
+
+class TextArea:
+ """
+ TextArea class is a libavg widget to create editable text fields
+
+ TextArea is an extended <words> node that reacts to user input (mouse/touch for
+ focus, keyboard for text input). Can be set as a single line or span to multiple
+ lines.
+ It sits in a given container matching its dimensions, therefore the appropriate
+ way to create it, is to set a <div> node with defined width/height attributes.
+ """
+ def __init__(self, parent, focusContext=None, disableMouseFocus=False, id=''):
+ """
+ @param parent: a div node with defined dimensions
+ @param focusContext: FocusContext object which directs focus for TextArea elements
+ @param disableMouseFocus: boolean, prevents that mouse can set focus for
+ this instance
+ @param id: optional handle to identify the object when dealing with events. ID
+ uniqueness is not guaranteed
+ """
+ global g_Player
+ g_Player = avg.Player.get()
+ self.__parent = parent
+ self.__focusContext = focusContext
+ self.__blurOpacity = DEFAULT_BLUR_OPACITY
+ self.__border = 0
+ self.__id = id
+ self.__data = []
+ self.__cursorPosition = 0
+
+ textNode = g_Player.createNode("words", {'rawtextmode':True})
+
+ if not disableMouseFocus:
+ parent.setEventHandler(avg.CURSORUP, avg.MOUSE, self.__onClick)
+ parent.setEventHandler(avg.CURSORUP, avg.TOUCH, self.__onClick)
+
+ parent.appendChild(textNode)
+
+ cursorContainer = g_Player.createNode('div', {})
+ cursorNode = g_Player.createNode('line', {'color': '000000'})
+ parent.appendChild(cursorContainer)
+ cursorContainer.appendChild(cursorNode)
+ self.__flashingCursor = False
+
+ self.__cursorContainer = cursorContainer
+ self.__cursorNode = cursorNode
+ self.__textNode = textNode
+ self.__charSize = -1
+ self.setStyle()
+
+ if focusContext is not None:
+ focusContext.register(self)
+ self.setFocus(False)
+ else:
+ self.setFocus(True)
+
+ g_Player.setInterval(CURSOR_FLASHING_DELAY, self.__tickFlashCursor)
+
+ self.__lastActivity = 0
+
+ def getID(self):
+ """
+ Returns the ID of the textarea (set on the constructor).
+ """
+ return self.__id
+
+ def clearText(self):
+ """
+ Clears the text
+ """
+ self.setText(u'')
+
+ def setText(self, uString):
+ """
+ Set the text on the TextArea
+
+ @param uString: an unicode string (or an utf-8 encoded string)
+ """
+ if not isinstance(uString, unicode):
+ uString = unicode(uString, 'utf-8')
+
+ self.__data = []
+ for c in uString:
+ self.__data.append(c)
+
+ self.__cursorPosition = len(self.__data)
+ self.__update()
+
+ def getText(self):
+ """
+ Get the text stored and displayed on the TextArea
+ """
+ return self.__getUnicodeFromData()
+
+ def setStyle(self, font='Arial', fontsize=12, alignment='left', variant='Regular',
+ color='000000', multiline=True, cursorWidth=None, border=0,
+ blurOpacity=DEFAULT_BLUR_OPACITY, flashingCursor=False,
+ cursorColor='000000', lineSpacing=0, letterSpacing=0):
+ """
+ Set TextArea's graphical appearance
+ @param font: font face
+ @param fontsize: font size in pixels
+ @param alignment: one among 'left', 'right', 'center'
+ @param variant: font variant (eg: 'bold')
+ @param color: RGB hex for text color
+ @param multiline: boolean, whether TextArea has to wrap (undefinitely)
+ or stop at full width
+ @param cursorWidth: int, width of the cursor in pixels
+ @param border: amount of offsetting pixels that words node will have from image
+ extents
+ @param blurOpacity: opacity that textarea gets when goes to blur state
+ @param flashingCursor: whether the cursor should flash or not
+ @param cursorColor: RGB hex for cursor color
+ @param lineSpacing: linespacing property of words node
+ @param letterSpacing: letterspacing property of words node
+ """
+ self.__textNode.font = font
+ self.__textNode.fontsize = int(fontsize)
+ self.__textNode.alignment = alignment
+ self.__textNode.color = color
+ self.__textNode.variant = variant
+ self.__textNode.linespacing = lineSpacing
+ self.__textNode.letterspacing = letterSpacing
+ self.__isMultiline = multiline
+ self.__border = border
+ self.__maxLength = -1
+ self.__blurOpacity = blurOpacity
+
+ if multiline:
+ self.__textNode.width = int(self.__parent.width) - self.__border * 2
+ self.__textNode.wrapmode = 'wordchar'
+ else:
+ self.__textNode.width = 0
+
+ self.__textNode.x = self.__border
+ self.__textNode.y = self.__border
+
+ self.__cursorNode.color = cursorColor
+ if cursorWidth is not None:
+ self.__cursorNode.strokewidth = cursorWidth
+ else:
+ w = float(fontsize) * CURSOR_WIDTH_PCT / 100.0
+ if w < 1:
+ w = 1
+ self.__cursorNode.strokewidth = w
+ x = self.__cursorNode.strokewidth / 2.0
+ self.__cursorNode.pos1 = Point2D(x, self.__cursorNode.pos1.y)
+ self.__cursorNode.pos2 = Point2D(x, self.__cursorNode.pos2.y)
+
+ self.__flashingCursor = flashingCursor
+ if not flashingCursor:
+ self.__cursorContainer.opacity = 1
+
+ self.__updateCursor()
+
+
+ def setMaxLength(self, maxlen):
+ """
+ Set character limit of the input
+
+ @param maxlen: max number of character allowed
+ """
+ self.__maxLength = maxlen
+
+ def clearFocus(self):
+ """
+ Compact form to blur the TextArea
+ """
+ self.__parent.opacity = self.__blurOpacity
+ self.__hasFocus = False
+
+ def setFocus(self, hasFocus):
+ """
+ Force the focus (or blur) of this TextArea
+
+ @param hasFocus: boolean
+ """
+ if self.__focusContext is not None:
+ self.__focusContext.resetFocuses()
+
+ if hasFocus:
+ self.__parent.opacity = 1
+ self.__cursorContainer.opacity = 1
+ else:
+ self.clearFocus()
+ self.__cursorContainer.opacity = 0
+
+ self.__hasFocus = hasFocus
+
+ def hasFocus(self):
+ """
+ Query the focus status for this TextArea
+ """
+ return self.__hasFocus
+
+ def showCursor(self, show):
+ if show:
+ avg.fadeIn(self.__cursorNode, 200)
+ else:
+ avg.fadeOut(self.__cursorNode, 200)
+
+ def onKeyDown(self, keycode):
+ """
+ Inject a keycode into TextArea flow
+
+ Used mainly by FocusContext. It can be used directly, but the best option
+ is always to use a FocusContext helper, which exposes convenience method for
+ injection.
+ @param keycode: characted to insert
+ @type keycode: int (SDL reference)
+ """
+ # Ensure that the cursor is shown
+ if self.__flashingCursor:
+ self.__cursorContainer.opacity = 1
+
+ if keycode in KEYCODES_BACKSPACE:
+ self.__removeChar(left=True)
+ self.__updateLastActivity()
+ self.__updateCursor()
+ elif keycode == KEYCODES_DEL:
+ self.__removeChar(left=False)
+ self.__updateLastActivity()
+ self.__updateCursor()
+ # NP/FF clears text
+ elif keycode == KEYCODE_FORMFEED:
+ self.clearText()
+ elif keycode in (KEYCODE_CRS_UP, KEYCODE_CRS_DOWN, KEYCODE_CRS_LEFT, KEYCODE_CRS_RIGHT):
+ if keycode == KEYCODE_CRS_LEFT and self.__cursorPosition > 0:
+ self.__cursorPosition -= 1
+ self.__update()
+ elif keycode == KEYCODE_CRS_RIGHT and self.__cursorPosition < len(self.__data):
+ self.__cursorPosition += 1
+ self.__update()
+ elif keycode == KEYCODE_CRS_UP and self.__cursorPosition != 0:
+ self.__cursorPosition = 0
+ self.__update()
+ elif keycode == KEYCODE_CRS_DOWN and self.__cursorPosition != len(self.__data):
+ self.__cursorPosition = len(self.__data)
+ self.__update()
+ # add linefeed only on multiline textareas
+ elif keycode == KEYCODE_LINEFEED and self.__isMultiline:
+ self.__appendUChar('\n')
+ # avoid shift-tab, return, zero, delete
+ elif keycode not in (KEYCODE_LINEFEED, 0, 25, 63272):
+ self.__appendKeycode(keycode)
+ self.__updateLastActivity()
+ self.__updateCursor()
+
+ def __onClick(self, e):
+ if self.__focusContext is not None:
+ if self.__focusContext.isActive():
+ self.setFocus(True)
+ else:
+ self.setFocus(True)
+
+ def __getUnicodeFromData(self):
+ return u''.join(self.__data)
+
+ def __appendKeycode(self, keycode):
+ self.__appendUChar(unichr(keycode))
+
+ def __appendUChar(self, uchar):
+ # if maximum number of char is specified, honour the limit
+ if self.__maxLength > -1 and len(self.__data) > self.__maxLength:
+ return
+
+ # Boundary control
+ if len(self.__data) > 0:
+ maxCharDim = self.__textNode.fontsize
+ lastCharPos = self.__textNode.getGlyphPos(len(self.__data) - 1)
+ if (not self.__isMultiline and
+ lastCharPos[0] + maxCharDim * 1.5 > self.__parent.width - self.__border * 2):
+ return
+
+ if (self.__isMultiline and
+ lastCharPos[1] + maxCharDim * 2 > self.__parent.height - self.__border * 2):
+ if (lastCharPos[0] + maxCharDim * 1.5 > self.__parent.width - self.__border * 2):
+ return
+ if (ord(uchar) == 10 and
+ lastCharPos[1] + maxCharDim * 2 > self.__parent.height - self.__border * 2):
+ return
+
+ self.__data.insert(self.__cursorPosition, uchar)
+ self.__cursorPosition += 1
+ self.__update()
+
+ def __removeChar(self, left=True):
+ if left and self.__cursorPosition > 0:
+ self.__cursorPosition -= 1
+ del self.__data[self.__cursorPosition]
+ self.__update()
+ elif not left and self.__cursorPosition < len(self.__data):
+ del self.__data[self.__cursorPosition]
+ self.__update()
+
+ def __update(self):
+ self.__textNode.text = self.__getUnicodeFromData()
+ self.__updateCursor()
+
+ def __updateCursor(self):
+ if self.__cursorPosition == 0:
+ lastCharPos = (0,0)
+ lastCharExtents = (0,0)
+ else:
+ lastCharPos = self.__textNode.getGlyphPos(self.__cursorPosition - 1)
+ lastCharExtents = self.__textNode.getGlyphSize(self.__cursorPosition - 1)
+
+ if self.__data[self.__cursorPosition - 1] == '\n':
+ lastCharPos = (0, lastCharPos[1] + lastCharExtents[1])
+ lastCharExtents = (0, lastCharExtents[1])
+
+ xPos = self.__cursorNode.pos2.x
+ if lastCharExtents[1] > 0:
+ self.__cursorNode.pos2 = Point2D(xPos, lastCharExtents[1] * (1 - CURSOR_PADDING_PCT/100.0))
+ else:
+ self.__cursorNode.pos2 = Point2D(xPos, self.__textNode.fontsize)
+
+ self.__cursorContainer.x = lastCharPos[0] + lastCharExtents[0] + self.__border
+ self.__cursorContainer.y = (lastCharPos[1] +
+ self.__cursorNode.pos2.y * CURSOR_PADDING_PCT/200.0 + self.__border)
+
+ def __updateLastActivity(self):
+ self.__lastActivity = time.time()
+
+ def __tickFlashCursor(self):
+ if (self.__flashingCursor and
+ self.__hasFocus and
+ time.time() - self.__lastActivity > CURSOR_FLASH_AFTER_INACTIVITY/1000.0):
+ if self.__cursorContainer.opacity == 0:
+ self.__cursorContainer.opacity = 1
+ else:
+ self.__cursorContainer.opacity = 0
+ elif self.__hasFocus:
+ self.__cursorContainer.opacity = 1
+
+
+##################################
+# MODULE FUNCTIONS
+
+def init(g_avg, catchKeyboard=True, repeatDelay=0.2, charDelay=0.1):
+ """
+ Initialization routine for the module
+
+ This method should be called immediately after avg file
+ load (Player.loadFile())
+ @param g_avg: avg package
+ @param catchKeyboard: boolean, if true events from keyboard are catched
+ @param repeatDelay: wait time (seconds) before starting to repeat a key which
+ is held down
+ @param charDelay: delay among character repetition (of an steadily pressed key)
+ """
+ global avg, g_RepeatDelay, g_CharDelay
+ avg = g_avg
+ g_RepeatDelay = repeatDelay
+ g_CharDelay = charDelay
+
+ avg.Player.get().setOnFrameHandler(_onFrame)
+
+ if catchKeyboard:
+ avg.Player.get().getRootNode().setEventHandler(avg.KEYDOWN, avg.NONE, _onKeyDown)
+ avg.Player.get().getRootNode().setEventHandler(avg.KEYUP, avg.NONE, _onKeyUp)
+
+def setActiveFocusContext(focusContext):
+ """
+ Tell the module what FocusContext is presently active
+
+ Only one FocusContext at once can be set 'active' and therefore
+ prepared to receive the flow of user events from keyboard.
+ @param focusContext: set the active focusContext. If initialization has been
+ made with 'catchKeyboard' == True, the new active focusContext will receive
+ the flow of events from keyboard.
+ """
+ global g_FocusContext
+
+ if g_FocusContext is not None:
+ g_FocusContext._switchActive(False)
+
+ g_FocusContext = focusContext
+ g_FocusContext._switchActive(True)
+
+def setActivityCallback(pyfunc):
+ """
+ Set a callback that is called at every keyboard's keypress
+
+ If a callback of user interaction is needed (eg: resetting idle timeout)
+ just pass a function to this method, which is going to be called at each
+ user intervention (keydown, keyup).
+ Active focusContext will be passed as argument
+ """
+ global g_activityCallback
+ g_activityCallback = pyfunc
+
+
+def _onFrame():
+ global g_LastKeyEvent, g_LastKeyRepeated, g_CharDelay
+ if (g_LastKeyEvent is not None and
+ time.time() - g_LastKeyRepeated > g_CharDelay and
+ g_FocusContext is not None):
+ g_FocusContext.keyUCodePressed(g_LastKeyEvent.unicode)
+ g_LastKeyRepeated = time.time()
+
+def _onKeyDown(e):
+ global g_LastKeyEvent, g_LastKeyRepeated, g_RepeatDelay, g_activityCallback
+
+ if e.unicode == 0:
+ return
+
+ g_LastKeyEvent = e
+ g_LastKeyRepeated = time.time() + g_RepeatDelay
+
+ if g_FocusContext is not None:
+ g_FocusContext.keyUCodePressed(e.unicode)
+
+ if g_activityCallback is not None:
+ g_activityCallback(g_FocusContext)
+
+def _onKeyUp(e):
+ global g_LastKeyEvent
+
+ g_LastKeyEvent = None
diff --git a/src/python/trackerhelper.py b/src/python/trackerhelper.py
new file mode 100644
index 0000000..93e0bf3
--- /dev/null
+++ b/src/python/trackerhelper.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import math
+from libavg import avg, Point2D, RasterNode
+
+g_Player = avg.Player.get()
+
+class TrackerImageFlipper:
+ def __init__(self):
+ self.readConfig()
+
+ def readConfig(self):
+ global g_tracker
+ print "reading tracker config"
+ g_tracker = g_Player.getTracker()
+ trackerAngle = float(g_tracker.getParam('/transform/angle/@value'))
+ self.angle = round(trackerAngle/math.pi) * math.pi
+ self.flipX = 0 > float(g_tracker.getParam('/transform/displayscale/@x'))
+ self.flipY = 0 > float(g_tracker.getParam('/transform/displayscale/@y'))
+
+ def transformPos(self, (x, y)):
+ if self.flipX:
+ x = 1 - x
+ if self.flipY:
+ y = 1 - y
+ return (x, y)
+
+ def flipNode(self, node):
+ node.angle = self.angle
+ grid = node.getOrigVertexCoords()
+ grid = [ [ self.transformPos(pos) for pos in line ] for line in grid]
+ node.setWarpedVertexCoords(grid)
+
+ def loadTrackerImage(self, node, imageID):
+ fingerBitmap = g_tracker.getImage(imageID)
+ node.setBitmap(fingerBitmap)
+ self.flipNode(node)
+
diff --git a/src/python/ui/Makefile.am b/src/python/ui/Makefile.am
new file mode 100644
index 0000000..e4fddd6
--- /dev/null
+++ b/src/python/ui/Makefile.am
@@ -0,0 +1,2 @@
+pkguidir = $(pkgpyexecdir)/ui
+pkgui_PYTHON = __init__.py button.py keyboard.py gesture.py helper.py
diff --git a/src/python/ui/Makefile.in b/src/python/ui/Makefile.in
new file mode 100644
index 0000000..fbb00e5
--- /dev/null
+++ b/src/python/ui/Makefile.in
@@ -0,0 +1,496 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/python/ui
+DIST_COMMON = $(pkgui_PYTHON) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkguidir)"
+py_compile = $(top_srcdir)/py-compile
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+pkguidir = $(pkgpyexecdir)/ui
+pkgui_PYTHON = __init__.py button.py keyboard.py gesture.py helper.py
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/python/ui/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/python/ui/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-pkguiPYTHON: $(pkgui_PYTHON)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkguidir)" || $(MKDIR_P) "$(DESTDIR)$(pkguidir)"
+ @list='$(pkgui_PYTHON)'; dlist=; list2=; test -n "$(pkguidir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
+ if test -f $$b$$p; then \
+ $(am__strip_dir) \
+ dlist="$$dlist $$f"; \
+ list2="$$list2 $$b$$p"; \
+ else :; fi; \
+ done; \
+ for file in $$list2; do echo $$file; done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkguidir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkguidir)" || exit $$?; \
+ done || exit $$?; \
+ if test -n "$$dlist"; then \
+ if test -z "$(DESTDIR)"; then \
+ PYTHON=$(PYTHON) $(py_compile) --basedir "$(pkguidir)" $$dlist; \
+ else \
+ PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(pkguidir)" $$dlist; \
+ fi; \
+ else :; fi
+
+uninstall-pkguiPYTHON:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgui_PYTHON)'; test -n "$(pkguidir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ filesc=`echo "$$files" | sed 's|$$|c|'`; \
+ fileso=`echo "$$files" | sed 's|$$|o|'`; \
+ echo " ( cd '$(DESTDIR)$(pkguidir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(pkguidir)" && rm -f $$files || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkguidir)' && rm -f" $$filesc ")"; \
+ cd "$(DESTDIR)$(pkguidir)" && rm -f $$filesc || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkguidir)' && rm -f" $$fileso ")"; \
+ cd "$(DESTDIR)$(pkguidir)" && rm -f $$fileso
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile
+installdirs:
+ for dir in "$(DESTDIR)$(pkguidir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pkguiPYTHON
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkguiPYTHON
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-pkguiPYTHON install-ps install-ps-am \
+ install-strip installcheck installcheck-am installdirs \
+ maintainer-clean maintainer-clean-generic mostlyclean \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ uninstall uninstall-am uninstall-pkguiPYTHON
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/python/ui/__init__.py b/src/python/ui/__init__.py
new file mode 100755
index 0000000..211e035
--- /dev/null
+++ b/src/python/ui/__init__.py
@@ -0,0 +1,4 @@
+from button import Button, TouchButton
+from keyboard import Keyboard
+from gesture import Recognizer, TapRecognizer, DragRecognizer, DoubletapRecognizer, TransformRecognizer, calcKMeans, Mat3x3, Transform, HoldRecognizer
+from helper import ScrollPane
diff --git a/src/python/ui/button.py b/src/python/ui/button.py
new file mode 100644
index 0000000..43b902d
--- /dev/null
+++ b/src/python/ui/button.py
@@ -0,0 +1,364 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Henrik Thoms
+
+from libavg import avg, statemachine, utils
+import gesture
+from helper import *
+
+g_Player = avg.Player.get()
+
+class Button(avg.DivNode):
+ STATE_DISABLED = 1
+ STATE_UP = 2
+ STATE_DOWN = 3
+
+ def __init__(self, upNode = None, downNode = None, disabledNode = None,
+ activeAreaNode = None, pressHandler = None, clickHandler = None,
+ stateChangeHandler = None, **kwargs):
+ avg.DivNode.__init__(self, **kwargs)
+
+ self.__upNode = upNode
+ self.__downNode = downNode
+ self.__disabledNode = disabledNode
+ self.__activeAreaNode = activeAreaNode
+
+ self.__pressCallback = utils.methodref(pressHandler)
+ self.__clickCallback = utils.methodref(clickHandler)
+ self.__stateChangeCallback = utils.methodref(stateChangeHandler)
+
+ self.__capturedCursorIds = set()
+ self.__overCursorIds = set()
+
+ self.__isCheckable = False
+ self.__isToggled = False
+
+ self.__isOver = False
+ self.__state = Button.STATE_UP
+
+ if self.__upNode and self.__downNode:
+ self.__setupNodes()
+
+ def delete(self):
+ self.__pressCallback = None
+ self.__clickCallback = None
+ self.__stateChangeCallback = None
+ self.__deactivateEventHandlers()
+
+ def setEventHandler(self, type, source, func):
+ raise RuntimeError("Setting event handlers for buttons is not supported")
+
+ def getUpNode(self):
+ return self.__upNode
+
+ def getDownNode(self):
+ return self.__downNode
+
+ def getDisabledNode(self):
+ return self.__disabledNode
+
+ def setNodes(self, upNode, downNode, disabledNode = None, activeAreaNode = None):
+ if self.__activeAreaNode and self.isEnabled():
+ self.__deactivateEventHandlers()
+ self.__upNode = upNode
+ self.__downNode = downNode
+ self.__disabledNode = disabledNode
+ self.__activeAreaNode = activeAreaNode
+ self.__setupNodes()
+
+ def setPressHandler(self, handler):
+ self.__pressCallback = utils.methodref(handler)
+
+ def setClickHandler(self, handler):
+ self.__clickCallback = utils.methodref(handler)
+
+ def setCheckable(self, val):
+ self.__isCheckable = val
+
+ def isCheckable(self):
+ return self.__isCheckable
+
+ def setChecked(self, val):
+ assert(self.__isCheckable)
+ assert(self.isEnabled())
+ self.__isToggled = val
+ state = Button.STATE_DOWN if self.__isToggled else Button.STATE_UP
+ self.__changeState(state)
+
+ def isChecked(self):
+ assert(self.__isCheckable)
+ # XXX: Shouldn't this check self.__isToggled?
+ return self.__state == Button.STATE_DOWN
+
+ def setEnabled(self, isEnabled):
+ if (isEnabled == self.isEnabled()):
+ # No state change
+ return
+
+ state = Button.STATE_DISABLED if not(isEnabled) else Button.STATE_UP
+ self.__changeState(state)
+
+ if self.__state == Button.STATE_DISABLED:
+ self.__deactivateEventHandlers()
+ self.__overCursorIds = set()
+ else:
+ self.__activateEventHandlers()
+
+ def isEnabled(self):
+ return self.__state != Button.STATE_DISABLED
+
+ def __setupNodes(self):
+ while self.getNumChildren() > 0:
+ self.removeChild(self.getChild(0))
+
+ self.appendChild(self.__upNode)
+ self.appendChild(self.__downNode)
+
+ if self.__disabledNode:
+ self.appendChild(self.__disabledNode)
+
+ if self.__activeAreaNode == None:
+ self.__activeAreaNode = avg.RectNode(opacity=0, size=self.__upNode.size)
+ self.appendChild(self.__activeAreaNode)
+
+ self.size = self.__activeAreaNode.size
+ self.__updateNodesVisibility()
+ if self.isEnabled():
+ self.__activateEventHandlers()
+
+ def __updateNodesVisibility(self):
+ for element in (self.__upNode, self.__downNode, self.__disabledNode):
+ if element:
+ element.active = False
+
+ if self.__state == Button.STATE_UP:
+ activeNode = self.__upNode
+ elif self.__state == Button.STATE_DOWN:
+ activeNode = self.__downNode
+ elif self.__state == Button.STATE_DISABLED:
+ activeNode = self.__disabledNode
+ else:
+ # This state doesn't exist.
+ assert(False)
+
+ activeNode.active = True
+
+ def __changeState(self, state):
+ self.__state = state
+ self.__updateNodesVisibility()
+ utils.callWeakRef(self.__stateChangeCallback, state)
+
+ def __captureCursor(self, id):
+ self.__capturedCursorIds.add(id)
+ self.__activeAreaNode.setEventCapture(id)
+
+ def __releaseCapturedCursor(self, id):
+ self.__capturedCursorIds.remove(id)
+ self.releaseEventCapture(id)
+
+ def __isCursorCaptured(self, id):
+ return id in self.__capturedCursorIds
+
+ def __getNumberOfCapturedCursors(self):
+ return len(self.__capturedCursorIds)
+
+ def __hasCapturedCursor(self):
+ return len(self.__capturedCursorIds) != 0
+
+ def __pressHandler(self, event):
+ if not self.__isCursorCaptured(event.cursorid):
+ self.__captureCursor(event.cursorid)
+
+ if event.cursorid not in self.__overCursorIds:
+ self.__overCursorIds.add(event.cursorid)
+
+ if self.__getNumberOfCapturedCursors() <= 1:
+ self.__changeState(Button.STATE_DOWN)
+ utils.callWeakRef(self.__pressCallback, event)
+
+ def __releaseHandler(self, event):
+ numberOfCapturedCursors = self.__getNumberOfCapturedCursors()
+ numberOfOverCursors = len(self.__overCursorIds)
+
+ if self.__isCursorCaptured(event.cursorid):
+ self.__releaseCapturedCursor(event.cursorid)
+
+ if event.cursorid in self.__overCursorIds:
+ self.__overCursorIds.remove(event.cursorid)
+
+ if numberOfCapturedCursors == 1 and numberOfOverCursors == 1:
+ newState = Button.STATE_UP
+ if self.isCheckable():
+ self.__isToggled = not self.__isToggled
+ if self.__isToggled:
+ newState = Button.STATE_DOWN
+
+ self.__changeState(newState)
+
+ utils.callWeakRef(self.__clickCallback, event)
+
+ def __overHandler(self, event):
+ if event.cursorid not in self.__overCursorIds:
+ self.__overCursorIds.add(event.cursorid)
+
+ if self.__hasCapturedCursor() and len(self.__overCursorIds):
+ self.__changeState(Button.STATE_DOWN)
+
+ self.__isOver = not(self.__isOver)
+ return True
+
+ def __outHandler(self, event):
+ if event.cursorid in self.__overCursorIds:
+ self.__overCursorIds.remove(event.cursorid)
+
+ if self.__hasCapturedCursor() and not len(self.__overCursorIds):
+ newState = Button.STATE_UP
+ if self.isCheckable():
+ if self.__isToggled:
+ newState = Button.STATE_DOWN
+ self.__changeState(newState)
+
+ self.__isOver = not(self.__isOver)
+ return True
+
+ def __activateEventHandlers(self):
+ def setOneHandler(type, handler):
+ self.__activeAreaNode.connectEventHandler(type, avg.MOUSE | avg.TOUCH,
+ self, handler)
+
+ setOneHandler(avg.CURSORDOWN, self.__pressHandler)
+ setOneHandler(avg.CURSORUP, self.__releaseHandler)
+ setOneHandler(avg.CURSOROVER, self.__overHandler)
+ setOneHandler(avg.CURSOROUT, self.__outHandler)
+
+ def __deactivateEventHandlers(self):
+ for id in self.__capturedCursorIds:
+ self.releaseEventCapture(id)
+ self.__capturedCursorIds = set()
+ self.__activeAreaNode.disconnectEventHandler(self)
+
+
+class TouchButton(avg.DivNode):
+
+ def __init__(self, upNode, downNode, disabledNode = None, activeAreaNode = None,
+ fatFingerEnlarge=False, clickHandler = None, **kwargs):
+ avg.DivNode.__init__(self, **kwargs)
+
+ self.__upNode = upNode
+ self.__downNode = downNode
+ self.__disabledNode = disabledNode
+ self.__activeAreaNode = activeAreaNode
+
+ self.__clickHandler = utils.methodref(clickHandler)
+
+ self.__isOver = False
+ self.__stateMachine = statemachine.StateMachine("TouchButton", "UP")
+ self.__stateMachine.addState("UP", ("DOWN", "DISABLED"),
+ enterFunc=self.enterUp, leaveFunc=self.leaveUp)
+ self.__stateMachine.addState("DOWN", ("UP", "DISABLED"),
+ enterFunc=self.enterDown, leaveFunc=self.leaveDown)
+ self.__stateMachine.addState("DISABLED", ("UP", "DOWN"),
+ enterFunc=self.enterDisabled, leaveFunc=self.leaveDisabled)
+
+ self.appendChild(self.__upNode)
+ self.__upNode.active = True
+ self.appendChild(self.__downNode)
+ self.__downNode.active = False
+
+ if self.__disabledNode:
+ self.appendChild(self.__disabledNode)
+ self.__disabledNode.active = False
+
+ if fatFingerEnlarge:
+ if self.__activeAreaNode != None:
+ raise(RuntimeError(
+ "TouchButton: Can't specify both fatFingerEnlarge and activeAreaNode"))
+ size = upNode.size
+ minSize = 20*g_Player.getPixelsPerMM()
+ size = avg.Point2D(max(minSize, size.x), max(minSize, size.y))
+ self.__activeAreaNode = avg.RectNode(size=size, opacity=0, parent=self)
+ else:
+ if self.__activeAreaNode == None:
+ self.__activeAreaNode = self.__upNode
+ else:
+ self.appendChild(self.__activeAreaNode)
+
+ self.__tapRecognizer = gesture.TapRecognizer(self.__activeAreaNode,
+ possibleHandler=self.__onDown,
+ detectedHandler=self.__onTap,
+ failHandler=self.__onTapFail)
+
+ @classmethod
+ def fromSrc(cls, upSrc, downSrc, disabledSrc=None, **kwargs):
+ upNode = avg.ImageNode(href=upSrc)
+ downNode = avg.ImageNode(href=downSrc)
+ if disabledSrc != None:
+ disabledNode = avg.ImageNode(href=disabledSrc)
+ else:
+ disabledNode = None
+ return TouchButton(upNode=upNode, downNode=downNode, disabledNode=disabledNode,
+ **kwargs)
+
+ def getEnabled(self):
+ return self.__stateMachine.state != "DISABLED"
+
+ def setEnabled(self, enabled):
+ if enabled:
+ if self.__stateMachine.state == "DISABLED":
+ self.__stateMachine.changeState("UP")
+ else:
+ if self.__stateMachine.state != "DISABLED":
+ self.__stateMachine.changeState("DISABLED")
+
+ enabled = property(getEnabled, setEnabled)
+
+ def __onDown(self, event):
+ self.__stateMachine.changeState("DOWN")
+
+ def __onTap(self, event):
+ self.__stateMachine.changeState("UP")
+ utils.callWeakRef(self.__clickHandler)
+
+ def __onTapFail(self, event):
+ self.__stateMachine.changeState("UP")
+
+ def enterUp(self):
+ self.__upNode.active = True
+
+ def leaveUp(self):
+ self.__upNode.active = False
+
+ def enterDown(self):
+ self.__downNode.active = True
+
+ def leaveDown(self):
+ self.__downNode.active = False
+
+ def enterDisabled(self):
+ if self.__disabledNode:
+ self.__disabledNode.active = True
+ self.__tapRecognizer.enable(False)
+
+ def leaveDisabled(self):
+ if self.__disabledNode:
+ self.__disabledNode.active = False
+ self.__tapRecognizer.enable(True)
+
diff --git a/src/python/ui/gesture.py b/src/python/ui/gesture.py
new file mode 100644
index 0000000..1c0782d
--- /dev/null
+++ b/src/python/ui/gesture.py
@@ -0,0 +1,746 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg, statemachine, utils
+
+from helper import *
+
+from math import *
+
+g_Player = avg.Player.get()
+
+MAX_TAP_DIST = 15
+MAX_TAP_TIME = 500
+MAX_DOUBLETAP_TIME = 300
+MIN_DRAG_DIST = 5
+HOLD_DELAY = 500
+
+class ContactData:
+
+ def __init__(self, listenerid):
+ self.listenerid = listenerid
+
+
+class Recognizer(object):
+
+ def __init__(self, node, isContinuous, eventSource, maxContacts, initialEvent,
+ possibleHandler=None, failHandler=None, detectedHandler=None,
+ endHandler=None):
+ self._node = node
+ self.__isContinuous = isContinuous
+ self.__eventSource = eventSource
+ self.__maxContacts = maxContacts
+
+ self.__possibleHandler = utils.methodref(possibleHandler)
+ self.__failHandler = utils.methodref(failHandler)
+ self.__detectedHandler = utils.methodref(detectedHandler)
+ self.__endHandler = utils.methodref(endHandler)
+
+ self.__setEventHandler()
+ self.__isEnabled = True
+ self._contacts = {}
+ self.__dirty = False
+
+ self.__stateMachine = statemachine.StateMachine(str(type(self)), "IDLE")
+ if self.__isContinuous:
+ self.__stateMachine.addState("IDLE", ("POSSIBLE", "RUNNING"))
+ self.__stateMachine.addState("POSSIBLE", ("IDLE", "RUNNING"))
+ self.__stateMachine.addState("RUNNING", ("IDLE",))
+ else:
+ self.__stateMachine.addState("IDLE", ("POSSIBLE",))
+ self.__stateMachine.addState("POSSIBLE", ("IDLE",))
+
+# self.__stateMachine.traceChanges(True)
+
+ if initialEvent:
+ self.__onDown(initialEvent)
+
+ def enable(self, isEnabled):
+ if isEnabled != self.__isEnabled:
+ self.__isEnabled = isEnabled
+ if isEnabled:
+ self.__setEventHandler()
+ else:
+ if self._contacts != {}:
+ self._abort()
+ if self._node:
+ self._node.disconnectEventHandler(self)
+
+ def getState(self):
+ return self.__stateMachine.state
+
+ def _setPossible(self, event):
+ self.__stateMachine.changeState("POSSIBLE")
+ utils.callWeakRef(self.__possibleHandler, event)
+
+ def _setFail(self, event):
+ assert(self.__stateMachine.state == "POSSIBLE")
+ self.__stateMachine.changeState("IDLE")
+ utils.callWeakRef(self.__failHandler, event)
+
+ def _setDetected(self, event):
+ if self.__isContinuous:
+ self.__stateMachine.changeState("RUNNING")
+ else:
+ self.__stateMachine.changeState("IDLE")
+ utils.callWeakRef(self.__detectedHandler, event)
+
+ def _setEnd(self, event):
+ assert(self.__stateMachine.state == "RUNNING")
+ self.__stateMachine.changeState("IDLE")
+ utils.callWeakRef(self.__endHandler, event)
+
+ def __onDown(self, event):
+ if self.__maxContacts == None or len(self._contacts) < self.__maxContacts:
+ listenerid = event.contact.connectListener(self.__onMotion, self.__onUp)
+ self._contacts[event.contact] = ContactData(listenerid)
+ if len(self._contacts) == 1:
+ self.__frameHandlerID = g_Player.setOnFrameHandler(self._onFrame)
+ self.__dirty = True
+ return self._handleDown(event)
+
+ def __onMotion(self, event):
+ self.__dirty = True
+ self._handleMove(event)
+
+ def __onUp(self, event):
+ self.__dirty = True
+ listenerid = self._contacts[event.contact].listenerid
+ del self._contacts[event.contact]
+ event.contact.disconnectListener(listenerid)
+ if self._contacts == {}:
+ g_Player.clearInterval(self.__frameHandlerID)
+ self._handleUp(event)
+
+ def _abort(self):
+ for contact, contactData in self._contacts.iteritems():
+ contact.disconnectListener(contactData.listenerid)
+ self._contacts = {}
+ g_Player.clearInterval(self.__frameHandlerID)
+
+ def _handleDown(self, event):
+ pass
+
+ def _handleMove(self, event):
+ pass
+
+ def _handleUp(self, event):
+ pass
+
+ def _handleChange(self):
+ pass
+
+ def _onFrame(self):
+ if self.__dirty:
+ self._handleChange()
+ self.__dirty = False
+
+ def __setEventHandler(self):
+ if self._node:
+ self._node.connectEventHandler(avg.CURSORDOWN, self.__eventSource, self,
+ self.__onDown)
+
+
+class TapRecognizer(Recognizer):
+
+ def __init__(self, node, eventSource=avg.TOUCH | avg.MOUSE,
+ maxTime=MAX_TAP_TIME, initialEvent=None,
+ possibleHandler=None, failHandler=None, detectedHandler=None):
+ self.__maxTime = maxTime
+
+ self.__maxDistance = (
+ MAX_TAP_DIST*g_Player.getPixelsPerMM())
+ Recognizer.__init__(self, node, False, eventSource, 1, initialEvent,
+ possibleHandler, failHandler, detectedHandler)
+
+ def _handleDown(self, event):
+ self._setPossible(event)
+ self.__startTime = g_Player.getFrameTime()
+
+ def _handleMove(self, event):
+ if self.getState() != "IDLE":
+ if event.contact.distancefromstart > self.__maxDistance:
+ self._setFail(event)
+
+ def _handleUp(self, event):
+ if self.getState() == "POSSIBLE":
+ if event.contact.distancefromstart > self.__maxDistance:
+ self._setFail(event)
+ else:
+ self._setDetected(event)
+
+ def _onFrame(self):
+ downTime = g_Player.getFrameTime() - self.__startTime
+ if self.getState() == "POSSIBLE":
+ if downTime > self.__maxTime:
+ self._setFail(None)
+ Recognizer._onFrame(self)
+
+
+class DoubletapRecognizer(Recognizer):
+
+ def __init__(self, node, eventSource=avg.TOUCH | avg.MOUSE,
+ maxTime=MAX_DOUBLETAP_TIME, initialEvent=None,
+ possibleHandler=None, failHandler=None, detectedHandler=None):
+ self.__maxTime = maxTime
+
+ self.__stateMachine = statemachine.StateMachine("TapRecognizer", "IDLE")
+ self.__stateMachine.addState("IDLE", ("DOWN1",), enterFunc=self.__enterIdle)
+ self.__stateMachine.addState("DOWN1", ("UP1", "IDLE"))
+ self.__stateMachine.addState("UP1", ("DOWN2", "IDLE"))
+ self.__stateMachine.addState("DOWN2", ("IDLE",))
+# self.__stateMachine.traceChanges(True)
+ self.__frameHandlerID = None
+ self.__maxDistance = MAX_TAP_DIST*g_Player.getPixelsPerMM()
+ Recognizer.__init__(self, node, False, eventSource, 1, initialEvent,
+ possibleHandler, failHandler, detectedHandler)
+
+ def _handleDown(self, event):
+ self.__startTime = g_Player.getFrameTime()
+ if self.__stateMachine.state == "IDLE":
+ self.__frameHandlerID = g_Player.setOnFrameHandler(self.__onFrame)
+ self.__stateMachine.changeState("DOWN1")
+ self.__startPos = event.pos
+ self._setPossible(event)
+ elif self.__stateMachine.state == "UP1":
+ if (event.pos - self.__startPos).getNorm() > self.__maxDistance:
+ self.__stateMachine.changeState("IDLE")
+ self._setFail(event)
+ else:
+ self.__stateMachine.changeState("DOWN2")
+ else:
+ assert(False)
+
+ def _handleMove(self, event):
+ if self.__stateMachine.state != "IDLE":
+ if (event.pos - self.__startPos).getNorm() > self.__maxDistance:
+ self.__stateMachine.changeState("IDLE")
+ self._setFail(event)
+
+ def _handleUp(self, event):
+ if self.__stateMachine.state == "DOWN1":
+ self.__startTime = g_Player.getFrameTime()
+ self.__stateMachine.changeState("UP1")
+ elif self.__stateMachine.state == "DOWN2":
+ if (event.pos - self.__startPos).getNorm() > self.__maxDistance:
+ self._setFail(event)
+ else:
+ self._setDetected(event)
+ self.__stateMachine.changeState("IDLE")
+ elif self.__stateMachine.state == "IDLE":
+ pass
+ else:
+ assert(False)
+
+ def __onFrame(self):
+ downTime = g_Player.getFrameTime() - self.__startTime
+ if downTime > self.__maxTime:
+ self._setFail(None)
+ self.__stateMachine.changeState("IDLE")
+
+ def __enterIdle(self):
+ g_Player.clearInterval(self.__frameHandlerID)
+
+
+class HoldRecognizer(Recognizer):
+
+ def __init__(self, node, eventSource=avg.TOUCH | avg.MOUSE,
+ delay=HOLD_DELAY, initialEvent=None, possibleHandler=None, failHandler=None,
+ detectedHandler=None, stopHandler=None):
+ self.__delay = delay
+
+ self.__maxDistance = (
+ MAX_TAP_DIST*g_Player.getPixelsPerMM())
+ self.__lastEvent = None
+ Recognizer.__init__(self, node, True, eventSource, 1, initialEvent,
+ possibleHandler, failHandler, detectedHandler, stopHandler)
+
+ def _handleDown(self, event):
+ self.__lastEvent = event
+ self._setPossible(event)
+ self.__startTime = g_Player.getFrameTime()
+
+ def _handleMove(self, event):
+ self.__lastEvent = event
+ if self.getState() == "POSSIBLE":
+ if event.contact.distancefromstart > self.__maxDistance:
+ self._setFail(event)
+
+ def _handleUp(self, event):
+ self.__lastEvent = event
+ if self.getState() == "POSSIBLE":
+ self._setFail(event)
+ elif self.getState() == "RUNNING":
+ self._setEnd(event)
+
+ def _onFrame(self):
+ downTime = g_Player.getFrameTime() - self.__startTime
+ if self.getState() == "POSSIBLE":
+ if downTime > self.__delay:
+ self._setDetected(self.__lastEvent)
+ Recognizer._onFrame(self)
+
+
+class DragRecognizer(Recognizer):
+
+ ANY_DIRECTION=0
+ VERTICAL=1
+ HORIZONTAL=2
+
+ DIRECTION_TOLERANCE=pi/4
+
+ def __init__(self, eventNode, coordSysNode=None, eventSource=avg.TOUCH | avg.MOUSE,
+ initialEvent=None,
+ direction=ANY_DIRECTION, directionTolerance=DIRECTION_TOLERANCE,
+ friction=-1,
+ possibleHandler=None, failHandler=None, detectedHandler=None,
+ moveHandler=None, upHandler=None, endHandler=None):
+
+ if coordSysNode != None:
+ self.__coordSysNode = coordSysNode
+ else:
+ self.__coordSysNode = eventNode
+ self.__moveHandler = utils.methodref(moveHandler)
+ self.__upHandler = utils.methodref(upHandler)
+ self.__direction = direction
+ if self.__direction == DragRecognizer.ANY_DIRECTION:
+ self.__minDist = 0
+ else:
+ self.__minDist = MIN_DRAG_DIST*g_Player.getPixelsPerMM()
+ self.__directionTolerance = directionTolerance
+ self.__friction = friction
+
+ self.__isSliding = False
+ self.__inertiaHandler = None
+ Recognizer.__init__(self, eventNode, True, eventSource, 1, initialEvent,
+ possibleHandler=possibleHandler, failHandler=failHandler,
+ detectedHandler=detectedHandler, endHandler=endHandler)
+
+ def abortInertia(self):
+ if self.__isSliding:
+ self.__inertiaHandler.abort()
+
+ def _handleDown(self, event):
+ if self.__isSliding:
+ self.__inertiaHandler.abort()
+ if self.__direction == DragRecognizer.ANY_DIRECTION:
+ self._setDetected(event)
+ else:
+ self._setPossible(event)
+ pos = self.__relEventPos(event)
+ if self.__friction != -1:
+ self.__inertiaHandler = InertiaHandler(self.__friction, self.__onInertiaMove,
+ self.__onInertiaStop)
+ self.__dragStartPos = pos
+ self.__lastPos = pos
+
+ def _handleMove(self, event):
+ if self.getState() != "IDLE":
+ pos = self.__relEventPos(event)
+ offset = pos - self.__dragStartPos
+ if self.getState() == "RUNNING":
+ utils.callWeakRef(self.__moveHandler, event, offset)
+ else:
+ if offset.getNorm() > self.__minDist:
+ if self.__angleFits(offset):
+ self._setDetected(event)
+ utils.callWeakRef(self.__moveHandler, event, offset)
+ else:
+ self._setFail(event)
+ self._abort()
+ self.__inertiaHandler = None
+ if self.__inertiaHandler:
+ self.__inertiaHandler.onDrag(Transform(pos - self.__lastPos))
+ self.__lastPos = pos
+
+ def _handleUp(self, event):
+ if self.getState() != "IDLE":
+ pos = self.__relEventPos(event)
+ if self.getState() == "RUNNING":
+ self.__offset = pos - self.__dragStartPos
+ utils.callWeakRef(self.__upHandler, event, self.__offset)
+ if self.__friction != -1:
+ self.__isSliding = True
+ self.__inertiaHandler.onDrag(Transform(pos - self.__lastPos))
+ self.__inertiaHandler.onUp()
+ else:
+ self._setEnd(event)
+ else:
+ self._setFail(event)
+ self.__inertiaHandler = None
+
+ def __onInertiaMove(self, transform):
+ self.__offset += transform.trans
+ utils.callWeakRef(self.__moveHandler, None, self.__offset)
+
+ def __onInertiaStop(self):
+ self._setEnd(None)
+ self.__inertiaHandler = None
+ self.__isSliding = False
+
+ def __relEventPos(self, event):
+ return self.__coordSysNode.getParent().getRelPos(event.pos)
+
+ def __angleFits(self, offset):
+ angle = offset.getAngle()
+ if angle < 0:
+ angle = -angle
+ if self.__direction == DragRecognizer.VERTICAL:
+ return (angle > pi/2-self.__directionTolerance
+ and angle < pi/2+self.__directionTolerance)
+ elif self.__direction == DragRecognizer.HORIZONTAL:
+ return (angle < self.__directionTolerance
+ or angle > pi-self.__directionTolerance)
+ else:
+ assert(False)
+
+class Mat3x3:
+ # Internal class. Will be removed again.
+
+ def __init__(self, row0=(1,0,0), row1=(0,1,0), row2=(0,0,1)):
+ self.m = [row0, row1, row2]
+
+ @classmethod
+ def translate(cls, t):
+ return Mat3x3([1, 0, t[0]],
+ [0, 1, t[1]])
+
+ @classmethod
+ def rotate(cls, a):
+ return Mat3x3([cos(a), -sin(a), 0],
+ [sin(a), cos(a), 0])
+
+ @classmethod
+ def pivotRotate(cls, t, a):
+ rot = Mat3x3.rotate(a)
+ trans = Mat3x3.translate(t)
+ return trans.applyMat(rot.applyMat(trans.inverse()))
+
+ @classmethod
+ def scale(cls, s):
+ return Mat3x3([s[0], 0, 0],
+ [0, s[1], 0])
+
+ @classmethod
+ def fromNode(cls, node):
+ return Mat3x3.translate(node.pos).applyMat(
+ Mat3x3.translate(node.pivot).applyMat(
+ Mat3x3.rotate(node.angle).applyMat(
+ Mat3x3.translate(-node.pivot).applyMat(
+ Mat3x3.scale(node.size)))))
+
+ def setNodeTransform(self, node):
+ v = self.applyVec([1,0,0])
+ rot = avg.Point2D(v[0], v[1]).getAngle()
+ node.angle = rot
+ node.size = self.getScale()
+ node.pivot = node.size/2
+ v = self.applyVec([0,0,1])
+ node.pos = (avg.Point2D(v[0], v[1]) + (node.pivot).getRotated(node.angle) -
+ node.pivot)
+
+ def getScale(self):
+ v = self.applyVec([1,0,0])
+ xscale = avg.Point2D(v[0], v[1]).getNorm()
+ v = self.applyVec([0,1,0])
+ yscale = avg.Point2D(v[0], v[1]).getNorm()
+ return avg.Point2D(xscale, yscale)
+
+ def __str__(self):
+ return self.m.__str__()
+
+ def applyVec(self, v):
+ m = self.m
+ v1 = []
+ for i in range(3):
+ v1.append(m[i][0]*v[0] + m[i][1]*v[1] + m[i][2]*v[2])
+ return v1
+
+ def applyMat(self, m1):
+ m0 = self.m
+ result = Mat3x3()
+ for i in range(3):
+ v = []
+ for j in range(3):
+ v.append(m0[i][0]*m1.m[0][j] + m0[i][1]*m1.m[1][j] + m0[i][2]*m1.m[2][j])
+ result.m[i] = v
+ return result
+
+ def det(self):
+ m = self.m
+ return float( m[0][0] * (m[2][2]*m[1][1]-m[2][1]*m[1][2])
+ -m[1][0] * (m[2][2]*m[0][1]-m[2][1]*m[0][2])
+ +m[2][0] * (m[1][2]*m[0][1]-m[1][1]*m[0][2]))
+
+ def scalarMult(self, s):
+ m = self.m
+ result = Mat3x3()
+ for i in range(3):
+ v = []
+ for j in range(3):
+ v.append(m[i][j]*s)
+ result.m[i] = v
+ return result
+
+ def inverse(self):
+ m = self.m
+ temp = Mat3x3([ m[2][2]*m[1][1]-m[2][1]*m[1][2], -(m[2][2]*m[0][1]-m[2][1]*m[0][2]), m[1][2]*m[0][1]-m[1][1]*m[0][2] ],
+ [-(m[2][2]*m[1][0]-m[2][0]*m[1][2]), m[2][2]*m[0][0]-m[2][0]*m[0][2] , -(m[1][2]*m[0][0]-m[1][0]*m[0][2])],
+ [ m[2][1]*m[1][0]-m[2][0]*m[1][1], -(m[2][1]*m[0][0]-m[2][0]*m[0][1]), m[1][1]*m[0][0]-m[1][0]*m[0][1] ])
+ return temp.scalarMult(1/self.det())
+
+
+def getCentroid(indexes, pts):
+ c = avg.Point2D(0, 0)
+ for i in indexes:
+ c += pts[i]
+ return c/len(indexes)
+
+def calcKMeans(pts):
+
+ # in: List of points
+ # out: Two lists, each containing indexes into the input list
+ assert(len(pts) > 1)
+ p1 = pts[0]
+ p2 = pts[1]
+ oldP1 = None
+ oldP2 = None
+ j = 0
+ while not(p1 == oldP1 and p2 == oldP2) and j < 50:
+ l1 = []
+ l2 = []
+ # Group points
+ for i, pt in enumerate(pts):
+ dist1 = (pt-p1).getNorm()
+ dist2 = (pt-p2).getNorm()
+ if dist1 < dist2:
+ l1.append(i)
+ else:
+ l2.append(i)
+ oldP1 = p1
+ oldP2 = p2
+ p1 = getCentroid(l1, pts)
+ p2 = getCentroid(l2, pts)
+ j += 1
+ return l1, l2
+
+
+class Transform():
+ def __init__(self, trans, rot=0, scale=1, pivot=(0,0)):
+ self.trans = avg.Point2D(trans)
+ self.rot = rot
+ self.scale = scale
+ self.pivot = avg.Point2D(pivot)
+
+ def moveNode(self, node):
+ transMat = Mat3x3.translate(self.trans)
+ rotMat = Mat3x3.rotate(self.rot)
+ scaleMat = Mat3x3.scale((self.scale, self.scale))
+ pivotMat = Mat3x3.translate(self.pivot)
+ invPivotMat = pivotMat.inverse()
+ startTransform = Mat3x3.fromNode(node)
+ newTransform = pivotMat.applyMat(
+ rotMat.applyMat(
+ scaleMat.applyMat(
+ invPivotMat.applyMat(
+ transMat.applyMat(
+ startTransform)))))
+ newTransform.setNodeTransform(node)
+
+ def __repr__(self):
+ return "Transform"+str((self.trans, self.rot, self.scale, self.pivot))
+
+
+class TransformRecognizer(Recognizer):
+
+ def __init__(self, eventNode, coordSysNode=None, eventSource=avg.TOUCH,
+ initialEvent=None, friction=-1,
+ detectedHandler=None, moveHandler=None, upHandler=None, endHandler=None):
+ if coordSysNode != None:
+ self.__coordSysNode = coordSysNode
+ else:
+ self.__coordSysNode = eventNode
+ self.__moveHandler = utils.methodref(moveHandler)
+ self.__upHandler = utils.methodref(upHandler)
+ self.__friction = friction
+
+ self.__baseTransform = Mat3x3()
+ self.__lastPosns = []
+ self.__posns = []
+ self.__inertiaHandler = None
+ Recognizer.__init__(self, eventNode, True, eventSource, None, initialEvent,
+ detectedHandler=detectedHandler, endHandler=endHandler)
+
+ def _handleDown(self, event):
+ numContacts = len(self._contacts)
+ self.__newPhase()
+ if numContacts == 1:
+ if self.__inertiaHandler:
+ self.__inertiaHandler.abort()
+ self._setDetected(event)
+ if self.__friction != -1:
+ self.__inertiaHandler = InertiaHandler(self.__friction,
+ self.__onInertiaMove, self.__onInertiaStop)
+
+ def _handleUp(self, event):
+ numContacts = len(self._contacts)
+ if numContacts == 0:
+ contact = event.contact
+ transform = Transform(self.__relContactPos(contact) - self.__lastPosns[0])
+ utils.callWeakRef(self.__upHandler, transform)
+ if self.__friction != -1:
+ self.__inertiaHandler.onDrag(transform)
+ self.__inertiaHandler.onUp()
+ else:
+ self._setEnd(event)
+ elif numContacts == 1:
+ self.__newPhase()
+ else:
+ self.__newPhase()
+
+ def _handleChange(self):
+ numContacts = len(self._contacts)
+ if numContacts == 1:
+ contact = self._contacts.keys()[0]
+ transform = Transform(self.__relContactPos(contact) - self.__lastPosns[0])
+ if self.__friction != -1:
+ self.__inertiaHandler.onDrag(transform)
+ utils.callWeakRef(self.__moveHandler, transform)
+ self.__lastPosns = [self.__relContactPos(contact)]
+ else:
+ contactPosns = [self.__relContactPos(contact)
+ for contact in self._contacts.keys()]
+ if numContacts == 2:
+ self.__posns = contactPosns
+ else:
+ self.__posns = [getCentroid(self.__clusters[i], contactPosns) for
+ i in range(2)]
+
+ startDelta = self.__lastPosns[1]-self.__lastPosns[0]
+ curDelta = self.__posns[1]-self.__posns[0]
+
+ pivot = (self.__posns[0]+self.__posns[1])/2
+
+ rot = avg.Point2D.angle(curDelta, startDelta)
+
+ if self.__lastPosns[0] == self.__lastPosns[1]:
+ scale = 1
+ else:
+ scale = ((self.__posns[0]-self.__posns[1]).getNorm() /
+ (self.__lastPosns[0]-self.__lastPosns[1]).getNorm())
+
+ trans = ((self.__posns[0]+self.__posns[1])/2 -
+ (self.__lastPosns[0]+self.__lastPosns[1])/2)
+ transform = Transform(trans, rot, scale, pivot)
+ if self.__friction != -1:
+ self.__inertiaHandler.onDrag(transform)
+ utils.callWeakRef(self.__moveHandler, transform)
+ self.__lastPosns = self.__posns
+
+
+ def __newPhase(self):
+ self.__lastPosns = []
+ numContacts = len(self._contacts)
+ if numContacts == 1:
+ contact = self._contacts.keys()[0]
+ self.__lastPosns.append(self.__relContactPos(contact))
+ else:
+ contactPosns = [self.__relContactPos(contact)
+ for contact in self._contacts.keys()]
+ if numContacts == 2:
+ self.__lastPosns = contactPosns
+ else:
+ self.__clusters = calcKMeans(contactPosns)
+ self.__lastPosns = [getCentroid(self.__clusters[i], contactPosns) for
+ i in range(2)]
+
+ def __onInertiaMove(self, transform):
+ utils.callWeakRef(self.__moveHandler, transform)
+
+ def __onInertiaStop(self):
+ self._setEnd(None)
+ self.__inertiaHandler = None
+
+ def __relContactPos(self, contact):
+ return self.__coordSysNode.getParent().getRelPos(contact.events[-1].pos)
+
+
+class InertiaHandler():
+ def __init__(self, friction, moveHandler, stopHandler):
+ self.__friction = friction
+ self.__moveHandler = moveHandler
+ self.__stopHandler = stopHandler
+
+ self.__transVel = avg.Point2D(0, 0)
+ self.__curPivot = avg.Point2D(0, 0)
+ self.__angVel = 0
+ self.__sizeVel = avg.Point2D(0, 0)
+ self.__frameHandlerID = g_Player.setOnFrameHandler(self.__onDragFrame)
+
+ def abort(self):
+ self.__stop()
+
+ def onDrag(self, transform):
+ frameDuration = g_Player.getFrameDuration()
+ self.__transVel += 0.1*transform.trans/frameDuration
+ if transform.pivot != avg.Point2D(0,0):
+ self.__curPivot = transform.pivot
+ if transform.rot > pi:
+ transform.rot -= 2*pi
+ self.__angVel += 0.1*transform.rot/frameDuration
+
+ def onUp(self):
+ g_Player.clearInterval(self.__frameHandlerID)
+ self.__frameHandlerID = g_Player.setOnFrameHandler(self.__onInertiaFrame)
+
+ def __onDragFrame(self):
+ self.__transVel *= 0.9
+ self.__angVel *= 0.9
+
+ def __onInertiaFrame(self):
+ transNorm = self.__transVel.getNorm()
+ if transNorm - self.__friction > 0:
+ direction = self.__transVel.getNormalized()
+ self.__transVel = direction * (transNorm-self.__friction)
+ curTrans = self.__transVel * g_Player.getFrameDuration()
+ else:
+ curTrans = avg.Point2D(0, 0)
+
+ if self.__angVel != 0:
+ angSign = self.__angVel/fabs(self.__angVel)
+ self.__angVel = self.__angVel - angSign*self.__friction/200
+ newAngSign = self.__angVel/fabs(self.__angVel)
+ if newAngSign != angSign:
+ self.__angVel = 0
+ curAng = self.__angVel * g_Player.getFrameDuration()
+ self.__curPivot += curTrans
+
+ if transNorm - self.__friction > 0 or self.__angVel != 0:
+ if self.__moveHandler:
+ self.__moveHandler(Transform(curTrans, curAng, 1, self.__curPivot))
+ else:
+ self.__stop()
+
+ def __stop(self):
+ g_Player.clearInterval(self.__frameHandlerID)
+ self.__stopHandler()
+ self.__stopHandler = None
+ self.__moveHandler = None
diff --git a/src/python/ui/helper.py b/src/python/ui/helper.py
new file mode 100644
index 0000000..3963a99
--- /dev/null
+++ b/src/python/ui/helper.py
@@ -0,0 +1,61 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg
+
+class ScrollPane(avg.DivNode):
+
+ def __init__(self, contentDiv, *args, **kwargs):
+
+ avg.DivNode.__init__(self, crop=True, *args, **kwargs)
+ self.appendChild(contentDiv)
+ self.__contentDiv = contentDiv
+
+ def setContentPos(self, pos):
+
+ def constrain(pos, limit):
+ if limit < 0:
+ # Content larger than container
+ if pos < limit:
+ pos = limit
+ elif pos > 0:
+ pos = 0
+ else:
+ # Content smaller than container
+ if pos < 0:
+ pos = 0
+ elif pos > limit:
+ pos = limit
+ return pos
+
+ maxPos = self.getMaxContentPos()
+ pos = avg.Point2D(pos)
+ pos.x = constrain(pos.x, maxPos.x)
+ pos.y = constrain(pos.y, maxPos.y)
+ self.__contentDiv.pos = pos
+
+ def getContentPos(self):
+ return self.__contentDiv.pos
+ contentpos = property(getContentPos, setContentPos)
+
+ def getMaxContentPos(self):
+ maxPos = self.size - self.__contentDiv.size
+ return maxPos
diff --git a/src/python/ui/keyboard.py b/src/python/ui/keyboard.py
new file mode 100644
index 0000000..419fd9f
--- /dev/null
+++ b/src/python/ui/keyboard.py
@@ -0,0 +1,243 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this module: Thomas Schott <scotty at c-base dot org>
+#
+
+import os.path
+
+from libavg import avg
+
+g_Player = avg.Player.get()
+g_Logger = avg.Logger.get()
+
+
+class Key(avg.ImageNode):
+ def __init__(self, keyDef, ovlHref, onDownCallback, onUpCallback,
+ onOutCallback=lambda event, keyCode:None, sticky=False, *args, **kwargs):
+ kwargs['pos'] = keyDef[1]
+ kwargs['size'] = keyDef[2]
+ kwargs['opacity'] = 0.0
+ super(Key, self).__init__(*args, **kwargs)
+
+ if ovlHref:
+ self.__createImage(ovlHref)
+ self.__keyCode = keyDef[0]
+ self.__onDownCallback = onDownCallback
+ self.__onUpCallback = onUpCallback
+ self.__onOutCallback = onOutCallback
+ self.__sticky = sticky
+ if self.__sticky:
+ self.__stickyIsDown = False
+ self.__cursorID = None
+ self.setEventHandler(avg.CURSORDOWN, avg.MOUSE | avg.TOUCH, self.__onDown)
+ self.setEventHandler(avg.CURSORUP, avg.MOUSE | avg.TOUCH, self.__onUp)
+ self.setEventHandler(avg.CURSOROUT, avg.MOUSE | avg.TOUCH, self.__onOut)
+
+ def reset(self):
+ if self.__sticky:
+ self.opacity = 0.0
+ self.__stickyIsDown = False
+
+ def __createImage(self, ovlHref):
+ if os.path.isabs(ovlHref):
+ effectiveHref = ovlHref
+ else:
+ effectiveHref = self.getParent().getEffectiveMediaDir() + ovlHref
+ canvas = g_Player.loadCanvasString(
+ '''
+ <canvas id="offscreen" size="%s">
+ <image href="%s" pos="%s"/>
+ </canvas>
+ '''
+ %(str(self.size),
+ effectiveHref,
+ str(-self.pos)))
+ canvas.render()
+ self.setBitmap(canvas.screenshot())
+ g_Player.deleteCanvas('offscreen')
+
+ def __onDown(self, event):
+ if self.__sticky:
+ self.__stickyIsDown = not(self.__stickyIsDown)
+ if self.__stickyIsDown:
+ self.__pseudoDown(event)
+ else:
+ self.__pseudoUp(event)
+ else:
+ if self.__cursorID:
+ return
+ self.__pseudoDown(event)
+
+ def __onUp(self, event):
+ if not self.__cursorID == event.cursorid:
+ return
+ if not (self.__sticky):
+ self.__pseudoUp(event)
+
+ def __onOut(self, event):
+ if not self.__cursorID == event.cursorid:
+ return
+ if not(self.__sticky):
+ self.__cursorID = None
+ self.opacity = 0.0
+ self.__onOutCallback(event, self.__keyCode)
+
+ def __pseudoDown(self, event):
+ self.__cursorID = event.cursorid
+
+ self.opacity = 1.0
+ if self.__onDownCallback:
+ self.__onDownCallback(event, self.__keyCode)
+
+ def __pseudoUp(self, event):
+ self.__cursorID = None
+
+ self.opacity = 0.0
+ if self.__onUpCallback:
+ self.__onUpCallback(event, self.__keyCode)
+
+
+
+class Keyboard(avg.DivNode):
+
+ def __init__(self, bgHref, ovlHref, keyDefs, shiftKeyCode, altGrKeyCode=None,
+ stickyShift=False, *args, **kwargs):
+ # TODO: shift and altGr handling have some duplicated code.
+ super(Keyboard, self).__init__(*args, **kwargs)
+
+ self.__shiftKeyCode = shiftKeyCode
+ self.__shiftDownCounter = 0
+ self.__stickyShift = stickyShift
+ self.__altGrKeyCode = altGrKeyCode
+ self.__altGrKeyCounter = 0
+ if not(self.__shiftKeyCode) and self.__altGrKeyCode:
+ raise RuntimeError(
+ "Keyboard: If there is an altgr key, there must also be a shift key.")
+ self.__codesPerKey = 1
+ if self.__shiftKeyCode:
+ self.__codesPerKey = 2
+ if self.__altGrKeyCode:
+ self.__codesPerKey = 3
+
+ self.__downKeyHandler = None
+ self.__upKeyHandler = None
+
+ self.__keys = []
+ if bgHref:
+ avg.ImageNode(href=bgHref, parent=self)
+ for kd in keyDefs:
+ if isinstance(kd[0], tuple):
+ while len(kd[0]) < self.__codesPerKey:
+ kd[0] += (kd[0][0],)
+ key = Key(kd, ovlHref, self.__onCharKeyDown, self.__onCharKeyUp,
+ parent=self)
+ else:
+ sticky =(self.__stickyShift and
+ (self.__shiftKeyCode == kd[0] or self.__altGrKeyCode == kd[0]))
+ key = Key(kd, ovlHref, self.__onCommandKeyDown, self.__onCommandKeyUp,
+ self.__onCommandKeyUp, sticky=sticky, parent=self)
+ self.__keys.append(key)
+
+ @classmethod
+ def makeRowKeyDefs(cls, startPos, keySize, spacing, keyStr, shiftKeyStr,
+ altGrKeyStr=None):
+ keyDefs = []
+ curPos = startPos
+ offset = keySize[0]+spacing
+ if altGrKeyStr:
+ for keyCode, shiftKeyCode, altGrKeyCode in (
+ zip(keyStr, shiftKeyStr, altGrKeyStr)):
+ keyDefs.append([(keyCode, shiftKeyCode, altGrKeyCode), curPos, keySize])
+ curPos = (curPos[0]+offset, curPos[1])
+ else:
+ for keyCode, shiftKeyCode in zip(keyStr, shiftKeyStr):
+ keyDefs.append([(keyCode, shiftKeyCode), curPos, keySize])
+ curPos = (curPos[0]+offset, curPos[1])
+ return keyDefs
+
+ def setKeyHandler(self, downHandler, upHandler=None):
+ self.__downKeyHandler = downHandler
+ self.__upKeyHandler = upHandler
+
+ def reset(self):
+ for key in self.__keys:
+ key.reset()
+ self.__shiftDownCounter = 0
+ self.__altGrKeyCounter = 0
+
+ def _getCharKeyCode(self, keyCodes):
+ '''
+ Return one of a character key's keycodes depending on shift key(s) status.
+ Overload this method to change character key keycode handling.
+ '''
+ if self.__shiftDownCounter:
+ return keyCodes[1]
+ elif self.__altGrKeyCounter:
+ return keyCodes[2]
+ else:
+ return keyCodes[0]
+
+ def _onCommandKeyDown(self, event, keyCode):
+ '''
+ Overload this method to add command key functionality.
+ '''
+ pass
+
+ def _onCommandKeyUp(self, event, keyCode):
+ '''
+ Overload this method to add command key functionality.
+ '''
+ pass
+
+ def __onCharKeyDown(self, event, keyCodes):
+ if self.__downKeyHandler:
+ self.__downKeyHandler(event, self._getCharKeyCode(keyCodes), None)
+
+ def __onCharKeyUp(self, event, keyCodes):
+ if self.__upKeyHandler:
+ self.__upKeyHandler(event, self._getCharKeyCode(keyCodes), None)
+
+ def __onCommandKeyDown(self, event, keyCode):
+ self._onCommandKeyDown(event, keyCode)
+ if keyCode == self.__shiftKeyCode:
+ self.__shiftDownCounter += 1
+ if keyCode == self.__altGrKeyCode:
+ self.__altGrKeyCounter += 1
+ if self.__downKeyHandler:
+ self.__downKeyHandler(event, None, keyCode)
+
+ def __onCommandKeyUp(self, event, keyCode):
+ self._onCommandKeyUp(event, keyCode)
+ if keyCode == self.__shiftKeyCode:
+ if self.__shiftDownCounter > 0:
+ self.__shiftDownCounter -= 1
+ else:
+ g_Logger.trace(g_Logger.WARNING,
+ 'Keyboard: ShiftDownCounter=0 on [%s] up'
+ %self.__shiftKeyCode)
+ elif keyCode == self.__altGrKeyCode:
+ if self.__altGrKeyCounter > 0:
+ self.__altGrKeyCounter -= 1
+ if self.__upKeyHandler:
+ self.__upKeyHandler(event, None, keyCode)
+
diff --git a/src/python/utils.py b/src/python/utils.py
new file mode 100644
index 0000000..363191b
--- /dev/null
+++ b/src/python/utils.py
@@ -0,0 +1,101 @@
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Martin Heistermann <mh at sponc dot de>
+#
+
+import os
+
+import weakref, new
+
+from libavg import avg, mathutil
+
+g_Player = avg.Player.get()
+
+def getMediaDir(_file_, subdir='media'):
+ """call with _file_=__file__"""
+ myDir = os.path.dirname(_file_)
+ mediaDir = os.path.join(myDir, subdir)
+ return os.path.abspath(mediaDir)
+
+def getMediaDirFromNode(node, path=''):
+ '''
+ Recursively build the mediadir path, starting from the given node.
+ '''
+ if node.getParent():
+ if type(node) in (avg.DivNode, avg.AVGNode):
+ return getMediaDirFromNode(node.getParent(), os.path.join(node.mediadir, path))
+ else:
+ return getMediaDirFromNode(node.getParent(), path)
+ else:
+ return path
+
+def createImagePreviewNode(maxSize, absHref):
+ node = g_Player.createNode('image', {'href': absHref})
+ node.size = mathutil.getScaledDim(node.size, max = maxSize)
+ return node
+
+def initFXCache(numFXNodes):
+ nodes = []
+ mediadir = os.path.join(os.path.dirname(__file__), 'data')
+ for i in range(numFXNodes):
+ node = avg.ImageNode(href=mediadir+"/black.png",
+ parent=g_Player.getRootNode())
+ node.setEffect(avg.NullFXNode())
+ nodes.append(node)
+ for node in nodes:
+ node.unlink(True)
+
+class methodref(object):
+ # From Python Cookbook
+ """ Wraps any callable, most importantly a bound method, in a way that allows a bound
+ method's object to be GC'ed, while providing the same interface as a normal weak
+ reference."""
+ def __init__(self, fn):
+ try:
+ # Try getting object, function and class
+ o, f, c = fn.im_self, fn.im_func, fn.im_class
+ except AttributeError:
+ # It's not a bound method
+ self._obj = None
+ self._func = fn
+ self._clas = None
+ else:
+ # Bound method
+ if o is None: # ... actually UN-bound
+ self._obj = None
+ else:
+ self._obj = weakref.ref(o)
+ self._func = f
+ self._clas = c
+
+ def __call__(self):
+ if self._obj is None:
+ return self._func
+ elif self._obj() is None:
+ return None
+ return new.instancemethod(self._func, self._obj(), self._clas)
+
+def callWeakRef(ref, *args, **kwargs):
+ func = ref()
+ if func is None:
+ return
+ else:
+ return func(*args, **kwargs)
+
diff --git a/src/samples/Makefile.am b/src/samples/Makefile.am
new file mode 100644
index 0000000..3840524
--- /dev/null
+++ b/src/samples/Makefile.am
@@ -0,0 +1,4 @@
+EXTRA_DIST = $(wildcard *.avg) $(wildcard *.png) $(wildcard *.avi)
+pkgsampledir = $(pkgpyexecdir)/samples
+pkgsample_PYTHON = $(wildcard *.py)
+pkgsample_DATA = $(wildcard *.avg) $(wildcard *.png) $(wildcard *.avi)
diff --git a/src/samples/Makefile.in b/src/samples/Makefile.in
new file mode 100644
index 0000000..8bd283b
--- /dev/null
+++ b/src/samples/Makefile.in
@@ -0,0 +1,522 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/samples
+DIST_COMMON = $(pkgsample_PYTHON) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkgsampledir)" \
+ "$(DESTDIR)$(pkgsampledir)"
+py_compile = $(top_srcdir)/py-compile
+DATA = $(pkgsample_DATA)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = $(wildcard *.avg) $(wildcard *.png) $(wildcard *.avi)
+pkgsampledir = $(pkgpyexecdir)/samples
+pkgsample_PYTHON = $(wildcard *.py)
+pkgsample_DATA = $(wildcard *.avg) $(wildcard *.png) $(wildcard *.avi)
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/samples/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/samples/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-pkgsamplePYTHON: $(pkgsample_PYTHON)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgsampledir)" || $(MKDIR_P) "$(DESTDIR)$(pkgsampledir)"
+ @list='$(pkgsample_PYTHON)'; dlist=; list2=; test -n "$(pkgsampledir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
+ if test -f $$b$$p; then \
+ $(am__strip_dir) \
+ dlist="$$dlist $$f"; \
+ list2="$$list2 $$b$$p"; \
+ else :; fi; \
+ done; \
+ for file in $$list2; do echo $$file; done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgsampledir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgsampledir)" || exit $$?; \
+ done || exit $$?; \
+ if test -n "$$dlist"; then \
+ if test -z "$(DESTDIR)"; then \
+ PYTHON=$(PYTHON) $(py_compile) --basedir "$(pkgsampledir)" $$dlist; \
+ else \
+ PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(pkgsampledir)" $$dlist; \
+ fi; \
+ else :; fi
+
+uninstall-pkgsamplePYTHON:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgsample_PYTHON)'; test -n "$(pkgsampledir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ filesc=`echo "$$files" | sed 's|$$|c|'`; \
+ fileso=`echo "$$files" | sed 's|$$|o|'`; \
+ echo " ( cd '$(DESTDIR)$(pkgsampledir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(pkgsampledir)" && rm -f $$files || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgsampledir)' && rm -f" $$filesc ")"; \
+ cd "$(DESTDIR)$(pkgsampledir)" && rm -f $$filesc || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgsampledir)' && rm -f" $$fileso ")"; \
+ cd "$(DESTDIR)$(pkgsampledir)" && rm -f $$fileso
+install-pkgsampleDATA: $(pkgsample_DATA)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgsampledir)" || $(MKDIR_P) "$(DESTDIR)$(pkgsampledir)"
+ @list='$(pkgsample_DATA)'; test -n "$(pkgsampledir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgsampledir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgsampledir)" || exit $$?; \
+ done
+
+uninstall-pkgsampleDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgsample_DATA)'; test -n "$(pkgsampledir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(pkgsampledir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(pkgsampledir)" && rm -f $$files
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(DATA)
+installdirs:
+ for dir in "$(DESTDIR)$(pkgsampledir)" "$(DESTDIR)$(pkgsampledir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-pkgsampleDATA install-pkgsamplePYTHON
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkgsampleDATA uninstall-pkgsamplePYTHON
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-pkgsampleDATA install-pkgsamplePYTHON \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am uninstall uninstall-am \
+ uninstall-pkgsampleDATA uninstall-pkgsamplePYTHON
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/samples/anim1.py b/src/samples/anim1.py
new file mode 100755
index 0000000..12d6bef
--- /dev/null
+++ b/src/samples/anim1.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import *
+
+def startAnim():
+ animObj.start()
+
+player = avg.Player.get()
+player.loadFile("text.avg")
+
+node = player.getElementByID("HelloText")
+animObj = LinearAnim(node, "x", 2000, 0, 200)
+player.setTimeout(0, startAnim)
+
+player.play()
+
diff --git a/src/samples/anim2.py b/src/samples/anim2.py
new file mode 100755
index 0000000..1eb3a27
--- /dev/null
+++ b/src/samples/anim2.py
@@ -0,0 +1,19 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import *
+
+def startAnim():
+ animObj.start()
+
+player = avg.Player.get()
+player.loadFile("text.avg")
+
+node = player.getElementByID("HelloText")
+animObj = ParallelAnim(
+ [LinearAnim(node, "x", 2000, 0, 200),
+ LinearAnim(node, "y", 2000, 0, 10)])
+player.setTimeout(0, startAnim)
+
+player.play()
+
diff --git a/src/samples/asyncload.py b/src/samples/asyncload.py
new file mode 100755
index 0000000..885fafb
--- /dev/null
+++ b/src/samples/asyncload.py
@@ -0,0 +1,96 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+'''
+Shows how to use BitmapManager to asynchronously load a Bitmap from a file.
+Run this snippet providing a list of filenames of (high resolution) pictures:
+
+$ ./asyncload.py /path/to/mypics/*.jpg anotherpic.png nonexistent.png
+
+Press space to sequentially load the pictures. A rotating rectangle appears
+during the time the picture file is being loaded to show how the main thread
+is not affected by the load operation.
+
+Press 'f' to display the frame time graph, which should show no significant
+glitches while loading
+'''
+
+import sys
+import libavg
+
+APP_RESOLUTION = (640, 480)
+
+g_player = libavg.avg.Player.get()
+
+
+class AsyncLoadApp(libavg.AVGApp):
+ def init(self):
+ '''
+ Create placeholders for the example. A single ImageNode is used to show
+ the pictures.
+ '''
+ self.__imageNode = libavg.avg.ImageNode(pos=(10, 20), parent=self._parentNode)
+ self.__spinner = libavg.avg.RectNode(color='222222',
+ fillopacity=1, size=(40, 40), active=False,
+ pos=(10, self._parentNode.size.y - 50), parent=self._parentNode)
+ self.__infoNode = libavg.avg.WordsNode(text='Press space to load the first image',
+ fontsize=11, pos=(10, 5), parent=self._parentNode)
+
+ self.__pics = sys.argv[1:]
+ self.__currentPic = -1
+ g_player.setOnFrameHandler(self.__onFrame)
+
+ def onKeyDown(self, event):
+ '''
+ Intercept a space keypress and trigger the request.
+ '''
+ if event.keystring == 'space':
+ self.__requestNextBitmap()
+
+ def __requestNextBitmap(self):
+ '''
+ Ask the BitmapManager to load a new file. loadBitmap() call returns immediately.
+ '''
+ self.__currentPic = (self.__currentPic + 1) % len(self.__pics)
+ libavg.avg.BitmapManager.get().loadBitmap(self.__pics[self.__currentPic],
+ self.__onBitmapLoaded)
+
+ self.__spinner.active = True
+ self.__spinner.angle = 0
+
+ def __onBitmapLoaded(self, bmp):
+ '''
+ This callback is invoked by BitmapManager, 'bmp' can be either a Bitmap instance
+ or a RuntimeError instance (hence checking for Exception is consistent).
+ '''
+ self.__spinner.active = False
+ if isinstance(bmp, Exception):
+ self.__infoNode.text = ('Error loading '
+ 'image %s : %s' % (self.__pics[self.__currentPic], str(bmp)))
+ self.__imageNode.href = ''
+ else:
+ self.__infoNode.text = ('Loaded %s, '
+ 'press space for the next one' % self.__pics[self.__currentPic])
+ self.__setBitmapAndResize(bmp)
+
+ def __setBitmapAndResize(self, bmp):
+ originalSize = bmp.getSize()
+
+ if originalSize.x > originalSize.y:
+ ratio = (APP_RESOLUTION[0] - 20) / originalSize.x
+ else:
+ ratio = (APP_RESOLUTION[1] - 40) / originalSize.y
+
+ self.__imageNode.setBitmap(bmp)
+ self.__imageNode.size = originalSize * ratio
+
+ def __onFrame(self):
+ if self.__spinner.active:
+ self.__spinner.angle += 0.05
+
+if len(sys.argv) == 1:
+ print 'Usage: %s <filename> [<filename> [<filename> [..]]]' % sys.argv[0]
+ sys.exit(1)
+
+AsyncLoadApp.start(resolution=APP_RESOLUTION)
+
diff --git a/src/samples/attributes.py b/src/samples/attributes.py
new file mode 100755
index 0000000..887271c
--- /dev/null
+++ b/src/samples/attributes.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+player = avg.Player.get()
+
+player.loadFile("text.avg")
+node = player.getElementByID("HelloText")
+print node.x
+node.x = 200
+player.play()
diff --git a/src/samples/canvas.avg b/src/samples/canvas.avg
new file mode 100644
index 0000000..e2244cf
--- /dev/null
+++ b/src/samples/canvas.avg
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<canvas id="londoncalling" width="320" height="240">
+ <words x="10" y="10" text="London Calling" font="Arial" variant="Bold"
+ fontsize="18" color="CF8000"/>
+</canvas>
+
diff --git a/src/samples/canvas.py b/src/samples/canvas.py
new file mode 100755
index 0000000..050f9a6
--- /dev/null
+++ b/src/samples/canvas.py
@@ -0,0 +1,13 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+player = avg.Player.get()
+player.loadCanvasFile("canvas.avg")
+player.loadString("""
+ <avg width="640" height="480">
+ <image href="canvas:londoncalling"/>
+ </avg>
+""")
+player.play()
diff --git a/src/samples/drag.py b/src/samples/drag.py
new file mode 100755
index 0000000..8541a26
--- /dev/null
+++ b/src/samples/drag.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+offset = None
+
+def onMouseDown(event):
+ global offset
+ node = event.node
+ offset = node.getRelPos((event.x, event.y))
+ node.setEventCapture()
+
+def onMouseMove(event):
+ global offset
+ node = event.node
+ if offset != None:
+ node.x = event.x-offset[0]
+ node.y = event.y-offset[1]
+
+def onMouseUp(event):
+ global offset
+ node = event.node
+ if offset != None:
+ node.releaseEventCapture()
+ offset = None;
+
+player = avg.Player.get()
+
+player.loadFile("text.avg")
+node = player.getElementByID("HelloText")
+node.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onMouseDown)
+node.setEventHandler(avg.CURSORMOTION, avg.MOUSE, onMouseMove)
+node.setEventHandler(avg.CURSORUP, avg.MOUSE, onMouseUp)
+
+player.play()
+
diff --git a/src/samples/event1.py b/src/samples/event1.py
new file mode 100755
index 0000000..a9b3422
--- /dev/null
+++ b/src/samples/event1.py
@@ -0,0 +1,21 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+def onMouseOver(event):
+ node = player.getElementByID("HelloText")
+ node.color = "FF8000"
+
+def onMouseOut(event):
+ node = player.getElementByID("HelloText")
+ node.color = "FFFFFF"
+
+player = avg.Player.get()
+
+player.loadFile("text.avg")
+node = player.getElementByID("HelloText")
+node.setEventHandler(avg.CURSOROVER, avg.MOUSE, onMouseOver)
+node.setEventHandler(avg.CURSOROUT, avg.MOUSE, onMouseOut)
+player.play()
+
diff --git a/src/samples/event2.avg b/src/samples/event2.avg
new file mode 100644
index 0000000..c6ff732
--- /dev/null
+++ b/src/samples/event2.avg
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<avg width="640" height="480">
+ <words id="ClashText" x="10" y="10" font="arial" text="Should I stay or should I go?"/>
+ <div id="div1" x="100" y="0" width="80" height="200"/>
+</avg>
+
diff --git a/src/samples/event2.py b/src/samples/event2.py
new file mode 100755
index 0000000..b9180cc
--- /dev/null
+++ b/src/samples/event2.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+def onDiv(event):
+ words.color = "FF8000"
+
+def onWords(event):
+ words.color = "00FF00"
+
+player = avg.Player.get()
+
+player.loadFile("event2.avg")
+words = player.getElementByID("ClashText")
+words.setEventHandler(avg.CURSORMOTION, avg.MOUSE, onWords)
+player.getElementByID("div1").setEventHandler(avg.CURSORMOTION, avg.MOUSE, onDiv)
+
+player.play()
+
diff --git a/src/samples/event3.py b/src/samples/event3.py
new file mode 100755
index 0000000..e51126f
--- /dev/null
+++ b/src/samples/event3.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+def clickFunc(event):
+ node = player.getElementByID("mouseBlock")
+ node.fillcolor = "FF0000"
+
+def keyboardFunc(event):
+ if event.keystring == 'x':
+ node = player.getElementByID("mouseBlock")
+ node.fillcolor = "00FF00"
+
+player = avg.Player.get()
+
+player.loadString('''
+<?xml version="1.0"?>
+<avg width="640" height="480">
+ <rect pos="(10,10)" size="(250,250)" fillopacity="1" id="mouseBlock"/>
+</avg>
+''')
+
+mouseBlock = player.getElementByID("mouseBlock")
+mouseBlock.setEventHandler(avg.CURSORDOWN, avg.MOUSE, clickFunc)
+
+rootNode = player.getRootNode()
+rootNode.setEventHandler(avg.KEYDOWN, avg.NONE, keyboardFunc)
+
+player.play()
+
diff --git a/src/samples/gestures.py b/src/samples/gestures.py
new file mode 100755
index 0000000..447691d
--- /dev/null
+++ b/src/samples/gestures.py
@@ -0,0 +1,256 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg, ui
+import libavg
+
+RESOLUTION = avg.Point2D(800, 600)
+
+def moveNodeToTop(node):
+ parent = node.getParent()
+ parent.reorderChild(node, parent.getNumChildren()-1)
+
+def moveNodeOnScreen(node):
+ center = node.pos + node.size/2
+ if center.x < 0:
+ node.pos = (-node.size.x/2, node.pos.y)
+ if center.x > RESOLUTION.x:
+ node.pos = (RESOLUTION.x-node.size.x/2, node.pos.y)
+ if center.y < 0:
+ node.pos = (node.pos.x, -node.size.y/2)
+ if center.y > RESOLUTION.y:
+ node.pos = (node.pos.x, RESOLUTION.y-node.size.y/2)
+
+
+class TextRect(avg.DivNode):
+ def __init__(self, text, **kwargs):
+ avg.DivNode.__init__(self, size=(150,40), **kwargs)
+ self.rect = avg.RectNode(size=self.size, fillopacity=1, fillcolor="000000",
+ color="FFFFFF", parent=self)
+ self.words = avg.WordsNode(color="FFFFFF", text=text, alignment="center",
+ parent=self)
+ self.words.pos = (self.size-(0,self.words.size.y)) / 2
+
+ def getSize(self):
+ return self.__divSize
+
+ def setSize(self, size):
+ self.rect.size = size
+ self.words.pos = (size-(0,self.words.size.y)) / 2
+ self.__divSize = size
+ __divSize = avg.DivNode.size
+ size = property(getSize, setSize)
+
+
+class TransformNode(TextRect):
+ def __init__(self, text, ignoreScale, ignoreRotation, friction=-1, **kwargs):
+ TextRect.__init__(self, text, **kwargs)
+ self.__ignoreScale = ignoreScale
+ self.__ignoreRotation = ignoreRotation
+
+ ui.TransformRecognizer(
+ eventNode=self,
+ detectedHandler=self.__onDetected,
+ moveHandler=self.__onMove,
+ upHandler=self.__onUp,
+ friction=friction
+ )
+
+ def __onDetected(self, event):
+ moveNodeToTop(self)
+
+ def __onMove(self, transform):
+ if self.__ignoreScale:
+ transform.scale = 1
+ if self.__ignoreRotation:
+ transform.rot = 0
+ transform.moveNode(self)
+ moveNodeOnScreen(self)
+
+ def __onUp(self, transform):
+ pass
+
+
+class TransformChildNode(avg.DivNode):
+ def __init__(self, text, **kwargs):
+ avg.DivNode.__init__(self, **kwargs)
+ self.textRect = TextRect(text, parent=self)
+ self.size = self.textRect.size
+
+ self.inputNode = avg.RectNode(size=(self.size.x, self.size.y/2),
+ fillopacity=0.5, fillcolor="808080", strokewidth=0, parent=self)
+ ui.TransformRecognizer(
+ eventNode=self.inputNode,
+ coordSysNode=self,
+ detectedHandler=self.__onDetected,
+ moveHandler=self.__onMove,
+ friction=0.05
+ )
+
+ def __onDetected(self, event):
+ moveNodeToTop(self)
+
+ def __onMove(self, transform):
+ transform.moveNode(self)
+ moveNodeOnScreen(self)
+ self.textRect.size = self.size
+ self.inputNode.size = (self.size.x, self.size.y/2)
+
+
+class DragNode(TextRect):
+ def __init__(self, text, friction=-1, **kwargs):
+ TextRect.__init__(self, text, **kwargs)
+
+ ui.DragRecognizer(
+ eventNode=self,
+ detectedHandler=self.__onDetected,
+ moveHandler=self.__onMove,
+ upHandler=self.__onMove,
+ endHandler=self.__onEnd,
+ friction=friction
+ )
+
+ def __onDetected(self, event):
+ self.__dragStartPos = self.pos
+ moveNodeToTop(self)
+
+ def __onMove(self, event, offset):
+ self.pos = self.__dragStartPos + offset
+ moveNodeOnScreen(self)
+
+ def __onEnd(self, event):
+ pass
+
+
+class ConstrainedDragNode(TextRect):
+ def __init__(self, text, friction=-1, **kwargs):
+ TextRect.__init__(self, text, **kwargs)
+
+ ui.DragRecognizer(
+ eventNode=self,
+ detectedHandler=self.__onDetected,
+ moveHandler=self.__onHorizMove,
+ upHandler=self.__onHorizMove,
+ direction=ui.DragRecognizer.HORIZONTAL,
+ friction=0.05
+ )
+
+ ui.DragRecognizer(
+ eventNode=self,
+ detectedHandler=self.__onDetected,
+ moveHandler=self.__onVertMove,
+ upHandler=self.__onVertMove,
+ direction=ui.DragRecognizer.VERTICAL,
+ friction=0.05
+ )
+
+ def __onDetected(self, event):
+ self.__dragStartPos = self.pos
+ moveNodeToTop(self)
+
+ def __onHorizMove(self, event, offset):
+ self.pos = self.__dragStartPos + (offset.x, 0)
+ moveNodeOnScreen(self)
+
+ def __onVertMove(self, event, offset):
+ self.pos = self.__dragStartPos + offset
+ moveNodeOnScreen(self)
+
+
+class TapNode(TextRect):
+ def __init__(self, text, isDoubleTap, **kwargs):
+ TextRect.__init__(self, text, **kwargs)
+
+ if isDoubleTap:
+ ui.DoubletapRecognizer(node=self, possibleHandler=self.__onPossible,
+ detectedHandler=self.__onDetected, failHandler=self.__onFail)
+ else:
+ ui.TapRecognizer(node=self, possibleHandler=self.__onPossible,
+ detectedHandler=self.__onDetected, failHandler=self.__onFail)
+
+ def __onPossible(self, event):
+ self.rect.fillcolor = "FFFFFF"
+ self.words.color = "000000"
+
+ def __onDetected(self, event):
+ self.rect.fillcolor = "000000"
+ self.words.color = "FFFFFF"
+ self.rect.color = "00FF00"
+
+ def __onFail(self, event):
+ self.rect.fillcolor = "000000"
+ self.words.color = "FFFFFF"
+ self.rect.color = "FF0000"
+
+
+class HoldNode(TextRect):
+ def __init__(self, text, **kwargs):
+ TextRect.__init__(self, text, **kwargs)
+
+ ui.HoldRecognizer(node=self, possibleHandler=self.__onPossible,
+ detectedHandler=self.__onDetected, failHandler=self.__onFail,
+ stopHandler=self.__onStop)
+
+ def __onPossible(self, event):
+ self.rect.fillcolor = "FFFFFF"
+ self.rect.color = "FFFFFF"
+ self.words.color = "000000"
+
+ def __onDetected(self, event):
+ self.rect.fillcolor = "000000"
+ self.words.color = "FFFFFF"
+ self.rect.color = "00FF00"
+
+ def __onFail(self, event):
+ self.rect.fillcolor = "000000"
+ self.words.color = "FFFFFF"
+ self.rect.color = "FF0000"
+
+ def __onStop(self, event):
+ self.rect.fillcolor = "000000"
+ self.rect.color = "FFFFFF"
+ self.words.color = "FFFFFF"
+
+
+class GestureDemoApp(libavg.AVGApp):
+ multitouch = True
+
+ def init(self):
+ TransformNode(text="TransformRecognizer",
+ ignoreRotation=False, ignoreScale=False,
+ pos=(20,20), parent=self._parentNode)
+
+ TransformNode(text="TransformRecognizer<br/>ignoreRotation",
+ ignoreRotation=True, ignoreScale=False,
+ pos=(20,70), parent=self._parentNode)
+
+ TransformNode(text="TransformRecognizer<br/>ignoreScale",
+ ignoreRotation=False, ignoreScale=True,
+ pos=(20,120), parent=self._parentNode)
+
+ TransformNode(text="TransformRecognizer<br/>friction",
+ ignoreRotation=False, ignoreScale=False,
+ pos=(20,170), friction=0.02, parent=self._parentNode)
+
+ TransformChildNode(text="TransformRecognizer<br/>child dragger",
+ pos=(20,220), parent=self._parentNode)
+
+ DragNode(text="DragRecognizer", pos=(200,20), parent=self._parentNode)
+
+ DragNode(text="DragRecognizer<br/>friction", pos=(200,70), friction=0.05,
+ parent=self._parentNode)
+
+ ConstrainedDragNode(text="DragRecognizer<br/>constrained", pos=(200,120),
+ parent=self._parentNode)
+
+ TapNode(text="TapRecognizer", pos=(380,20), isDoubleTap=False,
+ parent=self._parentNode)
+
+ TapNode(text="DoubletapRecognizer", pos=(380,70), isDoubleTap=True,
+ parent=self._parentNode)
+
+ HoldNode(text="HoldRecognizer", pos=(380,120), parent=self._parentNode)
+
+
+if __name__ == '__main__':
+ GestureDemoApp.start(resolution=RESOLUTION)
diff --git a/src/samples/globalcoords.avg b/src/samples/globalcoords.avg
new file mode 100644
index 0000000..e7dd70c
--- /dev/null
+++ b/src/samples/globalcoords.avg
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<avg width="160" height="120">
+ <image href="rgb24-64x64.png" pos="(40, 30)" size="(80, 60)"/>
+</avg>
diff --git a/src/samples/gpuhuefx.py b/src/samples/gpuhuefx.py
new file mode 100755
index 0000000..4188406
--- /dev/null
+++ b/src/samples/gpuhuefx.py
@@ -0,0 +1,77 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+
+from libavg import avg, AVGApp
+from libavg.avg import ImageNode
+
+g_Player = avg.Player.get()
+
+class HSL(AVGApp):
+
+ multiTouch = False
+
+ def init(self):
+ rootNode = g_Player.getRootNode()
+
+ background = ImageNode(parent=rootNode, href='../graphics/testfiles/hsl.png',
+ size=(640,640))
+ self.hsl_fx = avg.HueSatFXNode()
+ background.setEffect(self.hsl_fx)
+ self.sat = avg.WordsNode(pos=(800, 200), text="Sat: " +
+ str(self.hsl_fx.saturation), parent=rootNode)
+ self.light = avg.WordsNode(pos=(800, 250), text= "Bright" +
+ str(self.hsl_fx.lightness), parent=rootNode)
+ self.colorize = avg.WordsNode(pos=(800, 300), text="Colorized: " +
+ str(self.hsl_fx.colorize), parent=rootNode)
+ self.hue = avg.WordsNode(pos=(800, 350), text="Hue: " +
+ str(self.hsl_fx.hue), parent=rootNode)
+ rootNode.connectEventHandler(avg.KEYDOWN, avg.NONE, self,
+ self.__onKeyDown)
+ g_Player.setOnFrameHandler(self._increaseHue)
+
+ def __onKeyDown(self, event):
+ if event.keystring == 'v':
+ self.hsl_fx.saturation -= 10
+ elif event.keystring == 'b':
+ self.hsl_fx.saturation += 10
+ elif event.keystring == 'n':
+ self.hsl_fx.lightness += 10
+ elif event.keystring == 'k':
+ self.hsl_fx.lightness -= 10
+ elif event.keystring == 'h':
+ self.hsl_fx.hue += 10
+ elif event.keystring == 'g':
+ self.hsl_fx.hue -= 10
+ elif event.keystring == 'c':
+ self.hsl_fx.colorize = not(self.hsl_fx.colorize)
+ self.sat.text = "Sat: " + str(self.hsl_fx.saturation)
+ self.light.text = "Bright: " + str(self.hsl_fx.lightness)
+ self.colorize.text = "Colorized: " + str(self.hsl_fx.colorize)
+ self.hue.text = "Hue: " + str(self.hsl_fx.hue)
+
+ def _increaseHue(self):
+ self.hsl_fx.hue += 1
+ self.hue.text = "Hue: " + str(self.hsl_fx.hue)
+
+if __name__ == '__main__':
+ HSL.start(resolution=(1000,800),debugWindowSize=(800,600))
+
diff --git a/src/samples/invertfx.py b/src/samples/invertfx.py
new file mode 100644
index 0000000..40d2ae6
--- /dev/null
+++ b/src/samples/invertfx.py
@@ -0,0 +1,42 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+
+from libavg import avg, AVGApp
+from libavg.avg import ImageNode
+
+g_Player = avg.Player.get()
+
+class INVERT(AVGApp):
+
+ multiTouch = False
+
+ def init(self):
+ rootNode = g_Player.getRootNode()
+
+ orig = ImageNode(parent = rootNode, href='../graphics/testfiles/hsl.png')
+ invert = ImageNode(parent = rootNode, href='../graphics/testfiles/hsl.png',
+ pos=(orig.size.x+10, 0))
+ invert.setEffect(avg.InvertFXNode())
+
+if __name__ == '__main__':
+ INVERT.start(resolution=(200,200),debugWindowSize=(200,200))
+
diff --git a/src/samples/localcoords.avg b/src/samples/localcoords.avg
new file mode 100644
index 0000000..bea628c
--- /dev/null
+++ b/src/samples/localcoords.avg
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<avg width="160" height="120">
+ <div pos="(40, 30)">
+ <image href="rgb24-64x64.png" pos="(40, 30)" size="(80, 60)"/>
+ </div>
+</avg>
+
diff --git a/src/samples/localcoordsrot.avg b/src/samples/localcoordsrot.avg
new file mode 100644
index 0000000..69a6564
--- /dev/null
+++ b/src/samples/localcoordsrot.avg
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<avg width="160" height="120">
+ <div pos="(120, 30)" pivot="(0,0)" angle="1.570">
+ <image href="rgb24-64x64.png" pos="(40, 30)" size="(40, 30)"/>
+ </div>
+</avg>
+
diff --git a/src/samples/mesh.py b/src/samples/mesh.py
new file mode 100755
index 0000000..8ea8d03
--- /dev/null
+++ b/src/samples/mesh.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+player = avg.Player.get()
+
+player.loadString("""
+<avg width="160" height="120"/>
+""")
+mesh = avg.MeshNode(texhref="rgb24-64x64.png",
+ vertexcoords=((0,0), (64,0), (0,64), (64, 64), (32, 32)),
+ texcoords=((0,0), (1,0), (0,1), (1,1), (0.5,0.5)),
+ triangles=((0,1,4), (1,3,4), (3,2,4), (2,0,4)))
+player.getRootNode().appendChild(mesh)
+player.setResolution(0,640,0,0)
+player.play()
+
diff --git a/src/samples/minimal.py b/src/samples/minimal.py
new file mode 100755
index 0000000..971de97
--- /dev/null
+++ b/src/samples/minimal.py
@@ -0,0 +1,8 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+player = avg.Player.get()
+player.loadFile("text.avg")
+player.play()
diff --git a/src/samples/mpeg1-48x48-sound.avi b/src/samples/mpeg1-48x48-sound.avi
new file mode 100644
index 0000000..be415db
--- /dev/null
+++ b/src/samples/mpeg1-48x48-sound.avi
Binary files differ
diff --git a/src/samples/plugin.py b/src/samples/plugin.py
new file mode 100755
index 0000000..0d5084e
--- /dev/null
+++ b/src/samples/plugin.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+player = avg.Player.get()
+
+player.loadString("""<avg width="160" height="120" id="container" />""")
+# Change following line if the plugin is somewhere else.
+player.pluginPath = "../test/plugin/.libs"
+player.loadPlugin("libColorNode")
+
+node = player.createNode('<colornode fillcolor="0f3f7f" id="mynode" />')
+player.getElementByID("container").appendChild(node)
+mynode = player.getElementByID("mynode")
+mynode.fillcolor = "7f007f"
+player.play()
diff --git a/src/samples/rgb24-64x64.png b/src/samples/rgb24-64x64.png
new file mode 100644
index 0000000..cca71fe
--- /dev/null
+++ b/src/samples/rgb24-64x64.png
Binary files differ
diff --git a/src/samples/rotcustompivot.avg b/src/samples/rotcustompivot.avg
new file mode 100644
index 0000000..62cf9db
--- /dev/null
+++ b/src/samples/rotcustompivot.avg
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<avg width="160" height="120">
+ <image href="rgb24-64x64.png" pos="(80, 30)" size="(40, 30)" angle="1.570" pivot="(0,0)"/>
+</avg>
+
diff --git a/src/samples/rotdefaultpivot.avg b/src/samples/rotdefaultpivot.avg
new file mode 100644
index 0000000..3e802cc
--- /dev/null
+++ b/src/samples/rotdefaultpivot.avg
@@ -0,0 +1,5 @@
+<?xml version="1.0"?>
+<avg width="160" height="120">
+ <image href="rgb24-64x64.png" pos="(40, 30)" size="(80, 60)" angle="1.570"/>
+</avg>
+
diff --git a/src/samples/sampleapp.py b/src/samples/sampleapp.py
new file mode 100755
index 0000000..fb7af6a
--- /dev/null
+++ b/src/samples/sampleapp.py
@@ -0,0 +1,29 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg, AVGApp, utils, anim
+from libavg.utils import getMediaDir
+
+# usually you need the Player in many places, so it's useful
+# to keep it in a global variable (it's a singleton anyway).
+g_Player = avg.Player.get()
+
+class HelloWorld(AVGApp):
+ def init(self):
+ # Put all your nodes in the hierarchy below self._parentNode
+ self.node = avg.WordsNode(pos=(50,50), text="Hello World",
+ parent=self._parentNode)
+
+ def _enter(self):
+ # You should start and stop all animations, intervals etc.
+ # in _enter and _leave, so your application uses only
+ # minimal resources while it is not running.
+ self.anim = anim.ContinuousAnim(self.node, 'angle', 0, 3.14)
+ self.anim.start()
+
+ def _leave(self):
+ self.anim.abort()
+ self.anim = None
+
+HelloWorld.start(resolution=(640, 480))
+
diff --git a/src/samples/showvideo.py b/src/samples/showvideo.py
new file mode 100755
index 0000000..126deec
--- /dev/null
+++ b/src/samples/showvideo.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import *
+import sys
+
+g_Player = avg.Player.get()
+
+class VideoApp(AVGApp):
+ def init(self):
+ self.videoNode = VideoNode(
+ href=sys.argv[1],
+ parent=self._parentNode)
+ self.videoNode.play()
+
+VideoApp.start(resolution=(1920, 1080), debugWindowSize=(720, 450))
diff --git a/src/samples/text.avg b/src/samples/text.avg
new file mode 100644
index 0000000..270d904
--- /dev/null
+++ b/src/samples/text.avg
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<avg width="640" height="480">
+ <words id="HelloText" x="10" y="10" font="arial" text="Hello World"/>
+</avg>
diff --git a/src/samples/timer.py b/src/samples/timer.py
new file mode 100755
index 0000000..7c87910
--- /dev/null
+++ b/src/samples/timer.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+def moveText():
+ node = player.getElementByID("HelloText")
+ node.x = 200
+
+player = avg.Player.get()
+
+player.loadFile("text.avg")
+player.setTimeout(1000, moveText)
+
+player.play()
+
diff --git a/src/samples/timer2.py b/src/samples/timer2.py
new file mode 100755
index 0000000..9533e81
--- /dev/null
+++ b/src/samples/timer2.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+def moveText():
+ node = player.getElementByID("HelloText")
+ if node.x < 200:
+ node.x += 1
+
+player = avg.Player.get()
+
+player.loadFile("text.avg")
+player.setOnFrameHandler(moveText)
+
+player.setVBlankFramerate(1)
+player.play()
+
diff --git a/src/samples/timer3.py b/src/samples/timer3.py
new file mode 100755
index 0000000..9983685
--- /dev/null
+++ b/src/samples/timer3.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+def moveText():
+ node = player.getElementByID("HelloText")
+ if node.x < 200:
+ node.x += 20
+
+player = avg.Player.get()
+
+player.loadFile("text.avg")
+player.setInterval(200, moveText)
+
+player.play()
+
diff --git a/src/samples/twovideos.py b/src/samples/twovideos.py
new file mode 100755
index 0000000..a7cc58c
--- /dev/null
+++ b/src/samples/twovideos.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import *
+import sys
+
+g_Player = avg.Player.get()
+
+FADE_DURATION = 2000
+
+class HDVideoApp(AVGApp):
+ def init(self):
+ self.videoNodes = []
+ for fileName in (sys.argv[1], sys.argv[2]):
+ videoNode = VideoNode(
+ size=(1440, 810),
+ href=fileName,
+ opacity=0,
+ parent=self._parentNode)
+ videoNode.play()
+ self.videoNodes.append(videoNode)
+
+ self.videoNodes[0].opacity = 1
+ self.runningVideo = 0
+ self.isFading = False
+
+ def onKeyDown(self, event):
+ if event.keystring == '1':
+ if not(self.isFading):
+ if self.runningVideo == 0:
+ fadeIn(self.videoNodes[1], FADE_DURATION)
+ else:
+ fadeOut(self.videoNodes[1], FADE_DURATION)
+ g_Player.setTimeout(FADE_DURATION, self.fadeEnd)
+ self.runningVideo = (self.runningVideo+1)%2
+ self.isFading = True
+ return True
+ else:
+ return False
+
+ def fadeEnd(self):
+ self.isFading = False
+
+HDVideoApp.start(resolution=(1440, 900), debugWindowSize=(720, 450))
diff --git a/src/samples/video.py b/src/samples/video.py
new file mode 100755
index 0000000..7438d31
--- /dev/null
+++ b/src/samples/video.py
@@ -0,0 +1,11 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import avg
+
+player = avg.Player.get()
+player.loadString("""<avg size="(160,120)"/>""")
+videoNode = avg.VideoNode(href="mpeg1-48x48-sound.avi", pos=(10,10),
+ parent=player.getRootNode())
+videoNode.play()
+player.play()
diff --git a/src/samples/videochooser.py b/src/samples/videochooser.py
new file mode 100755
index 0000000..084bf08
--- /dev/null
+++ b/src/samples/videochooser.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+from libavg import *
+import os, sys
+
+g_Player = avg.Player.get()
+
+THUMBNAIL_WIDTH = 320
+FADE_DURATION = 1000
+
+class VideoChooserApp(AVGApp):
+ def init(self):
+ g_Player.showCursor(True)
+ dir = sys.argv[1]
+
+ self.videoListNode = DivNode(parent=self._parentNode)
+ self.videoNodes=[]
+ fileNames=os.listdir(dir)
+ i = 0
+ for fileName in fileNames:
+ try:
+ videoNode = VideoNode(
+ pos = (i*(THUMBNAIL_WIDTH+20), 0),
+ href=dir+"/"+fileName,
+ loop=True,
+ parent=self.videoListNode)
+ videoNode.play()
+ self.videoNodes.append(videoNode)
+
+ size = videoNode.getMediaSize()
+ height = (THUMBNAIL_WIDTH*size.y)/size.x
+ videoNode.size = (THUMBNAIL_WIDTH, height)
+
+ videoNode.setEventHandler(avg.CURSORDOWN, avg.MOUSE,
+ lambda event, videoNode=videoNode:
+ self.chooseVideo(event, videoNode))
+ i += 1
+ except RuntimeError:
+ pass
+
+ self._parentNode.setEventHandler(avg.CURSORMOTION, avg.MOUSE, self.onMouseMove)
+ self.bigVideoNode = None
+
+ def onMouseMove(self, event):
+ windowWidth = g_Player.getRootNode().width
+ ratio = event.x/float(windowWidth)
+ self.videoListNode.x = -(ratio*(self.getTotalWidth()-windowWidth))
+
+ def chooseVideo(self, event, videoNode):
+ if self.bigVideoNode:
+ self.removeBigVideo()
+ destSize = videoNode.size*2
+ destPos = Point2D(720, 550)-destSize/2
+ absPos = videoNode.getAbsPos(Point2D(0,0))
+ frame = videoNode.getCurFrame()
+ self.bigVideoNode = VideoNode(href=videoNode.href, loop=True,
+ parent=self._parentNode)
+ self.bigVideoNode.play()
+ self.bigVideoNode.seekToFrame(frame)
+ EaseInOutAnim(self.bigVideoNode, "pos", 1000, absPos, destPos, False,
+ 300, 300).start()
+ EaseInOutAnim(self.bigVideoNode, "size", 1000, videoNode.size, destSize, False,
+ 300, 300).start()
+
+ def removeBigVideo(self):
+ oldVideoNode = self.bigVideoNode
+ fadeOut(oldVideoNode, FADE_DURATION, lambda: oldVideoNode.unlink(True))
+
+ def getTotalWidth(self):
+ return (THUMBNAIL_WIDTH+20)*len(self.videoNodes)
+
+VideoChooserApp.start(resolution=(1440, 900), debugWindowSize=(720, 450))
+
diff --git a/src/samples/words1.avg b/src/samples/words1.avg
new file mode 100644
index 0000000..8d003fe
--- /dev/null
+++ b/src/samples/words1.avg
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<avg width="320" height="240">
+ <words x="10" y="10" text="Apples and Oranges" font="Arial" variant="Bold"
+ fontsize="18" color="CF8000"/>
+</avg>
+
diff --git a/src/samples/words2.avg b/src/samples/words2.avg
new file mode 100644
index 0000000..051d95a
--- /dev/null
+++ b/src/samples/words2.avg
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<avg width="320" height="240">
+ <words x="10" y="10" text="The quick brown fox jumped over the lazy dog."
+ font="Arial" variant="Bold" fontsize="18" color="CF8000"
+ width="170" linespacing="10" alignment="left" indent="10"/>
+</avg>
+
diff --git a/src/samples/wordspos.avg b/src/samples/wordspos.avg
new file mode 100644
index 0000000..4ca1efb
--- /dev/null
+++ b/src/samples/wordspos.avg
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<avg width="160" height="120">
+ <words pos="(10,10)" width="70">
+ <i>Left-justified paragraph.</i>
+ </words>
+ <words pos="(150, 10)" width="70" alignment="right"
+ text="Right-justified paragraph."/>
+ <words pos="(80, 80)" width="70" alignment="center"
+ text="Centered paragraph"/>
+</avg>
+
diff --git a/src/test/1x1_white.png b/src/test/1x1_white.png
new file mode 100644
index 0000000..5800230
--- /dev/null
+++ b/src/test/1x1_white.png
Binary files differ
diff --git a/src/test/AVGAppTest.py b/src/test/AVGAppTest.py
new file mode 100644
index 0000000..5c7ed1a
--- /dev/null
+++ b/src/test/AVGAppTest.py
@@ -0,0 +1,183 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import os
+import time
+
+import libavg
+from libavg import avg, Point2D
+import testcase
+
+g_Player = avg.Player.get()
+g_helper = g_Player.getTestHelper()
+
+TEST_RESOLUTION = (160, 120)
+
+class TestAppBase(libavg.AVGApp):
+ def requestStop(self, timeout=0):
+ g_Player.setTimeout(timeout, g_Player.stop)
+
+ def singleKeyPress(self, char):
+ g_helper.fakeKeyEvent(avg.KEYDOWN, ord(char), ord(char), char, ord(char),
+ avg.KEYMOD_NONE)
+ g_helper.fakeKeyEvent(avg.KEYUP, ord(char), ord(char), char, ord(char),
+ avg.KEYMOD_NONE)
+
+
+class AVGAppTestCase(testcase.AVGTestCase):
+ def testMinimal(self):
+ class MinimalApp(TestAppBase):
+ testInstance = self
+ def init(self):
+ self.testInstance.assert_(not g_Player.isFullscreen())
+ self.requestStop()
+
+ if 'AVG_DEPLOY' in os.environ:
+ del os.environ['AVG_DEPLOY']
+ MinimalApp.start(resolution=TEST_RESOLUTION)
+
+ def testAvgDeploy(self):
+ class FullscreenApp(TestAppBase):
+ testInstance = self
+ def init(self):
+ self.testInstance.assert_(g_Player.isFullscreen())
+ rootNodeSize = g_Player.getRootNode().size
+ self.testInstance.assertEqual(rootNodeSize, resolution)
+ self.requestStop()
+
+ resolution = g_Player.getScreenResolution()
+ os.environ['AVG_DEPLOY'] = '1'
+ FullscreenApp.start(resolution=resolution)
+ del os.environ['AVG_DEPLOY']
+
+ def testDebugWindowSize(self):
+ class DebugwindowApp(TestAppBase):
+ testInstance = self
+ def init(self):
+ self.testInstance.assert_(not g_Player.isFullscreen())
+ rootNodeSize = g_Player.getRootNode().size
+ self.testInstance.assertEqual(rootNodeSize, TEST_RESOLUTION)
+
+ # windowSize = g_Player.getWindowResolution()
+ # self.testInstance.assertEqual(windowSize, Point2D(TEST_RESOLUTION)/2)
+ self.requestStop()
+
+ DebugwindowApp.start(resolution=TEST_RESOLUTION,
+ debugWindowSize=Point2D(TEST_RESOLUTION) / 2)
+
+ def testScreenshot(self):
+ if not(self._isCurrentDirWriteable()):
+ self.skip("Current dir not writeable")
+ return
+
+ expectedFiles = ['screenshot-000.png', 'screenshot-001.png']
+
+ def cleanup():
+ for screenshotFile in expectedFiles[::-1]:
+ if os.path.exists(screenshotFile):
+ os.unlink(screenshotFile)
+
+ def checkCallback():
+ for screenshotFile in expectedFiles[::-1]:
+ if os.path.exists(screenshotFile):
+ avg.Bitmap(screenshotFile)
+ else:
+ raise RuntimeError('Cannot find the expected '
+ 'screenshot file %s' % screenshotFile)
+
+ g_Player.stop()
+
+ class ScreenshotApp(TestAppBase):
+ def init(self):
+ self.singleKeyPress('s')
+ self.singleKeyPress('s')
+ self.timeStarted = time.time()
+ self.timerId = g_Player.setOnFrameHandler(self.onFrame)
+
+ def onFrame(self):
+ if (os.path.exists(expectedFiles[-1]) or
+ time.time() - self.timeStarted > 1):
+ g_Player.clearInterval(self.timerId)
+ checkCallback()
+
+ cleanup()
+ ScreenshotApp.start(resolution=TEST_RESOLUTION)
+ cleanup()
+
+ def testGraphs(self):
+ class GraphsApp(TestAppBase):
+ def init(self):
+ self.enableGraphs()
+
+ def enableGraphs(self):
+ self.singleKeyPress('f')
+ self.singleKeyPress('m')
+ g_Player.setTimeout(500, self.disableGraphs)
+
+ def disableGraphs(self):
+ self.singleKeyPress('m')
+ self.singleKeyPress('f')
+ self.requestStop()
+
+ GraphsApp.start(resolution=TEST_RESOLUTION)
+
+ def testToggleKeys(self):
+ TOGGLE_KEYS = ['?', 't', 'e']
+ class ToggleKeysApp(TestAppBase):
+ def init(self):
+ self.keys = TOGGLE_KEYS[:]
+ g_Player.setTimeout(0, self.nextKey)
+
+ def nextKey(self):
+ if not self.keys:
+ g_Player.stop()
+ else:
+ key = self.keys.pop()
+ self.singleKeyPress(key)
+ g_Player.setTimeout(0, self.nextKey)
+
+ ToggleKeysApp.start(resolution=TEST_RESOLUTION)
+
+ def testFakeFullscreen(self):
+ class FakeFullscreenApp(TestAppBase):
+ fakeFullscreen = True
+ def init(self):
+ g_Player.setTimeout(0, g_Player.stop)
+
+ resolution = g_Player.getScreenResolution()
+ if os.name == 'nt':
+ FakeFullscreenApp.start(resolution=resolution)
+ else:
+ self.assertException(
+ lambda: FakeFullscreenApp.start(resolution=resolution))
+
+def avgAppTestSuite(tests):
+ availableTests = (
+ 'testMinimal',
+ 'testAvgDeploy',
+ 'testDebugWindowSize',
+ 'testScreenshot',
+ 'testGraphs',
+ 'testToggleKeys',
+ 'testFakeFullscreen',
+ )
+ return testcase.createAVGTestSuite(availableTests, AVGAppTestCase, tests)
diff --git a/src/test/AVTest.py b/src/test/AVTest.py
new file mode 100644
index 0000000..bc4e752
--- /dev/null
+++ b/src/test/AVTest.py
@@ -0,0 +1,621 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg
+from testcase import *
+
+class AVTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def setUp(self):
+ AVGTestCase.setUp(self)
+
+ def testEOF(self, node):
+ def onEOF():
+ Player.stop()
+
+ def onNoEOF():
+ self.fail("No EOF")
+
+ root = self.loadEmptyScene()
+ root.appendChild(node)
+ node.play()
+ node.setEOFCallback(onEOF)
+ Player.setTimeout(100000, onNoEOF)
+ Player.play()
+
+ def testVideoInfo(self):
+ def checkInfo():
+ node.pause()
+ self.assertEqual(node.getCurFrame(), 0)
+ self.assertEqual(node.getCurTime(), 0)
+ self.assertEqual(node.getDuration(), 1000)
+ self.assertEqual(node.getBitrate(), 224064)
+ self.assertEqual(node.getVideoCodec(), "mpeg4")
+ self.assertEqual(node.getStreamPixelFormat(), "yuv420p")
+ if isThreaded:
+ self.assertEqual(node.getAudioCodec(), "mp2")
+ self.assertEqual(node.getAudioSampleRate(), 44100)
+ self.assertEqual(node.getNumAudioChannels(), 2)
+
+ def checkExceptions():
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg",
+ threaded=isThreaded)
+ self.assertException(node.getDuration)
+ self.assertException(node.getBitrate)
+ self.assertException(node.getVideoCodec)
+ self.assertException(node.getStreamPixelFormat)
+ node.pause()
+ self.assertException(node.getAudioCodec)
+ self.assertException(node.getAudioSampleRate)
+ self.assertException(node.getNumAudioChannels)
+ root.appendChild(node)
+
+ def checkAudioFile():
+ node = avg.VideoNode(href="../video/testfiles/44.1kHz_16bit_stereo.wav",
+ threaded=isThreaded, parent=root)
+ self.assertException(node.pause)
+
+ for isThreaded in (False, True):
+ root = self.loadEmptyScene()
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48-sound.avi",
+ threaded=isThreaded, parent=root)
+ checkInfo()
+ checkExceptions()
+ self.start((
+ checkInfo,
+ checkExceptions,
+ checkAudioFile,
+ ))
+ root = self.loadEmptyScene()
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48-sound.avi",
+ queuelength=23, parent=root)
+ self.assertEqual(node.queuelength, 23)
+
+ def testVideoFiles(self):
+ def testVideoFile(filename, isThreaded):
+ def setVolume(volume):
+ node.volume = volume
+
+ def testGetVolume(volume):
+ self.assertEqual(node.volume, volume)
+
+ def checkImage(filename):
+ if not(isThreaded):
+ self.compareImage("testVideo-"+filename+"1", False)
+
+ def testInfo():
+ if filename == "mpeg1-48x48-sound.avi" and isThreaded:
+ self.assert_(node.hasAudio())
+ else:
+ self.assert_(not(node.hasAudio()))
+ self.assert_((filename == "rgba-48x48.mov" or
+ filename == "vp6a-yuva-48x48.flv") == node.hasAlpha())
+
+ root = self.loadEmptyScene()
+ node = avg.VideoNode(href="../video/testfiles/"+filename, volume=0.8,
+ size=(96,96), threaded=isThreaded)
+ self.assertEqual(node.threaded, isThreaded)
+ setVolume(0.6)
+ root.appendChild(node)
+ self.assertException(node.hasAudio)
+ self.start((
+ lambda: setVolume(0.5),
+ lambda: testGetVolume(0.5),
+ lambda: node.play(),
+ lambda: checkImage(filename),
+ lambda: setVolume(0.3),
+ lambda: testGetVolume(0.3),
+ testInfo,
+ lambda: node.stop()
+ ))
+ videoFiles = ["mjpeg-48x48.avi", "mpeg1-48x48.mpg", "mpeg1-48x48-sound.avi",
+ "rgba-48x48.mov", "h264-48x48.h264", "vp6a-yuva-48x48.flv"]
+ print
+ for filename in videoFiles:
+ print " " + filename
+ for isThreaded in [False, True]:
+ print " threaded: ", isThreaded
+ testVideoFile(filename, isThreaded)
+
+ def testPlayBeforeConnect(self):
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg", threaded=False)
+ node.play()
+ root = self.loadEmptyScene()
+ root.insertChild(node, 0)
+ Player.setFakeFPS(25)
+ self.start((
+ lambda: self.assertEqual(node.size, (48, 48)),
+ lambda: self.compareImage("testPlayBeforeConnect", False),
+ ))
+
+ def testVideoState(self):
+ for accelerated in [True, False]:
+ root = self.loadEmptyScene()
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg", size=(96,96),
+ threaded=False, accelerated=accelerated, parent=root)
+ Player.setFakeFPS(25)
+ self.start((
+ lambda: node.play(),
+ lambda: self.compareImage("testVideoState1", False),
+ lambda: node.pause(),
+ lambda: self.compareImage("testVideoState2", False),
+ lambda: self.compareImage("testVideoState2", False),
+ lambda: node.play(),
+ lambda: self.compareImage("testVideoState3", False),
+ lambda: node.stop(),
+ lambda: self.compareImage("testVideoState4", False),
+ lambda: node.pause(),
+ lambda: self.compareImage("testVideoState5", False),
+ lambda: self.compareImage("testVideoState5", False),
+ lambda: node.stop(),
+ lambda: self.compareImage("testVideoState4", False),
+ ))
+
+ def testVideoActive(self):
+ def deactivate():
+ node.active=0
+
+ def activate():
+ node.active=1
+
+ root = self.loadEmptyScene()
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg", size=(96,96),
+ threaded=False, parent=root)
+ Player.setFakeFPS(25)
+ self.start((
+ lambda: node.play(),
+ deactivate,
+ lambda: self.compareImage("testVideoActive1", False),
+ activate,
+ lambda: self.compareImage("testVideoActive2", False)
+ ))
+
+ def testVideoHRef(self):
+ def testGetMediaSize():
+ self.assertEqual(node.getMediaSize(), (48, 48))
+
+ def setHRefLoaded():
+ node.href = "../video/testfiles/h264-48x48.h264"
+
+ def setHRefUnloaded():
+ node = avg.VideoNode()
+ node.href = "../video/testfiles/h264-48x48.h264"
+ node.play()
+
+ def testVideoNotFound():
+ # Missing file, but no play() or pause(): Should just work.
+ node = avg.VideoNode(href="MissingFile.mov")
+ node.href = "SecondMissingFile.mov"
+ # Now libavg notices the missing file.
+ self.assertException(node.play)
+
+ root = self.loadEmptyScene()
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg", threaded=False,
+ parent=root)
+ Player.setFakeFPS(25)
+ testVideoNotFound()
+ setHRefUnloaded()
+ self.start((
+ lambda: node.play(),
+ testGetMediaSize,
+ setHRefLoaded,
+ lambda: self.compareImage("testVideoHRef1", False),
+ testGetMediaSize,
+ testVideoNotFound
+ ))
+
+ def testVideoOpacity(self):
+ def testWithFile(filename, testImgName):
+ def hide():
+ self.videoNode.opacity=0
+
+ def show():
+ self.videoNode.opacity=1
+
+ Player.setFakeFPS(25)
+ root = self.loadEmptyScene()
+ self.videoNode = avg.VideoNode(href=filename, loop=True, threaded=False,
+ parent=root)
+ self.start((
+ lambda: self.videoNode.play(),
+ None,
+ lambda: self.compareImage(testImgName+"1", False),
+ hide,
+ None,
+ None,
+ show,
+ lambda: self.compareImage(testImgName+"2", False)
+ ))
+ testWithFile("../video/testfiles/rgba-48x48.mov", "testVideoOpacityRGBA")
+ testWithFile("../video/testfiles/mpeg1-48x48.mpg", "testVideoOpacityYUV")
+
+ def testVideoSeek(self):
+ def seek(frame):
+ videoNode.seekToFrame(frame)
+
+ def checkCurFrame():
+ self.assertEqual(videoNode.getCurFrame(), 26)
+
+ Player.setFakeFPS(25)
+ for useCustomFPS in [False, True]:
+ root = self.loadEmptyScene()
+ if useCustomFPS:
+ videoNode = avg.VideoNode(parent=root, loop=True, size=(96,96), fps=25,
+ threaded=False, href="../video/testfiles/mjpeg-48x48.avi")
+ else:
+ videoNode = avg.VideoNode(parent=root, loop=True, size=(96,96),
+ threaded=False, href="../video/testfiles/mjpeg-48x48.avi")
+
+ videoNode.play()
+ seek(26)
+ self.start((
+ checkCurFrame,
+ lambda: self.compareImage("testVideoSeek0", False),
+ lambda: seek(100),
+ lambda: self.compareImage("testVideoSeek1", False),
+ lambda: videoNode.pause(),
+ lambda: seek(26),
+ None,
+ lambda: self.compareImage("testVideoSeek2", False),
+ lambda: videoNode.play(),
+ None,
+ lambda: self.compareImage("testVideoSeek3", False)
+ ))
+
+ def checkSeek():
+ seek(26)
+ self.assertNotEqual(videoNode.getCurFrame(), 0)
+
+ root = self.loadEmptyScene()
+ videoNode = avg.VideoNode(parent=root, loop=True, fps=25,
+ href="../video/testfiles/mjpeg-48x48.avi")
+ videoNode.play()
+ seek(5)
+ self.start((checkSeek,))
+
+ def testVideoFPS(self):
+ Player.setFakeFPS(25)
+ root = self.loadEmptyScene()
+ root = root
+ videoNode = avg.VideoNode(size=(80,80), loop=True, threaded=False,
+ href="../video/testfiles/mjpeg-48x48.avi", fps=250, parent=root)
+ self.start((
+ lambda: videoNode.play(),
+ None,
+ lambda: self.compareImage("testVideoFPS", False)
+ ))
+
+ def testVideoLoop(self):
+ def onEOF():
+ self.eof = True
+
+ def onFrame():
+ if self.eof:
+ if not(threaded):
+ self.compareImage("testVideoLoop", False)
+ Player.stop()
+
+ for threaded in [False, True]:
+ self.eof = False
+ Player.setFakeFPS(25)
+ root = self.loadEmptyScene()
+ videoNode = avg.VideoNode(parent=root, loop=True, fps=25, size=(96,96),
+ threaded=threaded, href="../video/testfiles/mpeg1-48x48.mpg")
+ videoNode.setEOFCallback(onEOF)
+ videoNode.play()
+ Player.setOnFrameHandler(onFrame)
+ Player.play()
+
+ def testVideoMask(self):
+ def testWithFile(filename, testImgName):
+ def setMask(href):
+ video.maskhref = href
+
+ def setOpacity():
+ video.opacity = 0.5
+
+ Player.setFakeFPS(25)
+ root = self.loadEmptyScene()
+ video = avg.VideoNode(href=filename, threaded=False,
+ parent=root)
+ video.play()
+ self.start([
+ lambda: setMask("mask.png"),
+ lambda: self.compareImage(testImgName+"1", False),
+ lambda: video.seekToFrame(10),
+ lambda: setMask(""),
+ lambda: self.compareImage(testImgName+"2", False),
+ lambda: setMask("mask2.png"),
+ lambda: self.compareImage(testImgName+"3", False),
+ setOpacity,
+ lambda: self.compareImage(testImgName+"4", False),
+ ])
+
+ if not(self._hasShaderSupport()):
+ return
+
+ testWithFile("../video/testfiles/mpeg1-48x48.mpg", "testVideoMaskYUV")
+ testWithFile("../video/testfiles/mjpeg-48x48.avi", "testVideoMaskYUVJ")
+ testWithFile("../video/testfiles/rgba-48x48.mov", "testVideoMaskRGBA")
+
+ def testException(self):
+ class TestException(Exception):
+ pass
+
+ def throwException():
+ raise TestException
+
+ Player.setFakeFPS(0.1)
+ videoNode = avg.VideoNode(threaded = False)
+ videoNode.href = "./testmediadir/mjpeg-48x48.avi"
+ videoNode.setEOFCallback(throwException)
+
+ root = self.loadEmptyScene()
+ avg.Player.get().getRootNode().appendChild(videoNode)
+
+ self.__exceptionThrown = False
+ try:
+ self.start((
+ videoNode.pause,
+ lambda: videoNode.seekToFrame(videoNode.getNumFrames()),
+ videoNode.play,
+ lambda: None))
+ except TestException:
+ self.__exceptionThrown = True
+
+ self.assert_(self.__exceptionThrown)
+
+ def testVideoEOF(self):
+ Player.setFakeFPS(25)
+ for filename in ["mpeg1-48x48.mpg", "mpeg1-48x48-sound.avi"]:
+ node = avg.VideoNode(href="../video/testfiles/"+filename)
+ self.testEOF(node)
+ node = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg", opacity=0)
+ self.testEOF(node)
+
+ root = self.loadEmptyScene()
+ video = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg", threaded=False,
+ parent=root)
+ Player.setFakeFPS(0.1)
+
+ video.setEOFCallback(lambda: foo) # Should never be called
+ self.start([
+ lambda: video.setEOFCallback(None),
+ video.play,
+ None
+ ])
+
+
+ def testSound(self):
+ def testSoundFile(filename):
+ def setVolume(volume):
+ node.volume = volume
+
+ def testGetVolume(volume):
+ self.assertEqual(node.volume, volume)
+
+ root = self.loadEmptyScene()
+ node = avg.SoundNode(href="../video/testfiles/"+filename,
+ parent=root)
+ self.start((
+ lambda: setVolume(0.5),
+ lambda: testGetVolume(0.5),
+ lambda: node.play(),
+ None,
+ lambda: node.stop(),
+ lambda: node.play(),
+ lambda: node.pause(),
+ lambda: node.play(),
+ lambda: setVolume(0.5),
+ lambda: testGetVolume(0.5),
+ lambda: node.pause(),
+ lambda: node.stop(),
+ lambda: setVolume(0.3),
+ lambda: testGetVolume(0.3),
+ lambda: node.pause()
+ ))
+ Player.setFakeFPS(-1)
+ Player.volume = 0
+ for filename in ["22.050Hz_16bit_mono.wav", "44.1kHz_16bit_stereo.aif",
+ "44.1kHz_16bit_stereo.wav", "44.1kHz_mono.ogg", "44.1kHz_stereo.mp3",
+ "48kHz_24bit_stereo.wav"]:
+ testSoundFile(filename)
+
+ def testSoundInfo(self):
+ def checkInfo():
+ node.pause()
+ self.assertEqual(node.getAudioCodec(), "pcm_s16le")
+ self.assertEqual(node.getAudioSampleRate(), 44100)
+ self.assertEqual(node.getNumAudioChannels(), 2)
+
+ def checkExceptions():
+ node = avg.SoundNode(href="../video/testfiles/44.1kHz_16bit_stereo.wav")
+ self.assertException(node.getAudioCodec)
+ self.assertException(node.getAudioSampleRate)
+ self.assertException(node.getNumAudioChannels)
+
+ def checkVideoFile():
+ node = avg.SoundNode(href="../video/testfiles/mpeg1-48x48.mpg",
+ parent=root)
+ self.assertException(node.pause)
+
+ root = self.loadEmptyScene()
+ node = avg.SoundNode(href="../video/testfiles/44.1kHz_16bit_stereo.wav",
+ parent=root)
+ checkInfo()
+ checkExceptions()
+ self.start((
+ checkInfo,
+ checkExceptions,
+ checkVideoFile,
+ ))
+
+ def testBrokenSound(self):
+ def openSound():
+ node = avg.SoundNode(href="../video/testfiles/44.1kHz_16bit_6Chan.ogg",
+ parent=root)
+ self.assertException(node.play)
+
+ root = self.loadEmptyScene()
+ self.start([openSound])
+
+ def testSoundEOF(self):
+ Player.setFakeFPS(-1)
+ Player.volume = 0
+ node = avg.SoundNode(href="../video/testfiles/44.1kHz_16bit_mono.wav")
+ self.testEOF(node)
+
+ def testVideoWriter(self):
+
+ def startWriter(fps, syncToPlayback):
+ self.videoWriter = avg.VideoWriter(canvas, "test.mov", fps, 3, 5,
+ syncToPlayback)
+
+ def stopWriter():
+ self.videoWriter.stop()
+
+ def killWriter():
+ self.videoWriter = None
+
+ def pauseWriter():
+ self.videoWriter.pause()
+
+ def playWriter():
+ self.videoWriter.play()
+
+ def hideVideo():
+ videoNode.opacity = 0
+
+ def showVideo():
+ videoNode.opacity = 1
+
+ def checkVideo(numFrames):
+ savedVideoNode = avg.VideoNode(href="test.mov", pos=(48,0), threaded=False,
+ parent=root)
+ savedVideoNode.pause()
+ self.assertEqual(savedVideoNode.getVideoCodec(), "mjpeg")
+ self.assertEqual(savedVideoNode.getNumFrames(), numFrames)
+ self.assertEqual(savedVideoNode.getStreamPixelFormat(), "yuvj420p")
+
+ def testCreateException():
+ self.assertException(lambda: avg.VideoWriter(Player.getMainCanvas(),
+ "nonexistentdir/test.mov", 30))
+
+ if not(self._isCurrentDirWriteable()):
+ self.skip("Current dir not writeable")
+ return
+
+ for useCanvas in (False, True):
+ Player.setFakeFPS(30)
+
+ root = self.loadEmptyScene()
+ videoNode = avg.VideoNode(href="../video/testfiles/mpeg1-48x48.mpg",
+ threaded=False)
+ if useCanvas:
+ canvas = Player.createCanvas(id="canvas", size=(48,48))
+ canvas.getRootNode().appendChild(videoNode)
+ avg.ImageNode(parent=root, href="canvas:canvas")
+ testImageName = "testVideoWriterCanvas"
+ else:
+ root.appendChild(videoNode)
+ canvas = Player.getMainCanvas()
+ testImageName = "testVideoWriter"
+
+ self.start((
+ videoNode.play,
+ lambda: startWriter(30, True),
+ lambda: self.delay(66),
+ stopWriter,
+ killWriter,
+ lambda: checkVideo(4),
+ hideVideo,
+ lambda: self.compareImage(testImageName+"1", False),
+ showVideo,
+ testCreateException,
+ lambda: startWriter(15, False),
+ lambda: self.delay(100),
+ stopWriter,
+ killWriter,
+ lambda: checkVideo(2),
+ lambda: startWriter(30, False),
+ pauseWriter,
+ lambda: self.delay(200),
+ playWriter,
+ stopWriter,
+ killWriter,
+ lambda: checkVideo(1),
+ lambda: startWriter(30, False),
+ killWriter,
+ lambda: checkVideo(1),
+ ))
+ os.remove("test.mov")
+
+ def test2VideosAtOnce(self):
+ Player.setFakeFPS(25)
+ self.loadEmptyScene()
+ root = Player.getRootNode()
+ for pos in ((0,0), (80,0)):
+ video = avg.VideoNode(pos=pos, threaded=False,
+ href="../video/testfiles/mpeg1-48x48.mpg", parent=root)
+ video.play()
+ self.start([lambda: self.compareImage("test2VideosAtOnce1", False),])
+
+ def testVideoAccel(self):
+ accelConfig = avg.VideoNode.getVideoAccelConfig()
+ video = avg.VideoNode(threaded=False, accelerated=False,
+ href="../video/testfiles/mpeg1-48x48.mpg")
+ video.play()
+ self.assertEqual(video.accelerated, False)
+ video = avg.VideoNode(threaded=False, accelerated=True,
+ href="../video/testfiles/mpeg1-48x48.mpg")
+ video.play()
+ self.assertEqual(video.accelerated, (accelConfig != avg.NO_ACCELERATION))
+
+
+def AVTestSuite(tests):
+ availableTests = [
+ "testSound",
+ "testSoundInfo",
+ "testBrokenSound",
+ "testSoundEOF",
+ "testVideoInfo",
+ "testVideoFiles",
+ "testPlayBeforeConnect",
+ "testVideoState",
+ "testVideoActive",
+ "testVideoHRef",
+ "testVideoOpacity",
+ "testVideoSeek",
+ "testVideoFPS",
+ "testVideoLoop",
+ "testVideoMask",
+ "testVideoEOF",
+ "testException",
+ "testVideoWriter",
+ "test2VideosAtOnce",
+ "testVideoAccel",
+ ]
+ return createAVGTestSuite(availableTests, AVTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/AnimTest.py b/src/test/AnimTest.py
new file mode 100644
index 0000000..bdd80cc
--- /dev/null
+++ b/src/test/AnimTest.py
@@ -0,0 +1,431 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import unittest
+
+from libavg import avg
+from testcase import *
+
+class AnimTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def initScene(self):
+ root = self.loadEmptyScene()
+ self.__node = avg.ImageNode(id="test", pos=(64,30), href="rgb24-65x65.png",
+ parent=root)
+ Player.setFakeFPS(10)
+
+ def testAnimType(self, curAnim, imgBaseName):
+ def onStop():
+ self.__onStopCalled = True
+
+ def startAnim():
+ self.__onStopCalled = False
+ self.__anim.start()
+
+ def startKeepAttr():
+ self.__node.x = 32
+ self.__anim.start(True)
+
+ def abortAnim():
+ self.__anim.abort()
+
+ self.__anim = curAnim
+ self.__anim.setStopCallback(onStop)
+ self.__onStopCalled = False
+ self.assertException(lambda: self.__anim.start())
+ self.start((
+ startAnim,
+ lambda: self.compareImage(imgBaseName+"1", False),
+ lambda: self.compareImage(imgBaseName+"2", False),
+ lambda: self.compareImage(imgBaseName+"3", False),
+ lambda: self.assert_(self.__onStopCalled),
+ lambda: self.assert_(not(self.__anim.isRunning())),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0),
+ lambda: self.compareImage(imgBaseName+"4", False),
+ lambda: self.assertEqual(self.__node.x, 100),
+ startAnim,
+ lambda: self.compareImage(imgBaseName+"1", False),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 1),
+ abortAnim,
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0),
+ lambda: self.compareImage(imgBaseName+"5", False),
+ lambda: self.assert_(not(self.__anim.isRunning())),
+ None,
+ lambda: self.assert_(self.__onStopCalled),
+ startKeepAttr,
+ lambda: self.compareImage(imgBaseName+"6", False),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 1)
+ ))
+ self.__anim = None
+
+ def testLinearAnim(self):
+ self.initScene()
+ curAnim = avg.LinearAnim(self.__node, "x", 300, 0, 100)
+ self.testAnimType(curAnim, "testLinearAnimC")
+
+ def testAnimRegistry(self):
+ def on1Stop():
+ self.__onStopCalled = True
+
+ def on2Start():
+ self.__onStopBeforeOnStart = self.__onStopCalled
+
+ self.initScene()
+ sameNode = Player.getElementByID("test")
+ anim1 = avg.LinearAnim(self.__node, "x", 500, 0, 100,
+ False, None, on1Stop)
+ anim2 = avg.LinearAnim(sameNode, "x", 300, 0, 100,
+ False, on2Start)
+ self.__onStopCalled = False
+ self.__onStopBeforeOnStart = False
+ self.start((
+ lambda: anim1.start(),
+ lambda: self.assert_(not(self.__onStopCalled)),
+ lambda: anim2.start(),
+ lambda: self.assert_(self.__onStopBeforeOnStart),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 1)
+ ))
+ anim1 = None
+ anim2 = None
+
+ def testFadeIn(self):
+ def onStop():
+ self.__onStopCalled = True
+
+ self.initScene()
+ self.__node.opacity=0.5
+ self.__onStopCalled = False
+ self.start((
+ lambda: avg.fadeIn(self.__node, 200, 1, onStop),
+ lambda: self.compareImage("testFadeIn1", False),
+ lambda: self.compareImage("testFadeIn2", False),
+ lambda: self.compareImage("testFadeIn3", False),
+ lambda: self.assert_(self.__onStopCalled),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0)
+ ))
+ self.__anim = None
+
+ def testFadeOut(self):
+ def onStop():
+ self.__onStopCalled = True
+
+ self.initScene()
+ self.__node.opacity=0.5
+ self.__onStopCalled = False
+ self.start((
+ lambda: avg.fadeOut(self.__node, 200, onStop),
+ lambda: self.compareImage("testFadeOut1", False),
+ lambda: self.compareImage("testFadeOut2", False),
+ lambda: self.compareImage("testFadeOut3", False),
+ lambda: self.assert_(self.__onStopCalled),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0)
+ ))
+ self.__anim = None
+
+ def testNonExistentAttributeAnim(self):
+ self.initScene()
+ self.assertException(lambda: avg.LinearAnim(self.__node, "foo", 0, 0, 0, False))
+ self.assertException(lambda: avg.LinearAnim(None, "x", 0, 0, 0, False))
+
+ def testLinearAnimZeroDuration(self):
+ def onStop():
+ self.__onStopCalled = True
+
+ def startAnim():
+ self.__onStopCalled = False
+ self.__anim.start()
+
+ self.initScene()
+ self.__anim = avg.LinearAnim(self.__node, "x", 0, 0, 100, False, None, onStop)
+ self.__onStopCalled = False
+ self.start((
+ startAnim,
+ lambda: self.compareImage("testLinearAnimZeroDurationC1", False),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0),
+ lambda: self.assert_(self.__onStopCalled),
+ lambda: self.assert_(not(self.__anim.isRunning()))
+ ))
+ self.__anim = None
+
+ def testPingPongStopAnim(self):
+ def forth():
+ anim = avg.LinearAnim(self.__node, 'pos', 100, (50, 100),
+ (100, 100), False, None, back)
+ anim.start()
+
+ def back():
+ anim = avg.LinearAnim(self.__node, 'pos', 100, (100, 100),
+ (50, 100), False, None, forth)
+ anim.start()
+
+ self.initScene()
+ self.start((
+ forth,
+ lambda: self.delay(300),
+ ))
+
+ def testPointAnim(self):
+ def startAnim():
+ self.__anim.start()
+
+ def startKeepAttr():
+ self.__node.pos = (50, 20)
+ self.__anim.start(True)
+
+ self.initScene()
+ self.__anim = avg.LinearAnim(self.__node, "pos", 200, avg.Point2D(0,0),
+ avg.Point2D(100,40), False)
+ self.start((
+ startAnim,
+ lambda: self.compareImage("testPointAnim1", False),
+ lambda: self.compareImage("testPointAnim2", False),
+ None,
+ lambda: self.assert_(not(self.__anim.isRunning())),
+ startKeepAttr,
+ lambda: self.compareImage("testPointAnim3", False),
+ ))
+
+ def testIntAnim(self):
+ def startAnim():
+ self.__anim.start()
+
+ self.initScene()
+ self.__doubleAnim = avg.LinearAnim(self.__node, "x", 300, 0, 100, True)
+ self.__pointAnim = avg.LinearAnim(self.__node, "pos", 200, avg.Point2D(0,0),
+ avg.Point2D(100,40), True)
+ self.start((
+ self.__doubleAnim.start,
+ lambda: self.delay(100),
+ lambda: self.compareImage("testIntAnim1", False),
+ self.__doubleAnim.abort,
+ self.__pointAnim.start,
+ lambda: self.delay(100),
+ lambda: self.compareImage("testIntAnim2", False),
+ ))
+
+ def testEaseInOutAnim(self):
+ self.initScene()
+ curAnim = avg.EaseInOutAnim(self.__node, "x", 300, 0, 100, 100, 100, False)
+ self.testAnimType(curAnim, "testEaseInOutAnimC")
+
+ def testContinuousAnim(self):
+ def startAnim():
+ self.__animStarted = True
+
+ def stopAnim():
+ self.__animStopped = True
+
+ def reset():
+ self.__animStarted = False
+ self.__animStopped = False
+
+ self.initScene()
+ self.__anim = avg.ContinuousAnim(self.__node, "angle", 0, 2*math.pi,
+ False, startAnim, stopAnim)
+ self.__linearAnim = avg.LinearAnim(self.__node, "angle", 1000, math.pi, math.pi)
+
+ self.__animStarted = False
+ self.__animStopped = False
+ self.start((
+ self.__anim.start,
+ lambda: self.assert_(self.__animStarted),
+ lambda: self.compareImage("testContinuousAnim1", False),
+ self.__anim.abort,
+ lambda: self.assert_(self.__animStopped),
+ reset,
+ self.__anim.start,
+ self.__linearAnim.start,
+ lambda: self.assert_(self.__animStopped),
+ lambda: self.compareImage("testContinuousAnim2", False),
+ self.__linearAnim.abort,
+ ))
+
+ def testWaitAnim(self):
+ def animStopped():
+ self.__endCalled = True
+
+ def startAnim():
+ self.anim = avg.WaitAnim(200, animStopped, None)
+ self.anim.start()
+
+ self.initScene()
+ self.__endCalled = False
+ self.start((
+ startAnim,
+ lambda: self.assert_(self.anim.isRunning()),
+ lambda: self.delay(200),
+ lambda: self.assert_(not(self.anim.isRunning())),
+ lambda: self.assert_(self.__endCalled)
+ ))
+
+ def testParallelAnim(self):
+ def animStopped():
+ self.__endCalled = True
+
+ def startFireForgetAnim():
+ avg.ParallelAnim(
+ [ avg.LinearAnim(self.nodes[0], "x", 200, 0, 60),
+ avg.LinearAnim(self.nodes[1], "x", 200, 0, 120)
+ ]).start()
+
+ def startAnim():
+ self.anim = avg.ParallelAnim(
+ [ avg.LinearAnim(self.nodes[0], "x", 200, 0, 60),
+ avg.LinearAnim(self.nodes[1], "x", 400, 0, 120),
+ avg.EaseInOutAnim(self.nodes[2], "x", 400, 0, 120, 100, 100)
+ ], None, animStopped)
+ self.__endCalled = False
+ self.anim.start()
+
+ def startTimedAnim():
+ self.anim = avg.ParallelAnim(
+ [ avg.LinearAnim(self.nodes[0], "x", 200, 0, 60),
+ avg.LinearAnim(self.nodes[1], "x", 400, 0, 120),
+ ], None, animStopped, 200)
+ self.__endCalled = False
+ self.anim.start()
+
+ def abortAnim():
+ self.anim.abort()
+
+ def deleteAnim():
+ self.anim = None
+
+ root = self.loadEmptyScene()
+ self.nodes = []
+ for i in range(3):
+ node = avg.ImageNode(id=str(i), pos=(64, i*20), href="rgb24-64x64.png")
+ root.appendChild(node)
+ self.nodes.append(node)
+ Player.setFakeFPS(10)
+ self.__endCalled = False
+ self.start((
+ startFireForgetAnim,
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 2),
+ None,
+ startAnim,
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 3),
+ lambda: self.compareImage("testParallelAnimC1", False),
+ lambda: self.assert_(self.anim.isRunning()),
+ lambda: self.delay(200),
+ lambda: self.assert_(not(self.anim.isRunning())),
+ lambda: self.compareImage("testParallelAnimC2", False),
+ lambda: self.assert_(self.__endCalled),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0),
+ startAnim,
+ abortAnim,
+ lambda: self.compareImage("testParallelAnimC3", False),
+ lambda: self.assert_(self.__endCalled),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0),
+ startTimedAnim,
+ lambda: self.delay(200),
+ lambda: self.assert_(self.__endCalled),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 0),
+ startAnim
+ ))
+ self.nodes = []
+
+ def testParallelAnimRegistry(self):
+ def makeAnims():
+ avg.ParallelAnim(
+ [ avg.LinearAnim(self.__node, "x", 200, 0, 60),
+ avg.LinearAnim(self.__node, "y", 200, 0, 120)
+ ]).start()
+
+ avg.LinearAnim(self.__node, "x", 300, 0, 100, False, None).start()
+
+ self.initScene()
+ self.start((
+ makeAnims,
+ None
+ ))
+
+ def testStateAnim(self):
+ def state1StopCallback():
+ self.__state1StopCallbackCalled = True
+
+ def state2StartCallback():
+ if self.__state1StopCallbackCalled:
+ self.__stop1Start2CallbackOrder = True
+ self.__state2StartCallbackCalled = True
+
+ def makeAnim():
+ self.anim = avg.StateAnim(
+ [avg.AnimState("STATE1", avg.LinearAnim(self.__node, "x", 200,
+ 0, 100, False, None, state1StopCallback), "STATE2"),
+ avg.AnimState("STATE2", avg.LinearAnim(self.__node, "x", 200,
+ 100, 50, False, state2StartCallback), "STATE3"),
+ avg.AnimState("STATE3", avg.WaitAnim())
+ ])
+# self.anim.setDebug(True)
+
+ def killAnim():
+ self.anim = None
+
+ self.initScene()
+ self.__state1StopCallbackCalled = False
+ self.__state2StartCallbackCalled = False
+ self.__stop1Start2CallbackOrder = False
+ self.start((
+ makeAnim,
+ lambda: self.compareImage("testStateAnimC1", False),
+ lambda: self.anim.setState("STATE1"),
+ None,
+ lambda: self.compareImage("testStateAnimC2", False),
+ lambda: self.assertEqual(self.anim.getState(), "STATE2"),
+ lambda: self.compareImage("testStateAnimC3", False),
+ lambda: self.assert_(self.__state1StopCallbackCalled),
+ lambda: self.assert_(self.__state2StartCallbackCalled),
+ lambda: self.assert_(self.__stop1Start2CallbackOrder),
+ lambda: self.assertEqual(self.anim.getState(), "STATE3"),
+ lambda: self.compareImage("testStateAnimC4", False),
+ lambda: self.anim.setState("STATE1"),
+ lambda: self.assertEqual(avg.getNumRunningAnims(), 1),
+ lambda: self.compareImage("testStateAnimC5", False),
+ killAnim,
+# lambda: Player.getTestHelper().dumpObjects()
+ ))
+
+
+def animTestSuite(tests):
+ availableTests = (
+ "testLinearAnim",
+ "testAnimRegistry",
+ "testFadeIn",
+ "testFadeOut",
+ "testNonExistentAttributeAnim",
+ "testLinearAnimZeroDuration",
+ "testPingPongStopAnim",
+ "testPointAnim",
+ "testEaseInOutAnim",
+ "testIntAnim",
+ "testContinuousAnim",
+ "testWaitAnim",
+ "testParallelAnim",
+ "testParallelAnimRegistry",
+ "testStateAnim",
+ )
+ return createAVGTestSuite(availableTests, AnimTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/DynamicsTest.py b/src/test/DynamicsTest.py
new file mode 100644
index 0000000..cc247f4
--- /dev/null
+++ b/src/test/DynamicsTest.py
@@ -0,0 +1,401 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg
+from testcase import *
+
+class DynamicsTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def __runDynamicsTest(self, createFunc, testName, isVideo = False,
+ warnOnImageDiff = False):
+
+ def createNode1(useXml):
+
+ def setNodeID():
+ node.id = "bork"
+
+ node = createFunc(useXml)
+ node.id = "nodeid1"
+ node.x = 10
+ node.y = 20
+ self.root.appendChild(node)
+ self.assertException(setNodeID)
+ self.assertEqual(self.root.indexOf(Player.getElementByID("nodeid1")), 0)
+
+ def createNode2(useXml):
+ node = createFunc(useXml)
+ node.id = "nodeid2"
+ oldNode = Player.getElementByID("nodeid1")
+ self.root.insertChildBefore(node, oldNode)
+
+ def reorderNode():
+ self.root.reorderChild(0, 1)
+ node = Player.getElementByID("nodeid1")
+ self.root.reorderChild(node, 0)
+
+ def removeNodes():
+ self.node = Player.getElementByID("nodeid1")
+ self.root.removeChild(self.root.indexOf(self.node))
+ node2 = Player.getElementByID("nodeid2")
+ self.root.removeChild(node2)
+ self.assertEqual(Player.getElementByID("nodeid1"), None)
+
+ def reAddNode():
+ self.root.appendChild(self.node)
+ if isVideo:
+ self.node.play()
+ self.node = None
+
+ def killNode():
+ self.node = Player.getElementByID("nodeid1")
+ self.node.unlink(True)
+ gone = Player.getElementByID("nodeid1")
+ self.assertEqual(gone, None)
+
+ def removeAgain():
+ node = Player.getElementByID("nodeid1")
+ node.unlink()
+ gone = Player.getElementByID("nodeid1")
+ self.assertEqual(gone, None)
+
+ def runTest(useXml):
+ self.root = self.loadEmptyScene()
+ createNode1(useXml)
+ Player.stop()
+ self.root = self.loadEmptyScene()
+ Player.setFakeFPS(25)
+ self.start((
+ lambda: createNode1(useXml),
+ lambda: self.compareImage(testName+"1", warnOnImageDiff),
+ lambda: createNode2(useXml),
+ lambda: self.compareImage(testName+"2", warnOnImageDiff),
+ reorderNode,
+ lambda: self.compareImage(testName+"3", warnOnImageDiff),
+ removeNodes,
+ lambda: self.compareImage(testName+"4", warnOnImageDiff),
+ reAddNode,
+ lambda: self.compareImage(testName+"5", warnOnImageDiff),
+ killNode,
+ reAddNode,
+ removeAgain
+ ))
+
+ runTest(True)
+ runTest(False)
+
+ def testImgDynamics(self):
+ def createImg(useXml):
+ if useXml:
+ node = Player.createNode("<image href='rgb24-64x64.png'/>")
+ else:
+ node = Player.createNode("image", {"href":"rgb24-64x64.png"})
+ return node
+
+ self.__runDynamicsTest(createImg, "testImgDynamics")
+
+ def testVideoDynamics(self):
+ def createVideo(useXml):
+ if useXml:
+ node = Player.createNode(
+ "<video href='../video/testfiles/mpeg1-48x48.mpg'"
+ " threaded='false'/>")
+ else:
+ node = Player.createNode("video",
+ {"href":"../video/testfiles/mpeg1-48x48.mpg",
+ "threaded":False})
+ node.play()
+ return node
+
+ self.__runDynamicsTest(createVideo, "testVideoDynamics", True)
+
+ def testWordsDynamics(self):
+ def createWords(useXml):
+ if useXml:
+ node = Player.createNode("<words text='test'/>")
+ else:
+ node = Player.createNode("words", {"text":"test"})
+ node.font="Bitstream Vera Sans"
+ node.fontsize=12
+ node.width=200
+ return node
+
+ self.__runDynamicsTest(createWords, "testWordsDynamics", False, True)
+
+ def testPanoDynamics(self):
+ def createPano(useXml):
+ if useXml:
+ node = Player.createNode("""
+ <panoimage href='panoimage.png' sensorwidth='4.60'
+ sensorheight='3.97' focallength='12'
+ width='160' height='120'/>
+ """)
+ else:
+ node = Player.createNode("panoimage",
+ {"href":"panoimage.png", "sensorwidth":4.60, "sensorheight":3.97,
+ "focallength":12, "width":160, "height":120})
+ return node
+
+ self.__runDynamicsTest(createPano, "testPanoDynamics")
+
+ def testDivDynamics(self):
+ def createDiv(useXml):
+ if useXml:
+ node = Player.createNode("""
+ <div>
+ <image href='rgb24-64x64.png'/>
+ </div>
+ """)
+ else:
+ node = avg.DivNode()
+ imgNode = avg.ImageNode(href="rgb24-64x64.png", parent=node)
+ return node
+
+ self.__runDynamicsTest(createDiv, "testDivDynamics")
+
+ def testDuplicateID(self):
+ root = self.loadEmptyScene()
+ avg.ImageNode(href="rgb24-64x64.png", id="testdup", parent=root)
+ self.assertException(lambda: avg.ImageNode(href="rgb24-64x64.png",
+ id="testdup", parent=root))
+ self.start((
+ self.assertException(lambda: avg.ImageNode(href="rgb24-64x64.png",
+ id="testdup", parent=root)),
+ ))
+
+ def testChangeParentError(self):
+ def changeParent():
+ div = avg.DivNode()
+ img = avg.ImageNode(href="additive/rgb24-64x64.png", parent=div)
+ root.appendChild(img)
+
+ root = self.loadEmptyScene()
+ self.assertException(changeParent)
+ self.start((self.assertException(changeParent),))
+
+ def testDynamicEventCapture(self):
+ # Tests if deleting a node that has events captured works.
+ def createImg():
+ parentNode = root
+ node = Player.createNode("image", {"id": "img", "href":"rgb24-64x64.png"})
+ parentNode.appendChild(node)
+ node.setEventHandler(avg.CURSORDOWN, avg.MOUSE, captureMouseDown)
+ parentNode.setEventHandler(avg.CURSORUP, avg.MOUSE, mainMouseUp)
+
+ def setEventCapture():
+ Player.getElementByID("img").setEventCapture()
+
+ def deleteImg():
+ parentNode = root
+ node = Player.getElementByID("img")
+ parentNode.removeChild(parentNode.indexOf(node))
+
+ def captureMouseDown(event):
+ self.captureMouseDownCalled = True
+
+ def mainMouseUp(event):
+ self.mainMouseUpCalled = True
+
+ Helper = Player.getTestHelper()
+ self.captureMouseDownCalled = False
+ self.mainMouseUpCalled = False
+ root = self.loadEmptyScene()
+ self.start((
+ createImg,
+ setEventCapture,
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 100, 10, 1),
+ lambda: self.assert_(self.captureMouseDownCalled),
+ deleteImg,
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, True, False, False,
+ 100, 10, 1),
+ lambda: self.assert_(self.mainMouseUpCalled)
+ ))
+
+ def testEventBubbling(self):
+ def click (x, y):
+ self.fakeClick(x, y)
+
+ def createNodes():
+ def appendEventString (s):
+ self.__eventString += s
+ return True
+
+ def setHandler (node, s, swallow = False):
+ node.setEventHandler(avg.CURSORDOWN, avg.MOUSE,
+ lambda e: appendEventString(s) and swallow)
+
+ parentNode = root
+ node = Player.createNode("div", {'x':0,'y':0,'width':50, 'height':50})
+ setHandler (node, 'a')
+ parentNode.appendChild(node)
+ node = Player.createNode("div", {'x':0,'y':0,'width':100, 'height':100})
+ setHandler (node, 'b')
+ parentNode.insertChild(node,0)
+ parentNode = node
+ node = Player.createNode("div", {'x':40,'y':40,'width':30, 'height':30})
+ setHandler (node, 'c')
+ parentNode.appendChild(node)
+ node = Player.createNode("div", {'x':60,'y':40,'width':30, 'height':30})
+ setHandler (node, 'd', True)
+ parentNode.appendChild(node)
+
+ def resetEventString():
+ self.__eventString = ''
+
+ root = self.loadEmptyScene()
+ self.start((
+ createNodes,
+ resetEventString,
+ lambda: click (10,10),
+ lambda: self.assertEqual(self.__eventString, 'a'),
+ resetEventString,
+ lambda: click (55,55),
+ lambda: self.assertEqual(self.__eventString, 'cb'),
+ resetEventString,
+ lambda: click (65,55),
+ lambda: self.assertEqual(self.__eventString, 'd'),
+ ))
+
+ def testComplexDiv(self):
+ def setImageID(imgNode):
+ imgNode.id = "imageid"
+
+ def createDiv():
+ imgNode = Player.createNode("image",
+ {"id":"imageid", "href":"rgb24-64x64.png"})
+ node = Player.createNode("div", {"id":"divid"})
+ node.appendChild(imgNode)
+ imgNode.id = "imageid"
+ root.appendChild(node)
+ self.assertException(lambda: setImageID(imgNode))
+
+ def removeDiv():
+ node = Player.getElementByID("divid")
+ imgNode = Player.getElementByID("imageid")
+ node.unlink()
+ imgNode.id = "imageid"
+ imgNode.unlink()
+ root.appendChild(node)
+ node.appendChild(imgNode)
+ self.assertException(lambda: setImageID(imgNode))
+
+ root = self.loadEmptyScene()
+ createDiv()
+ removeDiv()
+ Player.stop()
+ root = self.loadEmptyScene()
+ Player.setFakeFPS(25)
+ self.start((
+ createDiv,
+ lambda: self.compareImage("testComplexDiv1", False),
+ removeDiv,
+ lambda: self.compareImage("testComplexDiv1", False),
+ ))
+
+ def testNodeCustomization(self):
+ def testNodePythonAttribute():
+ node1 = Player.createNode("image", {"id":"foo", "pos":(23, 42)})
+ root.appendChild(node1)
+ node1.customAttribute = "bbb"
+ node2 = Player.getElementByID("foo")
+ self.assertEqual(node1, node2)
+ self.assertEqual(node2.customAttribute, "bbb")
+ node1.unlink(True)
+
+ def testNodePythonSubclass():
+
+ class CustomImageNode(avg.ImageNode):
+ def __init__(self, p, parent=None, **kwargs):
+ avg.ImageNode.__init__(self, pos=p, href="rgb24-64x64.png", **kwargs)
+ if parent:
+ parent.appendChild(self)
+
+ def customMethod(self):
+ pass
+
+ class CustomDivNode(avg.DivNode):
+ def __init__(self, parent=None, **kwargs):
+ avg.DivNode.__init__(self, **kwargs)
+ if parent:
+ parent.appendChild(self)
+ CustomImageNode((23,42), parent=self)
+
+
+ customNode = avg.ImageNode(id="foo")
+ self.assertEqual(customNode.id, "foo")
+ CustomImageNode((23, 42), parent=root)
+ retrievedImage = root.getChild(0)
+ self.assertEqual(type(retrievedImage), CustomImageNode)
+ self.assertEqual(retrievedImage.pos, (23,42))
+ self.assertEqual(retrievedImage.href, "rgb24-64x64.png")
+ retrievedImage.customMethod()
+
+ CustomDivNode(parent=Player.getRootNode())
+ retrievedDiv = Player.getRootNode().getChild(1)
+ self.assertEqual(type(retrievedDiv), CustomDivNode)
+ retrievedImage = retrievedDiv.getChild(0)
+ self.assertEqual(type(retrievedImage), CustomImageNode)
+# retrievedDiv = retrievedImage.getParent()
+# print type(retrievedDiv)
+# self.assertEqual(type(retrievedDiv), CustomDivNode)
+
+ root = self.loadEmptyScene()
+ testNodePythonAttribute()
+ testNodePythonSubclass()
+
+ def testDynamicMediaDir(self):
+ def attachNode():
+ root.appendChild(imageNode1)
+
+ root = self.loadEmptyScene()
+ root.mediadir="testmediadir"
+ imageNode1 = Player.createNode("image", {"href": "rgb24-64x64a.png"})
+ imageNode2 = Player.createNode("image", {"href": "rgb24-64x64a.png", "x":30})
+ root.appendChild(imageNode2)
+ self.start((
+ lambda: self.compareImage("testDynamicMediaDir1", False),
+ attachNode,
+ lambda: self.compareImage("testDynamicMediaDir2", False)
+ ))
+
+
+def dynamicsTestSuite(tests):
+ availableTests = (
+ "testImgDynamics",
+ "testVideoDynamics",
+ "testWordsDynamics",
+ # "testPanoDynamics",
+ "testDivDynamics",
+ "testEventBubbling",
+ "testDuplicateID",
+ "testChangeParentError",
+ "testDynamicEventCapture",
+ "testComplexDiv",
+ "testNodeCustomization",
+ "testDynamicMediaDir"
+ )
+
+ return createAVGTestSuite(availableTests, DynamicsTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/EventTest.py b/src/test/EventTest.py
new file mode 100644
index 0000000..8287be5
--- /dev/null
+++ b/src/test/EventTest.py
@@ -0,0 +1,739 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import unittest
+
+import time
+import math
+import sys
+
+from libavg import avg
+from testcase import *
+
+def dumpMouseEvent(Event):
+ print Event
+ print " type: "+str(Event.type)
+ print " leftbuttonstate: "+str(Event.leftbuttonstate)
+ print " middlebuttonstate: "+str(Event.middlebuttonstate)
+ print " rightbuttonstate: "+str(Event.rightbuttonstate)
+ print " position: "+str(Event.x)+","+str(Event.y)
+ print " node: "+Event.node.id
+
+mainMouseUpCalled = False
+mainMouseDownCalled = False
+
+def mainMouseUp(Event):
+ global mainMouseUpCalled
+ assert (Event.type == avg.CURSORUP)
+ mainMouseUpCalled = True
+
+def mainMouseDown(Event):
+ global mainMouseDownCalled
+ assert (Event.type == avg.CURSORDOWN)
+ mainMouseDownCalled = True
+
+
+class EventTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testKeyEvents(self):
+ def onKeyDown(Event):
+ if Event.keystring == 'A' and Event.keycode == 65 and Event.unicode == 65:
+ self.keyDownCalled = True
+
+ def onKeyUp(Event):
+ if Event.keystring == 'A' and Event.keycode == 65 and Event.unicode == 65:
+ self.keyUpCalled = True
+
+ root = self.loadEmptyScene()
+ root.setEventHandler(avg.KEYDOWN, avg.NONE, onKeyDown)
+ root.setEventHandler(avg.KEYUP, avg.NONE, onKeyUp)
+ self.start((
+ lambda: Helper.fakeKeyEvent(avg.KEYDOWN, 65, 65, "A", 65,
+ avg.KEYMOD_NONE),
+ lambda: self.assert_(self.keyDownCalled),
+ lambda: Helper.fakeKeyEvent(avg.KEYUP, 65, 65, "A", 65, avg.KEYMOD_NONE),
+ lambda: self.assert_(self.keyUpCalled)
+ ))
+
+ def testSimpleEvents(self):
+ def getMouseState():
+ Event = Player.getMouseState()
+ self.assertEqual(Event.pos, avg.Point2D(10,10))
+
+ root = self.loadEmptyScene()
+ img1 = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ handlerTester1 = NodeHandlerTester(self, img1)
+
+ img2 = avg.ImageNode(pos=(64,0), href="rgb24-65x65.png", parent=root)
+ handlerTester2 = NodeHandlerTester(self, img2)
+
+ self.start((
+ # down, getMouseState(), move, up.
+ # events are inside img1 but outside img2.
+ lambda: self.assert_(not(Player.isMultitouchAvailable())),
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: handlerTester1.assertState(
+ down=True, up=False, over=True, out=False, move=False),
+ lambda: handlerTester2.assertState(
+ down=False, up=False, over=False, out=False, move=False),
+ getMouseState,
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORMOTION, True, False, False,
+ 12, 12, 1),
+ lambda: handlerTester1.assertState(
+ down=False, up=False, over=False, out=False, move=True),
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 12, 12, 1),
+ lambda: handlerTester1.assertState(
+ down=False, up=True, over=False, out=False, move=False)
+
+ ))
+
+ def testTilted(self):
+ root = self.loadEmptyScene()
+ root = root
+ img = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", angle=0.785, parent=root)
+ handlerTester = NodeHandlerTester(self, img)
+
+ self.start((
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 32, 32, 1),
+ lambda: handlerTester.assertState(
+ down=True, up=False, over=True, out=False, move=False),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 0, 0, 1),
+ lambda: handlerTester.assertState(
+ down=False, up=False, over=False, out=True, move=False),
+ ))
+
+ def testDivEvents(self):
+ root = self.loadEmptyScene()
+ div = avg.DivNode(pos=(0,0), parent=root)
+ divHandlerTester = NodeHandlerTester(self, div)
+
+ img = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=div)
+ imgHandlerTester = NodeHandlerTester(self, img)
+
+ self.start((
+ # down, move, up.
+ # events are inside img and therefore should bubble to div.
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: divHandlerTester.assertState(
+ down=True, up=False, over=True, out=False, move=False),
+ lambda: imgHandlerTester.assertState(
+ down=True, up=False, over=True, out=False, move=False),
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORMOTION, True, False, False,
+ 12, 12, 1),
+ lambda: divHandlerTester.assertState(
+ down=False, up=False, over=False, out=False, move=True),
+ lambda: imgHandlerTester.assertState(
+ down=False, up=False, over=False, out=False, move=True),
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 12, 12, 1),
+ lambda: divHandlerTester.assertState(
+ down=False, up=True, over=False, out=False, move=False),
+ lambda: imgHandlerTester.assertState(
+ down=False, up=True, over=False, out=False, move=False)
+ ))
+
+ def testConnectHandler(self):
+ def onDown1(event):
+ self.down1Called = True
+
+ def onDown2(event):
+ self.down2Called = True
+
+ def resetDownCalled():
+ self.down1Called = False
+ self.down2Called = False
+
+ def connectTwoHandlers():
+ self.img.connectEventHandler(avg.CURSORDOWN, avg.MOUSE, self, onDown1)
+ self.img.connectEventHandler(avg.CURSORDOWN, avg.MOUSE, self, onDown2)
+
+ def connectUnlinkHandler():
+ self.img.disconnectEventHandler(self)
+ self.img.connectEventHandler(avg.CURSORDOWN, avg.MOUSE, self, unlinkHandler)
+ self.img.connectEventHandler(avg.CURSORDOWN, avg.MOUSE, self, onDown2)
+
+ def unlinkHandler(event):
+ self.img.disconnectEventHandler(self)
+
+ root = self.loadEmptyScene()
+ self.img = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ connectTwoHandlers()
+ self.img.disconnectEventHandler(self, onDown1)
+ self.img.disconnectEventHandler(self, onDown2)
+ connectTwoHandlers()
+ self.img.disconnectEventHandler(self)
+
+ resetDownCalled()
+ self.start((
+ connectTwoHandlers,
+ lambda: self.fakeClick(10,10),
+ lambda: self.assert_(self.down1Called and self.down2Called),
+ resetDownCalled,
+ lambda: self.img.disconnectEventHandler(self, onDown1),
+ lambda: self.fakeClick(10,10),
+ lambda: self.assert_(not(self.down1Called) and self.down2Called),
+ connectUnlinkHandler,
+ lambda: self.fakeClick(10,10),
+ ))
+
+ def testObscuringEvents(self):
+ root = self.loadEmptyScene()
+ img1 = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ handlerTester1 = NodeHandlerTester(self, img1)
+
+ img2 = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ handlerTester2 = NodeHandlerTester(self, img2)
+ self.start((
+ # down, move, up.
+ # events should only arrive at img2 because img1 is obscured by img1.
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: handlerTester1.assertState(
+ down=False, up=False, over=False, out=False, move=False),
+ lambda: handlerTester2.assertState(
+ down=True, up=False, over=True, out=False, move=False),
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORMOTION, True, False, False,
+ 12, 12, 1),
+ lambda: handlerTester1.assertState(
+ down=False, up=False, over=False, out=False, move=False),
+ lambda: handlerTester2.assertState(
+ down=False, up=False, over=False, out=False, move=True),
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 12, 12, 1),
+ lambda: handlerTester1.assertState(
+ down=False, up=False, over=False, out=False, move=False),
+ lambda: handlerTester2.assertState(
+ down=False, up=True, over=False, out=False, move=False)
+ ))
+
+ def testSensitive(self):
+ # Tests both sensitive and active attributes.
+ def activateNode(node, useSensitiveAttr, b):
+ if useSensitiveAttr:
+ node.sensitive = b
+ else:
+ node.active = b
+
+ def onNode2Down(event):
+ self.__node2Down = True
+
+ for useSensitiveAttr in (True, False):
+ root = self.loadEmptyScene()
+ self.img = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ handlerTester = NodeHandlerTester(self, self.img)
+
+ activateNode(self.img, useSensitiveAttr, False)
+ self.start((
+ # Node is inactive -> no events.
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: handlerTester.assertState(
+ down=False, up=False, over=False, out=False, move=False),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 10, 10, 1),
+
+ # Activate the node -> events arrive.
+ lambda: activateNode(self.img, useSensitiveAttr, True),
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: handlerTester.assertState(
+ down=True, up=False, over=True, out=False, move=False),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 10, 10, 1),
+ ))
+ self.img = None
+
+ # Check if sensitive is deactivated immediately, not at the end of the frame.
+ root = self.loadEmptyScene()
+ self.img1 = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ self.img2 = avg.ImageNode(pos=(64,0), href="rgb24-65x65.png", parent=root)
+ self.img1.connectEventHandler(avg.CURSORDOWN, avg.TOUCH, self,
+ lambda event: activateNode(self.img2, useSensitiveAttr, False))
+ self.img2.connectEventHandler(avg.CURSORDOWN, avg.TOUCH, self, onNode2Down)
+ self.__node2Down = False
+
+ self.start((
+ lambda: self._sendTouchEvents((
+ (1, avg.CURSORDOWN, 10, 10),
+ (2, avg.CURSORDOWN, 80, 10),)),
+ lambda: self.assert_(not(self.__node2Down)),
+ ))
+
+ def testChangingHandlers(self):
+ root = self.loadEmptyScene()
+ img = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ handlerTester = NodeHandlerTester(self, img)
+
+ self.start((
+ lambda: handlerTester.clearHandlers(),
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: handlerTester.assertState(
+ down=False, up=False, over=False, out=False, move=False),
+ lambda: handlerTester.setHandlers(),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 10, 10, 1),
+ lambda: handlerTester.assertState(
+ down=False, up=True, over=False, out=False, move=False),
+ ))
+
+ def testEventCapture(self):
+ def onMainMouseDown(Event):
+ self.mainMouseDownCalled = True
+
+ def onMouseDown(Event):
+ self.mouseDownCalled = True
+
+ def captureEvent():
+ self.mouseDownCalled = False
+ self.mainMouseDownCalled = False
+ self.img.setEventCapture()
+
+ def noCaptureEvent():
+ self.mouseDownCalled = False
+ self.mainMouseDownCalled = False
+ self.img.releaseEventCapture()
+
+ def doubleCaptureEvent():
+ self.mouseDownCalled = False
+ self.mainMouseDownCalled = False
+ self.img.setEventCapture()
+ self.img.setEventCapture()
+ self.img.releaseEventCapture()
+
+ def releaseTooMuch():
+ self.img.releaseEventCapture()
+ self.assertException(self.img.releaseEventCapture)
+
+ self.mouseDownCalled = False
+ self.mainMouseDownCalled = False
+
+ root = self.loadEmptyScene()
+ root.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onMainMouseDown)
+ self.img = avg.ImageNode(pos=(0,0), href="rgb24-65x65.png", parent=root)
+ self.img.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onMouseDown)
+
+ self.start((
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: self.assert_(self.mouseDownCalled),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 10, 10, 1),
+ captureEvent,
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 100, 10, 1),
+ lambda: self.assert_(self.mouseDownCalled and
+ self.mainMouseDownCalled),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 100, 10, 1),
+ noCaptureEvent,
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 100, 10, 1),
+ lambda: self.assert_(not(self.mouseDownCalled) and
+ self.mainMouseDownCalled),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 100, 10, 1),
+ doubleCaptureEvent,
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 100, 10, 1),
+ lambda: self.assert_(self.mouseDownCalled and
+ self.mainMouseDownCalled),
+ releaseTooMuch,
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 100, 10, 1),
+ ))
+ self.img = None
+
+ def testMouseOver(self):
+ def onImg2MouseOver(Event):
+ self.img2MouseOverCalled = True
+
+ def onImg2MouseOut(Event):
+ self.img2MouseOutCalled = True
+
+ def onDivMouseOver(Event):
+ self.divMouseOverCalled = True
+
+ def onDivMouseOut(Event):
+ self.divMouseOutCalled = True
+
+ def onAVGMouseOver(Event):
+ self.avgMouseOverCalled = True
+
+ def onImg1MouseOver(Event):
+ self.img1MouseOverCalled = True
+
+ def printState():
+ print "----"
+ print "img2MouseOverCalled=", self.img2MouseOverCalled
+ print "img2MouseOutCalled=", self.img2MouseOutCalled
+ print "divMouseOverCalled=", self.divMouseOverCalled
+ print "divMouseOutCalled=", self.divMouseOutCalled
+ print "avgMouseOverCalled=", self.avgMouseOverCalled
+ print "img1MouseOverCalled=", self.img1MouseOverCalled
+
+ def resetState():
+ self.img2MouseOverCalled = False
+ self.img2MouseOutCalled = False
+ self.divMouseOverCalled = False
+ self.divMouseOutCalled = False
+ self.avgMouseOverCalled = False
+ self.img1MouseOverCalled = False
+
+ def killNodeUnderCursor():
+ Parent = img1.getParent()
+ Parent.removeChild(Parent.indexOf(img1))
+
+ Helper = Player.getTestHelper()
+ root = self.loadEmptyScene()
+ img1 = avg.ImageNode(href="rgb24-65x65.png", parent=root)
+ div = avg.DivNode(pos=(65,0), parent=root)
+ img3 = avg.ImageNode(href="rgb24-65x65.png", parent=div)
+ img2 = avg.ImageNode(pos=(0,65), href="rgb24-65x65.png", parent=div)
+
+ img2.setEventHandler(avg.CURSOROVER, avg.MOUSE, onImg2MouseOver)
+ img2.setEventHandler(avg.CURSOROUT, avg.MOUSE, onImg2MouseOut)
+ div.setEventHandler(avg.CURSOROVER, avg.MOUSE, onDivMouseOver)
+ div.setEventHandler(avg.CURSOROUT, avg.MOUSE, onDivMouseOut)
+ root.setEventHandler(avg.CURSOROVER, avg.MOUSE, onAVGMouseOver)
+ img1.setEventHandler(avg.CURSOROVER, avg.MOUSE, onImg1MouseOver)
+ self.start((
+ resetState,
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 70, 70, 1),
+ lambda: self.assert_(
+ self.img2MouseOverCalled and
+ self.divMouseOverCalled and
+ self.avgMouseOverCalled and
+ not(self.img2MouseOutCalled) and
+ not(self.divMouseOutCalled) and
+ not(self.img1MouseOverCalled)),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 70, 70, 1),
+ resetState,
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 70, 10, 1),
+ lambda: self.assert_(
+ not(self.img2MouseOverCalled) and
+ not(self.divMouseOverCalled) and
+ not(self.avgMouseOverCalled) and
+ self.img2MouseOutCalled and
+ not(self.divMouseOutCalled) and
+ not(self.img1MouseOverCalled)),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 70, 10, 1),
+
+ resetState,
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ lambda: self.assert_(
+ not(self.img2MouseOverCalled) and
+ not(self.divMouseOverCalled) and
+ not(self.avgMouseOverCalled) and
+ not(self.img2MouseOutCalled) and
+ self.divMouseOutCalled and
+ self.img1MouseOverCalled),
+
+ resetState,
+ killNodeUnderCursor,
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 10, 10, 1),
+ lambda: self.assert_(
+ not(self.img2MouseOverCalled) and
+ not(self.divMouseOverCalled) and
+ not(self.avgMouseOverCalled) and
+ not(self.img2MouseOutCalled) and
+ not(self.divMouseOutCalled) and
+ not(self.img1MouseOverCalled)),
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 10, 10, 1),
+ resetState,
+ lambda: img2.setEventCapture(),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 70, 70, 1),
+ lambda: self.assert_(
+ self.img2MouseOverCalled and
+ self.divMouseOverCalled and
+ not(self.avgMouseOverCalled) and
+ not(self.img2MouseOutCalled) and
+ not(self.divMouseOutCalled) and
+ not(self.img1MouseOverCalled)),
+
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 70, 70, 1),
+ resetState,
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, False, False, False,
+ 10, 10, 1),
+ lambda: self.assert_(
+ not(self.img2MouseOverCalled) and
+ not(self.divMouseOverCalled) and
+ not(self.avgMouseOverCalled) and
+ self.img2MouseOutCalled and
+ self.divMouseOutCalled and
+ not(self.img1MouseOverCalled))
+ ))
+
+ def testEventErr(self):
+ def onErrMouseOver(Event):
+ undefinedFunction()
+
+ root = self.loadEmptyScene()
+ root.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onErrMouseOver)
+ self.assertException(lambda:
+ self.start((
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN,
+ False, False, False, 10, 10, 0),
+ )))
+
+ def testEventHook(self):
+ def resetState():
+ self.ehookMouseEvent = False
+ self.ehookKeyboardEvent = False
+
+ def cleanup():
+ resetState()
+ Player.setEventHook(None)
+
+ def handleEvent(event):
+ if isinstance(event, avg.MouseEvent) and event.source == avg.MOUSE:
+ if event.type == avg.CURSORDOWN:
+ self.ehookMouseEvent = True
+ elif isinstance(event, avg.KeyEvent):
+ self.ehookKeyboardEvent = True
+ else:
+ self.fail()
+
+ root = self.loadEmptyScene()
+ resetState()
+
+ Player.setEventHook(handleEvent)
+ self.start((
+ lambda: self.fakeClick(10, 10),
+ lambda: self.assert_(self.ehookMouseEvent),
+ lambda: Helper.fakeKeyEvent(avg.KEYDOWN, 65, 65, "A", 65, 0),
+ lambda: self.assert_(self.ehookKeyboardEvent),
+ cleanup,
+ lambda: self.fakeClick(10, 10),
+ lambda: self.assert_(not self.ehookMouseEvent),
+ lambda: Helper.fakeKeyEvent(avg.KEYDOWN, 65, 65, "A", 65, 0),
+ lambda: self.assert_(not self.ehookKeyboardEvent),
+ ))
+
+ def testException(self):
+
+ class TestException(Exception):
+ pass
+
+ def throwException(event):
+ raise TestException
+
+ rect = avg.RectNode(size = (50, 50))
+ rect.setEventHandler(avg.CURSORDOWN, avg.MOUSE, throwException)
+
+ root = self.loadEmptyScene()
+ root.appendChild(rect)
+
+ self.__exceptionThrown = False
+ try:
+ self.start((
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False, 10,
+ 10, 0),
+ lambda: None))
+ except TestException:
+ self.__exceptionThrown = True
+
+ self.assert_(self.__exceptionThrown)
+
+ def testContacts(self):
+
+ def onDown(event):
+ contact = event.contact
+ self.assertEqual(event.cursorid, contact.id)
+ self.assertEqual(contact.age, 0)
+ self.assertEqual(contact.distancefromstart, 0)
+ self.assertEqual(contact.motionangle, 0)
+ self.assertEqual(contact.motionvec, (0,0))
+ self.assertEqual(contact.distancetravelled, 0)
+ self.assertEqual(contact.events[0].pos, event.pos)
+ self.assertEqual(len(contact.events), 1)
+ contact.connectListener(onMotion, onUp)
+
+ def onMotion(event):
+ contact = event.contact
+ self.assertEqual(event.cursorid, contact.id)
+ self.assertEqual(contact.age, 40)
+ self.assertEqual(contact.distancefromstart, 10)
+ self.assertEqual(contact.motionangle, 0)
+ self.assertEqual(contact.motionvec, (10,0))
+ self.assertEqual(contact.distancetravelled, 10)
+ self.assertEqual(contact.events[-1].pos, event.pos)
+ self.assert_(len(contact.events) > 1)
+ self.numContactCallbacks += 1
+
+ def onUp(event):
+ contact = event.contact
+ self.assertEqual(event.cursorid, contact.id)
+ self.assertEqual(contact.age, 80)
+ self.assertEqual(contact.distancefromstart, 0)
+ self.assertEqual(contact.motionangle, 0)
+ self.assertEqual(contact.motionvec, (0,0))
+ self.assertEqual(contact.distancetravelled, 20)
+ self.assertEqual(contact.events[-1].pos, event.pos)
+ self.assert_(len(contact.events) > 1)
+ self.numContactCallbacks += 1
+
+ def onOver(event):
+ self.numOverCallbacks += 1
+ self.assertEqual(event.cursorid, event.contact.id)
+
+ def onOut(event):
+ self.numOutCallbacks += 1
+ self.assertEqual(event.cursorid, event.contact.id)
+
+ root = self.loadEmptyScene()
+ root.connectEventHandler(avg.CURSORDOWN, avg.TOUCH, self, onDown)
+ self.numContactCallbacks = 0
+ rect = avg.RectNode(pos=(5,5), size=(10,10), parent=root)
+ rect.connectEventHandler(avg.CURSOROVER, avg.TOUCH, self, onOver)
+ self.numOverCallbacks = 0
+ rect.connectEventHandler(avg.CURSOROUT, avg.TOUCH, self, onOut)
+ self.numOutCallbacks = 0
+ Player.setFakeFPS(25)
+ self.start((
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORDOWN, avg.TOUCH, (10,10)),
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORMOTION, avg.TOUCH, (20,10)),
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORUP, avg.TOUCH, (10,10)),
+ ))
+ self.assertEqual(self.numContactCallbacks, 2)
+ self.assertEqual(self.numOverCallbacks, 2)
+ self.assertEqual(self.numOutCallbacks, 2)
+
+ root = self.loadEmptyScene()
+ root.connectEventHandler(avg.CURSORDOWN, avg.MOUSE, self, onDown)
+ self.numContactCallbacks = 0
+ self.start((
+ lambda: Helper.fakeMouseEvent(avg.CURSORDOWN, 1, 0, 0, 10, 10, 0),
+ lambda: Helper.fakeMouseEvent(avg.CURSORMOTION, 1, 0, 0, 20, 10, 0),
+ lambda: Helper.fakeMouseEvent(avg.CURSORUP, 0, 0, 0, 10, 10, 0),
+ ))
+ self.assertEqual(self.numContactCallbacks, 2)
+
+ def testContactRegistration(self):
+
+ def onDown(event):
+ root.setEventCapture(event.cursorid)
+ root.releaseEventCapture(event.cursorid)
+
+ def onMotion(event):
+ contact = event.contact
+ self.contactID = contact.connectListener(onContactMotion, None)
+ self.numMotionCallbacks += 1
+ root.disconnectEventHandler(self)
+
+ def onContactMotion(event):
+ contact = event.contact
+ contact.disconnectListener(self.contactID)
+ self.assertException(lambda: contact.disconnectListener(self.contactID))
+ self.numContactCallbacks += 1
+
+ root = self.loadEmptyScene()
+ root.connectEventHandler(avg.CURSORDOWN, avg.TOUCH, self, onDown)
+ self.numMotionCallbacks = 0
+ root.connectEventHandler(avg.CURSORMOTION, avg.TOUCH, self, onMotion)
+ self.numContactCallbacks = 0
+ Player.setFakeFPS(25)
+ self.start((
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORDOWN, avg.TOUCH, (10,10)),
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORMOTION, avg.TOUCH, (20,10)),
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORMOTION, avg.TOUCH, (30,10)),
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORMOTION, avg.TOUCH, (40,10)),
+ ))
+ self.assertEqual(self.numContactCallbacks, 1)
+ self.assertEqual(self.numMotionCallbacks, 1)
+
+ def testMultiContactRegistration(self):
+
+ def onDown(event):
+ contact = event.contact
+ self.contactid = contact.connectListener(onContact2, onContact2)
+ contact.connectListener(onContact1, onContact1)
+
+ def onContact1(event):
+ if self.numContact1Callbacks == 0:
+ event.contact.disconnectListener(self.contactid)
+ self.numContact1Callbacks += 1
+
+ def onContact2(event):
+ self.assertEqual(self.numContact1Callbacks, 0)
+ self.numContact2Callbacks += 1
+
+ root = self.loadEmptyScene()
+ root.connectEventHandler(avg.CURSORDOWN, avg.TOUCH, self, onDown)
+ Player.setFakeFPS(25)
+ self.numContact1Callbacks = 0
+ self.numContact2Callbacks = 0
+ self.start((
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORDOWN, avg.TOUCH, (10,10)),
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORMOTION, avg.TOUCH, (20,10)),
+ lambda: Helper.fakeTouchEvent(1, avg.CURSORUP, avg.TOUCH, (10,10)),
+ ))
+ self.assertEqual(self.numContact1Callbacks, 2)
+ # The order of callbacks is unspecified, so onContact2 might be called once.
+ self.assert_(self.numContact2Callbacks <= 1)
+
+
+def eventTestSuite(tests):
+ availableTests = (
+ "testKeyEvents",
+ "testSimpleEvents",
+ "testTilted",
+ "testDivEvents",
+ "testConnectHandler",
+ "testObscuringEvents",
+ "testSensitive",
+ "testChangingHandlers",
+ "testEventCapture",
+ "testMouseOver",
+ "testEventErr",
+ "testEventHook",
+ "testException",
+ "testContacts",
+ "testContactRegistration",
+ "testMultiContactRegistration",
+ )
+ return createAVGTestSuite(availableTests, EventTestCase, tests)
+
+Player = avg.Player.get()
+Helper = Player.getTestHelper()
diff --git a/src/test/FXTest.py b/src/test/FXTest.py
new file mode 100644
index 0000000..043a5b2
--- /dev/null
+++ b/src/test/FXTest.py
@@ -0,0 +1,450 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg, utils
+from testcase import *
+
+class FXTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testImageNullFX(self):
+ def activateFX():
+ for node in self.nodes[0]:
+ node.setEffect(avg.NullFXNode())
+
+ def newNode():
+ self.newNode = avg.ImageNode(parent=root, href="rgb24-32x32.png", pos=(64,0))
+ self.newNode.setEffect(avg.NullFXNode())
+
+ def newFX():
+ self.newNode.setEffect(avg.NullFXNode())
+
+ def addBgNode():
+ node = avg.RectNode(pos=(0,0), size=(64,96), fillopacity=1, opacity=0,
+ fillcolor="FFFFFF")
+ root.insertChild(node, 0)
+
+ # Initial setup is 3x2 images:
+ # rows: no alpha, alpha, alpha & opacity 0.6
+ # cols: no FX, FX
+ # The two cols should look the same.
+ root = self.loadEmptyScene()
+ self.nodes = []
+ for fx in (False, True):
+ curNodes = []
+ self.nodes.append(curNodes)
+ def configureNode(node, fx):
+ curNodes.append(node)
+ if fx:
+ node.x = 32
+ node.setEffect(avg.NullFXNode())
+
+ node = avg.ImageNode(parent=root, href="rgb24-32x32.png", pos=(0,0))
+ configureNode(node, fx)
+ node = avg.ImageNode(parent=root, href="rgb24alpha-32x32.png", pos=(0,32))
+ configureNode(node, fx)
+ node = avg.ImageNode(parent=root, href="rgb24alpha-32x32.png", pos=(0,64),
+ opacity=0.6)
+ configureNode(node, fx)
+
+ self.start((
+ lambda: self.compareImage("testImageNullFX1", False),
+ addBgNode,
+ lambda: self.compareImage("testImageNullFX2", False),
+ activateFX,
+ lambda: self.compareImage("testImageNullFX2", False),
+ newNode,
+ lambda: self.compareImage("testImageNullFX3", False),
+ newFX,
+ lambda: self.compareImage("testImageNullFX3", False),
+ lambda: utils.initFXCache(10),
+ ))
+
+ def testVideoNullFX(self):
+ root = self.loadEmptyScene()
+ Player.setFakeFPS(25)
+ node = avg.VideoNode(parent=root, href="../video/testfiles/mjpeg-48x48.avi",
+ threaded=False)
+ node.setEffect(avg.NullFXNode())
+ node.play()
+ self.start((lambda: self.compareImage("testVideoNullFX", False),))
+
+ def testWordsNullFX(self):
+ root = self.loadEmptyScene()
+ node = avg.WordsNode(parent=root, text="testtext", font="Bitstream Vera Sans")
+ node.setEffect(avg.NullFXNode())
+ node = avg.WordsNode(parent=root, text="testtext", pos=(0,20),
+ font="Bitstream Vera Sans")
+ self.start((
+ lambda: self.compareImage("testWordsNullFX", True),
+ ))
+
+ def testCanvasNullFX(self):
+ def setOpacity():
+ node.opacity=0.6
+
+ root = self.loadEmptyScene()
+ self.__createOffscreenCanvas()
+ node = avg.ImageNode(parent=root, href="canvas:offscreen")
+ node.setEffect(avg.NullFXNode())
+ self.start((
+ lambda: self.compareImage("testCanvasNullFX1", False),
+ setOpacity,
+ lambda: self.compareImage("testCanvasNullFX2", False),
+ ))
+
+ def testNodeInCanvasNullFX(self):
+ root = self.loadEmptyScene()
+ canvas = self.__createOffscreenCanvas()
+ avg.ImageNode(parent=root, href="canvas:offscreen")
+ node = canvas.getElementByID("test")
+ node.setEffect(avg.NullFXNode())
+ rect = avg.RectNode(size=(100,100), strokewidth=0, fillcolor="FF0000",
+ fillopacity=1)
+ canvas.getRootNode().insertChild(rect, 0)
+
+ self.start((
+ lambda: self.compareImage("testNodeInCanvasNullFX1", False),
+ ))
+
+ def testRenderPipeline(self):
+ print
+ for useSrcCanvas in (False, True):
+ for useDestCanvas in (False, True):
+ for useFX in (False, True):
+ for useColorConv in (False, True):
+ print " ", useSrcCanvas, useDestCanvas, useFX, useColorConv
+ root = self.loadEmptyScene()
+ if useSrcCanvas:
+ srcCanvas = Player.createCanvas(id="src", size=(160,120))
+ avg.ImageNode(href="rgb24alpha-64x64.png",
+ parent=srcCanvas.getRootNode())
+ srcImg = avg.ImageNode(href="canvas:src")
+ else:
+ srcImg = avg.ImageNode(href="rgb24alpha-64x64.png")
+ if useFX:
+ srcImg.setEffect(avg.NullFXNode())
+ if useColorConv:
+ srcImg.contrast = (1.01, 1.0, 1.0)
+ if useDestCanvas:
+ destCanvas = Player.createCanvas(id="dest", size=(160,120))
+ destCanvas.getRootNode().appendChild(srcImg)
+ destImg = avg.ImageNode(href="canvas:dest", parent=root)
+ else:
+ root.appendChild(srcImg)
+ self.start((
+ lambda: self.compareImage("testRenderPipeline", False),
+ ))
+
+ def testBlurFX(self):
+
+ def setRadius(radius):
+ self.effect.radius = radius
+
+ def removeFX():
+ self.node.setEffect(None)
+
+ def reAddFX():
+ self.node.setEffect(self.effect)
+
+ def addNewFX():
+ effect = avg.BlurFXNode()
+ effect.radius = 8
+ self.node.setEffect(effect)
+
+ root = self.loadEmptyScene()
+ self.node = avg.ImageNode(parent=root, pos=(10,10), href="rgb24-64x64.png")
+ self.effect = avg.BlurFXNode()
+ self.node.setEffect(self.effect)
+ self.start((
+ lambda: self.compareImage("testBlurFX1", False),
+ lambda: setRadius(8),
+ lambda: self.compareImage("testBlurFX2", False),
+ removeFX,
+ lambda: self.compareImage("testBlurFX3", False),
+ reAddFX,
+ lambda: self.compareImage("testBlurFX2", False),
+ removeFX,
+ addNewFX,
+ lambda: self.compareImage("testBlurFX2", False),
+ ))
+
+ def testHueSatFX(self):
+
+ def resetFX():
+ self.effect = avg.HueSatFXNode()
+ self.node.setEffect(self.effect)
+
+ def setParam(param, value):
+ assert(hasattr(self.effect, param))
+ setattr(self.effect, param, value)
+
+ root = self.loadEmptyScene()
+ self.node = avg.ImageNode(parent=root, pos=(10,10), href="rgb24alpha-64x64.png")
+ resetFX()
+ self.start((
+ lambda: self.compareImage("testHueSatFX1", False),
+ lambda: setParam('saturation', -50),
+ lambda: self.compareImage("testHueSatFX2", False),
+ lambda: setParam('saturation', -100),
+ lambda: self.compareImage("testHueSatFX3", False),
+ lambda: setParam('saturation', -150),
+ lambda: self.compareImage("testHueSatFX3", False),
+ resetFX,
+ lambda: setParam('hue', 180),
+ lambda: self.compareImage("testHueSatFX4", False),
+ lambda: setParam('hue', -180),
+ lambda: self.compareImage("testHueSatFX4", False),
+ ))
+
+ def testInvertFX(self):
+
+ def resetFX():
+ self.effect = avg.InvertFXNode()
+ self.node.setEffect(self.effect)
+
+ def redAlphaScene():
+ self.redRect = avg.RectNode(parent=self.root, pos=(5, 5), fillcolor='FF0000',
+ fillopacity=1, opacity=0, size=(72, 72))
+ self.node = avg.ImageNode(parent=self.root, pos=(10,10),
+ href="../graphics/testfiles/rgb24alpha-64x64.png")
+ resetFX()
+
+ self.root = self.loadEmptyScene()
+ self.node = avg.ImageNode(parent=self.root, pos=(10,10),
+ href="../graphics/testfiles/hsl.png")
+ resetFX()
+ self.start((
+ lambda: self.compareImage("testInvertFX1", False),
+ redAlphaScene,
+ lambda: self.compareImage("testInvertFX2", False),
+ ))
+
+ def testShadowFX(self):
+
+ def setParams(offset, radius, opacity, color):
+ effect.offset = offset
+ effect.radius = radius
+ effect.opacity = opacity
+ effect.color = color
+
+ root = self.loadEmptyScene()
+ rect = avg.RectNode(parent=root, pos=(9.5,9.5), color="0000FF")
+ node = avg.ImageNode(parent=root, pos=(10,10), href="shadow.png")
+ rect.size = node.size + (1, 1)
+ effect = avg.ShadowFXNode()
+ node.setEffect(effect)
+ self.start((
+ lambda: self.compareImage("testShadowFX1", False),
+ lambda: setParams((0,0), 3, 2, "00FFFF"),
+ lambda: self.compareImage("testShadowFX2", False),
+ lambda: setParams((2,2), 0.1, 1, "FFFFFF"),
+ lambda: self.compareImage("testShadowFX3", False),
+ lambda: setParams((-2,-2), 0.1, 1, "FFFFFF"),
+ lambda: self.compareImage("testShadowFX4", False),
+ lambda: setParams((-2,-2), 3, 1, "FFFFFF"),
+ lambda: self.compareImage("testShadowFX5", False),
+ lambda: setParams((0,0), 0, 1, "FFFFFF"),
+ lambda: self.compareImage("testShadowFX6", False),
+ ))
+
+ def testWordsShadowFX(self):
+ root = self.loadEmptyScene()
+ node = avg.WordsNode(parent=root, pos=(10,10), text="testtext",
+ font="Bitstream Vera Sans")
+ effect = avg.ShadowFXNode()
+ effect.setParams((0,0), 1.5, 1.5, "FF0000")
+ node.setEffect(effect)
+ self.start((
+ lambda: self.compareImage("testWordsShadowFX1", True),
+ lambda: effect.setParams((2,2), 2, 2, "00FFFF"),
+ lambda: self.compareImage("testWordsShadowFX2", True),
+ ))
+
+ def testGamma(self):
+ def setGamma(val):
+ node.gamma = val
+
+ root = self.loadEmptyScene()
+ node = avg.ImageNode(parent=root, href="colorramp.png", gamma=(0.5,0.5,0.5))
+ self.assertEqual(node.gamma, (0.5,0.5,0.5))
+ self.start((
+ lambda: self.compareImage("testGamma1", False),
+ lambda: setGamma((1.5,2.0,2.5)),
+ lambda: self.assertEqual(node.gamma, (1.5,2.0,2.5)),
+ lambda: self.compareImage("testGamma2", False),
+ ))
+
+ def testIntensity(self):
+ def setIntensity(val):
+ node.intensity = val
+
+ def showVideo():
+ node.unlink(True)
+ self.videoNode = avg.VideoNode(parent=root, size=(96,96), threaded=False,
+ href="../video/testfiles/mpeg1-48x48.mpg", intensity=(0.5,0.5,0.5))
+ self.videoNode.play()
+
+ def showText():
+ self.videoNode.unlink(True)
+ textNode = avg.WordsNode(parent=root, fontsize=24, font="Bitstream Vera Sans",
+ intensity=(0.5,0.5,0.5), text="Half-brightness text.",
+ width=140)
+
+ root = self.loadEmptyScene()
+ node = avg.ImageNode(parent=root, href="colorramp.png", intensity=(0.5,0.5,0.5))
+ self.assertEqual(node.intensity, (0.5,0.5,0.5))
+ Player.setFakeFPS(10)
+ self.start((
+ lambda: self.compareImage("testIntensity1", False),
+ lambda: setIntensity((1.5,2.0,2.5)),
+ lambda: self.assertEqual(node.intensity, (1.5,2.0,2.5)),
+ lambda: self.compareImage("testIntensity2", False),
+ showVideo,
+ lambda: self.compareImage("testIntensity3", False),
+ showText,
+ lambda: self.compareImage("testIntensity4", False),
+ ))
+ Player.setFakeFPS(-1)
+ self.videoNode = None
+
+ def testContrast(self):
+ def setContrast(val):
+ node.contrast = val
+
+ def showVideo():
+ node.unlink(True)
+ videoNode = avg.VideoNode(parent=root, size=(96,96), threaded=False,
+ href="../video/testfiles/mpeg1-48x48.mpg", contrast=(0.5,0.5,0.5))
+ videoNode.play()
+
+ root = self.loadEmptyScene()
+ node = avg.ImageNode(parent=root, href="colorramp.png", contrast=(0.5,0.5,0.5))
+ self.assertEqual(node.contrast, (0.5,0.5,0.5))
+ Player.setFakeFPS(10)
+ self.start((
+ lambda: self.compareImage("testContrast1", False),
+ lambda: setContrast((1.5,2.0,2.5)),
+ lambda: self.assertEqual(node.contrast, (1.5,2.0,2.5)),
+ lambda: self.compareImage("testContrast2", False),
+ showVideo,
+ lambda: self.compareImage("testContrast3", False),
+ ))
+ Player.setFakeFPS(-1)
+
+ def testFXUpdate(self):
+ # This tests if the FX render-on-demand functionality doesn't forget updates.
+ def changeTexture():
+ node.href = "colorramp.png"
+
+ def addMaskTex():
+ node.maskhref = "mask.png"
+
+ def changeMaskTex():
+ node.maskhref = "mask2.png"
+
+ def changeMaskPos():
+ node.maskpos = (10, 10)
+
+ def changeFX():
+ effect.radius = 2
+
+ def addVideo():
+ node.unlink(True)
+ videoNode = avg.VideoNode(parent=root, threaded=False, size=(96,96),
+ href="../video/testfiles/mpeg1-48x48.mpg")
+ effect = avg.BlurFXNode()
+ effect.radius = 0
+ videoNode.setEffect(effect)
+ videoNode.play()
+
+ root = self.loadEmptyScene()
+ node = avg.ImageNode(parent=root, href="rgb24alpha-64x64.png")
+ effect = avg.BlurFXNode()
+ effect.radius = 0
+ node.setEffect(effect)
+ Player.setFakeFPS(25)
+ self.start((
+ changeTexture,
+ lambda: self.compareImage("testFXUpdateTex", False),
+ addMaskTex,
+ lambda: self.compareImage("testFXUpdateMaskTex1", False),
+ changeMaskTex,
+ lambda: self.compareImage("testFXUpdateMaskTex2", False),
+ changeMaskPos,
+ lambda: self.compareImage("testFXUpdateMaskPos", False),
+ changeFX,
+ lambda: self.compareImage("testFXUpdateFX", False),
+ addVideo,
+ None,
+ lambda: self.compareImage("testFXUpdateVideo", False),
+ ))
+
+ def __createOffscreenCanvas(self):
+ canvas = Player.createCanvas(id="offscreen", size=(160,120))
+ root = canvas.getRootNode()
+ avg.ImageNode(href="rgb24-32x32.png", parent=root)
+ avg.ImageNode(id="test", pos=(32,0), href="rgb24alpha-32x32.png", parent=root)
+ return canvas
+
+def areFXSupported():
+ sceneString = """<avg id="avg" width="160" height="120"/>"""
+ Player.loadString(sceneString)
+ root = Player.getRootNode()
+ # XXX: The second of the following two lines prevent an opengl error in
+ # testImageNullFX on the Mac (Snow Leopard) for some reason.
+ node = avg.ImageNode(href="rgb24-65x65.png", parent=root)
+ node = avg.ImageNode(href="rgb24-65x65.png", parent=root)
+ node.setEffect(avg.BlurFXNode())
+ Player.setTimeout(0, Player.stop)
+ try:
+ Player.play()
+ return True
+ except RuntimeError:
+ return False
+
+
+def fxTestSuite(tests):
+ if areFXSupported():
+ availableTests = [
+ "testImageNullFX",
+ "testVideoNullFX",
+ "testWordsNullFX",
+ "testCanvasNullFX",
+ "testNodeInCanvasNullFX",
+ "testRenderPipeline",
+ "testBlurFX",
+ "testHueSatFX",
+ "testInvertFX",
+ "testShadowFX",
+ "testWordsShadowFX",
+ "testGamma",
+ "testIntensity",
+ "testContrast",
+ "testFXUpdate",
+ ]
+ else:
+ availableTests = []
+ return createAVGTestSuite(availableTests, FXTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/ImageTest.py b/src/test/ImageTest.py
new file mode 100644
index 0000000..5939656
--- /dev/null
+++ b/src/test/ImageTest.py
@@ -0,0 +1,498 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+
+import shutil
+
+from libavg import avg
+from testcase import *
+
+g_IsMaskSupported = None
+
+class ImageTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testImageHRef(self):
+ def createXmlNode(pos):
+ node = Player.createNode(
+ """<image pos="%s" href="rgb24-32x32.png"/>"""%str(pos))
+ self.assertEqual(node.getMediaSize(), avg.Point2D(32, 32))
+ return node
+
+ def createDictNode(root, p):
+ node = avg.ImageNode(pos=p, href="rgb24-32x32.png", parent=root)
+ self.assertEqual(node.getMediaSize(), avg.Point2D(32, 32))
+ self.assertEqual(node.size, avg.Point2D(32, 32))
+ return node
+
+ def addNodes(y):
+
+ xmlNode = createXmlNode((16, y))
+ root.appendChild(xmlNode)
+
+ createDictNode(root, (48, y))
+
+ noAttachNode = createXmlNode((80, y))
+ noAttachNode.href = "rgb24alpha-32x32.png"
+ self.assertEqual(noAttachNode.getMediaSize(), avg.Point2D(32, 32))
+ self.assertEqual(noAttachNode.size, avg.Point2D(32,32))
+ root.appendChild(noAttachNode)
+
+ attachNode = createXmlNode((112, y))
+ root.appendChild(attachNode)
+ attachNode.href = "rgb24alpha-32x32.png"
+ self.assertEqual(attachNode.getMediaSize(), avg.Point2D(32, 32))
+ self.assertEqual(attachNode.size, avg.Point2D(32,32))
+
+ def setUnicodeHref():
+ if self._isCurrentDirWriteable():
+ # Can't check unicode filenames into svn or the windows client breaks.
+ # So we rename the file locally.
+ shutil.copyfile("oe.png", u"ö.png")
+ node = createXmlNode((16, 16))
+ root.appendChild(node)
+ node.href = u"ö.png"
+ os.remove(u"ö.png")
+
+ def compareUnicode():
+ if self._isCurrentDirWriteable():
+ self.compareImage("testImgHRef3", False)
+
+ root = self.loadEmptyScene()
+ addNodes(16)
+ self.start((
+ lambda: self.compareImage("testImgHRef1", False),
+ lambda: addNodes(48),
+ lambda: self.compareImage("testImgHRef2", False),
+ setUnicodeHref,
+ compareUnicode
+ ))
+
+ def testImagePos(self):
+ def createXmlNode(pos):
+ return Player.createNode(
+ """<image pos="%s" href="rgb24-32x32.png"/>"""%str(pos))
+
+ def createDictNode(root, p):
+ return avg.ImageNode(pos=p, href="rgb24-32x32.png", parent=root)
+
+ def illegalMove(node):
+ self.assertException(node.pos.x == 23)
+ self.assertException(node.pos.y == 23)
+
+ def addNodes(y):
+ xmlNode = createXmlNode((16, y))
+ root.appendChild(xmlNode)
+ createDictNode(root, (48, y))
+ noAttachNode = createXmlNode((0, 0))
+ noAttachNode.pos = avg.Point2D(80, y)
+ illegalMove(noAttachNode)
+ root.appendChild(noAttachNode)
+ attachNode = createXmlNode((0, 0))
+ root.appendChild(attachNode)
+ attachNode.pos = avg.Point2D(112, y)
+ illegalMove(attachNode)
+
+ root = self.loadEmptyScene()
+ addNodes(16)
+ self.start((
+ lambda: self.compareImage("testImgPos1", False),
+ lambda: addNodes(48),
+ lambda: self.compareImage("testImgPos2", False),
+ ))
+
+ def testImageSize(self):
+ def createXmlNode(pos, size):
+ return Player.createNode(
+ """<image pos="%s" size="%s" href="rgb24-64x64.png"/>"""
+ %(str(pos), str(size)))
+
+ def createDictNode(p, s):
+ return avg.ImageNode(pos=p, size=s, href="rgb24-64x64.png")
+
+ def addNodes(y):
+ xmlNode = createXmlNode((16, y), (32, 32))
+ self.assertEqual(xmlNode.size, avg.Point2D(32, 32))
+ root.appendChild(xmlNode)
+ dictNode = createDictNode((48, y), (32, 32))
+ self.assertEqual(dictNode.size, avg.Point2D(32, 32))
+ root.appendChild(dictNode)
+ noAttachNode = createXmlNode((80, y), (0, 0))
+ noAttachNode.size = avg.Point2D(32, 32)
+ self.assertEqual(noAttachNode.size, avg.Point2D(32, 32))
+ root.appendChild(noAttachNode)
+ attachNode = createXmlNode((112, y), (0, 0))
+ root.appendChild(attachNode)
+ attachNode.size = avg.Point2D(32, 32)
+ self.assertEqual(attachNode.size, avg.Point2D(32, 32))
+
+ root = self.loadEmptyScene()
+ addNodes(16)
+ self.start((
+ lambda: self.compareImage("testImgSize1", False),
+ lambda: addNodes(48),
+ lambda: self.compareImage("testImgSize2", False),
+ ))
+
+ def testImageWarp(self):
+ def createNode(p):
+ return avg.ImageNode(pos=p, href="rgb24-32x32.png",
+ maxtilewidth=16, maxtileheight=8)
+
+ def moveVertex(node):
+ grid = node.getWarpedVertexCoords()
+ grid[0][1] = (grid[0][1][0]+0.25, grid[0][1][1]+0.25)
+ node.setWarpedVertexCoords(grid)
+
+ def testEarlyAccessException():
+ node = createNode((16, 16))
+ root.appendChild(node)
+ self.assertException(node.getWarpedVertexCoords)
+ node.unlink()
+
+ def addNode():
+ node = createNode((16, 16))
+ root.appendChild(node)
+ moveVertex(node)
+
+ root = self.loadEmptyScene()
+ testEarlyAccessException()
+ self.start((
+ lambda: addNode(),
+ lambda: self.compareImage("testImgWarp1", False),
+ ))
+
+ def testBitmap(self):
+ def getBitmap(node):
+ bmp = node.getBitmap()
+ self.assertEqual(bmp.getSize(), (65,65))
+ self.assert_(bmp.getFormat() == avg.R8G8B8X8 or
+ bmp.getFormat() == avg.B8G8R8X8)
+ node.setBitmap(bmp)
+ self.assertEqual(node.getMediaSize(), (65,65))
+
+ def loadFromBitmap(p, orighref):
+ node = avg.ImageNode(pos=p, size=(32, 32), href=orighref)
+ bmp = avg.Bitmap('rgb24-65x65.png')
+ self.assertEqual(bmp.getSize(), (65,65))
+ node.setBitmap(bmp)
+ self.assertEqual(node.getMediaSize(), (65,65))
+ root.appendChild(node)
+
+ def testStringConversion():
+ bmp = avg.Bitmap('rgb24-65x65.png')
+ s = bmp.getPixels()
+ bmp1 = avg.Bitmap(bmp.getSize(), avg.B8G8R8X8, "sample")
+ bmp1.setPixels(s)
+ self.assert_(self.areSimilarBmps(bmp, bmp1, 0.01, 0.01))
+
+ def testUnicode():
+ if self._isCurrentDirWriteable():
+ # Can't check unicode filenames into svn or the windows client breaks.
+ # So we rename the file locally.
+ shutil.copyfile("oe.png", u"ö.png")
+ bmp = avg.Bitmap(u"ö.png")
+ os.remove(u"ö.png")
+
+ def testGetPixel():
+ bmp = avg.Bitmap('rgb24-65x65.png')
+ self.assertEqual(bmp.getPixel((1,1)), (255,0,0,255))
+ self.assertEqual(bmp.getPixel((33,1)), (0,255,0,255))
+ bmp = avg.Bitmap('rgb24alpha-64x64.png')
+ self.assertEqual(bmp.getPixel((1,1)), (0,0,0,0))
+ self.assertEqual(bmp.getPixel((63,1)), (83,255,83,142))
+ bmp = avg.Bitmap('greyscale.png')
+ self.assertEqual(bmp.getPixel((1,1)), (255,255,255,255))
+ self.assertEqual(bmp.getPixel((1,63)), (0,0,0,255))
+ self.assertException(lambda: bmp.getPixel((64,0)))
+
+ def setNullBitmap():
+ node.setBitmap(None)
+
+ node = avg.ImageNode(href="rgb24-65x65.png", size=(32, 32))
+ getBitmap(node)
+
+ root = self.loadEmptyScene()
+ node = avg.ImageNode(pos=(0,0), size=(32, 32), href="rgb24-65x65.png")
+ root.appendChild(node)
+ getBitmap(node)
+ self.assertEqual(node.size, (32,32))
+ loadFromBitmap((32,0), "")
+ loadFromBitmap((64,0), "rgb24alpha-64x64.png")
+ testStringConversion()
+ testUnicode()
+ self.start((
+ lambda: getBitmap(node),
+ lambda: loadFromBitmap((32,32), ""),
+ lambda: loadFromBitmap((64,32), "rgb24alpha-64x64.png"),
+ lambda: self.compareImage("testBitmap1", False),
+ testGetPixel,
+ lambda: self.assertException(setNullBitmap)
+ ))
+
+ def testBitmapManager(self):
+ WAIT_TIMEOUT = 2000
+ def expectException(returnValue, nextAction):
+ if isinstance(returnValue, Exception):
+ nextAction()
+ else:
+ raise RuntimeError("Expected exception, got %s (%s)" % (
+ returnValue, type(returnValue)))
+
+ def loadValidBitmap():
+ def validBitmapCb(bitmap):
+ self.assert_(not isinstance(bitmap, Exception))
+ Player.setTimeout(0, loadUnexistentBitmap)
+
+ avg.BitmapManager.get().loadBitmap("rgb24alpha-64x64.png", validBitmapCb)
+
+ def loadUnexistentBitmap():
+ avg.BitmapManager.get().loadBitmap("nonexistent.png",
+ lambda bmp: expectException(
+ returnValue=bmp,
+ nextAction=lambda: Player.setTimeout(0, loadBrokenImage)))
+
+ def loadBrokenImage():
+ import tempfile
+ tempFileName = os.path.join(tempfile.gettempdir(),
+ "broken.png")
+ open(tempFileName, "w")
+
+ def cleanupAndTestReturnValue(returnValue):
+ os.unlink(tempFileName)
+ expectException(returnValue=returnValue, nextAction=Player.stop)
+
+ avg.BitmapManager.get().loadBitmap(tempFileName,
+ cleanupAndTestReturnValue)
+
+ def reportStuck():
+ raise RuntimeError("BitmapManager didn't reply "
+ "within %dms timeout" % WAIT_TIMEOUT)
+ Player.stop()
+
+ root = self.loadEmptyScene()
+
+ Player.setTimeout(WAIT_TIMEOUT, reportStuck)
+ Player.setResolution(0, 0, 0, 0)
+ loadValidBitmap()
+ Player.play()
+
+ def testBlendMode(self):
+ def setBlendMode():
+ blendNode.blendmode="add"
+
+ root = self.loadEmptyScene()
+ avg.ImageNode(href="freidrehen.jpg", parent=root)
+ blendNode = avg.ImageNode(opacity=0.6, href="rgb24-65x65.png", parent=root)
+ avg.ImageNode(pos=(0,48), opacity=0.6, href="rgb24-65x65.png", blendmode="add",
+ parent=root)
+ avg.ImageNode(pos=(48,0), opacity=1, href="rgb24-65x65.png", blendmode="min",
+ parent=root)
+ avg.ImageNode(pos=(48,48), opacity=1, href="rgb24-65x65.png", blendmode="max",
+ parent=root)
+
+ self.start((
+ lambda: self.compareImage("testBlend1", False),
+ setBlendMode,
+ lambda: self.compareImage("testBlend2", False)
+ ))
+
+ def testImageMask(self):
+ def createNode(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", maskhref="mask.png",
+ pos=p, size=(32, 32))
+ root.appendChild(node)
+
+ def setNoAttach(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", pos=p, size=(32, 32))
+ node.maskhref = "mask.png"
+ root.appendChild(node)
+
+ def setAttach(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", pos=p, size=(32, 32))
+ root.appendChild(node)
+ node.maskhref = "mask.png"
+
+ def changeHRef():
+ node.maskhref = "mask2.png"
+
+ def changeBaseHRef():
+ node.href = "greyscale.png"
+
+ def setMaskNotFound():
+ node.maskhref = "nonexistentmask.png"
+
+ if not(self._hasShaderSupport()):
+ return
+ root = self.loadEmptyScene()
+ createNode((0,0))
+ node = root.getChild(0)
+ setNoAttach((32,0))
+ setAttach((64,0))
+ self.start((
+ lambda: createNode((0, 32)),
+ lambda: setNoAttach((32,32)),
+ lambda: setAttach((64,32)),
+ lambda: self.compareImage("testImgMask1", False),
+ changeHRef,
+ lambda: self.compareImage("testImgMask2", False),
+ changeBaseHRef,
+ lambda: self.compareImage("testImgMask3", False),
+ setMaskNotFound
+ ))
+
+ def testImageMaskCanvas(self):
+ if not(self._hasShaderSupport()):
+ return
+ root = self.loadEmptyScene()
+ canvas = Player.createCanvas(id="testcanvas", size=(64,64))
+ avg.ImageNode(href="rgb24-64x64.png", parent=canvas.getRootNode())
+ avg.RectNode(size=(160,120), fillcolor="FFFFFF", fillopacity=1, parent=root)
+ node = avg.ImageNode(href="canvas:testcanvas", maskhref="mask.png", parent=root)
+ self.start([lambda: self.compareImage("testImgMaskCanvas", False)])
+
+ def testImageMaskPos(self):
+ def createNode(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", maskhref="mask.png",
+ pos=p, size=(32, 32), maskpos=(32, 32))
+ root.appendChild(node)
+
+ def setNoAttach(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", maskhref="mask.png",
+ pos=p, size=(32, 32))
+ node.maskpos = (32, 32)
+ root.appendChild(node)
+
+ def setAttach(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", maskhref="mask.png",
+ pos=p, size=(32, 32))
+ root.appendChild(node)
+ node.maskpos = (32, 32)
+
+ root = self.loadEmptyScene()
+ if not(self._hasShaderSupport()):
+ return
+ createNode((0,0))
+ setNoAttach((32,0))
+ setAttach((64,0))
+ self.start((
+ lambda: createNode((0, 32)),
+ lambda: setNoAttach((32,32)),
+ lambda: setAttach((64,32)),
+ lambda: self.compareImage("testImgMaskPos", False)
+ ))
+
+ def testImageMaskSize(self):
+ def createNode(p):
+ avg.ImageNode(href="rgb24-65x65.png", maskhref="mask.png",
+ pos=p, size=(32, 32), masksize=(48, 48), parent=root)
+
+ def setNoAttach(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", maskhref="mask.png",
+ pos=p, size=(32, 32))
+ node.masksize = (48, 48)
+ root.appendChild(node)
+
+ def setAttach(p):
+ node = avg.ImageNode(href="rgb24-65x65.png", maskhref="mask.png",
+ pos=p, size=(32, 32), parent=root)
+ node.masksize = (48, 48)
+
+ def setPos():
+ node.maskpos = (16, 16)
+
+ def resetPos():
+ node.maskpos = (0, 0)
+ node.masksize = (0, 0)
+
+ root = self.loadEmptyScene()
+ if not(self._hasShaderSupport()):
+ return
+ createNode((0,0))
+ node = root.getChild(0)
+ setNoAttach((32,0))
+ setAttach((64,0))
+ self.start((
+ lambda: createNode((0, 32)),
+ lambda: setNoAttach((32,32)),
+ lambda: setAttach((64,32)),
+ lambda: self.compareImage("testImgMaskSize1", False),
+ setPos,
+ lambda: self.compareImage("testImgMaskSize2", False),
+ resetPos,
+ lambda: self.compareImage("testImgMaskSize3", False)
+ ))
+
+ def testImageMipmap(self):
+ root = self.loadEmptyScene()
+ avg.ImageNode(size=(64,64), href="checker.png", parent=root)
+ avg.ImageNode(pos=(64,0), size=(64,64), href="checker.png", mipmap=True,
+ parent=root)
+ self.start([lambda: self.compareImage("testMipmap", False)])
+
+ def testImageCompression(self):
+ def loadBitmap():
+ bmp = avg.Bitmap("colorramp.png")
+ self.image.setBitmap(bmp)
+
+ def relink():
+ self.image.unlink(False)
+ root.appendChild(self.image)
+
+ def checkAlpha():
+ self.image.href="rgb24alpha-64x64.png"
+
+ root = self.loadEmptyScene()
+ self.image = avg.ImageNode(href="rgb24-64x64.png", compression="B5G6R5",
+ parent=root)
+ self.assertEqual(self.image.compression, "B5G6R5")
+ self.start([
+ lambda: self.compareImage("testTexCompression1", False),
+ loadBitmap,
+ lambda: self.compareImage("testTexCompression2", False),
+ relink,
+ lambda: self.compareImage("testTexCompression2", False),
+ checkAlpha,
+ ])
+
+
+def imageTestSuite(tests):
+ availableTests = (
+ "testImageHRef",
+ "testImagePos",
+ "testImageSize",
+ "testImageWarp",
+ "testBitmap",
+ "testBitmapManager",
+ "testBlendMode",
+ "testImageMask",
+ "testImageMaskCanvas",
+ "testImageMaskPos",
+ "testImageMaskSize",
+ "testImageMipmap",
+ "testImageCompression",
+ )
+ return createAVGTestSuite(availableTests, ImageTestCase, tests)
+
+Player = avg.Player.get()
+
diff --git a/src/test/InputDeviceTest.py b/src/test/InputDeviceTest.py
new file mode 100644
index 0000000..f0bb935
--- /dev/null
+++ b/src/test/InputDeviceTest.py
@@ -0,0 +1,199 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import unittest
+
+from libavg import avg
+from testcase import *
+
+
+class CustomInputDevice(avg.InputDevice):
+ def __init__(self, eventReceiverNode=None):
+ if eventReceiverNode:
+ super(CustomInputDevice, self).__init__(self.__class__.__name__,
+ eventReceiverNode)
+ else:
+ super(CustomInputDevice, self).__init__(self.__class__.__name__)
+
+ self.__events = []
+
+ def pollEvents(self):
+ events = self.__events[:]
+ self.__events = []
+ return events
+
+ def feedEvent(self, event):
+ self.__events.append(event)
+
+
+class AnonymousInputDevice(avg.InputDevice):
+ def __init__(self, eventReceiverNode=None):
+ if eventReceiverNode:
+ super(AnonymousInputDevice, self).__init__(self.__class__.__name__,
+ eventReceiverNode)
+ else:
+ super(AnonymousInputDevice, self).__init__(self.__class__.__name__)
+
+ self.__isInitialized = False
+
+ def pollEvents(self):
+ if self.__isInitialized: return []
+ self.__isInitialized = True
+ return [ avg.Event(avg.CUSTOMEVENT, avg.CUSTOM) ]
+
+
+class EventTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testCustomInputDevice(self):
+ root = self.loadEmptyScene()
+
+ class DerivedEvent(avg.Event):
+ def __init__(self):
+ super(DerivedEvent, self).__init__(avg.CUSTOMEVENT, avg.NONE)
+ self.property = True
+
+ self.hasEventHandlerBeenCalled = False
+ self.isCustomInputDeviceSet = False
+ self.isCustomInputDeviceNameSet = False
+ self.hasCustomEventProperty = False
+
+ def eventHandler(event):
+ self.hasEventHandlerBeenCalled = True
+ self.isCustomInputDeviceSet = event.inputdevice == self.customInputDevice
+ self.isCustomInputDeviceNameSet = (event.inputdevicename ==
+ self.customInputDevice.name)
+
+ def customEventEventHandler(event):
+ self.hasCustomEventProperty = event.property
+
+ def checkAndResetResults():
+ if not self.hasEventHandlerBeenCalled: return False
+ if not self.isCustomInputDeviceSet: return False
+ if not self.isCustomInputDeviceNameSet: return False
+
+ self.hasEventHandlerBeenCalled = False
+ self.isCustomInputDeviceSet = False
+ self.isCustomInputDeviceNameSet = False
+ return True
+
+ rectNode = avg.RectNode(parent=root, pos=(0, 0), size=(50, 50))
+ rectNode.setEventHandler(avg.CURSORDOWN, avg.MOUSE|avg.TOUCH, eventHandler)
+
+ root.setEventHandler(avg.CURSORDOWN, avg.NONE, eventHandler)
+ root.setEventHandler(avg.CUSTOMEVENT, avg.NONE, customEventEventHandler)
+
+ self.customInputDevice = CustomInputDevice()
+ Player.addInputDevice(self.customInputDevice)
+
+ self.start((
+ lambda: self.customInputDevice.feedEvent(
+ avg.Event(avg.CURSORDOWN, avg.NONE)),
+ lambda: self.assert_(checkAndResetResults()),
+
+ lambda: self.customInputDevice.feedEvent(
+ DerivedEvent()),
+ lambda: self.assert_(self.hasCustomEventProperty),
+
+ lambda: self.customInputDevice.feedEvent(
+ avg.MouseEvent(avg.CURSORDOWN, False, False, False, (5, 5), 0)),
+ lambda: self.assert_(checkAndResetResults()),
+
+ lambda: self.customInputDevice.feedEvent(
+ avg.TouchEvent(300, avg.CURSORDOWN, (5, 5), avg.TOUCH, (10,10))),
+ lambda: self.assert_(checkAndResetResults())
+ ))
+
+ def testAnonymousInputDevice(self):
+ root = self.loadEmptyScene()
+
+ self.hasEventHandlerBeenCalled = False
+
+ def eventHandler(event):
+ self.hasEventHandlerBeenCalled = (event.inputdevicename ==
+ AnonymousInputDevice.__name__)
+
+ def checkAndResetResults():
+ if not self.hasEventHandlerBeenCalled:
+ return False
+
+ self.hasEventHandlerBeenCalled = False
+ return True
+
+ root.setEventHandler(avg.CUSTOMEVENT, avg.CUSTOM, eventHandler)
+ Player.addInputDevice(AnonymousInputDevice())
+
+ self.start((
+ lambda: None,
+ lambda: None,
+ lambda: self.assert_(checkAndResetResults())
+ ))
+
+ def testInputDeviceEventReceiverNode(self):
+ root = self.loadEmptyScene()
+
+ divNode = avg.DivNode(id="div", size=(50, 50), parent=root)
+ rectNode = avg.RectNode(id="rect", size=(50, 50), parent=root)
+
+ self.customInputDevice = CustomInputDevice(divNode)
+ Player.addInputDevice(self.customInputDevice)
+
+ handlerTester = NodeHandlerTester(self, divNode)
+
+ self.start((
+ lambda: self.customInputDevice.feedEvent(
+ avg.MouseEvent(avg.CURSORDOWN, True, False, False, (10, 10), 1)),
+ lambda: handlerTester.assertState(
+ down=True, up=False, over=True, out=False, move=False),
+
+ lambda: self.customInputDevice.feedEvent(avg.MouseEvent(
+ avg.CURSORMOTION, True, False, False, (12, 12), 1)),
+ lambda: handlerTester.assertState(
+ down=False, up=False, over=False, out=False, move=True),
+
+ lambda: self.customInputDevice.feedEvent(avg.MouseEvent(
+ avg.CURSORMOTION, True, False, False, (100, 100), 1)),
+ lambda: handlerTester.assertState(
+ down=False, up=False, over=False, out=True, move=False),
+
+ lambda: self.customInputDevice.feedEvent(avg.MouseEvent(
+ avg.CURSORMOTION, True, False, False, (12, 12), 1)),
+ lambda: handlerTester.assertState(
+ down=False, up=False, over=True, out=False, move=True),
+
+ lambda: self.customInputDevice.feedEvent(avg.MouseEvent(
+ avg.CURSORUP, False, False, False, (12, 12), 1)),
+ lambda: handlerTester.assertState(
+ down=False, up=True, over=False, out=False, move=False)
+
+ ))
+
+def inputDeviceTestSuite(tests):
+ availableTests = (
+ "testCustomInputDevice",
+ "testAnonymousInputDevice",
+ "testInputDeviceEventReceiverNode"
+ )
+ return createAVGTestSuite(availableTests, EventTestCase, tests)
+
+Player = avg.Player.get()
+Helper = Player.getTestHelper()
diff --git a/src/test/Makefile.am b/src/test/Makefile.am
new file mode 100644
index 0000000..215ce67
--- /dev/null
+++ b/src/test/Makefile.am
@@ -0,0 +1,9 @@
+SUBDIRS = plugin
+
+pkgpyexec_PYTHON = testcase.py testapp.py
+
+EXTRA_DIST = $(wildcard *.avg) $(wildcard *.png) $(wildcard *.jpg) $(wildcard *.tif) \
+ $(wildcard *.py) $(wildcard baseline/*.png) $(wildcard testmediadir/*) \
+ $(wildcard extrafonts) $(wildcard fonts) $(wildcard *.svg)
+
+TESTS= Test.py
diff --git a/src/test/Makefile.in b/src/test/Makefile.in
new file mode 100644
index 0000000..550dc45
--- /dev/null
+++ b/src/test/Makefile.in
@@ -0,0 +1,798 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/test
+DIST_COMMON = $(pkgpyexec_PYTHON) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+ html-recursive info-recursive install-data-recursive \
+ install-dvi-recursive install-exec-recursive \
+ install-html-recursive install-info-recursive \
+ install-pdf-recursive install-ps-recursive install-recursive \
+ installcheck-recursive installdirs-recursive pdf-recursive \
+ ps-recursive uninstall-recursive
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkgpyexecdir)"
+py_compile = $(top_srcdir)/py-compile
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
+ distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+ $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+ distdir
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+ dir0=`pwd`; \
+ sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+ sed_rest='s,^[^/]*/*,,'; \
+ sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+ sed_butlast='s,/*[^/]*$$,,'; \
+ while test -n "$$dir1"; do \
+ first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+ if test "$$first" != "."; then \
+ if test "$$first" = ".."; then \
+ dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+ dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+ else \
+ first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+ if test "$$first2" = "$$first"; then \
+ dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+ else \
+ dir2="../$$dir2"; \
+ fi; \
+ dir0="$$dir0"/"$$first"; \
+ fi; \
+ fi; \
+ dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+ done; \
+ reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+SUBDIRS = plugin
+pkgpyexec_PYTHON = testcase.py testapp.py
+EXTRA_DIST = $(wildcard *.avg) $(wildcard *.png) $(wildcard *.jpg) $(wildcard *.tif) \
+ $(wildcard *.py) $(wildcard baseline/*.png) $(wildcard testmediadir/*) \
+ $(wildcard extrafonts) $(wildcard fonts) $(wildcard *.svg)
+
+TESTS = Test.py
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/test/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/test/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-pkgpyexecPYTHON: $(pkgpyexec_PYTHON)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgpyexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgpyexecdir)"
+ @list='$(pkgpyexec_PYTHON)'; dlist=; list2=; test -n "$(pkgpyexecdir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
+ if test -f $$b$$p; then \
+ $(am__strip_dir) \
+ dlist="$$dlist $$f"; \
+ list2="$$list2 $$b$$p"; \
+ else :; fi; \
+ done; \
+ for file in $$list2; do echo $$file; done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgpyexecdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgpyexecdir)" || exit $$?; \
+ done || exit $$?; \
+ if test -n "$$dlist"; then \
+ if test -z "$(DESTDIR)"; then \
+ PYTHON=$(PYTHON) $(py_compile) --basedir "$(pkgpyexecdir)" $$dlist; \
+ else \
+ PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(pkgpyexecdir)" $$dlist; \
+ fi; \
+ else :; fi
+
+uninstall-pkgpyexecPYTHON:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgpyexec_PYTHON)'; test -n "$(pkgpyexecdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ filesc=`echo "$$files" | sed 's|$$|c|'`; \
+ fileso=`echo "$$files" | sed 's|$$|o|'`; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$files || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$filesc ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$filesc || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$fileso ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$fileso
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+# (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+ @fail= failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ target=`echo $@ | sed s/-recursive//`; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ dot_seen=yes; \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done; \
+ if test "$$dot_seen" = "no"; then \
+ $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+ fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+ @fail= failcom='exit 1'; \
+ for f in x $$MAKEFLAGS; do \
+ case $$f in \
+ *=* | --[!k]*);; \
+ *k*) failcom='fail=yes';; \
+ esac; \
+ done; \
+ dot_seen=no; \
+ case "$@" in \
+ distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+ *) list='$(SUBDIRS)' ;; \
+ esac; \
+ rev=''; for subdir in $$list; do \
+ if test "$$subdir" = "."; then :; else \
+ rev="$$subdir $$rev"; \
+ fi; \
+ done; \
+ rev="$$rev ."; \
+ target=`echo $@ | sed s/-recursive//`; \
+ for subdir in $$rev; do \
+ echo "Making $$target in $$subdir"; \
+ if test "$$subdir" = "."; then \
+ local_target="$$target-am"; \
+ else \
+ local_target="$$target"; \
+ fi; \
+ ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+ || eval $$failcom; \
+ done && test -z "$$fail"
+tags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+ done
+ctags-recursive:
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+ done
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+ include_option=--etags-include; \
+ empty_fix=.; \
+ else \
+ include_option=--include; \
+ empty_fix=; \
+ fi; \
+ list='$(SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test ! -f $$subdir/TAGS || \
+ set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+ fi; \
+ done; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ test -d "$(distdir)/$$subdir" \
+ || $(MKDIR_P) "$(distdir)/$$subdir" \
+ || exit 1; \
+ fi; \
+ done
+ @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+ if test "$$subdir" = .; then :; else \
+ dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+ $(am__relativize); \
+ new_distdir=$$reldir; \
+ dir1=$$subdir; dir2="$(top_distdir)"; \
+ $(am__relativize); \
+ new_top_distdir=$$reldir; \
+ echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+ echo " am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+ ($(am__cd) $$subdir && \
+ $(MAKE) $(AM_MAKEFLAGS) \
+ top_distdir="$$new_top_distdir" \
+ distdir="$$new_distdir" \
+ am__remove_distdir=: \
+ am__skip_length_check=: \
+ am__skip_mode_fix=: \
+ distdir) \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+ for dir in "$(DESTDIR)$(pkgpyexecdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-pkgpyexecPYTHON
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-pkgpyexecPYTHON
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) check-am \
+ ctags-recursive install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+ all all-am check check-TESTS check-am clean clean-generic \
+ clean-libtool ctags ctags-recursive distclean \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-pkgpyexecPYTHON install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs installdirs-am maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-generic \
+ mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+ uninstall uninstall-am uninstall-pkgpyexecPYTHON
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/test/OffscreenTest.py b/src/test/OffscreenTest.py
new file mode 100644
index 0000000..2ea6e6b
--- /dev/null
+++ b/src/test/OffscreenTest.py
@@ -0,0 +1,474 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import unittest
+
+from libavg import avg
+from testcase import *
+import gc
+
+class OffscreenTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testCanvasBasics(self):
+ def createCanvas(isFirst, canvasName, x):
+ canvas = self.__createOffscreenCanvas(canvasName, False)
+ canvas.getElementByID("test1").x = x
+ node = avg.ImageNode(parent=root, id="imagenode")
+ node.href="canvas:"+canvasName
+ if isFirst:
+ self.assertEqual(canvas.getNumDependentCanvases(), 0)
+ self.canvas1 = canvas
+ else:
+ self.assertEqual(canvas.getNumDependentCanvases(), 1)
+ self.canvas2 = canvas
+
+ def unlink():
+ self.node = Player.getElementByID("imagenode")
+ self.node.unlink()
+ self.assertEqual(self.canvas1.getNumDependentCanvases(), 0)
+ gc.collect()
+
+ def relink():
+ root.appendChild(self.node)
+ self.node = None
+ self.assertEqual(self.canvas1.getNumDependentCanvases(), 1)
+
+ def changeHRef(href):
+ Player.getElementByID("imagenode").href = href
+
+ def setBitmap():
+ bitmap = avg.Bitmap("rgb24-65x65.png")
+ Player.getElementByID("imagenode").setBitmap(bitmap)
+
+ def deleteCanvases():
+ changeHRef("")
+ firstNode.href = ""
+ Player.deleteCanvas("testcanvas1")
+# self.assertException(lambda: changeHRef("canvas:testcanvas1"))
+ changeHRef("canvas:testcanvas2")
+# self.assertException(lambda: Player.deleteCanvas("testcanvas2"))
+ changeHRef("")
+ Player.deleteCanvas("testcanvas2")
+# self.assertException(lambda: Player.deleteCanvas("foo"))
+
+ root = self.loadEmptyScene()
+ createCanvas(True, "testcanvas1", 0)
+ firstNode = Player.getElementByID("imagenode")
+ self.start((
+ lambda: self.compareImage("testOffscreen1", False),
+ unlink,
+ lambda: self.compareImage("testOffscreen2", False),
+ relink,
+ lambda: self.compareImage("testOffscreen1", False),
+ unlink,
+ lambda: createCanvas(False, "testcanvas2", 80),
+ lambda: self.compareImage("testOffscreen3", False),
+ lambda: changeHRef("canvas:testcanvas1"),
+ lambda: self.assertEqual(self.canvas1.getNumDependentCanvases(), 1),
+ lambda: self.assertEqual(self.canvas2.getNumDependentCanvases(), 0),
+ lambda: self.compareImage("testOffscreen1", False),
+ lambda: changeHRef("rgb24-65x65.png"),
+ lambda: self.assertEqual(self.canvas1.getNumDependentCanvases(), 0),
+ lambda: self.compareImage("testOffscreen4", False),
+ lambda: changeHRef("canvas:testcanvas1"),
+ lambda: self.assertEqual(self.canvas1.getNumDependentCanvases(), 1),
+ lambda: self.compareImage("testOffscreen1", False),
+ setBitmap,
+ lambda: self.compareImage("testOffscreen4", False),
+ deleteCanvases,
+ lambda: self.compareImage("testOffscreen5", False),
+ ))
+
+ def testCanvasLoadAfterPlay(self):
+ def createOffscreenCanvas():
+ offscreenCanvas = self.__createOffscreenCanvas("offscreencanvas", False)
+ self.node = avg.ImageNode(parent=root,
+ href="canvas:offscreencanvas")
+
+ root = self.loadEmptyScene()
+ self.start((
+ createOffscreenCanvas,
+ lambda: self.compareImage("testOffscreen1", False),
+ ))
+
+ def testCanvasResize(self):
+ def setSize():
+ self.node.size = (80, 60)
+
+ mainCanvas, offscreenCanvas = self.__setupCanvas(False)
+ self.start((
+ setSize,
+ lambda: self.compareImage("testCanvasResize", False)
+ ))
+
+ def testCanvasErrors(self):
+ self.loadEmptyScene()
+ # Missing size
+ self.assertException(
+ lambda: Player.createCanvas(id="foo"))
+ # Duplicate canvas id
+ Player.createCanvas(id="foo", size=(160, 120))
+ self.assertException(
+ lambda: Player.createCanvas(id="foo", size=(160, 120)))
+
+ def testCanvasAPI(self):
+ def checkMainScreenshot():
+ bmp1 = Player.screenshot()
+ bmp2 = mainCanvas.screenshot()
+ self.assert_(self.areSimilarBmps(bmp1, bmp2, 0.01, 0.01))
+
+ def checkCanvasScreenshot():
+ bmp = offscreenCanvas.screenshot()
+ self.compareBitmapToFile(bmp, "testOffscreenScreenshot", False)
+
+ def createCompressed():
+ avg.ImageNode(href="canvas:offscreencanvas", compression="B5G6R5",
+ parent=root)
+
+ root = self.loadEmptyScene()
+ mainCanvas = Player.getMainCanvas()
+ self.assertEqual(mainCanvas.getRootNode(), root)
+ offscreenCanvas = self.__createOffscreenCanvas("offscreencanvas", False)
+ self.assertEqual(offscreenCanvas, Player.getCanvas("offscreencanvas"))
+ self.assertEqual(offscreenCanvas.getElementByID("test1").href, "rgb24-65x65.png")
+ self.assertEqual(offscreenCanvas.getElementByID("missingnode"), None)
+ self.assertException(Player.screenshot)
+ self.assertException(createCompressed)
+ self.start((
+ checkMainScreenshot,
+ checkCanvasScreenshot))
+
+ def testCanvasEvents(self):
+ def onOffscreenImageDown(event):
+ self.__offscreenImageDownCalled = True
+
+ def onMainDown(event):
+ self.__mainDownCalled = True
+
+ def reset():
+ self.__offscreenImageDownCalled = False
+ self.__mainDownCalled = False
+
+ def setPos():
+ self.node.pos = (80, 60)
+ self.node.size = (80, 60)
+
+ mainCanvas, offscreenCanvas = self.__setupCanvas(True)
+ offscreenImage = offscreenCanvas.getElementByID("test1")
+ offscreenImage.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onOffscreenImageDown)
+ Player.getRootNode().setEventHandler(avg.CURSORDOWN, avg.MOUSE, onMainDown)
+ self.__offscreenImageDownCalled = False
+ self.__mainDownCalled = False
+ self.start((
+ lambda: self.fakeClick(10, 10),
+ lambda: self.assert_(self.__offscreenImageDownCalled),
+ reset,
+ lambda: self.fakeClick(80, 10),
+ lambda: self.assert_(not(self.__offscreenImageDownCalled)),
+ reset,
+ setPos,
+ lambda: self.fakeClick(70, 65),
+ lambda: self.assert_(not(self.__offscreenImageDownCalled)),
+ lambda: self.fakeClick(120, 65),
+ lambda: self.assert_(not(self.__offscreenImageDownCalled)),
+ reset,
+ lambda: self.fakeClick(110, 65),
+ lambda: self.assert_(self.__offscreenImageDownCalled and
+ self.__mainDownCalled),
+ reset,
+ lambda: self.fakeClick(1, 1),
+ lambda: self.assert_(not(self.__offscreenImageDownCalled) and
+ self.__mainDownCalled),
+ ))
+
+ def testCanvasEventCapture(self):
+ def onOffscreenImageDown(event):
+ self.__offscreenImageDownCalled = True
+
+ mainCanvas, offscreenCanvas = self.__setupCanvas(True)
+ offscreenImage = offscreenCanvas.getElementByID("test1")
+ offscreenImage.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onOffscreenImageDown);
+ helper = Player.getTestHelper()
+ self.__offscreenImageDownCalled = False
+ offscreenImage.setEventCapture()
+ self.start((
+ lambda: helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False,
+ 80, 10, 1),
+ lambda: self.assert_(self.__offscreenImageDownCalled),
+ ))
+
+ def testCanvasRender(self):
+ def createCanvas():
+ canvas = Player.createCanvas(id="testcanvas", size=(160,120),
+ autorender=False)
+ avg.ImageNode(id="test", href="rgb24-65x65.png", parent=canvas.getRootNode())
+ return canvas
+
+ def testEarlyScreenshotException():
+ self.assertException(self.__offscreenCanvas.screenshot)
+
+ def renderCanvas():
+ self.__offscreenCanvas.render()
+ bmp = self.__offscreenCanvas.screenshot()
+ self.compareBitmapToFile(bmp, "testOffscreenScreenshot", False)
+
+ def deleteCanvas():
+ Player.deleteCanvas("testcanvas")
+ self.__offscreenCanvas = None
+
+ def recreateCanvas():
+ self.__offscreenCanvas = createCanvas()
+
+ self.loadEmptyScene()
+ self.__offscreenCanvas = createCanvas()
+ self.assertException(renderCanvas)
+ self.start((
+ testEarlyScreenshotException,
+ renderCanvas,
+ deleteCanvas,
+ recreateCanvas,
+ renderCanvas
+ ))
+
+ def testCanvasAutoRender(self):
+ def createCanvas():
+ canvas = self.__createOffscreenCanvas("testcanvas", False)
+ avg.ImageNode(href="canvas:testcanvas", parent=root)
+ return canvas
+
+ def disableAutoRender():
+ self.__offscreenCanvas.autorender = False
+
+ def enableAutoRender():
+ self.__offscreenCanvas.autorender = True
+
+ def changeContent():
+ self.__offscreenCanvas.getElementByID("test1").x = 42
+
+ root = self.loadEmptyScene()
+ self.__offscreenCanvas = createCanvas()
+ self.start((
+ lambda: self.assert_(self.__offscreenCanvas.autorender),
+ lambda: self.compareImage("testOffscreenAutoRender1", False),
+ disableAutoRender,
+ lambda: self.assert_(not(self.__offscreenCanvas.autorender)),
+ changeContent,
+ lambda: self.compareImage("testOffscreenAutoRender1", False),
+ enableAutoRender,
+ lambda: self.assert_(self.__offscreenCanvas.autorender),
+ lambda: self.compareImage("testOffscreenAutoRender2", False)
+ ))
+
+ def testCanvasCrop(self):
+ root = self.loadEmptyScene()
+ canvas = Player.createCanvas(id="testcanvas", size=(160,120))
+ div = avg.DivNode(pos=(40,30), size=(80,60), crop=True,
+ parent=canvas.getRootNode())
+ avg.ImageNode(id="test1", pos=(-32, -32), href="rgb24-65x65.png", parent=div)
+ avg.ImageNode(parent=root, href="canvas:testcanvas")
+ self.start((lambda: self.compareImage("testCanvasCrop", False),))
+
+ def testCanvasAlpha(self):
+ root = self.loadEmptyScene()
+ canvas = Player.createCanvas(id="testcanvas", size=(80,120))
+ avg.ImageNode(id="test1", href="rgb24alpha-64x64.png",
+ parent=canvas.getRootNode())
+ avg.RectNode(parent=root, fillcolor="FFFFFF",
+ pos=(0.5, 0.5), size=(160, 48), fillopacity=1)
+ avg.ImageNode(parent=root, href="canvas:testcanvas")
+ avg.ImageNode(parent=root, x=64, href="rgb24alpha-64x64.png")
+ self.start((lambda: self.compareImage("testCanvasAlpha", False),))
+
+ def testCanvasBlendModes(self):
+ def createBaseCanvas():
+ canvas = Player.createCanvas(id="testcanvas", size=(64,64))
+ avg.ImageNode(href="rgb24alpha-64x64.png", parent=canvas.getRootNode())
+ return canvas
+
+ root = self.loadEmptyScene()
+ createBaseCanvas()
+ avg.RectNode(parent=root, pos=(48,0), size=(32, 120), strokewidth=2,
+ fillopacity=1, fillcolor="808080")
+ avg.ImageNode(parent=root, href="canvas:testcanvas")
+ avg.ImageNode(parent=root, pos=(0,64), href="canvas:testcanvas",
+ opacity=0.6)
+ avg.ImageNode(parent=root, pos=(64,0), href="canvas:testcanvas",
+ blendmode="add")
+ avg.ImageNode(parent=root, pos=(64,64), href="canvas:testcanvas",
+ opacity=0.6, blendmode="add")
+ self.start((lambda: self.compareImage("testCanvasBlendModes", False),))
+
+ def testCanvasMultisampling(self):
+ def testIllegalSamples():
+ self.canvas = Player.createCanvas(id="brokencanvas", size=(160,120),
+ multisamplesamples=42)
+
+ def screenshot():
+ bmp = self.canvas.screenshot()
+ self.compareBitmapToFile(bmp, "testOffscreenMultisampleScreenshot", False)
+
+ def createCanvas():
+ if not(avg.OffscreenCanvas.isMultisampleSupported()):
+ self.skip("Offscreen multisampling not supported")
+ Player.stop()
+ return
+ try:
+ self.canvas = Player.createCanvas(id="testcanvas", size=(160,120),
+ multisamplesamples=2)
+ avg.ImageNode(id="test1", href="rgb24-65x65.png", angle=0.1,
+ parent=self.canvas.getRootNode())
+ except RuntimeError:
+ self.skip("Offscreen multisampling init failed")
+ Player.stop()
+ return
+ self.assertEqual(self.canvas.multisamplesamples, 2)
+ avg.ImageNode(parent=root, href="canvas:testcanvas")
+
+
+ root = self.loadEmptyScene()
+ self.start((
+ createCanvas,
+ lambda: self.compareImage("testCanvasMultisample", False),
+ screenshot,
+ lambda: self.assertException(testIllegalSamples),
+ ))
+ self.canvas = None
+
+ def testCanvasMipmap(self):
+ root = self.loadEmptyScene()
+
+ canvas = Player.createCanvas(id="testcanvas", size=(80,120), mipmap=True)
+ avg.ImageNode(id="test1", href="rgb24alpha-64x64.png",
+ parent=canvas.getRootNode())
+ avg.ImageNode(parent=root, size=(40, 30), href="canvas:testcanvas")
+ try:
+ self.start((lambda: self.compareImage("testCanvasMipmap", False),))
+ except RuntimeError:
+ self.skip("Offscreen mipmap init failed.")
+ return
+
+ def testCanvasDependencies(self):
+ def makeCircularRef():
+ self.offscreen1.getElementByID("test1").href = "canvas:offscreencanvas2"
+
+ def makeSelfRef1():
+ avg.ImageNode(href="canvas:offscreencanvas1",
+ parent=self.offscreen1.getRootNode())
+
+ def makeSelfRef2():
+ self.offscreen1.getElementByID("test1").href = "canvas:offscreencanvas1"
+
+ def createTwoCanvases():
+ self.offscreen1 = self.__createOffscreenCanvas("offscreencanvas1", False)
+ self.offscreen2 = self.__createOffscreenCanvas("offscreencanvas2", False)
+ self.node = avg.ImageNode(parent=root,
+ href="canvas:offscreencanvas1")
+ node = self.offscreen1.getElementByID("test1")
+ node.href = "canvas:offscreencanvas2"
+ node.size = (80, 60)
+
+ def exchangeCanvases():
+ self.offscreen1.getElementByID("test1").href = "rgb24-65x65.png"
+ self.offscreen2.getElementByID("test1").href = "canvas:offscreencanvas1"
+ self.node.href = "canvas:offscreencanvas2"
+
+ def loadCanvasDepString():
+ Player.createCanvas(id="canvas1", size=(160, 120))
+ canvas2 = Player.createCanvas(id="canvas2", size=(160, 120))
+ avg.ImageNode(href="canvas:canvas1", parent=canvas2.getRootNode())
+ Player.deleteCanvas('canvas2')
+ Player.deleteCanvas('canvas1')
+
+ root = self.loadEmptyScene()
+ createTwoCanvases()
+ self.offscreen1.getElementByID("test1").href = ""
+ self.offscreen1 = None
+ self.offscreen2 = None
+ self.node.href = ""
+ self.node = None
+ Player.deleteCanvas("offscreencanvas1")
+ Player.deleteCanvas("offscreencanvas2")
+ self.start((
+ createTwoCanvases,
+ lambda: self.compareImage("testCanvasDependencies1", False),
+ exchangeCanvases,
+ lambda: self.compareImage("testCanvasDependencies2", False),
+ lambda: self.assertException(makeCircularRef),
+ lambda: self.assertException(makeSelfRef1),
+ lambda: self.assertException(makeSelfRef2),
+ loadCanvasDepString,
+ ))
+
+ def __setupCanvas(self, handleEvents):
+ root = self.loadEmptyScene()
+ mainCanvas = Player.getMainCanvas()
+ offscreenCanvas = self.__createOffscreenCanvas("offscreencanvas", handleEvents)
+ self.node = avg.ImageNode(parent=root, href="canvas:offscreencanvas")
+ return (mainCanvas, offscreenCanvas)
+
+ def __createOffscreenCanvas(self, canvasName, handleEvents):
+ canvas=Player.createCanvas(id=canvasName, size=(160,120),
+ handleevents=handleEvents)
+ avg.ImageNode(id="test1", href="rgb24-65x65.png", parent=canvas.getRootNode())
+ return canvas
+
+def isOffscreenSupported():
+
+ def testOffscreenSupported():
+ global offscreenSupported
+ offscreenSupported = avg.OffscreenCanvas.isSupported()
+ Player.stop()
+
+ global offscreenSupported
+ sceneString = """<avg id="avg" width="160" height="120"/>"""
+ Player.loadString(sceneString)
+ Player.setTimeout(0, testOffscreenSupported)
+ Player.play()
+ return offscreenSupported
+
+def offscreenTestSuite(tests):
+ if isOffscreenSupported():
+ availableTests = (
+ "testCanvasBasics",
+ "testCanvasLoadAfterPlay",
+ "testCanvasResize",
+ "testCanvasErrors",
+ "testCanvasAPI",
+ "testCanvasEvents",
+ "testCanvasEventCapture",
+ "testCanvasRender",
+ "testCanvasAutoRender",
+ "testCanvasCrop",
+ "testCanvasAlpha",
+ "testCanvasBlendModes",
+ "testCanvasMultisampling",
+ "testCanvasMipmap",
+ "testCanvasDependencies",
+ )
+ return createAVGTestSuite(availableTests, OffscreenTestCase, tests)
+ else:
+ print "Skipping offscreen tests - no canvas support with this graphics configuration."
+ return lambda x: None
+
+
+Player = avg.Player.get()
diff --git a/src/test/PlayerTest.py b/src/test/PlayerTest.py
new file mode 100644
index 0000000..e43e204
--- /dev/null
+++ b/src/test/PlayerTest.py
@@ -0,0 +1,769 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import time
+import math
+
+from libavg import avg
+from testcase import *
+
+class PlayerTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testPoint(self):
+ def testHash():
+ ptMap = {}
+ ptMap[avg.Point2D(0,0)] = 0
+ ptMap[avg.Point2D(1,0)] = 1
+ ptMap[avg.Point2D(0,0)] = 2
+ self.assertEqual(len(ptMap), 2)
+ self.assertEqual(ptMap[avg.Point2D(0,0)], 2)
+
+ pt = avg.Point2D()
+ self.assertEqual(pt, avg.Point2D(0,0))
+ pt = avg.Point2D(10, 10)
+ self.assertEqual(pt[0], pt.x)
+ self.assertEqual(pt[1], pt.y)
+ self.assertEqual(pt, avg.Point2D(10, 10))
+ self.assertEqual(pt, (10, 10))
+ self.assertEqual(pt, avg.Point2D([10, 10]))
+ self.assertNotEqual(pt, avg.Point2D(11, 10))
+ self.assertEqual(str(pt), "(10,10)")
+ pt2 = eval(repr(pt))
+ self.assertEqual(pt2, pt)
+ testHash()
+ self.assertAlmostEqual(avg.Point2D(10,0).getNormalized(), avg.Point2D(1,0))
+ self.assertAlmostEqual(pt.getRotated(math.pi, (5,5)), avg.Point2D(0,0))
+ self.assertEqual(-pt, (-10, -10))
+ self.assertEqual(pt-(10,0), (0,10))
+ self.assertEqual(pt+(10,0), (20,10))
+ self.assertEqual(pt*2, (20,20))
+ self.assertEqual(2*pt, (20,20))
+ pt.x = 21
+ pt.y = 23
+ self.assertEqual(pt, avg.Point2D(21, 23))
+ pt.x -= 11
+ pt.y -= 13
+ pt += avg.Point2D(10, 10)
+ self.assertEqual(pt, avg.Point2D(20, 20))
+ pt -= avg.Point2D(6, 6)
+ self.assertEqual(pt, avg.Point2D(14, 14))
+ self.assertNotEqual(pt, avg.Point2D(13, 13))
+ pt = pt/2.
+ self.assertEqual(pt, avg.Point2D(7, 7))
+ pt = avg.Point2D((10, 10))
+ self.assertEqual(pt, (10, 10))
+ self.assertEqual(len(pt), 2)
+ self.assertEqual(pt[0], pt.x)
+ self.assertEqual(pt[1], pt.y)
+ self.assertException(lambda: pt[2])
+ self.assertAlmostEqual(avg.Point2D(10,0), avg.Point2D.fromPolar(0,10))
+ self.assertException(avg.Point2D(0,0).getNormalized)
+ self.assertException(lambda: avg.Point2D(0,))
+ self.assertException(lambda: avg.Point2D(0,1,2))
+ for point in ((10,0), (0,10), (-10,0), (0,-10)):
+ pt = avg.Point2D(point)
+ angle = pt.getAngle()
+ norm = pt.getNorm()
+ self.assertAlmostEqual(pt, avg.Point2D.fromPolar(angle,norm))
+
+ def testBasics(self):
+ def getFramerate():
+ framerate = Player.getEffectiveFramerate()
+ self.assert_(framerate > 0)
+
+ def invalidCreateNode():
+ avg.ImageNode(1, 2, 3)
+
+ Player.showCursor(0)
+ Player.showCursor(1)
+ root = self.loadEmptyScene()
+ node = Player.createNode("""<image id="test1" href="rgb24-65x65.png"/>""")
+ root.appendChild(node)
+ self.assertException(invalidCreateNode)
+ self.start((
+ getFramerate,
+ lambda: self.compareImage("testbasics", False),
+ lambda: Player.setGamma(0.3, 0.3, 0.3),
+ lambda: Player.showCursor(0),
+ lambda: Player.showCursor(1),
+ ))
+
+ def testFakeTime(self):
+ def checkTime():
+ self.assertEqual(Player.getFrameTime(), 50)
+ self.assertEqual(Player.getFrameDuration(), 50)
+ self.assertEqual(Player.getEffectiveFramerate(), 20)
+
+ self.loadEmptyScene()
+ Player.setFakeFPS(20)
+ self.start((
+ checkTime,
+ ))
+
+ def testDivResize(self):
+ def checkSize (w, h):
+ self.assertEqual(node.width, w)
+ self.assertEqual(node.height, h)
+ self.assertEqual(node.size, (w,h))
+
+ def setSize (size):
+ node.size = size
+
+ def setWidth (w):
+ node.width = w
+
+ def setHeight (h):
+ node.height = h
+
+ self.__initDefaultScene()
+ node = Player.getElementByID('nestedavg')
+
+ self.start((
+ lambda: checkSize(128, 32),
+ lambda: setSize((14,15)),
+ lambda: checkSize(14,15),
+ lambda: setWidth(23),
+ lambda: checkSize(23,15),
+ lambda: setHeight(22),
+ lambda: checkSize(23,22),
+ ))
+
+ def testRotate(self):
+ def onOuterDown(Event):
+ self.onOuterDownCalled = True
+
+ def fakeRotate():
+ Player.getElementByID("outer").angle += 0.1
+ Player.getElementByID("inner").angle -= 0.1
+
+ def testCoordConversions():
+ innerNode = Player.getElementByID("inner")
+ relPos = innerNode.getRelPos((90, 80))
+ self.assertAlmostEqual(relPos, (10, 10))
+ outerNode = Player.getElementByID("outer")
+ relPos = outerNode.getRelPos((90, 80))
+ self.assertAlmostEqual(relPos[0], 12.332806394528092)
+ self.assertAlmostEqual(relPos[1], 6.9211188716194592)
+ absPos = outerNode.getAbsPos(relPos)
+ self.assertAlmostEqual(absPos, (90, 80))
+ self.assertEqual(outerNode.getElementByPos((10, 10)), innerNode)
+ self.assertEqual(outerNode.getElementByPos((0, 10)), outerNode)
+ self.assertEqual(outerNode.getElementByPos((-10, -110)), None)
+
+ def sendEvent(type, x, y):
+ Helper = Player.getTestHelper()
+ if type == avg.CURSORUP:
+ button = False
+ else:
+ button = True
+ Helper.fakeMouseEvent(type, button, False, False,
+ x, y, 1)
+
+ def disableCrop():
+ Player.getElementByID("outer").crop = False
+ Player.getElementByID("inner").crop = False
+
+ self.__initDefaultRotateScene()
+ Player.getElementByID("outer").setEventHandler(
+ avg.CURSORDOWN, avg.MOUSE, onOuterDown)
+ self.onOuterDownCalled = False
+ self.start((
+ lambda: self.compareImage("testRotate1", False),
+ testCoordConversions,
+ fakeRotate,
+ lambda: self.compareImage("testRotate1a", False),
+ lambda: sendEvent(avg.CURSORDOWN, 85, 70),
+ lambda: sendEvent(avg.CURSORUP, 85, 70),
+ lambda: self.assert_(not(self.onOuterDownCalled)),
+ lambda: sendEvent(avg.CURSORDOWN, 85, 75),
+ lambda: sendEvent(avg.CURSORUP, 85, 75),
+ lambda: self.assert_(self.onOuterDownCalled),
+ disableCrop,
+ lambda: self.compareImage("testRotate1b", False),
+ ))
+
+ def testRotate2(self):
+ root = self.loadEmptyScene()
+
+ div1 = avg.DivNode(pos=(80,0), size=(160,120), pivot=(0,0), angle=1.57,
+ parent=root)
+ avg.ImageNode(size=(16,16), href="rgb24-65x65.png", parent=div1)
+ div2 = avg.DivNode(pos=(40,0), size=(110,80), pivot=(0,0), angle=1.57,
+ crop=True, parent=div1)
+ avg.ImageNode(pos=(0,0), size=(16,16), href="rgb24-65x65.png", parent=div2)
+ avg.ImageNode(pos=(30,-6), size=(16,16), href="rgb24-65x65.png", parent=div2)
+ self.start([lambda: self.compareImage("testRotate2", False)])
+
+ def testRotatePivot(self):
+ def setPivot (pos):
+ node.pivot = pos
+
+ def addPivot (offset):
+ node.pivot += offset
+
+ root = self.loadEmptyScene()
+ node = avg.DivNode(pos=(80,0), size=(160,120), pivot=(0,0), angle=1.57,
+ crop=True, parent=root)
+ div = avg.DivNode(pos=(40,-20), size=(160,120), pivot=(0,0), angle=0.79,
+ crop=True, parent=node)
+ avg.ImageNode(pos=(-10,-10), size=(128,128), href="rgb24-65x65.png", parent=div)
+ avg.ImageNode(pos=(0,10), size=(32,32), href="rgb24-65x65.png", parent=node)
+ self.start((
+ lambda: self.compareImage("testRotatePivot1", False),
+ lambda: setPivot((10, 10)),
+ lambda: self.compareImage("testRotatePivot2", False),
+ lambda: addPivot((-8, 0)),
+ lambda: self.compareImage("testRotatePivot3", False),
+ ))
+
+ def testOutlines(self):
+ root = self.__initDefaultRotateScene()
+ root.elementoutlinecolor = "FFFFFF"
+ Player.getElementByID("inner").width = 100000
+ Player.getElementByID("inner").height = 100000
+ self.start([lambda: self.compareImage("testOutlines", False)])
+
+ def testError(self):
+ self.initDefaultImageScene()
+ Player.setTimeout(1, lambda: undefinedFunction)
+ Player.setTimeout(50, Player.stop)
+ try:
+ Player.play()
+ except NameError:
+ self.assert_(1)
+ else:
+ self.assert_(0)
+
+ def testExceptionInTimeout(self):
+ def throwException():
+ raise ZeroDivisionError
+
+ try:
+ self.initDefaultImageScene()
+ self.start([throwException])
+ except ZeroDivisionError:
+ self.assert_(1)
+ else:
+ self.assert_(0)
+
+ def testInvalidImageFilename(self):
+ def activateNode():
+ div.active = 1
+
+ root = self.loadEmptyScene()
+ div = avg.DivNode(active=False, parent=root)
+ avg.ImageNode(href="filedoesntexist.png", parent=div)
+ self.start([activateNode])
+
+ def testInvalidVideoFilename(self):
+ def tryplay():
+ assertException(lambda: video.play())
+
+ root = self.loadEmptyScene()
+ video = avg.VideoNode(href="filedoesntexist.avi", parent=root)
+ self.start((
+ lambda: tryplay,
+ lambda: video.stop()
+ ))
+
+ def testTimeouts(self):
+ class TestException(Exception):
+ pass
+
+ def timeout1():
+ Player.clearInterval(self.timeout1ID)
+ Player.clearInterval(self.timeout2ID)
+ self.timeout1called = True
+
+ def timeout2():
+ self.timeout2called = True
+
+ def wait():
+ pass
+
+ def throwException():
+ raise TestException
+
+ def initException():
+ self.timeout3ID = Player.setTimeout(0, throwException)
+
+ def setupTimeouts():
+ self.timeout1ID = Player.setTimeout(0, timeout1)
+ self.timeout2ID = Player.setTimeout(1, timeout2)
+
+ self.timeout1called = False
+ self.timeout2called = False
+ self.__exceptionThrown = False
+ try:
+ self.initDefaultImageScene()
+ self.start((
+ setupTimeouts,
+ wait,
+ lambda: self.assert_(self.timeout1called),
+ lambda: self.assert_(not(self.timeout2called)),
+ lambda: initException(),
+ wait,
+ wait,
+ wait,
+ wait,
+ wait))
+ except TestException:
+ self.__exceptionThrown = True
+
+ self.assert_(self.__exceptionThrown)
+ Player.clearInterval(self.timeout3ID)
+
+ def testPanoImage(self):
+ def changeProperties():
+ node = Player.getElementByID("pano")
+ node.sensorheight=10
+ node.sensorwidth=15
+ node.focallength=25
+
+ def loadImage():
+ node = Player.getElementByID("pano")
+ node.href = "rgb24-65x65.png"
+
+ root = self.loadEmptyScene()
+ avg.ImageNode(size=(320,240), href="rgb24-65x65.png", parent=root)
+ avg.PanoImageNode(id="pano", size=(160,120), href="panoimage.png",
+ sensorwidth=4.60, sensorheight=3.97, focallength=12, parent=root)
+ avg.ImageNode(pos=(120,0), size=(40,40), href="rgb24-65x65.png", parent=root)
+ self.start((
+ lambda: self.compareImage("testPanoImage", False),
+ lambda: time.sleep,
+ changeProperties,
+ loadImage
+ ))
+
+ def testAVGFile(self):
+ Player.loadFile("image.avg")
+ self.start((
+ lambda: self.compareImage("testAVGFile", False),
+ ))
+ self.assertException(lambda: Player.loadFile("filedoesntexist.avg"))
+
+ def testBroken(self):
+ def testBrokenString(string):
+ self.assertException(lambda: Player.loadString(string))
+
+ # This isn't xml
+ testBrokenString("""
+ xxx<avg width="400" height="300">
+ </avg>
+ """)
+ # This isn't avg
+ testBrokenString("""
+ <bla>hallo
+ </bla>""")
+ testBrokenString("""
+ <avg width="640" height="480" invalidattribute="bla">
+ </avg>
+ """)
+
+ def testMove(self):
+ def moveit():
+ node = Player.getElementByID("nestedimg1")
+ node.x += 50
+ node.opacity -= 0.7
+ node = Player.getElementByID("nestedavg")
+ node.x += 50
+
+ def checkRelPos():
+ RelPos = Player.getElementByID("obscured").getRelPos((50,52))
+ self.assertEqual(RelPos, (0, 0))
+
+ self.__initDefaultScene()
+ self.start((
+ lambda: self.compareImage("testMove1", False),
+ moveit,
+ checkRelPos
+ ))
+
+ def testCropImage(self):
+ def moveTLCrop():
+ node = Player.getElementByID("img")
+ node.x = -20
+ node.y = -20
+
+ def moveBRCrop():
+ node = Player.getElementByID("img")
+ node.x = 60
+ node.y = 40
+
+ def moveTLNegative():
+ node = Player.getElementByID("img")
+ node.x = -60
+ node.y = -50
+
+ def moveBRGone():
+ node = Player.getElementByID("img")
+ node.x = 140
+ node.y = 100
+
+ def rotate():
+ node = Player.getElementByID("img")
+ node.x = 10
+ node.y = 10
+ Player.getElementByID("nestedavg").angle = 1.0
+ Player.getElementByID("bkgd").angle = 1.0
+
+ root = self.loadEmptyScene()
+ avg.ImageNode(id="bkgd", href="crop_bkgd.png", parent=root)
+ root.appendChild(
+ Player.createNode("""
+ <div id="nestedavg" x="40" y="30" width="80" height="60" crop="True">
+ <div id="nestedavg2" crop="True">
+ <div id="nestedavg3" crop="True">
+ <image id="img" x="10" y="10" width="40" height="40"
+ href="rgb24-64x64.png"/>
+ </div>
+ </div>
+ </div>
+ """))
+ self.start((
+ lambda: self.compareImage("testCropImage1", False),
+ moveTLCrop,
+ lambda: self.compareImage("testCropImage2", False),
+ moveBRCrop,
+ lambda: self.compareImage("testCropImage3", False),
+ moveTLNegative,
+ lambda: self.compareImage("testCropImage4", False),
+ moveBRGone,
+ lambda: self.compareImage("testCropImage5", False),
+
+ rotate,
+ lambda: self.compareImage("testCropImage6", False),
+ moveTLCrop,
+ lambda: self.compareImage("testCropImage7", False),
+ moveBRCrop,
+ lambda: self.compareImage("testCropImage8", False),
+ moveTLNegative,
+ lambda: self.compareImage("testCropImage9", False),
+ moveBRGone,
+ lambda: self.compareImage("testCropImage10", False)
+ ))
+
+ def testCropMovie(self):
+ def playMovie():
+ node = Player.getElementByID("movie")
+ node.play()
+
+ def moveTLCrop():
+ node = Player.getElementByID("movie")
+ node.x = -20
+ node.y = -20
+
+ def moveBRCrop():
+ node = Player.getElementByID("movie")
+ node.x = 60
+ node.y = 40
+
+ def moveTLNegative():
+ node = Player.getElementByID("movie")
+ node.x = -60
+ node.y = -50
+
+ def moveBRGone():
+ node = Player.getElementByID("movie")
+ node.x = 140
+ node.y = 100
+
+ def rotate():
+ node = Player.getElementByID("movie")
+ node.x = 10
+ node.y = 10
+ Player.getElementByID("nestedavg").angle = 1.0
+ Player.getElementByID("bkgd").angle = 1.0
+
+ Player.setFakeFPS(30)
+ root = self.loadEmptyScene()
+ avg.ImageNode(id="bkgd", href="crop_bkgd.png", parent=root)
+ root.appendChild(
+ Player.createNode("""
+ <div id="nestedavg" x="40" y="30" width="80" height="60" crop="True">
+ <video id="movie" x="10" y="10" width="40" height="40"
+ threaded="false" href="../video/testfiles/mpeg1-48x48.mpg"
+ fps="30"/>
+ </div>
+ """))
+ self.start((
+ playMovie,
+ lambda: self.compareImage("testCropMovie1", False),
+ moveTLCrop,
+ lambda: self.compareImage("testCropMovie2", False),
+ moveBRCrop,
+ lambda: self.compareImage("testCropMovie3", False),
+ moveTLNegative,
+ lambda: self.compareImage("testCropMovie4", False),
+ moveBRGone,
+ lambda: self.compareImage("testCropMovie5", False),
+
+ rotate,
+ lambda: self.compareImage("testCropMovie6", False),
+ moveTLCrop,
+ lambda: self.compareImage("testCropMovie7", False),
+ moveBRCrop,
+ lambda: self.compareImage("testCropMovie8", False),
+ moveTLNegative,
+ lambda: self.compareImage("testCropMovie9", False),
+ moveBRGone,
+ lambda: self.compareImage("testCropMovie10", False)
+ ))
+
+ def testWarp(self):
+ def moveVertex():
+ grid = image.getWarpedVertexCoords()
+ grid[1][1] = (grid[1][1][0]+0.06, grid[1][1][1]+0.06)
+ image.setWarpedVertexCoords(grid)
+ grid = video.getWarpedVertexCoords()
+ grid[0][0] = (grid[0][0][0]+0.06, grid[0][0][1]+0.06)
+ grid[1][1] = (grid[1][1][0]-0.06, grid[1][1][1]-0.06)
+ video.setWarpedVertexCoords(grid)
+
+ def flip():
+ grid = image.getOrigVertexCoords()
+ grid = [ [ (1-pos[0], pos[1]) for pos in line ] for line in grid]
+ image.setWarpedVertexCoords(grid)
+
+ root = self.loadEmptyScene()
+ image = avg.ImageNode(href="rgb24-64x64.png",
+ maxtilewidth=32, maxtileheight=16, parent=root)
+ video = avg.VideoNode(pos=(40,0), size=(80,80), opacity=0.5, loop=True,
+ href="../video/testfiles/mpeg1-48x48.mpg", threaded=False, fps=30,
+ parent=root)
+
+ self.assertException(image.getOrigVertexCoords)
+ self.assertException(image.getWarpedVertexCoords)
+ Player.setFakeFPS(30)
+ self.start((
+ lambda: video.play(),
+ lambda: self.compareImage("testWarp1", False),
+ moveVertex,
+ lambda: self.compareImage("testWarp2", False),
+ flip,
+ lambda: self.compareImage("testWarp3", False)
+ ))
+
+ def testMediaDir(self):
+ def createImageNode():
+ # Node is not in tree; mediadir should be root node dir.
+ node = avg.ImageNode(href="rgb24-64x64a.png")
+ self.assertEqual(node.size, avg.Point2D(0,0)) # File not found
+ node.href = "rgb24-64x64.png"
+ self.assertEqual(node.size, avg.Point2D(64,64)) # File found
+ node = avg.ImageNode(href="rgb24-64x64a.png", width=23, height=42)
+ # File not found, but custom size
+ self.assertEqual(node.size, avg.Point2D(23,42))
+ node.href = "rgb24-64x64.png"
+ # File found, custom size stays
+ self.assertEqual(node.size, avg.Point2D(23,42))
+ node.size = (0,0)
+ # File found, custom size cleared. Media size should be used.
+ self.assertEqual(node.size, avg.Point2D(64,64))
+
+ def setDir():
+ div.mediadir="../video/testfiles"
+
+ def setAbsDir():
+ def absDir():
+ # Should not find any media here...
+ div.mediadir="/testmediadir"
+
+ self.assertException(absDir)
+
+ def createNode():
+ node = avg.VideoNode(href="mjpeg1-48x48.avi", fps=30)
+
+ root = self.loadEmptyScene()
+ div = avg.DivNode(mediadir="testmediadir", parent=root)
+ image = avg.ImageNode(pos=(0,30), href="rgb24-64x64a.png", parent=div)
+ video = avg.VideoNode(href="mjpeg-48x48.avi", threaded=False, parent=div)
+ self.start((
+ createImageNode,
+ lambda: video.play(),
+ lambda: self.compareImage("testMediaDir1", False),
+ setDir,
+ lambda: video.play(),
+ lambda: self.compareImage("testMediaDir2", False),
+ lambda: self.assertEqual(image.width, 0),
+ createNode,
+ setAbsDir
+ ))
+
+ def testMemoryQuery(self):
+ self.assertNotEqual(avg.getMemoryUsage(), 0)
+
+ def testStopOnEscape(self):
+ def pressEscape():
+ Helper = Player.getTestHelper()
+ escape = 27
+ Helper.fakeKeyEvent(avg.KEYDOWN, escape, escape, "escape", escape,
+ avg.KEYMOD_NONE),
+ Helper.fakeKeyEvent(avg.KEYUP, escape, escape, "escape", escape,
+ avg.KEYMOD_NONE),
+
+ def testEscape1():
+ Player.stopOnEscape(False)
+ pressEscape()
+
+ def testEscape2():
+ Player.stopOnEscape(True)
+ Player.stopOnEscape(False)
+ pressEscape()
+
+ def testEscape3():
+ Player.stopOnEscape(True)
+ pressEscape()
+
+ def setAlive():
+ self.testStopOnEscapeAlive = True
+
+ self.testStopOnEscapeAlive = False
+ self.__initDefaultScene()
+ self.start((
+ testEscape1,
+ testEscape2,
+ setAlive
+ ))
+ self.assert_(self.testStopOnEscapeAlive)
+ self.__initDefaultScene()
+ self.start((
+ testEscape3, # this should exit the player
+ lambda: self.fail(),
+ ))
+
+ # Not executed due to bug #145 - hangs with some window managers.
+ def testWindowFrame(self):
+ def revertWindowFrame():
+ Player.setWindowFrame(True)
+
+ Player.setWindowFrame(False)
+ self.__initDefaultScene()
+ self.start([revertWindowFrame])
+
+ def testScreenDimensions(self):
+ res = Player.getScreenResolution()
+ self.assert_(res.x > 0 and res.y > 0 and res.x < 10000 and res.y < 10000)
+ ppmm = Player.getPixelsPerMM()
+ self.assert_(ppmm > 0 and ppmm < 10000)
+ mm = Player.getPhysicalScreenDimensions()
+ self.assert_(mm.x > 0 and mm.y > 0 and mm.x < 10000 and mm.y < 10000)
+ print res, ppmm, mm
+ Player.assumePixelsPerMM(ppmm)
+ newPPMM = Player.getPixelsPerMM()
+ newMM = Player.getPhysicalScreenDimensions()
+ self.assertAlmostEqual(newPPMM, ppmm)
+ self.assertEqual(newMM, mm)
+
+ def testSVG(self):
+ svgFile = avg.SVG("rect.svg", False)
+
+ # renderElement
+ bmp = svgFile.renderElement("rect")
+ self.compareBitmapToFile(bmp, "testSvgBmp", False)
+ self.assertEqual(svgFile.getElementSize("rect"), avg.Point2D(22,12))
+ bmp = svgFile.renderElement("pos_rect")
+ self.compareBitmapToFile(bmp, "testSvgPosBmp", False)
+ bmp = svgFile.renderElement("rect", 5)
+ self.compareBitmapToFile(bmp, "testSvgScaleBmp1", False)
+ bmp = svgFile.renderElement("rect", (20,20))
+ self.compareBitmapToFile(bmp, "testSvgScaleBmp2", False)
+
+ # error handling
+ self.assertException(lambda: avg.SVG("filedoesntexist.svg", False))
+ self.assertException(lambda: svgFile.renderElement("missing_id"))
+
+ # unescapeIllustratorIDs
+ svgIllustratorFile = avg.SVG("illustratorRect.svg", True)
+ svgIllustratorFile.getElementSize("pos_rect")
+
+ # createImageNode
+ root = self.loadEmptyScene()
+ self.start((
+ lambda: svgFile.createImageNode("rect", {"pos":(10,10), "parent":root}),
+ lambda: self.compareImage("testSvgNode", False),
+ lambda: svgFile.createImageNode("rect", {"pos":(5,5), "parent":root},
+ 5),
+ lambda: self.compareImage("testSvgScaledNode1", False),
+ lambda: svgFile.createImageNode("rect", {"pos":(1,1), "parent":root},
+ (40,40)),
+ lambda: self.compareImage("testSvgScaledNode2", False)
+ ))
+
+ def __initDefaultScene(self):
+ root = self.loadEmptyScene()
+ avg.ImageNode(id="mainimg", size=(100, 75), href="rgb24-65x65.png", parent=root)
+ div = avg.DivNode(id="nestedavg", pos=(0,32), opacity=1, size=(128, 32),
+ crop=True, parent=root)
+ avg.ImageNode(id="obscured", pos=(0,20), size=(96,40), href="rgb24-65x65.png",
+ parent=div)
+ avg.ImageNode(id="nestedimg1", size=(96,48), href="rgb24-65x65.png",
+ parent=div)
+ avg.ImageNode(id="nestedimg2", pos=(65,0), href="rgb24alpha-64x64.png",
+ parent=div)
+
+ def __initDefaultRotateScene(self):
+ root = self.loadEmptyScene()
+ div = avg.DivNode(pos=(80,10), size=(80,60), pivot=(0,0), angle=0.274,
+ crop=True, parent=root)
+ avg.ImageNode(pos=(10,10), size=(32,32), href="rgb24-65x65.png", parent=div)
+ outerDiv = avg.DivNode(id="outer", pos=(80,70), size=(80,60),
+ pivot=(0,0), angle=0.274, crop=True, parent=root)
+ innerDiv = avg.DivNode(id="inner", size=(80,60), pivot=(0,0), angle=-0.274,
+ crop=True, parent=outerDiv)
+ avg.ImageNode(pos=(10,10), size=(32,32), href="rgb24-65x65.png", parent=innerDiv)
+ return root
+
+def playerTestSuite(tests):
+ availableTests = (
+ "testPoint",
+ "testBasics",
+ "testFakeTime",
+ "testDivResize",
+ "testRotate",
+ "testRotate2",
+ "testRotatePivot",
+ "testOutlines",
+ "testError",
+ "testExceptionInTimeout",
+ "testInvalidImageFilename",
+ "testInvalidVideoFilename",
+ "testTimeouts",
+ "testPanoImage",
+ "testAVGFile",
+ "testBroken",
+ "testMove",
+ "testCropImage",
+ "testCropMovie",
+ "testWarp",
+ "testMediaDir",
+ "testMemoryQuery",
+ "testStopOnEscape",
+ "testScreenDimensions",
+ "testSVG",
+# "testWindowFrame",
+ )
+ return createAVGTestSuite(availableTests, PlayerTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/PluginTest.py b/src/test/PluginTest.py
new file mode 100644
index 0000000..a9bd3db
--- /dev/null
+++ b/src/test/PluginTest.py
@@ -0,0 +1,72 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import platform
+
+from libavg import avg
+from testcase import *
+
+class PluginTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testColorNodePlugin(self):
+ def loadPlugin():
+ if platform.system() != 'Windows':
+ if os.getenv('srcdir') in ('.', None):
+ # make check or ./Test.py
+ addpth = './'
+ else:
+ # make distcheck
+ addpth = '../../_build/src/test/'
+
+ Player.pluginPath += ":"+addpth+"plugin/.libs"
+ Player.loadPlugin("colorplugin")
+
+ def usePlugin1():
+ node = colorplugin.ColorNode(fillcolor="7f7f00", id="mynode1")
+ root.appendChild(node)
+
+ mynode = Player.getElementByID("mynode1")
+ self.assertEqual(mynode.fillcolor, "7f7f00")
+
+ def usePlugin2():
+ node = Player.createNode('<colornode fillcolor="0f3f7f" id="mynode2" />')
+ root.appendChild(node)
+
+ mynode = Player.getElementByID("mynode2")
+ self.assertEqual(mynode.fillcolor, "0f3f7f")
+
+ root = self.loadEmptyScene()
+ self.start((
+ loadPlugin,
+ usePlugin1,
+ lambda: self.compareImage("testplugin1", False),
+ usePlugin2,
+ lambda: self.compareImage("testplugin2", False),
+ ))
+
+def pluginTestSuite (tests):
+ availableTests = ("testColorNodePlugin",)
+ return createAVGTestSuite(availableTests, PluginTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/PythonTest.py b/src/test/PythonTest.py
new file mode 100644
index 0000000..e002ffb
--- /dev/null
+++ b/src/test/PythonTest.py
@@ -0,0 +1,431 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg, anim, draggable, geom, statemachine
+
+from testcase import *
+
+class PythonTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testAnimType(self, curAnim, imgBaseName):
+ def onStop():
+ self.__onStopCalled = True
+
+ def startAnim():
+ self.__onStopCalled = False
+ node = Player.getElementByID("test")
+ self.__anim.start()
+
+ def startKeepAttr():
+ node = Player.getElementByID("test")
+ node.x = 25
+ self.__anim.start(keepAttr=True)
+
+ def abortAnim():
+ self.__anim.abort()
+
+ self.__anim = curAnim
+ self.__anim.setHandler(onStop, None)
+ self.__onStopCalled = False
+ Player.setFakeFPS(10)
+ self.start((
+ startAnim,
+ lambda: self.compareImage(imgBaseName+"1", False),
+ lambda: self.assertEqual(anim.getNumRunningAnims(), 1),
+ None,
+ None,
+ lambda: self.assert_(self.__onStopCalled),
+ lambda: self.assert_(self.__anim.isDone()),
+ lambda: self.compareImage(imgBaseName+"2", False),
+ lambda: self.assertEqual(Player.getElementByID("test").x, 100),
+ startAnim,
+ lambda: self.compareImage(imgBaseName+"1", False),
+ abortAnim,
+ lambda: self.assertEqual(anim.getNumRunningAnims(), 0),
+ lambda: self.compareImage(imgBaseName+"3", False),
+ lambda: self.assert_(self.__anim.isDone()),
+ None,
+ lambda: self.assert_(not(self.__onStopCalled)),
+ startAnim,
+ startKeepAttr,
+ lambda: self.assertEqual(anim.getNumRunningAnims(), 1),
+ abortAnim
+ ))
+ self.__anim = None
+
+ def testLinearAnim(self):
+ self.initDefaultImageScene()
+ node = Player.getElementByID("test")
+ curAnim = anim.LinearAnim(node, "x", 200, 0, 100, False)
+ self.testAnimType(curAnim, "testLinearAnim")
+
+ def testLinearAnimZeroDuration(self):
+ def onStop():
+ self.__onStopCalled = True
+
+ def startAnim():
+ self.__onStopCalled = False
+ node = Player.getElementByID("test")
+ self.__anim.start()
+
+ self.initDefaultImageScene()
+ node = Player.getElementByID("test")
+ self.__anim = anim.LinearAnim(node, "x", 0, 0, 100, False)
+ self.__anim.setHandler(onStop, None)
+ self.__onStopCalled = False
+ Player.setFakeFPS(10)
+ self.start((
+ startAnim,
+ lambda: self.compareImage("testLinearAnimZeroDuration1", False),
+ lambda: self.assertEqual(anim.getNumRunningAnims(), 0),
+ lambda: self.assert_(self.__onStopCalled),
+ lambda: self.assert_(self.__anim.isDone())
+ ))
+ self.__anim = None
+
+ def testEaseInOutAnim(self):
+ self.initDefaultImageScene()
+ node = Player.getElementByID("test")
+ curAnim = anim.EaseInOutAnim(node, "x", 400, 0, 100, 100, 100, False)
+ self.testAnimType(curAnim, "testEaseInOutAnim")
+
+ def testSplineAnim(self):
+ self.initDefaultImageScene()
+ node = Player.getElementByID("test")
+ curAnim = anim.SplineAnim(node, "x", 300, 0, 0, 100, 0, False)
+ self.testAnimType(curAnim, "testSplineAnim")
+
+ def testContinuousAnim(self):
+ def onStart():
+ Player.setTimeout(10,startAnim)
+ Player.setTimeout(100,lambda:self.compareImage("testContAnim1", False))
+ Player.setTimeout(200,startAnim2)
+ Player.setTimeout(400,lambda:self.compareImage("testContAnim2", False))
+ Player.setTimeout(450,startAnim3)
+ Player.setTimeout(700,lambda:self.compareImage("testContAnim3", False))
+ Player.setTimeout(800,stopAnim)
+ Player.setTimeout(900,lambda:self.compareImage("testContAnim4", False))
+ Player.setTimeout(1000,Player.stop)
+
+ def startAnim():
+ node=Player.getElementByID("testtiles")
+ self.anim=anim.ContinuousAnim(node,"angle",0,1,0)
+ self.anim.start()
+
+ def startAnim2():
+ node=Player.getElementByID("test")
+ self.anim2=anim.ContinuousAnim(node,"width",0,50,0)
+ self.anim2.start()
+
+ def startAnim3():
+ node=Player.getElementByID("test1")
+ self.anim3=anim.ContinuousAnim(node,"x",0,50,0)
+ self.anim3.start()
+
+ def stopAnim():
+ self.anim.abort()
+ self.anim2.abort()
+ self.anim3.abort()
+ self.anim = None
+ self.anim2 = None
+ self.anim3 = None
+
+ Player.setFakeFPS(25)
+ anim.init(avg)
+ self.initDefaultImageScene()
+ Player.setTimeout(1, onStart)
+ Player.play()
+
+ def testWaitAnim(self):
+ def animStopped():
+ self.__endCalled = True
+
+ def startAnim():
+ self.anim = anim.WaitAnim(200, animStopped, False)
+ self.anim.start()
+
+ anim.init(avg)
+ Player.setFakeFPS(10)
+ self.__endCalled = False
+ self.initDefaultImageScene()
+ self.start((
+ startAnim,
+ lambda: self.assert_(not(self.anim.isDone())),
+ None,
+ None,
+ lambda: self.assert_(self.anim.isDone()),
+ lambda: self.assert_(self.__endCalled)
+ ))
+
+ def testStateAnim(self):
+ def state2Callback():
+ self.__state2CallbackCalled = True
+
+ def makeAnim():
+ node = Player.getElementByID("test")
+ self.anim = anim.StateAnim(
+ {"STATE1": anim.LinearAnim(node, "x", 200, 64, 128),
+ "STATE2": anim.LinearAnim(node, "x", 200, 128, 64),
+ "STATE3": anim.WaitAnim()},
+ {"STATE1": anim.AnimTransition("STATE2", state2Callback),
+ "STATE2": anim.AnimTransition("STATE3")})
+ anim.init(avg)
+ Player.setFakeFPS(10)
+ self.__state2CallbackCalled = False
+ self.initDefaultImageScene()
+ self.start((
+ makeAnim,
+ lambda: self.compareImage("testStateAnim1", False),
+ lambda: self.anim.setState("STATE1"),
+ None,
+ lambda: self.compareImage("testStateAnim2", False),
+ lambda: self.anim.getState() == "STATE2",
+ lambda: self.compareImage("testStateAnim3", False),
+ lambda: self.assert_(self.__state2CallbackCalled),
+ lambda: self.anim.getState() == "STATE3",
+ lambda: self.compareImage("testStateAnim4", False),
+ lambda: self.anim.setState("STATE1"),
+ lambda: self.assertEqual(anim.getNumRunningAnims(), 1),
+ lambda: self.compareImage("testStateAnim5", False)
+ ))
+
+ def testParallelAnim(self):
+ def animStopped():
+ self.__endCalled = True
+
+ def startAnim():
+ node0 = Player.getElementByID("mainimg")
+ node1 = Player.getElementByID("test")
+ node2 = Player.getElementByID("test1")
+ self.anim = anim.ParallelAnim(
+ [ anim.SplineAnim(node1, "x", 400, 0, 40, 0, 0),
+ anim.EaseInOutAnim(node2, "x", 300, 129, 99, 100, 100)
+ ], animStopped)
+ self.anim.start()
+
+ anim.init(avg)
+ self.__endCalled = False
+ Player.setFakeFPS(10)
+ self.initDefaultImageScene()
+ self.start((
+ startAnim,
+ lambda: self.assertEqual(anim.getNumRunningAnims(), 2),
+ lambda: self.assert_(not(self.anim.isDone())),
+ lambda: self.compareImage("testParallelAnims1", False),
+ None,
+ None,
+ lambda: self.compareImage("testParallelAnims2", False),
+ lambda: self.assert_(self.anim.isDone()),
+ lambda: self.assert_(self.__endCalled)
+ ))
+
+ def testDraggable(self):
+ def onDragStart(event):
+ self.__dragStartCalled = True
+
+ def onDragEnd(event):
+ self.__dragEndCalled = True
+
+ def startDrag():
+ Helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False, 140, 40, 1)
+
+ def move():
+ Helper.fakeMouseEvent(avg.CURSORMOTION, True, False, False, 150, 50, 1)
+
+ def stop():
+ Helper.fakeMouseEvent(avg.CURSORUP, False, False, False, 140, 40, 1)
+
+ self.__dragEndCalled = False
+ self.__dragStartCalled = False
+ Helper = Player.getTestHelper()
+ self.initDefaultImageScene()
+ draggable.init(avg)
+ dragger = draggable.Draggable(Player.getElementByID("test1"),
+ onDragStart, onDragEnd)
+ dragger.enable()
+ self.start((
+ startDrag,
+ lambda: self.assert_(self.__dragStartCalled),
+ move,
+ lambda: self.compareImage("testDraggable1", False),
+ stop,
+ lambda: self.assert_(self.__dragEndCalled),
+ lambda: self.compareImage("testDraggable2", False),
+ dragger.disable,
+ startDrag,
+ move,
+ lambda: self.compareImage("testDraggable2", False)
+ ))
+
+ def testRoundedRect(self):
+ def setPos():
+ self.rect.pos = (20.5, 3.5)
+
+ def setSize():
+ self.rect.size = (40, 20)
+
+ def setRadius(r):
+ self.rect.radius = r
+
+ def setFill():
+ self.rect.fillcolor = "0000FF"
+ self.rect.fillopacity = 0.5
+
+ def createDegenRect():
+ self.rect.unlink(True)
+ geom.RoundedRect(parent=root, pos=(10.5,10.5), size=(10,10), radius=6,
+ fillopacity=0.5, color="FFFFFF")
+
+ root = self.loadEmptyScene()
+ self.rect = geom.RoundedRect(parent=root, pos=(2.5,2.5),
+ size=(64,64), radius=5, color="FF0000")
+ self.start((
+ lambda: self.compareImage("testRoundedRect1", True),
+ setPos,
+ lambda: self.compareImage("testRoundedRect2", True),
+ setSize,
+ lambda: self.compareImage("testRoundedRect3", True),
+ lambda: setRadius(10),
+ lambda: self.compareImage("testRoundedRect4", True),
+ setFill,
+ lambda: self.compareImage("testRoundedRect5", True),
+ createDegenRect,
+ lambda: self.compareImage("testRoundedRect6", True),
+ ))
+
+ def testPieSlice(self):
+ def changeAttrs():
+ self.pieSlice.startangle = -1
+ self.pieSlice.endangle = 3.14
+ self.pieSlice.radius = 50
+ self.pieSlice.pos = (80.5, 60.5)
+ self.pieSlice.fillcolor = "00FFFF"
+ self.pieSlice.fillopacity = 0.5
+
+ def makeSmall():
+ self.pieSlice.radius = 0.6
+
+ root = self.loadEmptyScene()
+ self.pieSlice = geom.PieSlice(parent=root, pos=(20.5,20.5),
+ radius=40, startangle=0, endangle=1.57, color="FF0000")
+
+ self.start((
+ lambda: self.compareImage("testPieSlice1", True),
+ changeAttrs,
+ lambda: self.compareImage("testPieSlice2", True),
+ makeSmall,
+ lambda: self.compareImage("testPieSlice3", True),
+ ))
+
+ def testArc(self):
+ def changeAttrs():
+ self.arc.startangle = -1
+ self.arc.endangle = 3.14
+ self.arc.radius = 50
+ self.arc.pos = (80.5, 60.5)
+
+ root = self.loadEmptyScene()
+ self.arc = geom.Arc(parent=root, pos=(20.5,20.5),
+ radius=40, startangle=0, endangle=1.57, color="FF0000")
+
+ self.start((
+ lambda: self.compareImage("testArc1", True),
+ changeAttrs,
+ lambda: self.compareImage("testArc2", True),
+ ))
+
+ def testStateMachine(self):
+ def atob(oldState, newState):
+ self.atobCalled = True
+
+ def btoc():
+ self.btocCalled = True
+
+ def btoa(oldState, newState):
+ self.btoaCalled = True
+
+ def aEntered():
+ self.aEnteredCalled = True
+
+ def aLeft():
+ self.aLeftCalled = True
+
+ self.atobCalled = False
+ self.btocCalled = False
+ self.btoaCalled = False
+ self.aLeftCalled = False
+ self.aEnteredCalled = False
+ machine = statemachine.StateMachine("testmachine", 'A')
+ machine.addState('A', {'B': atob, 'nostate': atob}, aEntered, aLeft)
+ machine.addState('B', {'C': btoc, 'A': btoa})
+ machine.addState('C', {'A': None})
+ self.assertException(lambda: machine.addState('C', {'A': None}))
+ self.assertException(lambda: machine.changeState('C'))
+ self.assertException(lambda: machine.changeState('nostate'))
+ machine.changeState('B')
+ self.assert_(self.atobCalled)
+ self.assert_(self.aLeftCalled)
+ machine.changeState('A')
+ self.assert_(self.aEnteredCalled)
+ self.assert_(self.btoaCalled)
+ machine.changeState('B')
+ machine.changeState('C')
+ self.assert_(self.btocCalled)
+ machine.changeState('A')
+ self.assertEqual(machine.state, 'A')
+ self.assertException(lambda: machine.addState('illegal', {}))
+
+ # Create a machine without transition callbacks
+ machine = statemachine.StateMachine("testmachine", 'A')
+ machine.addState('A', ('B',), aEntered, aLeft)
+ machine.addState('B', ('C', 'A'))
+ machine.addState('C', ('A',))
+ machine.changeState('B')
+
+ # Make a machine with a transition to a nonexistent state.
+ kaputtMachine = statemachine.StateMachine("kaputt", 'A')
+ kaputtMachine.addState('A', {'B': None})
+ self.assertException(lambda: kaputtMachine.changeState('B'))
+
+
+def pythonTestSuite(tests):
+ availableTests = (
+ "testLinearAnim",
+ "testLinearAnimZeroDuration",
+ "testEaseInOutAnim",
+ "testSplineAnim",
+ "testContinuousAnim",
+ "testWaitAnim",
+ "testParallelAnim",
+ "testStateAnim",
+ "testDraggable",
+ "testRoundedRect",
+ "testPieSlice",
+ "testArc",
+ "testStateMachine",
+ )
+
+ return createAVGTestSuite(availableTests, PythonTestCase, tests)
+
+Player = avg.Player.get()
+anim.init(avg)
diff --git a/src/test/Test.py b/src/test/Test.py
new file mode 100755
index 0000000..929b398
--- /dev/null
+++ b/src/test/Test.py
@@ -0,0 +1,138 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+'''
+Runner for libavg unit tests
+
+On autotools-based systems, tests are performed on a local libavg package.
+This package is created by symlinking all the relevant files in a local, temporary
+directory, letting python find it as first instance.
+On windows, instead, tests are always carried on after distutils installs the package.
+'''
+
+import sys
+import os
+import shutil
+import atexit
+
+def cleanup(folder):
+ if os.path.isdir(folder):
+ print 'Wiping out directory: %s' % folder
+ shutil.rmtree(folder)
+
+def symtree(src, dest):
+ os.mkdir(dest)
+ for f in os.listdir(src):
+ fpath = os.path.join(src, f)
+ if (f and f[0] != '.' and
+ (os.path.isdir(fpath) or
+ (os.path.isfile(fpath) and os.path.splitext(f)[1] == '.py'))):
+ os.symlink(os.path.join(os.pardir, src, f), os.path.join(dest, f))
+
+
+if sys.platform != 'win32':
+ tempPackageDir = os.path.join(os.getcwd(), 'libavg')
+ # Possible values for srcdir:
+ # '.': make check
+ # None: ./Test.py
+ # dir name: make distcheck
+ srcDir = os.getenv("srcdir",".")
+ if srcDir == '.':
+ # Running make check or ./Test.py
+ if os.path.basename(os.getcwd()) != 'test':
+ raise RuntimeError('Manual tests must be performed inside directory "test"')
+
+ cleanup(tempPackageDir)
+
+ try:
+ symtree('../python', 'libavg')
+ except OSError:
+ pass
+ else:
+ # Running make distcheck
+ symtree('../../../../src/python', 'libavg')
+
+ # distcheck doesn't want leftovers (.pyc files)
+ atexit.register(lambda tempPackageDir=tempPackageDir: cleanup(tempPackageDir))
+
+ if os.path.exists('../wrapper/.libs/avg.so'):
+ # Normal case: use the local version (not the installed one)
+ os.symlink('../../wrapper/.libs/avg.so', 'libavg/avg.so')
+ elif os.path.exists('../../avg.so'):
+ # Mac version after installer dmg
+ pass
+ else:
+ raise RuntimeError('Compile libavg before running tests or use "make check"')
+
+ # The following line prevents the test to be run
+ # with an unknown version of libavg, which can be hiding somewhere
+ # in the system
+ sys.path.insert(0, os.getcwd())
+
+ # Meaningful only for distcheck
+ os.chdir(srcDir)
+
+ import libavg
+ libavg.avg.Logger.get().trace(libavg.avg.Logger.APP, "Using libavg from: "+
+ os.path.dirname(libavg.__file__))
+
+
+import testapp
+
+import PluginTest
+import PlayerTest
+import OffscreenTest
+import ImageTest
+import FXTest
+import VectorTest
+import WordsTest
+import AVTest
+import DynamicsTest
+import PythonTest
+import AnimTest
+import EventTest
+import InputDeviceTest
+import AVGAppTest
+import UITest
+
+app = testapp.TestApp()
+
+app.registerSuiteFactory('plugin', PluginTest.pluginTestSuite)
+app.registerSuiteFactory('player', PlayerTest.playerTestSuite)
+app.registerSuiteFactory('offscreen', OffscreenTest.offscreenTestSuite)
+app.registerSuiteFactory('image', ImageTest.imageTestSuite)
+app.registerSuiteFactory('fx', FXTest.fxTestSuite)
+app.registerSuiteFactory('vector', VectorTest.vectorTestSuite)
+app.registerSuiteFactory('words', WordsTest.wordsTestSuite)
+app.registerSuiteFactory('av', AVTest.AVTestSuite)
+app.registerSuiteFactory('dynamics', DynamicsTest.dynamicsTestSuite)
+app.registerSuiteFactory('python', PythonTest.pythonTestSuite)
+app.registerSuiteFactory('anim', AnimTest.animTestSuite)
+app.registerSuiteFactory('event', EventTest.eventTestSuite)
+app.registerSuiteFactory('inputdevice', InputDeviceTest.inputDeviceTestSuite)
+app.registerSuiteFactory('ui', UITest.uiTestSuite)
+app.registerSuiteFactory('avgapp', AVGAppTest.avgAppTestSuite)
+
+app.run()
+
+sys.exit(app.exitCode())
+
diff --git a/src/test/UITest.py b/src/test/UITest.py
new file mode 100644
index 0000000..18f6678
--- /dev/null
+++ b/src/test/UITest.py
@@ -0,0 +1,1370 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import avg, textarea, ui
+
+import math
+from testcase import *
+
+class UITestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testKeyboard(self):
+ def setup():
+ keyDefs = [
+ [("a", "A"), ( 5, 5), (30, 30)],
+ [(1, ), (35, 5), (30, 30)],
+ ["SHIFT", (65, 5), (50, 30)]]
+ kbNoShift = ui.Keyboard("keyboard_bg.png", "keyboard_ovl.png", keyDefs, None,
+ pos=(10, 10), parent = root)
+ kbNoShift.setKeyHandler(onKeyDown, onKeyUp)
+ kbShift = ui.Keyboard("keyboard_bg.png", "keyboard_ovl.png", keyDefs, "SHIFT",
+ pos=(10, 60), parent = root)
+ kbShift.setKeyHandler(onKeyDown, onKeyUp)
+
+ def onKeyDown(event, char, cmd):
+ self.__keyDown = True
+ self.__keyUp = False
+ self.__char = char
+ self.__cmd = cmd
+
+ def onKeyUp(event, char, cmd):
+ self.__keyDown = False
+ self.__keyUp = True
+ self.__char = char
+ self.__cmd = cmd
+
+ root = self.loadEmptyScene()
+
+ self.__keyDown = False
+ self.__keyUp = True
+ self.__char = "foo"
+ self.__cmd = "bar"
+ self.start((
+ setup,
+ lambda: self.compareImage("testUIKeyboard", False),
+ # test character key
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self.assert_(self.__keyDown and not self.__keyUp),
+ lambda: self.assert_(self.__char == "a" and self.__cmd is None),
+ lambda: self.compareImage("testUIKeyboardDownA1", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: self.assert_(not self.__keyDown and self.__keyUp),
+ lambda: self.assert_(self.__char == "a" and self.__cmd is None),
+ lambda: self.compareImage("testUIKeyboard", False),
+ # test command key
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 100, 30),
+ lambda: self.assert_(self.__keyDown and not self.__keyUp),
+ lambda: self.assert_(self.__char is None and self.__cmd == "SHIFT"),
+ lambda: self.compareImage("testUIKeyboardDownS1", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 100, 30),
+ lambda: self.assert_(not self.__keyDown and self.__keyUp),
+ lambda: self.assert_(self.__char is None and self.__cmd == "SHIFT"),
+ lambda: self.compareImage("testUIKeyboard", False),
+ # test shift key (no shift key support)
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 100, 30),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 30, 30),
+ lambda: self.assert_(self.__char == "a" and self.__cmd is None),
+ lambda: self._sendTouchEvent(3, avg.CURSORDOWN, 60, 30),
+ lambda: self.assert_(self.__char == 1 and self.__cmd is None),
+ lambda: self.compareImage("testUIKeyboardDownA111S1", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 30, 30),
+ lambda: self.assert_(self.__char == "a" and self.__cmd is None),
+ lambda: self._sendTouchEvent(3, avg.CURSORUP, 60, 30),
+ lambda: self.assert_(self.__char == 1 and self.__cmd is None),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 100, 30),
+ lambda: self.compareImage("testUIKeyboard", False),
+ # test shift key (with shift key support)
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 100, 80),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 30, 80),
+ lambda: self.assert_(self.__char == "A" and self.__cmd is None),
+ lambda: self._sendTouchEvent(3, avg.CURSORDOWN, 60, 80),
+ lambda: self.assert_(self.__char == 1 and self.__cmd is None),
+ lambda: self.compareImage("testUIKeyboardDownA212S2", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 30, 80),
+ lambda: self.assert_(self.__char == "A" and self.__cmd is None),
+ lambda: self._sendTouchEvent(3, avg.CURSORUP, 60, 80),
+ lambda: self.assert_(self.__char == 1 and self.__cmd is None),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 100, 80),
+ lambda: self.compareImage("testUIKeyboard", False)
+ ))
+
+ def testTextArea(self):
+ def setup():
+ self.ta1 = textarea.TextArea(Player.getElementByID('ph1'), id='ta1')
+ self.ta1.setStyle(font='Bitstream Vera Sans', variant='Roman',
+ fontsize=16, multiline=True, color='FFFFFF')
+ self.ta1.setText('Lorem ipsum')
+ self.ta1.setFocus(True) # TODO: REMOVE
+
+ self.ta2 = textarea.TextArea(Player.getElementByID('ph2'), id='ta2')
+ self.ta2.setStyle(font='Bitstream Vera Sans', variant='Roman',
+ fontsize=14, multiline=False, color='FFFFFF')
+ self.ta2.setText('sit dolor')
+ self.ta2.setFocus(True) # TODO: REMOVE
+
+ def setAndCheck(ta, text):
+ ta.setText(text)
+ self.assertEqual(ta.getText(), text)
+
+ def clear(ta):
+ ta.onKeyDown(textarea.KEYCODE_FORMFEED)
+ self.assertEqual(ta.getText(), '')
+
+ def testUnicode():
+ self.ta1.setText(u'some ùnìcöde')
+ self.ta1.onKeyDown(textarea.KEYCODES_BACKSPACE[0])
+ self.assertEqual(self.ta1.getText(), u'some ùnìcöd')
+ self.ta1.onKeyDown(textarea.KEYCODES_BACKSPACE[1])
+ self.ta1.onKeyDown(textarea.KEYCODES_BACKSPACE[0])
+ self.assertEqual(self.ta1.getText(), u'some ùnìc')
+ self.ta1.onKeyDown(ord(u'Ä'))
+ self.assertEqual(self.ta1.getText(), u'some ùnìcÄ')
+
+ def testSpecialChars():
+ clear(self.ta1)
+ self.ta1.onKeyDown(ord(u'&'))
+ self.ta1.onKeyDown(textarea.KEYCODES_BACKSPACE[0])
+ self.assertEqual(self.ta1.getText(), '')
+
+ def checkSingleLine():
+ text = ''
+ self.ta2.setText('')
+ while True:
+ self.assert_(len(text) < 20)
+ self.ta2.onKeyDown(ord(u'A'))
+ text = text + 'A'
+ if text != self.ta2.getText():
+ self.assertEqual(len(text), 16)
+ break
+
+ root = self.loadEmptyScene()
+ avg.DivNode(id="ph1", pos=(2,2), size=(156, 96), parent=root)
+ avg.DivNode(id="ph2", pos=(2,100), size=(156, 18), parent=root)
+
+ textarea.init(avg, False)
+ self.start((
+ setup,
+ lambda: self.assertEqual(self.ta1.getText(), 'Lorem ipsum'),
+ lambda: setAndCheck(self.ta1, ''),
+ lambda: setAndCheck(self.ta2, 'Lorem Ipsum'),
+ testUnicode,
+ lambda: self.compareImage("testTextArea1", True),
+ testSpecialChars,
+ checkSingleLine,
+ lambda: self.compareImage("testTextArea2", True),
+ ))
+
+
+ def testTapRecognizer(self):
+
+ def onPossible(event):
+ self.__possible = True
+
+ def onDetected(event):
+ self.__detected = True
+
+ def onFail(event):
+ self.__failed = True
+
+ def initState():
+ self.__possible = False
+ self.__detected = False
+ self.__failed = False
+
+ def assertEvents(possible, detected, failed):
+# print (self.__possible, self.__detected, self.__failed)
+ self.assert_(self.__possible == possible and
+ self.__detected == detected and
+ self.__failed == failed)
+
+ root = self.loadEmptyScene()
+ image = avg.ImageNode(parent=root, href="rgb24-64x64.png")
+ self.__tapRecognizer = ui.TapRecognizer(image,
+ possibleHandler=onPossible,
+ detectedHandler=onDetected,
+ failHandler=onFail)
+ initState()
+ Player.setFakeFPS(10)
+ self.start((
+ # Down-up: recognized as tap.
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertEvents(True, False, False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, True, False),
+ # Down-small move-up: recognized as tap.
+ initState,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 31, 30),
+ lambda: assertEvents(True, False, False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, True, False),
+ # Down-big move-up: fail
+ initState,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 1, 1),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 150, 50),
+ lambda: assertEvents(True, False, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 1, 1),
+ lambda: assertEvents(True, False, True),
+ # Down-delay: fail
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self.delay(600),
+ lambda: assertEvents(True, False, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, False, True),
+ ))
+
+
+ def testHoldRecognizer(self):
+
+ def onPossible(event):
+ self.__possible = True
+
+ def onDetected(event):
+ self.__detected = True
+
+ def onFail(event):
+ self.__failed = True
+
+ def onStop(event):
+ self.__stopped = True
+
+ def initState():
+ self.__possible = False
+ self.__detected = False
+ self.__failed = False
+ self.__stopped = False
+
+ def assertEvents(possible, detected, failed, stopped):
+# print (self.__possible, self.__detected, self.__failed, self.__stopped)
+ self.assert_(self.__possible == possible and
+ self.__detected == detected and
+ self.__failed == failed and
+ self.__stopped == stopped)
+
+ Player.setFakeFPS(2)
+ root = self.loadEmptyScene()
+ image = avg.ImageNode(parent=root, href="rgb24-64x64.png")
+ self.__holdRecognizer = ui.HoldRecognizer(image,
+ delay=1000,
+ possibleHandler=onPossible,
+ detectedHandler=onDetected,
+ failHandler=onFail,
+ stopHandler=onStop)
+ initState()
+ self.start((
+ # Standard down-hold-up sequence.
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertEvents(True, False, False, False),
+ None,
+ lambda: assertEvents(True, True, False, False),
+ None,
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, True, False, True),
+
+ # down-up sequence, hold not long enough.
+ initState,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, False, True, False),
+
+ # down-move-up sequence, should abort.
+ initState,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 1, 1),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 150, 50),
+ lambda: assertEvents(True, False, True, False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 150, 50),
+ lambda: assertEvents(True, False, True, False),
+ ))
+ Player.setFakeFPS(-1)
+
+
+ def testDoubletapRecognizer(self):
+
+ def onPossible(event):
+ self.__possible = True
+
+ def onDetected(event):
+ self.__detected = True
+
+ def onFail(event):
+ self.__failed = True
+
+ def initState():
+ self.__possible = False
+ self.__detected = False
+ self.__failed = False
+
+ def assertEvents(possible, detected, failed):
+ self.assert_(self.__possible == possible and
+ self.__detected == detected and
+ self.__failed == failed)
+
+ root = self.loadEmptyScene()
+ image = avg.ImageNode(parent=root, href="rgb24-64x64.png", size=(128,128))
+ self.__tapRecognizer = ui.DoubletapRecognizer(image,
+ possibleHandler=onPossible,
+ detectedHandler=onDetected,
+ failHandler=onFail)
+ initState()
+ Player.setFakeFPS(10)
+ self.start((
+ # Down, up, down, up: click
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertEvents(True, False, False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, False, False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertEvents(True, False, False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, True, False),
+ # Down, move: abort
+ initState,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 80, 30),
+ lambda: assertEvents(True, False, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 30),
+ lambda: assertEvents(True, False, True),
+ # Down, up, move: abort
+ initState,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 30),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 80, 30),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 80, 30),
+ lambda: assertEvents(True, False, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 30),
+ lambda: assertEvents(True, False, True),
+ # Down, up, down, move: abort
+ initState,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 30),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 30),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 80, 30),
+ lambda: assertEvents(True, False, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 30),
+ lambda: assertEvents(True, False, True),
+ # Down,delay: abort
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self.delay(600),
+ lambda: assertEvents(True, False, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertEvents(True, False, True),
+ # Down, up, delay: abort
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: self.delay(600),
+ lambda: assertEvents(True, False, True),
+ # Down, up, down, delay: abort
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self.delay(600),
+ lambda: assertEvents(True, False, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ ))
+
+
+ def testDragRecognizer(self):
+
+ def onDetected(event):
+ self.__detected = True
+
+ def onMove(event, offset):
+ if self.friction == -1:
+ self.assertEqual(offset, (40,40))
+ self.__moved = True
+
+ def onUp(event, offset):
+ if self.friction == -1:
+ self.assertEqual(offset, (10,-10))
+ self.__up = True
+
+ def onEnd(event):
+ self.__ended = True
+
+ def disable():
+ dragRecognizer.enable(False)
+ initState()
+
+ def initState():
+ self.__detected = False
+ self.__moved = False
+ self.__up = False
+ self.__ended = False
+
+ self.__possible = False
+ self.__failed = False
+
+ def assertDragEvents(detected, moved, up, ended, possible=False, failed=False):
+# print (self.__detected, self.__moved, self.__up,
+# self.__ended, self.__possible, self.__failed)
+ self.assert_(self.__detected == detected and self.__moved == moved and
+ self.__up == up and self.__ended == ended and
+ self.__possible == possible and self.__failed == failed)
+
+ Player.setFakeFPS(100)
+ for self.friction in (-1, 100):
+ root = self.loadEmptyScene()
+ image = avg.ImageNode(parent=root, href="rgb24-64x64.png")
+ dragRecognizer = ui.DragRecognizer(image,
+ detectedHandler=onDetected, moveHandler=onMove, upHandler=onUp,
+ endHandler=onEnd, friction=self.friction)
+ initState()
+ self.start((
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertDragEvents(True, False, False, False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 70, 70),
+ lambda: assertDragEvents(True, True, False, False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 40, 20),
+ lambda: assertDragEvents(True, True, True, True),
+ disable,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertDragEvents(False, False, False, False),
+ lambda: dragRecognizer.enable(True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertDragEvents(True, False, False, False),
+ ))
+
+ # Test with constraint.
+ def onPossible(event):
+ self.__possible = True
+
+ def onFail(event):
+ self.__failed = True
+
+ def onVertMove(event, offset):
+ if self.friction == -1:
+ self.assertEqual(offset, (0,40))
+ self.__moved = True
+
+ for friction in (-1, 100):
+ root = self.loadEmptyScene()
+ image = avg.ImageNode(parent=root, href="rgb24-64x64.png")
+ dragRecognizer = ui.DragRecognizer(image,
+ possibleHandler=onPossible, failHandler=onFail,
+ detectedHandler=onDetected,
+ moveHandler=onVertMove, upHandler=onUp, endHandler=onEnd,
+ friction=self.friction, direction=ui.DragRecognizer.VERTICAL)
+ initState()
+ self.start((
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: assertDragEvents(False, False, False, False, True, False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 35, 30),
+ lambda: assertDragEvents(False, False, False, False, True, False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 30, 70),
+ lambda: assertDragEvents(True, True, False, False, True, False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 40, 20),
+ lambda: assertDragEvents(True, True, True, True, True, False),
+ initState,
+ # Wrong direction -> abort.
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 70, 30),
+ lambda: assertDragEvents(False, False, False, False, True, True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 70, 30),
+ lambda: assertDragEvents(False, False, False, False, True, True),
+
+ # No movement -> abort.
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 30, 30),
+ lambda: assertDragEvents(False, False, False, False, True, True),
+ ))
+
+ Player.setFakeFPS(-1)
+
+
+ def testDragRecognizerRelCoords(self):
+
+ def onDrag(event, offset):
+ self.assertAlmostEqual(offset, (-40,-40))
+
+ Player.setFakeFPS(100)
+ for self.friction in (-1, 100):
+ root = self.loadEmptyScene()
+ div = avg.DivNode(pos=(64,64), angle=math.pi, parent=root)
+ image = avg.ImageNode(parent=div, href="rgb24-64x64.png")
+ ui.DragRecognizer(image, moveHandler=onDrag, friction=self.friction)
+ self.start((
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 70, 70),
+ ))
+ Player.setFakeFPS(-1)
+
+
+ def testDragRecognizerInitialEvent(self):
+
+ def onMotion(event):
+ ui.DragRecognizer(self.image,
+ detectedHandler=onDragStart, moveHandler=onDrag, initialEvent=event)
+ self.image.disconnectEventHandler(self)
+
+ def onDragStart(event):
+ self.__dragStartCalled = True
+
+ def onDrag(event, offset):
+ self.assertEqual(offset, (10,0))
+
+ root = self.loadEmptyScene()
+ self.image = avg.ImageNode(parent=root, href="rgb24-64x64.png")
+ self.image.connectEventHandler(avg.CURSORMOTION, avg.MOUSE, self, onMotion)
+ self.__dragStartCalled = False
+ self.start((
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 40, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 50, 30),
+ ))
+ assert(self.__dragStartCalled)
+
+
+ def testDragRecognizerCoordSysNode(self):
+
+ def onDrag(event, offset):
+ self.assertEqual(offset, (40,40))
+
+ root = self.loadEmptyScene()
+ div = avg.DivNode(pos=(64,64), angle=math.pi, parent=root)
+ image = avg.ImageNode(parent=div, href="rgb24-64x64.png")
+ ui.DragRecognizer(image, moveHandler=onDrag, coordSysNode=div, friction=-1)
+ self.start((
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 30, 30),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 70, 70),
+ ))
+
+
+ def testTransformRecognizer(self):
+
+ def onDetected(event):
+ pass
+
+ def onMove(transform):
+ self.transform = transform
+
+ def onUp(transform):
+ self.transform = transform
+
+ def checkTransform(expectedTransform):
+# print self.transform
+# print expectedTransform
+# print
+ self.assertAlmostEqual(self.transform.trans, expectedTransform.trans)
+ self.assertAlmostEqual(self.transform.rot, expectedTransform.rot)
+ self.assertAlmostEqual(self.transform.scale, expectedTransform.scale)
+ if expectedTransform.rot != 0 or expectedTransform.scale != 1:
+ self.assertAlmostEqual(self.transform.pivot, expectedTransform.pivot)
+
+ def createTransTestFrames():
+ return (
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 10, 10),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 20, 10),
+ lambda: checkTransform(ui.Transform((10,0))),
+ )
+
+ def createRotTestFrames(expectedTransform):
+ return (
+ lambda: self._sendTouchEvents((
+ (1, avg.CURSORDOWN, 0, 10),
+ (2, avg.CURSORDOWN, 0, 20))),
+ lambda: self._sendTouchEvents((
+ (1, avg.CURSORMOTION, 0, 20),
+ (2, avg.CURSORMOTION, 0, 10))),
+ lambda: checkTransform(expectedTransform),
+ lambda: self._sendTouchEvents((
+ (1, avg.CURSORUP, 0, 20),
+ (2, avg.CURSORUP, 0, 10))),
+ )
+
+ def createScaleTestFrames(expectedTransform):
+ return (
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 10),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 20),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, 10),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, 30),
+ lambda: checkTransform(expectedTransform),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 10),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 30),
+ )
+
+ root = self.loadEmptyScene()
+ image = avg.ImageNode(parent=root, href="rgb24-64x64.png")
+ self.__transformRecognizer = ui.TransformRecognizer(image,
+ detectedHandler=onDetected, moveHandler=onMove, upHandler=onUp)
+ self.start((
+ # Check up/down handling
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 10, 10),
+ lambda: checkTransform(ui.Transform((0,0))),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 20, 10),
+ lambda: checkTransform(ui.Transform((10,0))),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 20, 20),
+ lambda: checkTransform(ui.Transform((0,0))),
+ lambda: self._sendTouchEvents((
+ (1, avg.CURSORMOTION, 30, 10),
+ (2, avg.CURSORMOTION, 30, 20))),
+ lambda: checkTransform(ui.Transform((10,0))),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 30, 20),
+ lambda: checkTransform(ui.Transform((0,0))),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 40, 10),
+ lambda: checkTransform(ui.Transform((10,0))),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 50, 10),
+ lambda: checkTransform(ui.Transform((10,0))),
+
+ createRotTestFrames(ui.Transform((0,0), math.pi, 1, (0,15))),
+
+ createScaleTestFrames(ui.Transform((0,5), 0, 2, (0,20)))
+ ))
+
+ # Test rel. coords.
+ root = self.loadEmptyScene()
+ div = avg.DivNode(parent=root, pos=(0,10))
+ image = avg.ImageNode(parent=div, href="rgb24-64x64.png")
+ self.__transformRecognizer = ui.TransformRecognizer(image,
+ detectedHandler=onDetected, moveHandler=onMove, upHandler=onUp)
+ self.start((
+ createTransTestFrames(),
+ createRotTestFrames(ui.Transform((0,0), math.pi, 1, (0,5))),
+ createScaleTestFrames(ui.Transform((0,5), 0, 2, (0,10))),
+ ))
+
+ # Test coordSysNode.
+ root = self.loadEmptyScene()
+ div = avg.DivNode(parent=root, pos=(0,10))
+ image = avg.ImageNode(parent=div, href="rgb24-64x64.png")
+ self.__transformRecognizer = ui.TransformRecognizer(image, coordSysNode=div,
+ detectedHandler=onDetected, moveHandler=onMove, upHandler=onUp)
+ self.start((
+ createTransTestFrames(),
+ createRotTestFrames(ui.Transform((0,0), math.pi, 1, (0,15))),
+ createScaleTestFrames(ui.Transform((0,5), 0, 2, (0,20))),
+ ))
+
+
+ def testKMeans(self):
+ pts = [avg.Point2D(0,0), avg.Point2D(0,1)]
+ means = ui.calcKMeans(pts)
+ self.assertEqual(means, ([0], [1]))
+
+ pts.append (avg.Point2D(0,4))
+ means = ui.calcKMeans(pts)
+ self.assertEqual(means, ([0,1], [2]))
+
+
+ def testMat3x3(self):
+ t = ui.Mat3x3.translate([1,0,1])
+ v = [1,0,1]
+ self.assertEqual(t.applyVec(v), [2,0,1])
+ r = ui.Mat3x3.rotate(math.pi/2)
+ self.assertAlmostEqual(r.applyVec(v), [0,1,1])
+ t2 = t.applyMat(t)
+ self.assertAlmostEqual(t.applyMat(t).m, ui.Mat3x3.translate([2,0,1]).m)
+ self.assertAlmostEqual(t.applyMat(r).m, ui.Mat3x3([0,-1,1],[1,0,0]).m)
+ self.assertAlmostEqual(r.applyMat(t).m, ui.Mat3x3([0,-1,0],[1,0,1]).m)
+ self.assertAlmostEqual(ui.Mat3x3().m, ui.Mat3x3().inverse().m)
+ m = ui.Mat3x3([-1, 3, -3],
+ [ 0, -6, 5],
+ [-5, -3, 1])
+ im = ui.Mat3x3([3./2, 1., -1./2],
+ [-25./6, -8./3, 5./6],
+ [-5., -3., 1.])
+ self.assertAlmostEqual(m.inverse().m, im.m)
+
+ image = avg.ImageNode(pos=(10,20), size=(30,40), angle=1.57,
+ href="rgb24alpha-64x64.png")
+ mat = ui.Mat3x3.fromNode(image)
+ mat.setNodeTransform(image)
+ self.assertAlmostEqual(image.pos, (10,20))
+ self.assertAlmostEqual(image.size, (30,40))
+ self.assertAlmostEqual(image.angle, 1.57)
+
+
+ def testFocusContext(self):
+ def setup():
+ textarea.init(avg)
+ self.ctx1 = textarea.FocusContext()
+ self.ctx2 = textarea.FocusContext()
+
+ self.ta1 = textarea.TextArea(Player.getElementByID('ph1'),
+ self.ctx1, id='ta1')
+ self.ta1.setStyle(font='Bitstream Vera Sans', variant='Roman',
+ fontsize=16, multiline=True, color='FFFFFF')
+ self.ta1.setText('Lorem ipsum')
+
+ self.ta2 = textarea.TextArea(Player.getElementByID('ph2'),
+ self.ctx1, id='ta2')
+ self.ta2.setStyle(font='Bitstream Vera Sans', variant='Roman',
+ fontsize=14, multiline=False, color='FFFFFF')
+ self.ta2.setText('dolor')
+
+ self.ta3 = textarea.TextArea(Player.getElementByID('ph3'),
+ self.ctx2, disableMouseFocus=True, id='ta3')
+ self.ta3.setStyle(font='Bitstream Vera Sans', variant='Roman',
+ fontsize=14, multiline=True, color='FFFFFF')
+ self.ta3.setText('dolor sit amet')
+
+ textarea.setActiveFocusContext(self.ctx1)
+
+ def writeChar():
+ helper = Player.getTestHelper()
+ helper.fakeKeyEvent(avg.KEYDOWN, 65, 65, "A", 65, 0)
+ helper.fakeKeyEvent(avg.KEYUP, 65, 65, "A", 65, 0)
+ helper.fakeKeyEvent(avg.KEYDOWN, 66, 66, "B", 66, 0)
+ helper.fakeKeyEvent(avg.KEYUP, 66, 66, "B", 66, 0)
+ helper.fakeKeyEvent(avg.KEYDOWN, 67, 67, "C", 67, 0)
+ helper.fakeKeyEvent(avg.KEYUP, 67, 67, "C", 67, 0)
+
+ def switchFocus():
+ self.ctx1.cycleFocus()
+
+ def clearFocused():
+ self.ctx1.clear()
+
+ def clickForFocus():
+ self._sendMouseEvent(avg.CURSORDOWN, 20, 70)
+ self._sendMouseEvent(avg.CURSORUP, 20, 70)
+
+ root = self.loadEmptyScene()
+ avg.DivNode(id="ph1", pos=(2,2), size=(156,54), parent=root)
+ avg.DivNode(id="ph2", pos=(2,58), size=(76,54), parent=root)
+ div3 = avg.DivNode(id="ph3", pos=(80,58), size=(76,54), parent=root)
+ avg.ImageNode(href="1x1_white.png", size=(76,54), parent=div3)
+ self.start((
+ setup,
+ lambda: self.compareImage("testFocusContext1", True),
+ writeChar,
+ lambda: self.compareImage("testFocusContext2", True),
+ switchFocus,
+ writeChar,
+ lambda: self.compareImage("testFocusContext3", True),
+ switchFocus,
+ clearFocused,
+ lambda: self.compareImage("testFocusContext4", True),
+ clickForFocus,
+ clearFocused,
+ lambda: self.compareImage("testFocusContext5", True),
+ ))
+
+ def testButton(self):
+ def onDown(event):
+ self.__down = True
+
+ def onClick(event):
+ self.__clicked = True
+
+ def reset():
+ self.__down = False
+ self.__clicked = False
+
+ def printAddress(obj):
+ print obj
+
+ def setObjectActive(obj, active):
+ obj.active = active
+
+ root = self.loadEmptyScene()
+
+ b = ui.Button(
+ parent = root,
+ upNode = avg.ImageNode(href="button_up.png"),
+ downNode = avg.ImageNode(href="button_down.png"),
+ disabledNode = avg.ImageNode(href="button_disabled.png"),
+ pressHandler = onDown,
+ clickHandler = onClick)
+
+ b1 = ui.Button(parent=root,
+ active=False,
+ pressHandler=onDown,
+ clickHandler=onClick)
+
+ b.pos = (0, 0)
+ yOutDistance = int(b.height * 2)
+
+ self.__down = False
+ self.__clicked = False
+
+ self.start((
+ # Normal click: Down & up over button
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__clicked),
+ reset,
+
+ # Down, move away from button, move over button, up
+ # ==> click
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # Down, move away from button, up ==> no click
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, yOutDistance),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ reset,
+
+ # Move away from button, down, mover over button, up
+ # ==> no click
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, yOutDistance),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(not(self.__down) and not(self.__clicked)),
+ reset,
+
+ # Move away from button, down, mover over button, move away from button, up
+ # ==> no click
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, yOutDistance),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, yOutDistance),
+ lambda: self.assert_(not(self.__down) and not(self.__clicked)),
+ reset,
+
+ # Check checkable button
+ # Set checkable, down, up => pressed, down, up ==> click
+ lambda: b.setCheckable(True),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # not checked, down, out, in, up ==> pressed, click
+ lambda: b.setCheckable(True),
+ lambda: b.setChecked(False),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # not checked, down, out, up ==> pressed, no click
+ lambda: b.setCheckable(True),
+ lambda: b.setChecked(False),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ reset,
+
+ # not checked, down, out, up ==> pressed, no click
+ lambda: b.setCheckable(True),
+ lambda: b.setChecked(True),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ reset,
+
+ # checked, down, out, in, up ==> pressed, clicked
+ lambda: b.setCheckable(True),
+ lambda: b.setChecked(True),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.assert_(self.__down),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # Test public interface
+ lambda: b.setCheckable(False),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(b.isEnabled()),
+ lambda: self.assert_(not(b.isCheckable())),
+ lambda: b.setCheckable(True),
+ lambda: self.assert_(b.isCheckable()),
+ lambda: b.setChecked(True),
+ lambda: self.assert_(b.isChecked()),
+ lambda: b.setEnabled(False),
+ lambda: self.assert_(not(b.isEnabled())),
+ lambda: self.assert_(not(self.__down) and not(self.__clicked)),
+ lambda: b.setEnabled(True),
+ lambda: b.setChecked(False),
+ reset,
+
+ # Disable: Various up/down combinations have no effect
+ lambda: b.setEnabled(False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDisabled", False),
+ lambda: self.assert_(not(self.__down) and not(self.__clicked)),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDisabled", False),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDisabled", False),
+ lambda: self.assert_(not(self.__down) and not(self.__clicked)),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDisabled", False),
+ lambda: b.setEnabled(True),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(not(self.__down)),
+ lambda: self.assert_(not(self.__clicked)),
+ reset,
+
+ # Checking functionality while resetting the visible nodes
+ lambda: b.setNodes(upNode = avg.ImageNode(href="button_up.png"),
+ downNode = avg.ImageNode(href="button_down.png"),
+ disabledNode = avg.ImageNode(href="button_disabled.png")),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ lambda: b.setEnabled(False),
+ lambda: b.setNodes(upNode = avg.ImageNode(href="button_up.png"),
+ downNode = avg.ImageNode(href="button_down.png"),
+ disabledNode = avg.ImageNode(href="button_disabled.png")),
+ lambda: self.compareImage("testUIButtonDisabled", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.assert_(not(self.__down) and not(self.__clicked)),
+ reset,
+
+ lambda: b.setEnabled(True),
+ lambda: b.setNodes(upNode = avg.ImageNode(href="button_up.png"),
+ downNode = avg.ImageNode(href="button_down.png"),
+ disabledNode = None),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # resetting the nodes on an empty button
+ lambda: setObjectActive(b, False),
+ lambda: setObjectActive(b1, True),
+ lambda: b1.setNodes(upNode = avg.ImageNode(href="button_up.png"),
+ downNode = avg.ImageNode(href="button_down.png"),
+ disabledNode = avg.ImageNode(href="button_disabled.png")),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendMouseEvent(avg.CURSORDOWN, 0, 0),
+ lambda: self._sendMouseEvent(avg.CURSORUP, 0, 0),
+ lambda: self.assert_(self.__down and self.__clicked),
+ ))
+
+
+ def testMultitouchButton(self):
+ def onDown(event):
+ self.__down = True
+
+ def onClick(event):
+ self.__clicked = True
+
+ def reset():
+ self.__down = False
+ self.__clicked = False
+
+ root = self.loadEmptyScene()
+ b = ui.Button(
+ parent = root,
+ upNode = avg.ImageNode(href="button_up.png"),
+ downNode = avg.ImageNode(href="button_down.png"),
+ disabledNode = avg.ImageNode(href="button_disabled.png"),
+ pressHandler = onDown,
+ clickHandler = onClick,
+ )
+ b.pos = (0,0)
+ yOutDistance = b.height * 2
+
+ self.__down = False
+ self.__clicked = False
+ self.start((
+ # Two downs, two ups ==> click after second up.
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__clicked),
+ reset,
+
+ # Two downs, one out, out up, in up ==> click
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 50),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # Two down, both out, both in, both up ==> click
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # Two down both out, both up ==> no click
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, yOutDistance),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ reset,
+
+ # Two downs, one out, in up, out up ==> no click
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ reset,
+
+ # Check checkable multitouch button
+ # 2 down, 2 up ==> pressed, clicked,
+ # 2 down, 2 up ==> pressed, clicked
+ lambda: b.setCheckable(True),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # not checked, 2 down, 2 out, 2 in, first up, second up
+ # ==> pressed, clicked
+ lambda: b.setChecked(False),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # checked, 2 down, 2 out, 2 in, first up, second up
+ # ==> pressed, clicked
+ lambda: b.setCheckable(True),
+ lambda: b.setChecked(True),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 0),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and self.__clicked),
+ reset,
+
+ # not checked, 2 down, 2 out, first up, second up
+ # ==> pressed, not clicked
+ lambda: b.setCheckable(True),
+ lambda: b.setChecked(False),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonUp", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ reset,
+
+ # checked, 2 down, 2 out, first up, second up
+ # ==> pressed, not clicked
+ lambda: b.setCheckable(True),
+ lambda: b.setChecked(True),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(1, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORMOTION, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, yOutDistance),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self.assert_(self.__down and not(self.__clicked)),
+ reset,
+ ))
+
+
+ def testTouchButton(self):
+
+ def onClick():
+ self.clicked = True
+
+ def reset():
+ self.clicked = False
+
+ def enable(enabled):
+ button.enabled = enabled
+
+ def createScene(**kwargs):
+ root = self.loadEmptyScene()
+ return ui.TouchButton(
+ parent = root,
+ upNode = avg.ImageNode(href="button_up.png"),
+ downNode = avg.ImageNode(href="button_down.png"),
+ disabledNode = avg.ImageNode(href="button_disabled.png"),
+ clickHandler = onClick,
+ **kwargs
+ )
+
+ def runTest():
+ self.clicked = False
+ self.start((
+ # Standard down->up
+ lambda: self._sendTouchEvent(1, avg.CURSORDOWN, 0, 0),
+ lambda: self.assert_(not(self.clicked)),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(1, avg.CURSORUP, 0, 0),
+ lambda: self.assert_(self.clicked),
+ lambda: self.compareImage("testUIButtonUp", False),
+
+ # Disable, down, up -> no click
+ reset,
+ lambda: self.assert_(button.enabled),
+ lambda: enable(False),
+ lambda: self.assert_(not(button.enabled)),
+ lambda: self.compareImage("testUIButtonDisabled", False),
+ lambda: self._sendTouchEvent(2, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(2, avg.CURSORUP, 0, 0),
+ lambda: self.assert_(not(self.clicked)),
+ lambda: enable(True),
+ lambda: self.assert_(button.enabled),
+
+ # Down, up further away -> no click
+ reset,
+ lambda: self._sendTouchEvent(3, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(3, avg.CURSORUP, 100, 0),
+ lambda: self.assert_(not(self.clicked)),
+ lambda: self.compareImage("testUIButtonUp", False),
+
+ # Down, move further away, up -> no click
+ reset,
+ lambda: self._sendTouchEvent(3, avg.CURSORDOWN, 0, 0),
+ lambda: self._sendTouchEvent(3, avg.CURSORMOTION, 100, 0),
+ lambda: self._sendTouchEvent(3, avg.CURSORUP, 100, 0),
+ lambda: self.assert_(not(self.clicked)),
+ lambda: self.compareImage("testUIButtonUp", False),
+
+ # Test if button still reacts after abort
+ lambda: self._sendTouchEvent(4, avg.CURSORDOWN, 0, 0),
+ lambda: self.assert_(not(self.clicked)),
+ lambda: self.compareImage("testUIButtonDown", False),
+ lambda: self._sendTouchEvent(4, avg.CURSORUP, 0, 0),
+ lambda: self.assert_(self.clicked),
+ lambda: self.compareImage("testUIButtonUp", False),
+ ))
+
+ button = createScene()
+ runTest()
+
+ button = createScene(activeAreaNode = avg.CircleNode(r=5, opacity=0))
+ runTest()
+
+ button = createScene(fatFingerEnlarge = True)
+ runTest()
+
+ root = self.loadEmptyScene()
+ button = ui.TouchButton.fromSrc(
+ parent = root,
+ upSrc = "button_up.png",
+ downSrc = "button_down.png",
+ disabledSrc = "button_disabled.png",
+ clickHandler = onClick
+ )
+ runTest()
+
+ def testScrollPane(self):
+ def scrollLarge():
+ scrollPane.contentpos = (-34, -34)
+ self.assertEqual(scrollPane.contentpos, (-32,-32))
+
+ def initSmallContent():
+ scrollPane.size = (64, 64)
+ contentArea.size = (32, 32)
+ image.size = (32, 32)
+ scrollPane.contentpos = (0, 0)
+ self.assertEqual(scrollPane.getMaxContentPos(), (32,32))
+
+ def scrollSmall():
+ scrollPane.contentpos = (32, 32)
+
+ root = self.loadEmptyScene()
+ contentArea = avg.DivNode(size=(64,64))
+ image = avg.ImageNode(href="rgb24-64x64.png", parent=contentArea)
+ scrollPane = ui.ScrollPane(contentDiv=contentArea, size=(32,32), parent=root)
+
+ self.start((
+ lambda: self.compareImage("testScrollPane1", False),
+ scrollLarge,
+ lambda: self.compareImage("testScrollPane2", False),
+ initSmallContent,
+ lambda: self.compareImage("testScrollPane3", False),
+ scrollSmall,
+ lambda: self.compareImage("testScrollPane4", False),
+ ))
+
+
+def uiTestSuite(tests):
+ availableTests = (
+ "testKeyboard",
+ "testTextArea",
+ "testFocusContext",
+ "testTapRecognizer",
+ "testHoldRecognizer",
+ "testDoubletapRecognizer",
+ "testDragRecognizer",
+ "testDragRecognizerRelCoords",
+ "testDragRecognizerInitialEvent",
+ "testDragRecognizerCoordSysNode",
+ "testTransformRecognizer",
+ "testKMeans",
+ "testMat3x3",
+ "testButton",
+ "testMultitouchButton",
+ "testTouchButton",
+ "testScrollPane"
+ )
+
+ return createAVGTestSuite(availableTests, UITestCase, tests)
+
+Player = avg.Player.get()
+
diff --git a/src/test/VectorTest.py b/src/test/VectorTest.py
new file mode 100644
index 0000000..f408aa8
--- /dev/null
+++ b/src/test/VectorTest.py
@@ -0,0 +1,698 @@
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import unittest
+
+from libavg import avg
+from testcase import *
+
+class VectorTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def makeEmptyCanvas(self):
+ root = self.loadEmptyScene()
+ canvas = avg.DivNode(id="canvas", size=(160,120), parent=root)
+ return canvas
+
+ def testLine(self):
+ def addLines():
+ def addLine(attribs):
+ line = Player.createNode("line", attribs)
+ canvas.appendChild(line)
+
+ addLine({"pos1":(2, 2.5), "pos2":(100, 2.5)})
+ addLine({"pos1":(2, 5), "pos2":(100, 5), "strokewidth":2})
+ addLine({"pos1":(2.5, 20), "pos2":(2.5, 100)})
+ addLine({"pos1":(5, 20), "pos2":(5, 100), "strokewidth":2})
+ addLine({"pos1":(2, 7.5), "pos2":(100, 7.5), "color":"FF0000"})
+ addLine({"pos1":(2, 9.5), "pos2":(100, 9.5), "color":"00FF00"})
+ addLine({"pos1":(2, 11.5), "pos2":(100, 11.5), "color":"0000FF"})
+
+ def changeLine():
+ line.color="FF0000"
+ line.strokewidth=3
+
+ def moveLine():
+ line.pos1 += (0, 30)
+ line.pos2 += (0, 30)
+
+ def blendMode():
+ line = canvas.getChild(6)
+ line.pos1 = (line.pos1.x, 7.9)
+ line.pos2 = (line.pos2.x, 7.9)
+ line.strokewidth = 10
+ line.blendmode="add"
+
+ canvas = self.makeEmptyCanvas()
+ addLines()
+ line = canvas.getChild(0)
+ self.start((
+ lambda: self.compareImage("testline1", False),
+ changeLine,
+ lambda: self.compareImage("testline2", False),
+ moveLine,
+ lambda: self.compareImage("testline3", False),
+ blendMode,
+ lambda: self.compareImage("testline4", False)
+ ))
+
+ def testLotsOfLines(self):
+ def addLines():
+ for i in xrange(500):
+ y = i+2.5
+ line = avg.LineNode(pos1=(2, y), pos2=(10, y))
+ canvas.appendChild(line)
+
+ canvas = self.makeEmptyCanvas()
+ self.start((
+ addLines,
+ lambda: self.compareImage("testlotsoflines", False),
+ ))
+
+ def testTexturedLine(self):
+ def addLine():
+ line = avg.LineNode(pos1=(2, 20), pos2=(100, 20), texhref="rgb24-64x64.png",
+ strokewidth=30)
+ canvas.appendChild(line)
+
+ def removeLine():
+ self.line = canvas.getChild(0)
+ self.line.unlink()
+
+ def reAddLine():
+ canvas.appendChild(self.line)
+
+ def moveTexture():
+ self.line.texcoord1 = -0.5
+ self.line.texcoord2 = 1.5
+
+ def bmpTexture():
+ bmp = avg.Bitmap("rgb24alpha-64x64.png")
+ self.line.setBitmap(bmp)
+
+ def bmpNoTexture():
+ self.line.setBitmap(None)
+
+ canvas = self.makeEmptyCanvas()
+ addLine()
+ self.start((
+ lambda: self.compareImage("testtexturedline1", False),
+ removeLine,
+ lambda: self.compareImage("testtexturedline2", False),
+ addLine,
+ lambda: self.compareImage("testtexturedline1", False),
+ removeLine,
+ lambda: self.compareImage("testtexturedline2", False),
+ reAddLine,
+ lambda: self.compareImage("testtexturedline1", False),
+ moveTexture,
+ lambda: self.compareImage("testtexturedline3", False),
+ bmpTexture,
+ lambda: self.compareImage("testtexturedline4", False),
+ bmpNoTexture,
+ lambda: self.compareImage("testtexturedline5", False),
+ ))
+
+ def testLineOpacity(self):
+ def addLine():
+ line = avg.LineNode(pos1=(2, 2.5), pos2=(158, 2.5), opacity=0.5)
+ canvas.appendChild(line)
+
+ def changeCanvasOpacity():
+ canvas.opacity = 0.5
+ canvas.getChild(0).opacity = 0.25
+
+ canvas = self.makeEmptyCanvas()
+ self.start((
+ addLine,
+ lambda: self.compareImage("testlineopacity1", False),
+ changeCanvasOpacity,
+ lambda: self.compareImage("testlineopacity2", False),
+ ))
+
+ def testRect(self):
+ def addRect():
+ rect = avg.RectNode(pos=(2, 2), size=(50, 30), fillopacity=1,
+ strokewidth=0)
+ canvas.appendChild(rect)
+ rect.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onMouseDown)
+ return rect
+
+ def moveRect():
+ rect.pos = (50, 50)
+ rect.size = (30, 10)
+ rect.fillcolor = "FF0000"
+ rect.fillopacity = 0.5
+ rect.color = "FFFF00"
+ rect.strokewidth = 2
+
+ def rotateRect():
+ rect.angle = 1.57
+
+ def addRect2():
+ rect = avg.RectNode(pos=(60, 2), size=(50, 30), fillopacity=1,
+ strokewidth=2)
+ rect.color = "FFFF00"
+ canvas.insertChild(rect, 0)
+
+ def onMouseDown(event):
+ self.__mouseDownCalled = True
+
+ self.__mouseDownCalled = False
+ canvas = self.makeEmptyCanvas()
+ rect = addRect()
+ helper = Player.getTestHelper()
+ self.start((
+ lambda: self.compareImage("testRect1", False),
+ moveRect,
+ lambda: self.compareImage("testRect2", False),
+ rotateRect,
+ lambda: self.compareImage("testRect3", False),
+ addRect2,
+ lambda: self.compareImage("testRect4", False),
+ lambda: self.fakeClick(100, 100),
+ lambda: self.assertEqual(self.__mouseDownCalled, False),
+ lambda: self.fakeClick(55, 50),
+ lambda: self.assertEqual(self.__mouseDownCalled, False),
+ lambda: self.fakeClick(65, 60),
+ lambda: self.assert_(self.__mouseDownCalled)
+ ))
+
+ def testTexturedRect(self):
+ def addRect():
+ self.rect = avg.RectNode(pos=(20, 20), size=(50, 40), fillopacity=1,
+ filltexcoord1=(1,1), filltexcoord2=(0,0), strokewidth=20,
+ texcoords=(1, 0.75, 0.5, 0.25, 0), texhref="rgb24-64x64.png")
+ canvas.appendChild(self.rect)
+ return self.rect
+
+ def newRect():
+ self.rect.unlink()
+ self.rect = Player.createNode(
+ """<rect pos="(20, 20)" size="(50, 40)" fillopacity="1"
+ filltexcoord1="(1,1)" filltexcoord2="(0,0)"
+ texcoords="(0, 0.25, 0.5, 0.75, 1)"
+ strokewidth="20" texhref="rgb24-64x64.png"/>""")
+ canvas.appendChild(self.rect)
+
+ def setTexCoords():
+ self.rect.texcoords = [-1, 0, 1, 2, 3]
+
+ def setFillTex():
+ self.rect.strokewidth = 2
+ self.rect.texhref = ""
+ self.rect.filltexhref="rgb24alpha-64x64.png"
+
+ def setFillTexCoords():
+ self.rect.filltexcoord1 = (0.5, 0.5)
+ self.rect.filltexcoord2 = (1.5, 1.5)
+
+ def setFillBitmap():
+ bmp = avg.Bitmap("rgb24-64x64.png")
+ self.rect.setFillBitmap(bmp)
+
+ def clearFillBitmap():
+ self.rect.fillcolor = "FF0000"
+ self.rect.setFillBitmap(None)
+
+ def setTransparentBorder():
+ self.rect.fillopacity = 0
+ self.rect.texhref = "rectborder.png"
+ self.rect.strokewidth = 10
+
+ canvas = self.makeEmptyCanvas()
+ addRect()
+ self.start((
+ lambda: self.compareImage("testTexturedRect1", False),
+ newRect,
+ lambda: self.compareImage("testTexturedRect2", False),
+ setTexCoords,
+ lambda: self.compareImage("testTexturedRect3", False),
+ setFillTex,
+ lambda: self.compareImage("testTexturedRect4", False),
+ setFillTexCoords,
+ lambda: self.compareImage("testTexturedRect5", False),
+ setFillBitmap,
+ lambda: self.compareImage("testTexturedRect6", False),
+ clearFillBitmap,
+ lambda: self.compareImage("testTexturedRect7", False),
+ setFillBitmap,
+ lambda: self.compareImage("testTexturedRect6", False),
+# setTransparentBorder,
+# lambda: self.compareImage("testTexturedRect8", False),
+ ))
+
+ def testCurve(self):
+ def addCurve():
+ curve = avg.CurveNode(pos1=(10.5, 10), pos2=(10.5, 80), pos3=(80.5, 80),
+ pos4=(80.5, 10))
+ canvas.appendChild(curve)
+ return curve
+
+ def changeCurve():
+ curve.strokewidth = 19
+ curve.color="FFFF00"
+
+ def moveCurve():
+ curve.pos2 = (10.5, 120)
+ curve.pos3 = (80.5, 120)
+
+ def addCurve2():
+ curve = avg.CurveNode(pos1=(30.5, 10), pos2=(30.5, 120), pos3=(100.5, 120),
+ pos4=(100.5, 10))
+ curve.color="FF0000"
+ canvas.appendChild(curve)
+
+ canvas = self.makeEmptyCanvas()
+ curve = addCurve()
+ self.start((
+ lambda: self.compareImage("testCurve1", False),
+ changeCurve,
+ lambda: self.compareImage("testCurve2", False),
+ moveCurve,
+ lambda: self.compareImage("testCurve3", False),
+ addCurve2,
+ lambda: self.compareImage("testCurve4", False),
+ ))
+
+ def testTexturedCurve(self):
+ def addCurve():
+ curve = avg.CurveNode(pos1=(10.5, 10), pos2=(10.5, 80), pos3=(80.5, 80),
+ pos4=(80.5, 10), strokewidth=19, texhref="rgb24-64x64.png")
+ canvas.appendChild(curve)
+ return curve
+
+ def setTexCoords():
+ curve.texcoord1=-1
+ curve.texcoord2=2
+
+ canvas = self.makeEmptyCanvas()
+ curve = addCurve()
+ self.start((
+ lambda: self.compareImage("testTexturedCurve1", False),
+ setTexCoords,
+ lambda: self.compareImage("testTexturedCurve2", False)
+ ))
+
+ def testPolyLine(self):
+ def addPolyLine():
+ polyline = avg.PolyLineNode(strokewidth=2, color="FF00FF",
+ pos=[(10,10), (50,10), (90,50), (90, 90)])
+ canvas.appendChild(polyline)
+ return polyline
+
+ def changePolyLine():
+ polyline.strokewidth = 16
+ polyline.color="FFFF00"
+ pos = polyline.pos
+ pos.append((110, 90))
+ polyline.pos = pos
+
+ def miterPolyLine():
+ polyline.linejoin = "miter"
+
+ def addPolyLine2():
+ polyline2 = Player.createNode(
+ """<polyline strokewidth="2" color="FF00FF"
+ pos="((110,10), (100,50), (110,70))" />""")
+ canvas.insertChild(polyline2,0)
+
+ def testEmptyPolyLine():
+ polyline2 = canvas.getChild(0)
+ polyline2.pos=[]
+
+ def testAlmostEmptyPolyLine():
+ polyline2 = canvas.getChild(0)
+ polyline2.pos=[(10,10)]
+
+ def testAcutePolyLine():
+ polyline2 = canvas.getChild(0)
+ polyline2.strokewidth = 10
+ polyline2.linejoin="bevel"
+ polyline2.pos = [(50,10), (60,10), (50,11)]
+ canvas.removeChild(1)
+
+ canvas = self.makeEmptyCanvas()
+ polyline = addPolyLine()
+ self.start((
+ lambda: self.compareImage("testPolyLine1", False),
+ changePolyLine,
+ lambda: self.compareImage("testPolyLine2", False),
+ miterPolyLine,
+ lambda: self.compareImage("testPolyLine3", False),
+ addPolyLine2,
+ lambda: self.compareImage("testPolyLine4", False),
+ testEmptyPolyLine,
+ lambda: self.compareImage("testPolyLine5", False),
+ testAlmostEmptyPolyLine,
+ lambda: self.compareImage("testPolyLine5", False),
+ testAcutePolyLine,
+ lambda: self.compareImage("testPolyLine6", False)
+ ))
+
+ def testTexturedPolyLine(self):
+ def texturePolyLine():
+ polyline = avg.PolyLineNode(strokewidth=20, color="FF00FF",
+ texhref="rgb24-64x64.png", pos=((10,10), (50,10), (90,50), (90, 90)),
+ texcoords=(0, 0.3, 0.7, 1))
+ canvas.appendChild(polyline)
+ return polyline
+
+ def miter():
+ polyline.linejoin = "miter"
+
+ def setTexCoords():
+ polyline.texcoords = [-1, 0, 1, 2]
+
+ def repeatTexCoords():
+ polyline.pos = [(10,10), (30,10), (30,50), (50,50), (50,70), (70,70)]
+ polyline.texcoords = [1, 2, 3]
+
+ canvas = self.makeEmptyCanvas()
+ polyline = texturePolyLine()
+ self.start((
+ lambda: self.compareImage("testTexturedPolyLine1", False),
+ miter,
+ lambda: self.compareImage("testTexturedPolyLine2", False),
+ setTexCoords,
+ lambda: self.compareImage("testTexturedPolyLine3", False),
+ repeatTexCoords,
+ lambda: self.compareImage("testTexturedPolyLine4", False)
+ ))
+
+ def testPolygon(self):
+ def addPolygon():
+ polygon = avg.PolygonNode(strokewidth=2, color="FF00FF",
+ pos=((10,10), (50,10), (90,50), (90, 90)))
+ polygon.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onMouseDown)
+ canvas.appendChild(polygon)
+ return polygon
+
+ def changePolygon():
+ polygon.strokewidth = 12
+ polygon.color="FFFF00"
+ pos = polygon.pos
+ pos.append((10, 90))
+ polygon.pos = pos
+
+ def fillPolygon():
+ polygon.strokewidth = 4
+ polygon.fillcolor = "00FFFF"
+ polygon.fillopacity = 0.5
+ pos = polygon.pos
+ pos.append((80, 50))
+ pos.append((50, 20))
+ pos.append((40, 40))
+ polygon.pos = pos
+
+ def addEmptyPoint():
+ pos = polygon.pos
+ pos.insert(1, (10, 10))
+ pos.append((40, 40))
+ polygon.pos = pos
+
+ def addPolygon2():
+ polygon = avg.PolygonNode(strokewidth=3, color="FF00FF",
+ pos=((100.5,10.5), (100.5,30.5), (120.5,30.5), (120.5, 10.5)))
+ canvas.insertChild(polygon, 0)
+
+ def miterPolygons():
+ polygon.linejoin = "miter"
+ polygon2 = canvas.getChild(0)
+ polygon2.linejoin = "miter"
+
+ def onMouseDown(event):
+ self.__mouseDownCalled = True
+
+ def addEmptyPolygon():
+ avg.PolygonNode(parent=canvas, fillopacity=1)
+
+ self.__mouseDownCalled = False
+ canvas = self.makeEmptyCanvas()
+ polygon = addPolygon()
+ helper = Player.getTestHelper()
+ self.start((
+ lambda: self.compareImage("testPolygon1", True),
+ changePolygon,
+ lambda: self.compareImage("testPolygon2", True),
+ fillPolygon,
+ lambda: self.compareImage("testPolygon3", True),
+ addEmptyPoint,
+ lambda: self.compareImage("testPolygon4", True),
+ addPolygon2,
+ lambda: self.compareImage("testPolygon5", True),
+ miterPolygons,
+ lambda: self.compareImage("testPolygon6", False),
+ lambda: self.fakeClick(50, 50),
+ lambda: self.assertEqual(self.__mouseDownCalled, False),
+ lambda: self.fakeClick(20, 87),
+ lambda: self.assert_(self.__mouseDownCalled),
+ addEmptyPolygon
+ ))
+
+ def testSelfIntersectPolygon(self):
+ def addPolygon():
+ polygon = avg.PolygonNode(strokewidth=3, color="FF00FF",
+ pos=((100.5, 10.5), (100.5, 30.5), (120.5, 10.5), (120.5, 30.5)),
+ fillcolor="00FFFF", fillopacity=0.5)
+ canvas.insertChild(polygon, 0)
+
+ canvas = self.makeEmptyCanvas()
+ self.assertException(lambda: self.start([addPolygon]))
+
+ def testTexturedPolygon(self):
+ def texturePolygon():
+ polygon = avg.PolygonNode(strokewidth=20, color="FF00FF",
+ texhref="rgb24-64x64.png", pos=((10,10), (50,10), (90,50), (90, 90)))
+ canvas.appendChild(polygon)
+ return polygon
+
+ def miter():
+ polygon.linejoin = "miter"
+
+ def setTexCoords():
+ polygon.texcoords = [-1, 0, 1, 2, 3]
+
+ def repeatTexCoords():
+ polygon.texcoords = [0, 1]
+
+ def setFillTex():
+ polygon.fillopacity=1
+ polygon.texhref=""
+ polygon.strokewidth=2
+ polygon.filltexhref="rgb24alpha-64x64.png"
+
+ def setFillTexCoords():
+ polygon.filltexcoord1=(0.5, 1)
+ polygon.filltexcoord2=(1.5, 3)
+
+ canvas = self.makeEmptyCanvas()
+ polygon = texturePolygon()
+ self.start((
+ lambda: self.compareImage("testTexturedPolygon1", False),
+ miter,
+ lambda: self.compareImage("testTexturedPolygon2", False),
+ setTexCoords,
+ lambda: self.compareImage("testTexturedPolygon3", False),
+ repeatTexCoords,
+ lambda: self.compareImage("testTexturedPolygon4", False),
+ setFillTex,
+ lambda: self.compareImage("testTexturedPolygon5", False),
+ setFillTexCoords,
+ lambda: self.compareImage("testTexturedPolygon6", False)
+ ))
+
+ def testPointInPolygon(self):
+ polygon_pos = [(10, 10), (50, 10), (90, 50), (90, 90)]
+ self.assert_(avg.pointInPolygon((50, 20), polygon_pos))
+ self.assert_(avg.pointInPolygon((10, 20), polygon_pos) == False)
+
+ def testCircle(self):
+ def addCircle():
+ circle = avg.CircleNode(pos=(30, 30), r=20)
+ circle.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onMouseDown)
+ canvas.appendChild(circle)
+ return circle
+
+ def changeCircle():
+ circle.color="FF0000"
+ circle.fillcolor="FFFFFF"
+ circle.fillopacity=0.5
+ circle.strokewidth=3
+
+ def textureCircle():
+ circle.texhref="rgb24-64x64.png"
+ circle.strokewidth=20
+ circle.pos = (50, 50)
+ circle.texcoord1 = -1
+ circle.texcoord2 = 1
+
+ def setFillTex():
+ circle.strokewidth=1
+ circle.fillopacity=1
+ circle.texhref = ""
+ circle.filltexhref="rgb24alpha-64x64.png"
+
+ def setFillTexCoords():
+ circle.filltexcoord1 = (0.5, 0.5)
+ circle.filltexcoord2 = (1.5, 1.5)
+
+ def onMouseDown(event):
+ self.__mouseDownCalled = True
+
+ self.__mouseDownCalled = False
+ canvas = self.makeEmptyCanvas()
+ circle = addCircle()
+ helper = Player.getTestHelper()
+ self.start((
+ lambda: self.compareImage("testCircle1", False),
+ changeCircle,
+ lambda: self.compareImage("testCircle2", False),
+ textureCircle,
+ lambda: self.compareImage("testCircle3", False),
+ setFillTex,
+ lambda: self.compareImage("testCircle4", False),
+ setFillTexCoords,
+ lambda: self.compareImage("testCircle5", False),
+ lambda: self.fakeClick(32, 32),
+ lambda: self.assert_(self.__mouseDownCalled == False),
+ lambda: self.fakeClick(67, 50),
+ lambda: self.assert_(self.__mouseDownCalled)
+ ))
+
+ def testMesh(self):
+ def addMesh():
+ div = avg.DivNode()
+ mesh = avg.MeshNode(
+ texhref="rgb24-64x64.png",
+ vertexcoords=((0,0), (64,0), (0,64), (64, 64),(32, 32)),
+ texcoords=((0,0),(1,0),(0,1),(1,1),(0.5,0.5)),
+ triangles=((0,1,4),(1,3,4),(3,2,4),(2,0,4)))
+ div.appendChild(mesh)
+ div.x = 50
+ div.y = 30
+ canvas.appendChild(div)
+ return mesh
+
+ def setVertexCoords():
+ mesh.vertexcoords = ((0,0), (64,0), (0,64), (64, 64),(32, 64))
+
+ def setTexCoords():
+ mesh.vertexcoords = ((0,0), (64,0), (0,64), (64, 64),(32, 32))
+ mesh.texcoords = ((1,1),(1,1),(1,1),(1,1),(0.5,0.5))
+
+ def setTriangles():
+ mesh.vertexcoords = ((0,0), (64,0), (0,64), (64, 64),(31.5, 32))
+ mesh.texcoords = ((0,0),(1,0),(0,1),(1,1),(0.5,0.5))
+ mesh.triangles = ((3,1,4),(1,3,4),(1,2,4),(2,0,4))
+
+ def setTrianglesSameItem():
+ mesh.vertexcoords = ((0,0), (64,0), (0,64), (64, 64),(32, 32))
+ mesh.texcoords = ((0,0),(1,0),(0,1),(1,1),(0.5,0.5))
+ mesh.triangles = ((1,1,1),(2,2,2),(3,3,3),(4,4,4))
+
+ def setHref():
+ mesh.texhref = "rgb24alpha-64x64.png"
+
+ def setIllegalVertexes():
+ mesh.vertexcoords = ((0,0), (64,0), (0,64), (64, 64),(32, 32), (16,16))
+
+ def setIllegalTextures():
+ mesh.texcoords = ((100,0),(1,0),(0,1),(1,1),(0.5,0.5), (1.0,1.0))
+
+ def setIllegalIndexes():
+ mesh.triangles = ((27,1,1),(1,3,4),(3,2,4),(2,0,4))
+
+ canvas = self.makeEmptyCanvas()
+ mesh = addMesh()
+ self.assertException(setIllegalVertexes)
+ self.assertException(setIllegalTextures)
+ self.assertException(setIllegalIndexes)
+ self.start((
+ lambda: self.compareImage("testMesh1", False),
+ setVertexCoords,
+ lambda: self.compareImage("testMesh2", False),
+ setTexCoords,
+ lambda: self.compareImage("testMesh3", False),
+ setTriangles,
+ lambda: self.compareImage("testMesh4", False),
+ setHref,
+ lambda: self.compareImage("testMesh5", False),
+ setTrianglesSameItem,
+ lambda: self.compareImage("testMesh6", False)
+ ))
+
+ def testInactiveVector(self):
+ def addVectorNode():
+ node = avg.LineNode(pos1=(2, 2), pos2=(50, 2), strokewidth=2)
+ canvas.appendChild(node)
+ return node
+
+ def addFilledVectorNode():
+ node = avg.RectNode(pos=(2, 6), size=(50, 30), strokewidth=2)
+ node.setEventHandler(avg.CURSORDOWN, avg.MOUSE, onDown)
+ canvas.appendChild(node)
+ return node
+
+ def onDown(Event):
+ vNode.active = False
+ fvNode.active = False
+ self.onDownCalled = not self.onDownCalled
+
+ Helper = Player.getTestHelper()
+ canvas = self.makeEmptyCanvas()
+ vNode = addVectorNode()
+ fvNode = addFilledVectorNode()
+ self.onDownCalled = False
+ self.start((
+ lambda: self.compareImage("testInactiveVector1", False),
+ lambda: self.fakeClick(20, 20),
+ lambda: self.assert_(self.onDownCalled),
+ lambda: self.compareImage("testInactiveVector2", False),
+ lambda: self.fakeClick(20, 20),
+ lambda: self.assert_(self.onDownCalled)
+ ))
+
+
+def vectorTestSuite(tests):
+ availableTests = (
+ "testLine",
+ "testLotsOfLines",
+ "testLineOpacity",
+ "testTexturedLine",
+ "testRect",
+ "testTexturedRect",
+ "testCurve",
+ "testTexturedCurve",
+ "testPolyLine",
+ "testTexturedPolyLine",
+ "testPolygon",
+ "testSelfIntersectPolygon",
+ "testTexturedPolygon",
+ "testPointInPolygon",
+ "testCircle",
+ "testMesh",
+ "testInactiveVector"
+ )
+ return createAVGTestSuite(availableTests, VectorTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/WordsTest.py b/src/test/WordsTest.py
new file mode 100644
index 0000000..1fdbfd5
--- /dev/null
+++ b/src/test/WordsTest.py
@@ -0,0 +1,621 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import platform
+
+from libavg import avg
+from testcase import *
+
+class WordsTestCase(AVGTestCase):
+ def __init__(self, testFuncName):
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testSimpleWords(self):
+ def checkFont():
+ self.assertEqual(node.variant, "bold")
+
+ def checkUnicodeText():
+ node.text = u"föa"
+ newNode = avg.WordsNode(text=u"öäü")
+
+ fontList = avg.WordsNode.getFontFamilies()
+ try:
+ fontList.index("Bitstream Vera Sans")
+ except ValueError:
+ self.fail("Font not found")
+ variantList = avg.WordsNode.getFontVariants("Bitstream Vera Sans")
+ self.assert_(len(variantList) >= 4)
+ root = self.loadEmptyScene()
+ avg.WordsNode (pos=(1,1), fontsize=12, font="Bitstream Vera Sans",
+ text="Bitstream Vera Sans", variant="roman", parent=root)
+ node = avg.WordsNode (pos=(1,16), fontsize=12, font="Bitstream Vera Sans",
+ text="Bold", variant="bold", parent=root)
+ self.assertNotEqual(node.size, (0,0))
+ pos = node.getGlyphPos(0)
+ self.start((
+ lambda: self.compareImage("testSimpleWords", True),
+ checkFont,
+ checkUnicodeText,
+ ))
+
+ def testRedrawOnDemand(self):
+
+ def changeText(newText):
+ size = node.size
+ node.text = newText
+ self.assertNotEqual(node.size, size)
+
+ root = self.loadEmptyScene()
+ node = avg.WordsNode(font="Bitstream Vera Sans", fontsize=12, text="foo",
+ parent=root)
+ changeText("foobar")
+ self.start((lambda: changeText("bar"),))
+
+ def testGlyphPos(self):
+ def posAlmostEqual(pos1, pos2):
+ return math.fabs(pos1[0]-pos2[0]) <= 2 and math.fabs(pos1[1]-pos2[1]) <= 2
+
+ node = avg.WordsNode(text="Bold", font="Bitstream Vera Sans")
+ self.assertEqual(node.getGlyphPos(0), (0,0))
+ size = node.getGlyphSize(0)
+ self.assert_(posAlmostEqual(size, (10, 18)))
+ self.assert_(posAlmostEqual(node.getGlyphPos(3), (22,0)))
+ size = node.getGlyphSize(3)
+ self.assert_(posAlmostEqual(size, (8, 18)))
+ self.assertException(lambda: node.getGlyphPos(4))
+ node.text=u"föa"
+ self.assert_(posAlmostEqual(node.getGlyphPos(1), (4,0)))
+# print [ node.getGlyphPos(i) for i in range(3)]
+ self.assert_(posAlmostEqual(node.getGlyphPos(2), (12,0)))
+ self.assertException(lambda: node.getGlyphPos(3))
+
+ def testParaWords(self):
+ root = self.loadEmptyScene()
+ avg.LineNode(pos1=(0.5, 0), pos2=(0.5, 50), color="FF0000", parent=root)
+ avg.LineNode(pos1=(119.5, 0.5), pos2=(119.5, 50), color="FF0000", parent=root)
+ avg.LineNode(pos1=(74.5,60), pos2=(74.5, 110), color="FF0000", parent=root)
+ avg.WordsNode(id="para", pos=(1,1), fontsize=12, width=70,
+ font="Bitstream Vera Sans", text="Left-justified paragraph.",
+ parent=root)
+ avg.WordsNode(id="paracenter", pos=(120,1), fontsize=12, width=70,
+ font="Bitstream Vera Sans", text="Centered paragraph",
+ alignment="center", parent=root)
+ avg.WordsNode(id="pararight", pos=(75,60), fontsize=12, width=70,
+ font="Bitstream Vera Sans", alignment="right",
+ text="Right-justified paragraph.<i>l</i>",
+ parent=root)
+ avg.WordsNode(id="paralinespacing", pos=(80,60), fontsize=12, width=70,
+ font="Bitstream Vera Sans", linespacing=-4,
+ text="Paragraph with custom line spacing.",
+ parent=root)
+ self.start([lambda: self.compareImage("testParaWords", True)])
+
+ def testJustify(self):
+ root = self.loadEmptyScene()
+ avg.WordsNode(pos=(1,1), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", justify=True, width=100,
+ text="Justified paragraph more than one line long.", parent=root)
+ self.start([lambda: self.compareImage("testJustify", True)])
+
+ def testWrapMode(self):
+ def setCharMode():
+ node.wrapmode = 'char'
+
+ def setWordMode():
+ node.wrapmode = 'word'
+
+ def setWordCharMode():
+ node.wrapmode = 'wordchar'
+
+ root = self.loadEmptyScene()
+ node = avg.WordsNode(pos=(1,1), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", width=100,
+ text="""Wrapped paragraph more than one line long.
+ Withaverylongpackedlinewithnobreaks""",
+ parent=root)
+ self.start([
+ lambda: self.compareImage("testWrapMode1", True),
+ setCharMode,
+ lambda: self.compareImage("testWrapMode2", True),
+ setWordMode,
+ lambda: self.compareImage("testWrapMode3", True),
+ setWordCharMode,
+ lambda: self.compareImage("testWrapMode4", True),
+ ])
+
+ def testWordsMask(self):
+ def setMask():
+ try:
+ node.maskhref = "mask1.png"
+ except RuntimeError:
+ self.skip("no shader support")
+ Player.stop()
+
+ def setColor():
+ node.color = "FFFF00"
+
+ def setOpacity():
+ node.opacity = 0.5
+
+ def setSize():
+ rect = avg.RectNode(pos=(39.5, 30.5), size=(80, 60))
+ root.appendChild(rect)
+ node.masksize = (160, 120)
+ node.opacity = 1
+
+ def setPos():
+ node.pos = (40, 20)
+ node.maskpos = (-40, -20)
+
+ def setDefaultSize():
+ node.masksize = (0,0)
+
+ root = self.loadEmptyScene()
+ node = avg.WordsNode(fontsize=8, linespacing=-4, font="Bitstream Vera Sans",
+ variant="roman", width=160,
+ text="Ich bin nur ein kleiner Blindtext. Wenn ich gross bin, will ich \
+ Ulysses von James Joyce werden. Aber jetzt lohnt es sich noch nicht, \
+ mich weiterzulesen. Denn vorerst bin ich nur ein kleiner Blindtext. \
+ Ich bin nur ein kleiner Blindtext. Wenn ich gross bin, will ich \
+ Ulysses von James Joyce werden. Aber jetzt lohnt es sich noch nicht, \
+ mich weiterzulesen. Denn vorerst bin ich nur ein kleiner Blindtext. \
+ Ich bin nur ein kleiner Blindtext. Wenn ich gross bin, will ich \
+ Ulysses von James Joyce werden. Aber jetzt lohnt es sich noch nicht, \
+ mich weiterzulesen. Denn vorerst bin ich nur ein kleiner Blindtext.",
+ parent=root)
+ self.start((
+ setMask,
+ lambda: self.compareImage("testWordsMask1", False),
+ setColor,
+ lambda: self.compareImage("testWordsMask2", False),
+ setOpacity,
+ lambda: self.compareImage("testWordsMask3", False),
+ setSize,
+ lambda: self.compareImage("testWordsMask4", False),
+ setPos,
+ lambda: self.compareImage("testWordsMask5", False),
+ setDefaultSize,
+ lambda: self.compareImage("testWordsMask6", False),
+ ))
+
+ def testHinting(self):
+ def checkPositions():
+# node0 = root.getChild(0)
+# for i in range(len(node0.text)):
+# print node0.getGlyphPos(i)
+ noHint = root.getChild(0)
+ hint = root.getChild(1)
+ posNoHint = noHint.getGlyphPos(6)
+ posHint = hint.getGlyphPos(6)
+ self.assertNotEqual(posNoHint, posHint)
+ noHint.hint = True
+ hint.hint = False
+ self.assertEqual(posNoHint, hint.getGlyphPos(6))
+ self.assertEqual(posHint, noHint.getGlyphPos(6))
+
+ if platform.system() == "Linux":
+ self.skip("Linux support requires modified font config")
+ else:
+ root = self.loadEmptyScene()
+ avg.WordsNode(pos=(1,1), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", hint=False, text="Lorem ipsum dolor (no hinting)",
+ parent=root)
+ avg.WordsNode(pos=(1,15), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", hint=True, text="Lorem ipsum dolor (hinting)",
+ parent=root)
+ self.start([checkPositions])
+
+
+ def testSpanWords(self):
+ def setTextAttrib():
+ self.baselineBmp = Player.screenshot()
+ Player.getElementByID("words").text = self.text
+
+ def checkSameImage():
+ bmp = Player.screenshot()
+ self.assert_(self.areSimilarBmps(bmp, self.baselineBmp, 0, 0))
+
+ def createUsingDict():
+ Player.getElementByID("words").unlink()
+ node = avg.WordsNode(id="words", pos=(1,1), fontsize=12, width=120,
+ font="Bitstream Vera Sans", variant="roman", text=self.text)
+ root.appendChild(node)
+
+ self.text = """
+ Markup:
+ <span size='14000' rise='5000' foreground='red'>span</span>,
+ <i>italics</i>, <b>bold</b>
+ """
+ root = self.loadEmptyScene()
+ node = Player.createNode("""
+ <words id="words" x="1" y="1" fontsize="12" width="120"
+ font="Bitstream Vera Sans" variant="roman">
+ """
+ +self.text+
+ """
+ </words>
+ """)
+ root.appendChild(node)
+ self.start(
+ [lambda: self.compareImage("testSpanWords", True),
+ setTextAttrib,
+ lambda: self.compareImage("testSpanWords", True),
+ checkSameImage,
+ createUsingDict,
+ lambda: self.compareImage("testSpanWords", True),
+ checkSameImage,
+ ])
+
+ def testDynamicWords(self):
+ def changeText():
+ oldwidth = words.width
+ words.text = "blue"
+ self.assertNotEqual(words.width, oldwidth)
+ words.color = "404080"
+ words.x += 10
+
+ def changeHeight():
+ words.height = 28
+
+ def activateText():
+ words.active = True
+
+ def deactivateText():
+ words.active = False
+
+ def changeFont():
+ words.font = "Bitstream Vera Sans"
+ words.height = 0
+ words.fontsize = 30
+
+ def changeFont2():
+ words.fontsize = 18
+
+ def changeTextWithInvalidTag():
+ try:
+ words.text = "This <invalid_tag/>bombs"
+ except:
+ words.text = "except"
+ self.assertEqual(words.text, "except")
+
+ root = self.loadEmptyScene()
+ words = avg.WordsNode(pos=(1,1), fontsize=12, font="Bitstream Vera Sans",
+ text="foo", parent=root)
+ self.start((
+ lambda: self.compareImage("testDynamicWords1", True),
+ changeText,
+ changeHeight,
+ changeFont,
+ lambda: self.compareImage("testDynamicWords2", True),
+ deactivateText,
+ lambda: self.compareImage("testDynamicWords3", True),
+ activateText,
+ changeFont2,
+ lambda: self.compareImage("testDynamicWords4", True),
+ changeTextWithInvalidTag
+ ))
+
+ def testI18NWords(self):
+ def changeUnicodeText():
+ words.text = "Arabic nonsense: ﯿﭗ"
+
+ def setNBSP():
+ words.width=100
+ words.text=(u"blindtext1\u00A0blindtext2\u00Ablindtext3 "+
+ u"blindtext4\u00A0blindtext\u00A0blindtext\u00A0")
+
+ root = self.loadEmptyScene()
+ avg.WordsNode(pos=(1,1), fontsize=14, font="Bitstream Vera Sans",
+ text="一二三四五六七八九", parent=root)
+ words = avg.WordsNode(pos=(1,24), fontsize=12, font="Bitstream Vera Sans",
+ text="foo", parent=root)
+ root.appendChild(
+ Player.createNode("""
+ <words x="1" y="48" fontsize="12" font="Bitstream Vera Sans">
+ &amp;
+ </words>
+ """))
+ avg.WordsNode(pos=(12,48), fontsize=12, font="Bitstream Vera Sans", text="&amp;",
+ rawtextmode=True, parent=root)
+
+ self.start((
+ lambda: self.compareImage("testI18NWords1", True),
+ changeUnicodeText,
+ lambda: self.compareImage("testI18NWords2", True),
+ setNBSP,
+ lambda: self.compareImage("testI18NWords3", True),
+ ))
+
+ def testRawText(self):
+ def createDynNodes():
+ self.dictdnode = avg.WordsNode(text='&lt;test dyndict&amp;',
+ rawtextmode=True, pos=(1,65), font='Bitstream Vera Sans',
+ variant='roman', fontsize=12)
+ root.appendChild(self.dictdnode)
+
+ self.xmldnode = Player.createNode("""
+ <words text="&lt;test dynattr&amp;" fontsize="12"
+ font="Bitstream Vera Sans" variant="roman" rawtextmode="true"
+ x="1" y="85"/>""")
+ root.appendChild(self.xmldnode)
+
+ def switchRawMode():
+ self.dictdnode.rawtextmode = False
+ valNode.rawtextmode = True
+ attribNode.rawtextmode = True
+
+ def bombIt():
+ def cantRun():
+ self.xmldnode.rawtextmode = False
+ self.assert_(0)
+ self.assertException(cantRun)
+
+ def assignNewTexts():
+ text = u'&ùùààxx>'
+ self.dictdnode.rawtextmode = True
+ self.dictdnode.text = text
+ self.xmldnode.text = text
+ valNode.text = text
+ attribNode.text = text
+
+ root = self.loadEmptyScene()
+ attribNode = avg.WordsNode(text="ùnicòdé <b>bold</b>",
+ fontsize=12, pos=(1,5), font="Bitstream Vera Sans", parent=root)
+ valNode = Player.createNode("""
+ <words id="nodeval" fontsize="10" x="1" y="25" font="Bitstream Vera Sans"><b>bold</b> ùnicòdé &lt;</words>""")
+ root.appendChild(valNode)
+ root.appendChild(
+ Player.createNode("""
+ <words x="1" y="45" fontsize="15" font="Bitstream Vera Sans">
+ &amp;
+ </words>"""))
+
+ self.start((
+ lambda: self.compareImage("testRawText1", True),
+ createDynNodes,
+ lambda: self.compareImage("testRawText2", True),
+ switchRawMode,
+ lambda: self.compareImage("testRawText3", True),
+ bombIt,
+ assignNewTexts,
+ lambda: self.compareImage("testRawText4", True),
+ ))
+
+ def testWordsBR(self):
+ root = self.loadEmptyScene()
+ avg.WordsNode(pos=(1,1), fontsize=12, font="Bitstream Vera Sans", variant="roman",
+ text="paragraph 1<br/>paragraph 2", parent=root)
+ self.start([lambda: self.compareImage("testWordsBR", True)])
+
+ def testLetterSpacing(self):
+ def setSpacing():
+ Player.getElementByID("words1").letterspacing=-2
+ Player.getElementByID("words2").letterspacing=-2
+
+ root = self.loadEmptyScene()
+ avg.WordsNode(id="words1", pos=(1,1), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman",
+ text="""normal
+ <span letter_spacing="-2048"> packed</span>
+ <span letter_spacing="2048"> spaced</span>""",
+ parent=root)
+ avg.WordsNode(id="words2", pos=(1,20), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", letterspacing=2, text="spaced", parent=root)
+ self.start((
+ lambda: self.compareImage("testLetterSpacing1", True),
+ setSpacing,
+ lambda: self.compareImage("testLetterSpacing2", True)
+ ))
+
+ def testPositioning(self):
+ def click(pos):
+ self.fakeClick(int(pos[0]), int(pos[1]))
+
+ def testInside(bInside):
+ ok = bInside == self.clicked
+ self.clicked = False
+ return ok
+
+ def onMouse(event):
+ self.clicked = True
+
+ root = self.loadEmptyScene()
+ avg.LineNode(pos1=(4, 20.5), pos2=(157, 20.5), color="FF0000", parent=root)
+ avg.LineNode(pos1=(4.5, 20.5), pos2=(4.5, 110), color="FF0000", parent=root)
+ avg.LineNode(pos1=(156.5, 20.5), pos2=(156.5, 110), color="FF0000", parent=root)
+ avg.LineNode(pos1=(80.5, 20.5), pos2=(80.5, 110), color="FF0000", parent=root)
+ avg.WordsNode(id="left", pos=(4,20), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", text="Norm", parent=root)
+ avg.WordsNode(pos=(45,20), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", text="orm", parent=root)
+ avg.WordsNode(pos=(75,20), fontsize=12, font="Bitstream Vera Sans",
+ variant="roman", text="ÖÄÜ", parent=root)
+ avg.WordsNode(pos=(4,40), fontsize=12, font="Bitstream Vera Sans",
+ variant="oblique", text="Jtalic", parent=root)
+ avg.WordsNode(id="right", pos=(156,60), fontsize=12, alignment="right",
+ font="Bitstream Vera Sans", variant="roman", text="Right-aligned",
+ parent=root)
+ avg.WordsNode(id="center", pos=(80,80), fontsize=12, alignment="center",
+ font="Bitstream Vera Sans", variant="roman", text="Centered",
+ parent=root)
+ for id in ["left", "center", "right"]:
+ Player.getElementByID(id).setEventHandler(avg.CURSORDOWN, avg.MOUSE,
+ onMouse)
+ self.clicked = False
+ helper = Player.getTestHelper()
+ leftWidth = Player.getElementByID("left").getMediaSize()[0]
+ centerWidth = Player.getElementByID("center").getMediaSize()[0]
+ rightWidth = Player.getElementByID("right").getMediaSize()[0]
+
+ self.start((
+ lambda: self.compareImage("testPositioning", True),
+ lambda: click((4,20)),
+ lambda: self.assert_(testInside(True)),
+ lambda: click((3,20)),
+ lambda: self.assert_(testInside(False)),
+ lambda: click((3+leftWidth,20)),
+ lambda: self.assert_(testInside(True)),
+ lambda: click((4+leftWidth,20)),
+ lambda: self.assert_(testInside(False)),
+
+ lambda: click((81-centerWidth/2,80)),
+ lambda: self.assert_(testInside(True)),
+ lambda: click((80-centerWidth/2,80)),
+ lambda: self.assert_(testInside(False)),
+ lambda: click((80+centerWidth/2,80)),
+ lambda: self.assert_(testInside(True)),
+ lambda: click((81+centerWidth/2,80)),
+ lambda: self.assert_(testInside(False)),
+
+ lambda: click((156-rightWidth,60)),
+ lambda: self.assert_(testInside(True)),
+ lambda: click((155-rightWidth,60)),
+ lambda: self.assert_(testInside(False)),
+ lambda: click((155,60)),
+ lambda: self.assert_(testInside(True)),
+ lambda: click((156,60)),
+ lambda: self.assert_(testInside(False)),
+ ))
+
+ def testInvalidColor(self):
+ def testColor(col):
+ avg.WordsNode(color=col)
+
+ def assignValidColor():
+ testColor('123456')
+
+ def assignInvalidColor1():
+ testColor('1234567')
+
+ def assignInvalidColor2():
+ testColor('xxx')
+
+ def assignInvalidColor3():
+ testColor('xxxxxx')
+
+ root = self.loadEmptyScene()
+ self.start((
+ self.assertException(assignInvalidColor1),
+ self.assertException(assignInvalidColor2),
+ self.assertException(assignInvalidColor3),
+ ))
+
+ def testFontDir(self):
+ avg.WordsNode.addFontDir('extrafonts')
+ root = self.loadEmptyScene()
+ avg.WordsNode(font="testaddfontdir", fontsize=50, text="ABAAA", parent=root)
+ self.start((lambda: self.compareImage("testFontDir", True),))
+
+ def testGetNumLines(self):
+ textNode = avg.WordsNode(text="paragraph 1<br/>paragraph 2<br/>paragraph 3")
+ self.assertEqual(textNode.getNumLines(), 3)
+
+ def testGetLineExtents(self):
+ textNode = avg.WordsNode(fontsize = 100,
+ font = "Bitstream Vera Sans",
+ text = "bla <br/> blabli <br/> blabliblabla")
+ self.assertEqual(textNode.getLineExtents(0), (184,117))
+ textNode.parent = Player.getRootNode()
+ self.assertEqual(textNode.getLineExtents(1), (303,117))
+
+ def testGetCharIndexFromPos(self):
+ textNode = avg.WordsNode(fontsize=30,
+ font = "Bitstream Vera Sans",
+ text = "A B C D E F G H Ä Ö Ü ? Ì Á Í Å Ø ∏ ~ ç Ç Å",
+ width = 300)
+
+ for k in (1,2,3,23,42):
+ pos = textNode.getGlyphPos(k)
+ char = textNode.getCharIndexFromPos(pos)
+ self.assertEqual(char, k)
+
+ def testGetTextAsDisplayed(self):
+ orgText = "A<br/>B C <b>D</b> E F G H <i>Ä</i> Ö Ü ? Ì Á<br/>Í Å Ø ∏ ~ ç Ç Å"
+ orgTextWithout = "A\nB C D E F G H Ä Ö Ü ? Ì Á\nÍ Å Ø ∏ ~ ç Ç Å"
+ textNode = avg.WordsNode(fontsize=30,
+ font = "Bitstream Vera Sans",
+ text = orgText,
+ width = 300)
+ self.assertEqual(orgTextWithout, textNode.getTextAsDisplayed())
+
+ def testSetWidth(self):
+ root = self.loadEmptyScene()
+ text = "42 " * 42
+ textNode = avg.WordsNode(
+ parent=root,
+ fontsize = 10,
+ font = "Bitstream Vera Sans",
+ text = text)
+
+ def testSize(p1, p2):
+ self.assert_(abs(p1.x - p2.x) < 5)
+ self.assert_(abs(p1.y - p2.y) < 5)
+
+ testSize(textNode.size, avg.Point2D(630,13))
+ testSize(textNode.getMediaSize(), avg.Point2D(630,13))
+ mediaSize = textNode.getMediaSize()
+
+ def changeSize():
+ textNode.width = 50
+ testSize(textNode.size, avg.Point2D(50,182))
+ testSize(textNode.getMediaSize(), avg.Point2D(45,182))
+ self.assertNotEqual(mediaSize, textNode.getMediaSize())
+
+ self.start([lambda: changeSize()])
+
+ def testTooWide(self):
+ root = self.loadEmptyScene()
+ text = "42 " * 42 * 20
+ node = avg.WordsNode(parent=root, text=text)
+ self.assertException(
+ lambda: self.start((None, None))
+ )
+
+def wordsTestSuite(tests):
+ availableTests = (
+ "testSimpleWords",
+ "testRedrawOnDemand",
+ "testGlyphPos",
+ "testParaWords",
+ "testJustify",
+ "testWrapMode",
+ "testWordsMask",
+ "testHinting",
+ "testSpanWords",
+ "testDynamicWords",
+ "testI18NWords",
+ "testRawText",
+ "testWordsBR",
+ "testLetterSpacing",
+ "testPositioning",
+ "testInvalidColor",
+ "testFontDir",
+ "testGetNumLines",
+ "testGetLineExtents",
+ "testGetCharIndexFromPos",
+ "testGetTextAsDisplayed",
+ "testSetWidth",
+ "testTooWide",
+ )
+ return createAVGTestSuite(availableTests, WordsTestCase, tests)
+
+Player = avg.Player.get()
diff --git a/src/test/baseline/test2VideosAtOnce1.png b/src/test/baseline/test2VideosAtOnce1.png
new file mode 100644
index 0000000..f561888
--- /dev/null
+++ b/src/test/baseline/test2VideosAtOnce1.png
Binary files differ
diff --git a/src/test/baseline/testAVGFile.png b/src/test/baseline/testAVGFile.png
new file mode 100644
index 0000000..375582b
--- /dev/null
+++ b/src/test/baseline/testAVGFile.png
Binary files differ
diff --git a/src/test/baseline/testAnim1.png b/src/test/baseline/testAnim1.png
new file mode 100644
index 0000000..6651fc3
--- /dev/null
+++ b/src/test/baseline/testAnim1.png
Binary files differ
diff --git a/src/test/baseline/testAnim2.png b/src/test/baseline/testAnim2.png
new file mode 100644
index 0000000..d8553de
--- /dev/null
+++ b/src/test/baseline/testAnim2.png
Binary files differ
diff --git a/src/test/baseline/testAnim3.png b/src/test/baseline/testAnim3.png
new file mode 100644
index 0000000..4d6dbd7
--- /dev/null
+++ b/src/test/baseline/testAnim3.png
Binary files differ
diff --git a/src/test/baseline/testArc1.png b/src/test/baseline/testArc1.png
new file mode 100644
index 0000000..9c4a2f0
--- /dev/null
+++ b/src/test/baseline/testArc1.png
Binary files differ
diff --git a/src/test/baseline/testArc2.png b/src/test/baseline/testArc2.png
new file mode 100644
index 0000000..1e321a3
--- /dev/null
+++ b/src/test/baseline/testArc2.png
Binary files differ
diff --git a/src/test/baseline/testBitmap1.png b/src/test/baseline/testBitmap1.png
new file mode 100644
index 0000000..c5b06a0
--- /dev/null
+++ b/src/test/baseline/testBitmap1.png
Binary files differ
diff --git a/src/test/baseline/testBlend1.png b/src/test/baseline/testBlend1.png
new file mode 100644
index 0000000..29e4a11
--- /dev/null
+++ b/src/test/baseline/testBlend1.png
Binary files differ
diff --git a/src/test/baseline/testBlend2.png b/src/test/baseline/testBlend2.png
new file mode 100644
index 0000000..8b2ae59
--- /dev/null
+++ b/src/test/baseline/testBlend2.png
Binary files differ
diff --git a/src/test/baseline/testBlurFX1.png b/src/test/baseline/testBlurFX1.png
new file mode 100644
index 0000000..9564d6f
--- /dev/null
+++ b/src/test/baseline/testBlurFX1.png
Binary files differ
diff --git a/src/test/baseline/testBlurFX2.png b/src/test/baseline/testBlurFX2.png
new file mode 100644
index 0000000..0147846
--- /dev/null
+++ b/src/test/baseline/testBlurFX2.png
Binary files differ
diff --git a/src/test/baseline/testBlurFX3.png b/src/test/baseline/testBlurFX3.png
new file mode 100644
index 0000000..b50decf
--- /dev/null
+++ b/src/test/baseline/testBlurFX3.png
Binary files differ
diff --git a/src/test/baseline/testButtonDisabled.png b/src/test/baseline/testButtonDisabled.png
new file mode 100644
index 0000000..6b7eea4
--- /dev/null
+++ b/src/test/baseline/testButtonDisabled.png
Binary files differ
diff --git a/src/test/baseline/testButtonDown.png b/src/test/baseline/testButtonDown.png
new file mode 100644
index 0000000..96e6e40
--- /dev/null
+++ b/src/test/baseline/testButtonDown.png
Binary files differ
diff --git a/src/test/baseline/testButtonOver.png b/src/test/baseline/testButtonOver.png
new file mode 100644
index 0000000..f3d5a0e
--- /dev/null
+++ b/src/test/baseline/testButtonOver.png
Binary files differ
diff --git a/src/test/baseline/testButtonUp.png b/src/test/baseline/testButtonUp.png
new file mode 100644
index 0000000..a9adeb5
--- /dev/null
+++ b/src/test/baseline/testButtonUp.png
Binary files differ
diff --git a/src/test/baseline/testCanvasAlpha.png b/src/test/baseline/testCanvasAlpha.png
new file mode 100644
index 0000000..63fb052
--- /dev/null
+++ b/src/test/baseline/testCanvasAlpha.png
Binary files differ
diff --git a/src/test/baseline/testCanvasBlendModes.png b/src/test/baseline/testCanvasBlendModes.png
new file mode 100644
index 0000000..f0feba3
--- /dev/null
+++ b/src/test/baseline/testCanvasBlendModes.png
Binary files differ
diff --git a/src/test/baseline/testCanvasCrop.png b/src/test/baseline/testCanvasCrop.png
new file mode 100644
index 0000000..ffcdcfa
--- /dev/null
+++ b/src/test/baseline/testCanvasCrop.png
Binary files differ
diff --git a/src/test/baseline/testCanvasDependencies1.png b/src/test/baseline/testCanvasDependencies1.png
new file mode 100644
index 0000000..5821855
--- /dev/null
+++ b/src/test/baseline/testCanvasDependencies1.png
Binary files differ
diff --git a/src/test/baseline/testCanvasDependencies2.png b/src/test/baseline/testCanvasDependencies2.png
new file mode 100644
index 0000000..d38ac6a
--- /dev/null
+++ b/src/test/baseline/testCanvasDependencies2.png
Binary files differ
diff --git a/src/test/baseline/testCanvasMipmap.png b/src/test/baseline/testCanvasMipmap.png
new file mode 100644
index 0000000..ecc51f0
--- /dev/null
+++ b/src/test/baseline/testCanvasMipmap.png
Binary files differ
diff --git a/src/test/baseline/testCanvasMultisample.png b/src/test/baseline/testCanvasMultisample.png
new file mode 100644
index 0000000..1f30aad
--- /dev/null
+++ b/src/test/baseline/testCanvasMultisample.png
Binary files differ
diff --git a/src/test/baseline/testCanvasNullFX1.png b/src/test/baseline/testCanvasNullFX1.png
new file mode 100644
index 0000000..c877bdf
--- /dev/null
+++ b/src/test/baseline/testCanvasNullFX1.png
Binary files differ
diff --git a/src/test/baseline/testCanvasNullFX2.png b/src/test/baseline/testCanvasNullFX2.png
new file mode 100644
index 0000000..8e485f7
--- /dev/null
+++ b/src/test/baseline/testCanvasNullFX2.png
Binary files differ
diff --git a/src/test/baseline/testCanvasResize.png b/src/test/baseline/testCanvasResize.png
new file mode 100644
index 0000000..5821855
--- /dev/null
+++ b/src/test/baseline/testCanvasResize.png
Binary files differ
diff --git a/src/test/baseline/testCheckboxClickedDown.png b/src/test/baseline/testCheckboxClickedDown.png
new file mode 100644
index 0000000..2065be3
--- /dev/null
+++ b/src/test/baseline/testCheckboxClickedDown.png
Binary files differ
diff --git a/src/test/baseline/testCheckboxClickedOut.png b/src/test/baseline/testCheckboxClickedOut.png
new file mode 100644
index 0000000..a17d5b2
--- /dev/null
+++ b/src/test/baseline/testCheckboxClickedOut.png
Binary files differ
diff --git a/src/test/baseline/testCheckboxClickedOver.png b/src/test/baseline/testCheckboxClickedOver.png
new file mode 100644
index 0000000..b94c9d9
--- /dev/null
+++ b/src/test/baseline/testCheckboxClickedOver.png
Binary files differ
diff --git a/src/test/baseline/testCheckboxDown.png b/src/test/baseline/testCheckboxDown.png
new file mode 100644
index 0000000..96e6e40
--- /dev/null
+++ b/src/test/baseline/testCheckboxDown.png
Binary files differ
diff --git a/src/test/baseline/testCheckboxOver.png b/src/test/baseline/testCheckboxOver.png
new file mode 100644
index 0000000..f3d5a0e
--- /dev/null
+++ b/src/test/baseline/testCheckboxOver.png
Binary files differ
diff --git a/src/test/baseline/testCheckboxUp.png b/src/test/baseline/testCheckboxUp.png
new file mode 100644
index 0000000..a9adeb5
--- /dev/null
+++ b/src/test/baseline/testCheckboxUp.png
Binary files differ
diff --git a/src/test/baseline/testCircle1.png b/src/test/baseline/testCircle1.png
new file mode 100644
index 0000000..45f2c58
--- /dev/null
+++ b/src/test/baseline/testCircle1.png
Binary files differ
diff --git a/src/test/baseline/testCircle2.png b/src/test/baseline/testCircle2.png
new file mode 100644
index 0000000..26ca01c
--- /dev/null
+++ b/src/test/baseline/testCircle2.png
Binary files differ
diff --git a/src/test/baseline/testCircle3.png b/src/test/baseline/testCircle3.png
new file mode 100644
index 0000000..4824bcf
--- /dev/null
+++ b/src/test/baseline/testCircle3.png
Binary files differ
diff --git a/src/test/baseline/testCircle4.png b/src/test/baseline/testCircle4.png
new file mode 100644
index 0000000..be36e58
--- /dev/null
+++ b/src/test/baseline/testCircle4.png
Binary files differ
diff --git a/src/test/baseline/testCircle5.png b/src/test/baseline/testCircle5.png
new file mode 100644
index 0000000..f70b3eb
--- /dev/null
+++ b/src/test/baseline/testCircle5.png
Binary files differ
diff --git a/src/test/baseline/testColorFX1.png b/src/test/baseline/testColorFX1.png
new file mode 100644
index 0000000..1a225e9
--- /dev/null
+++ b/src/test/baseline/testColorFX1.png
Binary files differ
diff --git a/src/test/baseline/testColorFX2.png b/src/test/baseline/testColorFX2.png
new file mode 100644
index 0000000..dc708c6
--- /dev/null
+++ b/src/test/baseline/testColorFX2.png
Binary files differ
diff --git a/src/test/baseline/testColorFX3.png b/src/test/baseline/testColorFX3.png
new file mode 100644
index 0000000..b82c72d
--- /dev/null
+++ b/src/test/baseline/testColorFX3.png
Binary files differ
diff --git a/src/test/baseline/testColorFX4.png b/src/test/baseline/testColorFX4.png
new file mode 100644
index 0000000..5722a24
--- /dev/null
+++ b/src/test/baseline/testColorFX4.png
Binary files differ
diff --git a/src/test/baseline/testColorFX5.png b/src/test/baseline/testColorFX5.png
new file mode 100644
index 0000000..dbcec1c
--- /dev/null
+++ b/src/test/baseline/testColorFX5.png
Binary files differ
diff --git a/src/test/baseline/testColorFX6.png b/src/test/baseline/testColorFX6.png
new file mode 100644
index 0000000..ab46da3
--- /dev/null
+++ b/src/test/baseline/testColorFX6.png
Binary files differ
diff --git a/src/test/baseline/testColorFX7.png b/src/test/baseline/testColorFX7.png
new file mode 100644
index 0000000..5fb43b8
--- /dev/null
+++ b/src/test/baseline/testColorFX7.png
Binary files differ
diff --git a/src/test/baseline/testComplexDiv1.png b/src/test/baseline/testComplexDiv1.png
new file mode 100644
index 0000000..bde774d
--- /dev/null
+++ b/src/test/baseline/testComplexDiv1.png
Binary files differ
diff --git a/src/test/baseline/testContAnim1.png b/src/test/baseline/testContAnim1.png
new file mode 100644
index 0000000..f337d2f
--- /dev/null
+++ b/src/test/baseline/testContAnim1.png
Binary files differ
diff --git a/src/test/baseline/testContAnim2.png b/src/test/baseline/testContAnim2.png
new file mode 100644
index 0000000..1e2b4fd
--- /dev/null
+++ b/src/test/baseline/testContAnim2.png
Binary files differ
diff --git a/src/test/baseline/testContAnim3.png b/src/test/baseline/testContAnim3.png
new file mode 100644
index 0000000..cdf6b45
--- /dev/null
+++ b/src/test/baseline/testContAnim3.png
Binary files differ
diff --git a/src/test/baseline/testContAnim4.png b/src/test/baseline/testContAnim4.png
new file mode 100644
index 0000000..3a16eeb
--- /dev/null
+++ b/src/test/baseline/testContAnim4.png
Binary files differ
diff --git a/src/test/baseline/testContinuousAnim1.png b/src/test/baseline/testContinuousAnim1.png
new file mode 100644
index 0000000..4f8a5be
--- /dev/null
+++ b/src/test/baseline/testContinuousAnim1.png
Binary files differ
diff --git a/src/test/baseline/testContinuousAnim2.png b/src/test/baseline/testContinuousAnim2.png
new file mode 100644
index 0000000..34a9e24
--- /dev/null
+++ b/src/test/baseline/testContinuousAnim2.png
Binary files differ
diff --git a/src/test/baseline/testContrast1.png b/src/test/baseline/testContrast1.png
new file mode 100644
index 0000000..06bf3d0
--- /dev/null
+++ b/src/test/baseline/testContrast1.png
Binary files differ
diff --git a/src/test/baseline/testContrast2.png b/src/test/baseline/testContrast2.png
new file mode 100644
index 0000000..fc1e0e6
--- /dev/null
+++ b/src/test/baseline/testContrast2.png
Binary files differ
diff --git a/src/test/baseline/testContrast3.png b/src/test/baseline/testContrast3.png
new file mode 100644
index 0000000..e979473
--- /dev/null
+++ b/src/test/baseline/testContrast3.png
Binary files differ
diff --git a/src/test/baseline/testCropImage1.png b/src/test/baseline/testCropImage1.png
new file mode 100644
index 0000000..40bdcfe
--- /dev/null
+++ b/src/test/baseline/testCropImage1.png
Binary files differ
diff --git a/src/test/baseline/testCropImage10.png b/src/test/baseline/testCropImage10.png
new file mode 100644
index 0000000..f05723a
--- /dev/null
+++ b/src/test/baseline/testCropImage10.png
Binary files differ
diff --git a/src/test/baseline/testCropImage2.png b/src/test/baseline/testCropImage2.png
new file mode 100644
index 0000000..e0706ea
--- /dev/null
+++ b/src/test/baseline/testCropImage2.png
Binary files differ
diff --git a/src/test/baseline/testCropImage3.png b/src/test/baseline/testCropImage3.png
new file mode 100644
index 0000000..33078f2
--- /dev/null
+++ b/src/test/baseline/testCropImage3.png
Binary files differ
diff --git a/src/test/baseline/testCropImage4.png b/src/test/baseline/testCropImage4.png
new file mode 100644
index 0000000..e230b9a
--- /dev/null
+++ b/src/test/baseline/testCropImage4.png
Binary files differ
diff --git a/src/test/baseline/testCropImage5.png b/src/test/baseline/testCropImage5.png
new file mode 100644
index 0000000..0636df4
--- /dev/null
+++ b/src/test/baseline/testCropImage5.png
Binary files differ
diff --git a/src/test/baseline/testCropImage6.png b/src/test/baseline/testCropImage6.png
new file mode 100644
index 0000000..566f599
--- /dev/null
+++ b/src/test/baseline/testCropImage6.png
Binary files differ
diff --git a/src/test/baseline/testCropImage7.png b/src/test/baseline/testCropImage7.png
new file mode 100644
index 0000000..632a158
--- /dev/null
+++ b/src/test/baseline/testCropImage7.png
Binary files differ
diff --git a/src/test/baseline/testCropImage8.png b/src/test/baseline/testCropImage8.png
new file mode 100644
index 0000000..017faca
--- /dev/null
+++ b/src/test/baseline/testCropImage8.png
Binary files differ
diff --git a/src/test/baseline/testCropImage9.png b/src/test/baseline/testCropImage9.png
new file mode 100644
index 0000000..2f013fc
--- /dev/null
+++ b/src/test/baseline/testCropImage9.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie1.png b/src/test/baseline/testCropMovie1.png
new file mode 100644
index 0000000..aaff2c3
--- /dev/null
+++ b/src/test/baseline/testCropMovie1.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie10.png b/src/test/baseline/testCropMovie10.png
new file mode 100644
index 0000000..1ef3ca3
--- /dev/null
+++ b/src/test/baseline/testCropMovie10.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie2.png b/src/test/baseline/testCropMovie2.png
new file mode 100644
index 0000000..1345610
--- /dev/null
+++ b/src/test/baseline/testCropMovie2.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie3.png b/src/test/baseline/testCropMovie3.png
new file mode 100644
index 0000000..a2aef90
--- /dev/null
+++ b/src/test/baseline/testCropMovie3.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie4.png b/src/test/baseline/testCropMovie4.png
new file mode 100644
index 0000000..72a5ae2
--- /dev/null
+++ b/src/test/baseline/testCropMovie4.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie5.png b/src/test/baseline/testCropMovie5.png
new file mode 100644
index 0000000..8e663fc
--- /dev/null
+++ b/src/test/baseline/testCropMovie5.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie6.png b/src/test/baseline/testCropMovie6.png
new file mode 100644
index 0000000..ff47430
--- /dev/null
+++ b/src/test/baseline/testCropMovie6.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie7.png b/src/test/baseline/testCropMovie7.png
new file mode 100644
index 0000000..60941e4
--- /dev/null
+++ b/src/test/baseline/testCropMovie7.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie8.png b/src/test/baseline/testCropMovie8.png
new file mode 100644
index 0000000..e12b702
--- /dev/null
+++ b/src/test/baseline/testCropMovie8.png
Binary files differ
diff --git a/src/test/baseline/testCropMovie9.png b/src/test/baseline/testCropMovie9.png
new file mode 100644
index 0000000..f0ede3e
--- /dev/null
+++ b/src/test/baseline/testCropMovie9.png
Binary files differ
diff --git a/src/test/baseline/testCurve1.png b/src/test/baseline/testCurve1.png
new file mode 100644
index 0000000..70127bc
--- /dev/null
+++ b/src/test/baseline/testCurve1.png
Binary files differ
diff --git a/src/test/baseline/testCurve2.png b/src/test/baseline/testCurve2.png
new file mode 100644
index 0000000..6046c98
--- /dev/null
+++ b/src/test/baseline/testCurve2.png
Binary files differ
diff --git a/src/test/baseline/testCurve3.png b/src/test/baseline/testCurve3.png
new file mode 100644
index 0000000..9545904
--- /dev/null
+++ b/src/test/baseline/testCurve3.png
Binary files differ
diff --git a/src/test/baseline/testCurve4.png b/src/test/baseline/testCurve4.png
new file mode 100644
index 0000000..1472c2f
--- /dev/null
+++ b/src/test/baseline/testCurve4.png
Binary files differ
diff --git a/src/test/baseline/testDivDynamics1.png b/src/test/baseline/testDivDynamics1.png
new file mode 100644
index 0000000..d05741d
--- /dev/null
+++ b/src/test/baseline/testDivDynamics1.png
Binary files differ
diff --git a/src/test/baseline/testDivDynamics2.png b/src/test/baseline/testDivDynamics2.png
new file mode 100644
index 0000000..b3f308f
--- /dev/null
+++ b/src/test/baseline/testDivDynamics2.png
Binary files differ
diff --git a/src/test/baseline/testDivDynamics3.png b/src/test/baseline/testDivDynamics3.png
new file mode 100644
index 0000000..72a9acf
--- /dev/null
+++ b/src/test/baseline/testDivDynamics3.png
Binary files differ
diff --git a/src/test/baseline/testDivDynamics4.png b/src/test/baseline/testDivDynamics4.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testDivDynamics4.png
Binary files differ
diff --git a/src/test/baseline/testDivDynamics5.png b/src/test/baseline/testDivDynamics5.png
new file mode 100644
index 0000000..d05741d
--- /dev/null
+++ b/src/test/baseline/testDivDynamics5.png
Binary files differ
diff --git a/src/test/baseline/testDraggable1.png b/src/test/baseline/testDraggable1.png
new file mode 100644
index 0000000..d60276f
--- /dev/null
+++ b/src/test/baseline/testDraggable1.png
Binary files differ
diff --git a/src/test/baseline/testDraggable2.png b/src/test/baseline/testDraggable2.png
new file mode 100644
index 0000000..19ad729
--- /dev/null
+++ b/src/test/baseline/testDraggable2.png
Binary files differ
diff --git a/src/test/baseline/testDynamicMediaDir1.png b/src/test/baseline/testDynamicMediaDir1.png
new file mode 100644
index 0000000..71c0100
--- /dev/null
+++ b/src/test/baseline/testDynamicMediaDir1.png
Binary files differ
diff --git a/src/test/baseline/testDynamicMediaDir2.png b/src/test/baseline/testDynamicMediaDir2.png
new file mode 100644
index 0000000..392e2a8
--- /dev/null
+++ b/src/test/baseline/testDynamicMediaDir2.png
Binary files differ
diff --git a/src/test/baseline/testDynamicWords1.png b/src/test/baseline/testDynamicWords1.png
new file mode 100644
index 0000000..9b37b72
--- /dev/null
+++ b/src/test/baseline/testDynamicWords1.png
Binary files differ
diff --git a/src/test/baseline/testDynamicWords2.png b/src/test/baseline/testDynamicWords2.png
new file mode 100644
index 0000000..390d0f3
--- /dev/null
+++ b/src/test/baseline/testDynamicWords2.png
Binary files differ
diff --git a/src/test/baseline/testDynamicWords3.png b/src/test/baseline/testDynamicWords3.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testDynamicWords3.png
Binary files differ
diff --git a/src/test/baseline/testDynamicWords4.png b/src/test/baseline/testDynamicWords4.png
new file mode 100644
index 0000000..789c2c8
--- /dev/null
+++ b/src/test/baseline/testDynamicWords4.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnim1.png b/src/test/baseline/testEaseInOutAnim1.png
new file mode 100644
index 0000000..82abf89
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnim1.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnim2.png b/src/test/baseline/testEaseInOutAnim2.png
new file mode 100644
index 0000000..e299221
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnim2.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnim3.png b/src/test/baseline/testEaseInOutAnim3.png
new file mode 100644
index 0000000..03311b5
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnim3.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnimC1.png b/src/test/baseline/testEaseInOutAnimC1.png
new file mode 100644
index 0000000..fbe5b29
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnimC1.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnimC2.png b/src/test/baseline/testEaseInOutAnimC2.png
new file mode 100644
index 0000000..1e889df
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnimC2.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnimC3.png b/src/test/baseline/testEaseInOutAnimC3.png
new file mode 100644
index 0000000..40d820a
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnimC3.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnimC4.png b/src/test/baseline/testEaseInOutAnimC4.png
new file mode 100644
index 0000000..9703e09
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnimC4.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnimC5.png b/src/test/baseline/testEaseInOutAnimC5.png
new file mode 100644
index 0000000..40d820a
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnimC5.png
Binary files differ
diff --git a/src/test/baseline/testEaseInOutAnimC6.png b/src/test/baseline/testEaseInOutAnimC6.png
new file mode 100644
index 0000000..60da2b1
--- /dev/null
+++ b/src/test/baseline/testEaseInOutAnimC6.png
Binary files differ
diff --git a/src/test/baseline/testEvents.png b/src/test/baseline/testEvents.png
new file mode 100644
index 0000000..bdd9280
--- /dev/null
+++ b/src/test/baseline/testEvents.png
Binary files differ
diff --git a/src/test/baseline/testFXUpdateFX.png b/src/test/baseline/testFXUpdateFX.png
new file mode 100644
index 0000000..a2d1a44
--- /dev/null
+++ b/src/test/baseline/testFXUpdateFX.png
Binary files differ
diff --git a/src/test/baseline/testFXUpdateMaskPos.png b/src/test/baseline/testFXUpdateMaskPos.png
new file mode 100644
index 0000000..150ebd2
--- /dev/null
+++ b/src/test/baseline/testFXUpdateMaskPos.png
Binary files differ
diff --git a/src/test/baseline/testFXUpdateMaskTex1.png b/src/test/baseline/testFXUpdateMaskTex1.png
new file mode 100644
index 0000000..18588ff
--- /dev/null
+++ b/src/test/baseline/testFXUpdateMaskTex1.png
Binary files differ
diff --git a/src/test/baseline/testFXUpdateMaskTex2.png b/src/test/baseline/testFXUpdateMaskTex2.png
new file mode 100644
index 0000000..4790154
--- /dev/null
+++ b/src/test/baseline/testFXUpdateMaskTex2.png
Binary files differ
diff --git a/src/test/baseline/testFXUpdateTex.png b/src/test/baseline/testFXUpdateTex.png
new file mode 100644
index 0000000..3111780
--- /dev/null
+++ b/src/test/baseline/testFXUpdateTex.png
Binary files differ
diff --git a/src/test/baseline/testFXUpdateVideo.png b/src/test/baseline/testFXUpdateVideo.png
new file mode 100644
index 0000000..fed9567
--- /dev/null
+++ b/src/test/baseline/testFXUpdateVideo.png
Binary files differ
diff --git a/src/test/baseline/testFadeIn1.png b/src/test/baseline/testFadeIn1.png
new file mode 100644
index 0000000..e4a332a
--- /dev/null
+++ b/src/test/baseline/testFadeIn1.png
Binary files differ
diff --git a/src/test/baseline/testFadeIn2.png b/src/test/baseline/testFadeIn2.png
new file mode 100644
index 0000000..b1c6746
--- /dev/null
+++ b/src/test/baseline/testFadeIn2.png
Binary files differ
diff --git a/src/test/baseline/testFadeIn3.png b/src/test/baseline/testFadeIn3.png
new file mode 100644
index 0000000..02f0389
--- /dev/null
+++ b/src/test/baseline/testFadeIn3.png
Binary files differ
diff --git a/src/test/baseline/testFadeOut1.png b/src/test/baseline/testFadeOut1.png
new file mode 100644
index 0000000..e4a332a
--- /dev/null
+++ b/src/test/baseline/testFadeOut1.png
Binary files differ
diff --git a/src/test/baseline/testFadeOut2.png b/src/test/baseline/testFadeOut2.png
new file mode 100644
index 0000000..f7bcf5b
--- /dev/null
+++ b/src/test/baseline/testFadeOut2.png
Binary files differ
diff --git a/src/test/baseline/testFadeOut3.png b/src/test/baseline/testFadeOut3.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testFadeOut3.png
Binary files differ
diff --git a/src/test/baseline/testFocusContext1.png b/src/test/baseline/testFocusContext1.png
new file mode 100644
index 0000000..380902e
--- /dev/null
+++ b/src/test/baseline/testFocusContext1.png
Binary files differ
diff --git a/src/test/baseline/testFocusContext2.png b/src/test/baseline/testFocusContext2.png
new file mode 100644
index 0000000..5ecbcf4
--- /dev/null
+++ b/src/test/baseline/testFocusContext2.png
Binary files differ
diff --git a/src/test/baseline/testFocusContext3.png b/src/test/baseline/testFocusContext3.png
new file mode 100644
index 0000000..0606d81
--- /dev/null
+++ b/src/test/baseline/testFocusContext3.png
Binary files differ
diff --git a/src/test/baseline/testFocusContext4.png b/src/test/baseline/testFocusContext4.png
new file mode 100644
index 0000000..9629e81
--- /dev/null
+++ b/src/test/baseline/testFocusContext4.png
Binary files differ
diff --git a/src/test/baseline/testFocusContext5.png b/src/test/baseline/testFocusContext5.png
new file mode 100644
index 0000000..2ae68e0
--- /dev/null
+++ b/src/test/baseline/testFocusContext5.png
Binary files differ
diff --git a/src/test/baseline/testFontDir.png b/src/test/baseline/testFontDir.png
new file mode 100644
index 0000000..5dc4858
--- /dev/null
+++ b/src/test/baseline/testFontDir.png
Binary files differ
diff --git a/src/test/baseline/testGamma1.png b/src/test/baseline/testGamma1.png
new file mode 100644
index 0000000..a713a13
--- /dev/null
+++ b/src/test/baseline/testGamma1.png
Binary files differ
diff --git a/src/test/baseline/testGamma2.png b/src/test/baseline/testGamma2.png
new file mode 100644
index 0000000..18d0479
--- /dev/null
+++ b/src/test/baseline/testGamma2.png
Binary files differ
diff --git a/src/test/baseline/testHinting1.png b/src/test/baseline/testHinting1.png
new file mode 100644
index 0000000..4657e71
--- /dev/null
+++ b/src/test/baseline/testHinting1.png
Binary files differ
diff --git a/src/test/baseline/testHueSatFX1.png b/src/test/baseline/testHueSatFX1.png
new file mode 100644
index 0000000..abe4582
--- /dev/null
+++ b/src/test/baseline/testHueSatFX1.png
Binary files differ
diff --git a/src/test/baseline/testHueSatFX2.png b/src/test/baseline/testHueSatFX2.png
new file mode 100644
index 0000000..736bfbd
--- /dev/null
+++ b/src/test/baseline/testHueSatFX2.png
Binary files differ
diff --git a/src/test/baseline/testHueSatFX3.png b/src/test/baseline/testHueSatFX3.png
new file mode 100644
index 0000000..96e7744
--- /dev/null
+++ b/src/test/baseline/testHueSatFX3.png
Binary files differ
diff --git a/src/test/baseline/testHueSatFX4.png b/src/test/baseline/testHueSatFX4.png
new file mode 100644
index 0000000..7aff060
--- /dev/null
+++ b/src/test/baseline/testHueSatFX4.png
Binary files differ
diff --git a/src/test/baseline/testHugeImage0.png b/src/test/baseline/testHugeImage0.png
new file mode 100644
index 0000000..eb59ae0
--- /dev/null
+++ b/src/test/baseline/testHugeImage0.png
Binary files differ
diff --git a/src/test/baseline/testHugeImage1.png b/src/test/baseline/testHugeImage1.png
new file mode 100644
index 0000000..241b52f
--- /dev/null
+++ b/src/test/baseline/testHugeImage1.png
Binary files differ
diff --git a/src/test/baseline/testI18NWords1.png b/src/test/baseline/testI18NWords1.png
new file mode 100644
index 0000000..b9b8808
--- /dev/null
+++ b/src/test/baseline/testI18NWords1.png
Binary files differ
diff --git a/src/test/baseline/testI18NWords2.png b/src/test/baseline/testI18NWords2.png
new file mode 100644
index 0000000..e3f649b
--- /dev/null
+++ b/src/test/baseline/testI18NWords2.png
Binary files differ
diff --git a/src/test/baseline/testI18NWords3.png b/src/test/baseline/testI18NWords3.png
new file mode 100644
index 0000000..ace8433
--- /dev/null
+++ b/src/test/baseline/testI18NWords3.png
Binary files differ
diff --git a/src/test/baseline/testImageNullFX1.png b/src/test/baseline/testImageNullFX1.png
new file mode 100644
index 0000000..cdbf3fb
--- /dev/null
+++ b/src/test/baseline/testImageNullFX1.png
Binary files differ
diff --git a/src/test/baseline/testImageNullFX2.png b/src/test/baseline/testImageNullFX2.png
new file mode 100644
index 0000000..a5dd14b
--- /dev/null
+++ b/src/test/baseline/testImageNullFX2.png
Binary files differ
diff --git a/src/test/baseline/testImageNullFX3.png b/src/test/baseline/testImageNullFX3.png
new file mode 100644
index 0000000..f9b00d9
--- /dev/null
+++ b/src/test/baseline/testImageNullFX3.png
Binary files differ
diff --git a/src/test/baseline/testImgDynamics1.png b/src/test/baseline/testImgDynamics1.png
new file mode 100644
index 0000000..d05741d
--- /dev/null
+++ b/src/test/baseline/testImgDynamics1.png
Binary files differ
diff --git a/src/test/baseline/testImgDynamics2.png b/src/test/baseline/testImgDynamics2.png
new file mode 100644
index 0000000..b3f308f
--- /dev/null
+++ b/src/test/baseline/testImgDynamics2.png
Binary files differ
diff --git a/src/test/baseline/testImgDynamics3.png b/src/test/baseline/testImgDynamics3.png
new file mode 100644
index 0000000..72a9acf
--- /dev/null
+++ b/src/test/baseline/testImgDynamics3.png
Binary files differ
diff --git a/src/test/baseline/testImgDynamics4.png b/src/test/baseline/testImgDynamics4.png
new file mode 100644
index 0000000..21c01f2
--- /dev/null
+++ b/src/test/baseline/testImgDynamics4.png
Binary files differ
diff --git a/src/test/baseline/testImgDynamics5.png b/src/test/baseline/testImgDynamics5.png
new file mode 100644
index 0000000..d05741d
--- /dev/null
+++ b/src/test/baseline/testImgDynamics5.png
Binary files differ
diff --git a/src/test/baseline/testImgHRef1.png b/src/test/baseline/testImgHRef1.png
new file mode 100644
index 0000000..a1df968
--- /dev/null
+++ b/src/test/baseline/testImgHRef1.png
Binary files differ
diff --git a/src/test/baseline/testImgHRef2.png b/src/test/baseline/testImgHRef2.png
new file mode 100644
index 0000000..03c8e41
--- /dev/null
+++ b/src/test/baseline/testImgHRef2.png
Binary files differ
diff --git a/src/test/baseline/testImgHRef3.png b/src/test/baseline/testImgHRef3.png
new file mode 100644
index 0000000..b18ec93
--- /dev/null
+++ b/src/test/baseline/testImgHRef3.png
Binary files differ
diff --git a/src/test/baseline/testImgMask1.png b/src/test/baseline/testImgMask1.png
new file mode 100644
index 0000000..2fe736a
--- /dev/null
+++ b/src/test/baseline/testImgMask1.png
Binary files differ
diff --git a/src/test/baseline/testImgMask2.png b/src/test/baseline/testImgMask2.png
new file mode 100644
index 0000000..9d1f486
--- /dev/null
+++ b/src/test/baseline/testImgMask2.png
Binary files differ
diff --git a/src/test/baseline/testImgMask3.png b/src/test/baseline/testImgMask3.png
new file mode 100644
index 0000000..70f58ff
--- /dev/null
+++ b/src/test/baseline/testImgMask3.png
Binary files differ
diff --git a/src/test/baseline/testImgMaskCanvas.png b/src/test/baseline/testImgMaskCanvas.png
new file mode 100644
index 0000000..1faa5d5
--- /dev/null
+++ b/src/test/baseline/testImgMaskCanvas.png
Binary files differ
diff --git a/src/test/baseline/testImgMaskPos.png b/src/test/baseline/testImgMaskPos.png
new file mode 100644
index 0000000..16176eb
--- /dev/null
+++ b/src/test/baseline/testImgMaskPos.png
Binary files differ
diff --git a/src/test/baseline/testImgMaskSize1.png b/src/test/baseline/testImgMaskSize1.png
new file mode 100644
index 0000000..41ac537
--- /dev/null
+++ b/src/test/baseline/testImgMaskSize1.png
Binary files differ
diff --git a/src/test/baseline/testImgMaskSize2.png b/src/test/baseline/testImgMaskSize2.png
new file mode 100644
index 0000000..de6549d
--- /dev/null
+++ b/src/test/baseline/testImgMaskSize2.png
Binary files differ
diff --git a/src/test/baseline/testImgMaskSize3.png b/src/test/baseline/testImgMaskSize3.png
new file mode 100644
index 0000000..d452f98
--- /dev/null
+++ b/src/test/baseline/testImgMaskSize3.png
Binary files differ
diff --git a/src/test/baseline/testImgPos1.png b/src/test/baseline/testImgPos1.png
new file mode 100644
index 0000000..5bb376d
--- /dev/null
+++ b/src/test/baseline/testImgPos1.png
Binary files differ
diff --git a/src/test/baseline/testImgPos2.png b/src/test/baseline/testImgPos2.png
new file mode 100644
index 0000000..017609d
--- /dev/null
+++ b/src/test/baseline/testImgPos2.png
Binary files differ
diff --git a/src/test/baseline/testImgSize1.png b/src/test/baseline/testImgSize1.png
new file mode 100644
index 0000000..5a5a7d6
--- /dev/null
+++ b/src/test/baseline/testImgSize1.png
Binary files differ
diff --git a/src/test/baseline/testImgSize2.png b/src/test/baseline/testImgSize2.png
new file mode 100644
index 0000000..df562d3
--- /dev/null
+++ b/src/test/baseline/testImgSize2.png
Binary files differ
diff --git a/src/test/baseline/testImgWarp1.png b/src/test/baseline/testImgWarp1.png
new file mode 100644
index 0000000..a5ee5c0
--- /dev/null
+++ b/src/test/baseline/testImgWarp1.png
Binary files differ
diff --git a/src/test/baseline/testInactiveVector1.png b/src/test/baseline/testInactiveVector1.png
new file mode 100644
index 0000000..be0f350
--- /dev/null
+++ b/src/test/baseline/testInactiveVector1.png
Binary files differ
diff --git a/src/test/baseline/testInactiveVector2.png b/src/test/baseline/testInactiveVector2.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testInactiveVector2.png
Binary files differ
diff --git a/src/test/baseline/testIntAnim1.png b/src/test/baseline/testIntAnim1.png
new file mode 100644
index 0000000..904a872
--- /dev/null
+++ b/src/test/baseline/testIntAnim1.png
Binary files differ
diff --git a/src/test/baseline/testIntAnim2.png b/src/test/baseline/testIntAnim2.png
new file mode 100644
index 0000000..c2df44a
--- /dev/null
+++ b/src/test/baseline/testIntAnim2.png
Binary files differ
diff --git a/src/test/baseline/testIntensity1.png b/src/test/baseline/testIntensity1.png
new file mode 100644
index 0000000..cf19285
--- /dev/null
+++ b/src/test/baseline/testIntensity1.png
Binary files differ
diff --git a/src/test/baseline/testIntensity2.png b/src/test/baseline/testIntensity2.png
new file mode 100644
index 0000000..c8bb26a
--- /dev/null
+++ b/src/test/baseline/testIntensity2.png
Binary files differ
diff --git a/src/test/baseline/testIntensity3.png b/src/test/baseline/testIntensity3.png
new file mode 100644
index 0000000..450327c
--- /dev/null
+++ b/src/test/baseline/testIntensity3.png
Binary files differ
diff --git a/src/test/baseline/testIntensity4.png b/src/test/baseline/testIntensity4.png
new file mode 100644
index 0000000..649cd82
--- /dev/null
+++ b/src/test/baseline/testIntensity4.png
Binary files differ
diff --git a/src/test/baseline/testInvertFX1.png b/src/test/baseline/testInvertFX1.png
new file mode 100644
index 0000000..cbce0de
--- /dev/null
+++ b/src/test/baseline/testInvertFX1.png
Binary files differ
diff --git a/src/test/baseline/testInvertFX2.png b/src/test/baseline/testInvertFX2.png
new file mode 100644
index 0000000..2c5a673
--- /dev/null
+++ b/src/test/baseline/testInvertFX2.png
Binary files differ
diff --git a/src/test/baseline/testJustify.png b/src/test/baseline/testJustify.png
new file mode 100644
index 0000000..4d5affc
--- /dev/null
+++ b/src/test/baseline/testJustify.png
Binary files differ
diff --git a/src/test/baseline/testLetterSpacing1.png b/src/test/baseline/testLetterSpacing1.png
new file mode 100644
index 0000000..3b04e0e
--- /dev/null
+++ b/src/test/baseline/testLetterSpacing1.png
Binary files differ
diff --git a/src/test/baseline/testLetterSpacing2.png b/src/test/baseline/testLetterSpacing2.png
new file mode 100644
index 0000000..8385a22
--- /dev/null
+++ b/src/test/baseline/testLetterSpacing2.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnim1.png b/src/test/baseline/testLinearAnim1.png
new file mode 100644
index 0000000..82abf89
--- /dev/null
+++ b/src/test/baseline/testLinearAnim1.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnim2.png b/src/test/baseline/testLinearAnim2.png
new file mode 100644
index 0000000..e299221
--- /dev/null
+++ b/src/test/baseline/testLinearAnim2.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnim3.png b/src/test/baseline/testLinearAnim3.png
new file mode 100644
index 0000000..e299221
--- /dev/null
+++ b/src/test/baseline/testLinearAnim3.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimC1.png b/src/test/baseline/testLinearAnimC1.png
new file mode 100644
index 0000000..fbe5b29
--- /dev/null
+++ b/src/test/baseline/testLinearAnimC1.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimC2.png b/src/test/baseline/testLinearAnimC2.png
new file mode 100644
index 0000000..b6403be
--- /dev/null
+++ b/src/test/baseline/testLinearAnimC2.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimC3.png b/src/test/baseline/testLinearAnimC3.png
new file mode 100644
index 0000000..b5e695e
--- /dev/null
+++ b/src/test/baseline/testLinearAnimC3.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimC4.png b/src/test/baseline/testLinearAnimC4.png
new file mode 100644
index 0000000..9703e09
--- /dev/null
+++ b/src/test/baseline/testLinearAnimC4.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimC5.png b/src/test/baseline/testLinearAnimC5.png
new file mode 100644
index 0000000..b5e695e
--- /dev/null
+++ b/src/test/baseline/testLinearAnimC5.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimC6.png b/src/test/baseline/testLinearAnimC6.png
new file mode 100644
index 0000000..f1fbb13
--- /dev/null
+++ b/src/test/baseline/testLinearAnimC6.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimZeroDuration1.png b/src/test/baseline/testLinearAnimZeroDuration1.png
new file mode 100644
index 0000000..e299221
--- /dev/null
+++ b/src/test/baseline/testLinearAnimZeroDuration1.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimZeroDuration2.png b/src/test/baseline/testLinearAnimZeroDuration2.png
new file mode 100644
index 0000000..ef346f8
--- /dev/null
+++ b/src/test/baseline/testLinearAnimZeroDuration2.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimZeroDuration3.png b/src/test/baseline/testLinearAnimZeroDuration3.png
new file mode 100644
index 0000000..ef346f8
--- /dev/null
+++ b/src/test/baseline/testLinearAnimZeroDuration3.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimZeroDurationC1.png b/src/test/baseline/testLinearAnimZeroDurationC1.png
new file mode 100644
index 0000000..9703e09
--- /dev/null
+++ b/src/test/baseline/testLinearAnimZeroDurationC1.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimZeroDurationC2.png b/src/test/baseline/testLinearAnimZeroDurationC2.png
new file mode 100644
index 0000000..ef346f8
--- /dev/null
+++ b/src/test/baseline/testLinearAnimZeroDurationC2.png
Binary files differ
diff --git a/src/test/baseline/testLinearAnimZeroDurationC3.png b/src/test/baseline/testLinearAnimZeroDurationC3.png
new file mode 100644
index 0000000..ef346f8
--- /dev/null
+++ b/src/test/baseline/testLinearAnimZeroDurationC3.png
Binary files differ
diff --git a/src/test/baseline/testMediaDir1.png b/src/test/baseline/testMediaDir1.png
new file mode 100644
index 0000000..d566076
--- /dev/null
+++ b/src/test/baseline/testMediaDir1.png
Binary files differ
diff --git a/src/test/baseline/testMediaDir2.png b/src/test/baseline/testMediaDir2.png
new file mode 100644
index 0000000..e46ab2c
--- /dev/null
+++ b/src/test/baseline/testMediaDir2.png
Binary files differ
diff --git a/src/test/baseline/testMesh1.png b/src/test/baseline/testMesh1.png
new file mode 100644
index 0000000..533ea09
--- /dev/null
+++ b/src/test/baseline/testMesh1.png
Binary files differ
diff --git a/src/test/baseline/testMesh2.png b/src/test/baseline/testMesh2.png
new file mode 100644
index 0000000..d81ddbd
--- /dev/null
+++ b/src/test/baseline/testMesh2.png
Binary files differ
diff --git a/src/test/baseline/testMesh3.png b/src/test/baseline/testMesh3.png
new file mode 100644
index 0000000..4e3dab2
--- /dev/null
+++ b/src/test/baseline/testMesh3.png
Binary files differ
diff --git a/src/test/baseline/testMesh4.png b/src/test/baseline/testMesh4.png
new file mode 100644
index 0000000..f325b53
--- /dev/null
+++ b/src/test/baseline/testMesh4.png
Binary files differ
diff --git a/src/test/baseline/testMesh5.png b/src/test/baseline/testMesh5.png
new file mode 100644
index 0000000..86c0a24
--- /dev/null
+++ b/src/test/baseline/testMesh5.png
Binary files differ
diff --git a/src/test/baseline/testMesh6.png b/src/test/baseline/testMesh6.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testMesh6.png
Binary files differ
diff --git a/src/test/baseline/testMipmap.png b/src/test/baseline/testMipmap.png
new file mode 100644
index 0000000..7068a7a
--- /dev/null
+++ b/src/test/baseline/testMipmap.png
Binary files differ
diff --git a/src/test/baseline/testMove1.png b/src/test/baseline/testMove1.png
new file mode 100644
index 0000000..4d0bdec
--- /dev/null
+++ b/src/test/baseline/testMove1.png
Binary files differ
diff --git a/src/test/baseline/testNodeInCanvasNullFX1.png b/src/test/baseline/testNodeInCanvasNullFX1.png
new file mode 100644
index 0000000..00767fb
--- /dev/null
+++ b/src/test/baseline/testNodeInCanvasNullFX1.png
Binary files differ
diff --git a/src/test/baseline/testOffscreen1.png b/src/test/baseline/testOffscreen1.png
new file mode 100644
index 0000000..4c1afa7
--- /dev/null
+++ b/src/test/baseline/testOffscreen1.png
Binary files differ
diff --git a/src/test/baseline/testOffscreen2.png b/src/test/baseline/testOffscreen2.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testOffscreen2.png
Binary files differ
diff --git a/src/test/baseline/testOffscreen3.png b/src/test/baseline/testOffscreen3.png
new file mode 100644
index 0000000..f274a2b
--- /dev/null
+++ b/src/test/baseline/testOffscreen3.png
Binary files differ
diff --git a/src/test/baseline/testOffscreen4.png b/src/test/baseline/testOffscreen4.png
new file mode 100644
index 0000000..4c1afa7
--- /dev/null
+++ b/src/test/baseline/testOffscreen4.png
Binary files differ
diff --git a/src/test/baseline/testOffscreen5.png b/src/test/baseline/testOffscreen5.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testOffscreen5.png
Binary files differ
diff --git a/src/test/baseline/testOffscreenAutoRender1.png b/src/test/baseline/testOffscreenAutoRender1.png
new file mode 100644
index 0000000..4c1afa7
--- /dev/null
+++ b/src/test/baseline/testOffscreenAutoRender1.png
Binary files differ
diff --git a/src/test/baseline/testOffscreenAutoRender2.png b/src/test/baseline/testOffscreenAutoRender2.png
new file mode 100644
index 0000000..0d508a9
--- /dev/null
+++ b/src/test/baseline/testOffscreenAutoRender2.png
Binary files differ
diff --git a/src/test/baseline/testOffscreenMultisampleScreenshot.png b/src/test/baseline/testOffscreenMultisampleScreenshot.png
new file mode 100644
index 0000000..1a04a20
--- /dev/null
+++ b/src/test/baseline/testOffscreenMultisampleScreenshot.png
Binary files differ
diff --git a/src/test/baseline/testOffscreenScreenshot.png b/src/test/baseline/testOffscreenScreenshot.png
new file mode 100644
index 0000000..31fcc27
--- /dev/null
+++ b/src/test/baseline/testOffscreenScreenshot.png
Binary files differ
diff --git a/src/test/baseline/testOutlines.png b/src/test/baseline/testOutlines.png
new file mode 100644
index 0000000..0ef64ad
--- /dev/null
+++ b/src/test/baseline/testOutlines.png
Binary files differ
diff --git a/src/test/baseline/testPanoDynamics1.png b/src/test/baseline/testPanoDynamics1.png
new file mode 100644
index 0000000..8cac76c
--- /dev/null
+++ b/src/test/baseline/testPanoDynamics1.png
Binary files differ
diff --git a/src/test/baseline/testPanoDynamics2.png b/src/test/baseline/testPanoDynamics2.png
new file mode 100644
index 0000000..21c01f2
--- /dev/null
+++ b/src/test/baseline/testPanoDynamics2.png
Binary files differ
diff --git a/src/test/baseline/testPanoDynamics3.png b/src/test/baseline/testPanoDynamics3.png
new file mode 100644
index 0000000..e52d01b
--- /dev/null
+++ b/src/test/baseline/testPanoDynamics3.png
Binary files differ
diff --git a/src/test/baseline/testPanoImage.png b/src/test/baseline/testPanoImage.png
new file mode 100644
index 0000000..6ce1008
--- /dev/null
+++ b/src/test/baseline/testPanoImage.png
Binary files differ
diff --git a/src/test/baseline/testPanoImagewNOP.png b/src/test/baseline/testPanoImagewNOP.png
new file mode 100644
index 0000000..6ce1008
--- /dev/null
+++ b/src/test/baseline/testPanoImagewNOP.png
Binary files differ
diff --git a/src/test/baseline/testParaWords.png b/src/test/baseline/testParaWords.png
new file mode 100644
index 0000000..4709a3b
--- /dev/null
+++ b/src/test/baseline/testParaWords.png
Binary files differ
diff --git a/src/test/baseline/testParallelAnimC1.png b/src/test/baseline/testParallelAnimC1.png
new file mode 100644
index 0000000..69aa068
--- /dev/null
+++ b/src/test/baseline/testParallelAnimC1.png
Binary files differ
diff --git a/src/test/baseline/testParallelAnimC2.png b/src/test/baseline/testParallelAnimC2.png
new file mode 100644
index 0000000..80a7f81
--- /dev/null
+++ b/src/test/baseline/testParallelAnimC2.png
Binary files differ
diff --git a/src/test/baseline/testParallelAnimC3.png b/src/test/baseline/testParallelAnimC3.png
new file mode 100644
index 0000000..ec591f3
--- /dev/null
+++ b/src/test/baseline/testParallelAnimC3.png
Binary files differ
diff --git a/src/test/baseline/testParallelAnims1.png b/src/test/baseline/testParallelAnims1.png
new file mode 100644
index 0000000..4d189b7
--- /dev/null
+++ b/src/test/baseline/testParallelAnims1.png
Binary files differ
diff --git a/src/test/baseline/testParallelAnims2.png b/src/test/baseline/testParallelAnims2.png
new file mode 100644
index 0000000..64f85d1
--- /dev/null
+++ b/src/test/baseline/testParallelAnims2.png
Binary files differ
diff --git a/src/test/baseline/testPieSlice1.png b/src/test/baseline/testPieSlice1.png
new file mode 100644
index 0000000..9d5bc4d
--- /dev/null
+++ b/src/test/baseline/testPieSlice1.png
Binary files differ
diff --git a/src/test/baseline/testPieSlice2.png b/src/test/baseline/testPieSlice2.png
new file mode 100644
index 0000000..5d62891
--- /dev/null
+++ b/src/test/baseline/testPieSlice2.png
Binary files differ
diff --git a/src/test/baseline/testPieSlice3.png b/src/test/baseline/testPieSlice3.png
new file mode 100644
index 0000000..c011af3
--- /dev/null
+++ b/src/test/baseline/testPieSlice3.png
Binary files differ
diff --git a/src/test/baseline/testPlayBeforeConnect.png b/src/test/baseline/testPlayBeforeConnect.png
new file mode 100644
index 0000000..d27fda0
--- /dev/null
+++ b/src/test/baseline/testPlayBeforeConnect.png
Binary files differ
diff --git a/src/test/baseline/testPointAnim1.png b/src/test/baseline/testPointAnim1.png
new file mode 100644
index 0000000..4c1afa7
--- /dev/null
+++ b/src/test/baseline/testPointAnim1.png
Binary files differ
diff --git a/src/test/baseline/testPointAnim2.png b/src/test/baseline/testPointAnim2.png
new file mode 100644
index 0000000..1d46750
--- /dev/null
+++ b/src/test/baseline/testPointAnim2.png
Binary files differ
diff --git a/src/test/baseline/testPointAnim3.png b/src/test/baseline/testPointAnim3.png
new file mode 100644
index 0000000..1d46750
--- /dev/null
+++ b/src/test/baseline/testPointAnim3.png
Binary files differ
diff --git a/src/test/baseline/testPolyLine1.png b/src/test/baseline/testPolyLine1.png
new file mode 100644
index 0000000..e2843f6
--- /dev/null
+++ b/src/test/baseline/testPolyLine1.png
Binary files differ
diff --git a/src/test/baseline/testPolyLine2.png b/src/test/baseline/testPolyLine2.png
new file mode 100644
index 0000000..4b26092
--- /dev/null
+++ b/src/test/baseline/testPolyLine2.png
Binary files differ
diff --git a/src/test/baseline/testPolyLine3.png b/src/test/baseline/testPolyLine3.png
new file mode 100644
index 0000000..80df8a0
--- /dev/null
+++ b/src/test/baseline/testPolyLine3.png
Binary files differ
diff --git a/src/test/baseline/testPolyLine4.png b/src/test/baseline/testPolyLine4.png
new file mode 100644
index 0000000..e37c026
--- /dev/null
+++ b/src/test/baseline/testPolyLine4.png
Binary files differ
diff --git a/src/test/baseline/testPolyLine5.png b/src/test/baseline/testPolyLine5.png
new file mode 100644
index 0000000..80df8a0
--- /dev/null
+++ b/src/test/baseline/testPolyLine5.png
Binary files differ
diff --git a/src/test/baseline/testPolyLine6.png b/src/test/baseline/testPolyLine6.png
new file mode 100644
index 0000000..2607d53
--- /dev/null
+++ b/src/test/baseline/testPolyLine6.png
Binary files differ
diff --git a/src/test/baseline/testPolygon1.png b/src/test/baseline/testPolygon1.png
new file mode 100644
index 0000000..441ed9b
--- /dev/null
+++ b/src/test/baseline/testPolygon1.png
Binary files differ
diff --git a/src/test/baseline/testPolygon2.png b/src/test/baseline/testPolygon2.png
new file mode 100644
index 0000000..858bf40
--- /dev/null
+++ b/src/test/baseline/testPolygon2.png
Binary files differ
diff --git a/src/test/baseline/testPolygon3.png b/src/test/baseline/testPolygon3.png
new file mode 100644
index 0000000..636ada8
--- /dev/null
+++ b/src/test/baseline/testPolygon3.png
Binary files differ
diff --git a/src/test/baseline/testPolygon4.png b/src/test/baseline/testPolygon4.png
new file mode 100644
index 0000000..636ada8
--- /dev/null
+++ b/src/test/baseline/testPolygon4.png
Binary files differ
diff --git a/src/test/baseline/testPolygon5.png b/src/test/baseline/testPolygon5.png
new file mode 100644
index 0000000..964a01b
--- /dev/null
+++ b/src/test/baseline/testPolygon5.png
Binary files differ
diff --git a/src/test/baseline/testPolygon6.png b/src/test/baseline/testPolygon6.png
new file mode 100644
index 0000000..45ee95d
--- /dev/null
+++ b/src/test/baseline/testPolygon6.png
Binary files differ
diff --git a/src/test/baseline/testPositioning.png b/src/test/baseline/testPositioning.png
new file mode 100644
index 0000000..1b174b0
--- /dev/null
+++ b/src/test/baseline/testPositioning.png
Binary files differ
diff --git a/src/test/baseline/testRawText1.png b/src/test/baseline/testRawText1.png
new file mode 100644
index 0000000..4733e87
--- /dev/null
+++ b/src/test/baseline/testRawText1.png
Binary files differ
diff --git a/src/test/baseline/testRawText2.png b/src/test/baseline/testRawText2.png
new file mode 100644
index 0000000..cedb8bb
--- /dev/null
+++ b/src/test/baseline/testRawText2.png
Binary files differ
diff --git a/src/test/baseline/testRawText3.png b/src/test/baseline/testRawText3.png
new file mode 100644
index 0000000..e91b743
--- /dev/null
+++ b/src/test/baseline/testRawText3.png
Binary files differ
diff --git a/src/test/baseline/testRawText4.png b/src/test/baseline/testRawText4.png
new file mode 100644
index 0000000..cd1c0dc
--- /dev/null
+++ b/src/test/baseline/testRawText4.png
Binary files differ
diff --git a/src/test/baseline/testRect1.png b/src/test/baseline/testRect1.png
new file mode 100644
index 0000000..c2f4c5e
--- /dev/null
+++ b/src/test/baseline/testRect1.png
Binary files differ
diff --git a/src/test/baseline/testRect2.png b/src/test/baseline/testRect2.png
new file mode 100644
index 0000000..9d9ec9d
--- /dev/null
+++ b/src/test/baseline/testRect2.png
Binary files differ
diff --git a/src/test/baseline/testRect3.png b/src/test/baseline/testRect3.png
new file mode 100644
index 0000000..aabb540
--- /dev/null
+++ b/src/test/baseline/testRect3.png
Binary files differ
diff --git a/src/test/baseline/testRect4.png b/src/test/baseline/testRect4.png
new file mode 100644
index 0000000..c549747
--- /dev/null
+++ b/src/test/baseline/testRect4.png
Binary files differ
diff --git a/src/test/baseline/testRenderPipeline.png b/src/test/baseline/testRenderPipeline.png
new file mode 100644
index 0000000..f9603fd
--- /dev/null
+++ b/src/test/baseline/testRenderPipeline.png
Binary files differ
diff --git a/src/test/baseline/testRotate1.png b/src/test/baseline/testRotate1.png
new file mode 100644
index 0000000..7c8aa25
--- /dev/null
+++ b/src/test/baseline/testRotate1.png
Binary files differ
diff --git a/src/test/baseline/testRotate1a.png b/src/test/baseline/testRotate1a.png
new file mode 100644
index 0000000..4e71a64
--- /dev/null
+++ b/src/test/baseline/testRotate1a.png
Binary files differ
diff --git a/src/test/baseline/testRotate1b.png b/src/test/baseline/testRotate1b.png
new file mode 100644
index 0000000..d1b5321
--- /dev/null
+++ b/src/test/baseline/testRotate1b.png
Binary files differ
diff --git a/src/test/baseline/testRotate2.png b/src/test/baseline/testRotate2.png
new file mode 100644
index 0000000..5db6d09
--- /dev/null
+++ b/src/test/baseline/testRotate2.png
Binary files differ
diff --git a/src/test/baseline/testRotatePivot1.png b/src/test/baseline/testRotatePivot1.png
new file mode 100644
index 0000000..6b4d6ef
--- /dev/null
+++ b/src/test/baseline/testRotatePivot1.png
Binary files differ
diff --git a/src/test/baseline/testRotatePivot2.png b/src/test/baseline/testRotatePivot2.png
new file mode 100644
index 0000000..d5122c7
--- /dev/null
+++ b/src/test/baseline/testRotatePivot2.png
Binary files differ
diff --git a/src/test/baseline/testRotatePivot3.png b/src/test/baseline/testRotatePivot3.png
new file mode 100644
index 0000000..8237df6
--- /dev/null
+++ b/src/test/baseline/testRotatePivot3.png
Binary files differ
diff --git a/src/test/baseline/testRoundedRect1.png b/src/test/baseline/testRoundedRect1.png
new file mode 100644
index 0000000..44e5013
--- /dev/null
+++ b/src/test/baseline/testRoundedRect1.png
Binary files differ
diff --git a/src/test/baseline/testRoundedRect2.png b/src/test/baseline/testRoundedRect2.png
new file mode 100644
index 0000000..b50d434
--- /dev/null
+++ b/src/test/baseline/testRoundedRect2.png
Binary files differ
diff --git a/src/test/baseline/testRoundedRect3.png b/src/test/baseline/testRoundedRect3.png
new file mode 100644
index 0000000..b35eb14
--- /dev/null
+++ b/src/test/baseline/testRoundedRect3.png
Binary files differ
diff --git a/src/test/baseline/testRoundedRect4.png b/src/test/baseline/testRoundedRect4.png
new file mode 100644
index 0000000..a6e5d6e
--- /dev/null
+++ b/src/test/baseline/testRoundedRect4.png
Binary files differ
diff --git a/src/test/baseline/testRoundedRect5.png b/src/test/baseline/testRoundedRect5.png
new file mode 100644
index 0000000..c6da32c
--- /dev/null
+++ b/src/test/baseline/testRoundedRect5.png
Binary files differ
diff --git a/src/test/baseline/testRoundedRect6.png b/src/test/baseline/testRoundedRect6.png
new file mode 100644
index 0000000..a9e76a8
--- /dev/null
+++ b/src/test/baseline/testRoundedRect6.png
Binary files differ
diff --git a/src/test/baseline/testScrollPane1.png b/src/test/baseline/testScrollPane1.png
new file mode 100644
index 0000000..68fcad1
--- /dev/null
+++ b/src/test/baseline/testScrollPane1.png
Binary files differ
diff --git a/src/test/baseline/testScrollPane2.png b/src/test/baseline/testScrollPane2.png
new file mode 100644
index 0000000..3e58737
--- /dev/null
+++ b/src/test/baseline/testScrollPane2.png
Binary files differ
diff --git a/src/test/baseline/testScrollPane3.png b/src/test/baseline/testScrollPane3.png
new file mode 100644
index 0000000..834a091
--- /dev/null
+++ b/src/test/baseline/testScrollPane3.png
Binary files differ
diff --git a/src/test/baseline/testScrollPane4.png b/src/test/baseline/testScrollPane4.png
new file mode 100644
index 0000000..9daf9a5
--- /dev/null
+++ b/src/test/baseline/testScrollPane4.png
Binary files differ
diff --git a/src/test/baseline/testShadowFX1.png b/src/test/baseline/testShadowFX1.png
new file mode 100644
index 0000000..7d1d5d7
--- /dev/null
+++ b/src/test/baseline/testShadowFX1.png
Binary files differ
diff --git a/src/test/baseline/testShadowFX2.png b/src/test/baseline/testShadowFX2.png
new file mode 100644
index 0000000..0d9b1ee
--- /dev/null
+++ b/src/test/baseline/testShadowFX2.png
Binary files differ
diff --git a/src/test/baseline/testShadowFX3.png b/src/test/baseline/testShadowFX3.png
new file mode 100644
index 0000000..3a3a678
--- /dev/null
+++ b/src/test/baseline/testShadowFX3.png
Binary files differ
diff --git a/src/test/baseline/testShadowFX4.png b/src/test/baseline/testShadowFX4.png
new file mode 100644
index 0000000..13da229
--- /dev/null
+++ b/src/test/baseline/testShadowFX4.png
Binary files differ
diff --git a/src/test/baseline/testShadowFX5.png b/src/test/baseline/testShadowFX5.png
new file mode 100644
index 0000000..b1ed885
--- /dev/null
+++ b/src/test/baseline/testShadowFX5.png
Binary files differ
diff --git a/src/test/baseline/testShadowFX6.png b/src/test/baseline/testShadowFX6.png
new file mode 100644
index 0000000..52e8c14
--- /dev/null
+++ b/src/test/baseline/testShadowFX6.png
Binary files differ
diff --git a/src/test/baseline/testSimpleWords.png b/src/test/baseline/testSimpleWords.png
new file mode 100644
index 0000000..21e1a1b
--- /dev/null
+++ b/src/test/baseline/testSimpleWords.png
Binary files differ
diff --git a/src/test/baseline/testSpanWords.png b/src/test/baseline/testSpanWords.png
new file mode 100644
index 0000000..c206d60
--- /dev/null
+++ b/src/test/baseline/testSpanWords.png
Binary files differ
diff --git a/src/test/baseline/testSplineAnim1.png b/src/test/baseline/testSplineAnim1.png
new file mode 100644
index 0000000..82abf89
--- /dev/null
+++ b/src/test/baseline/testSplineAnim1.png
Binary files differ
diff --git a/src/test/baseline/testSplineAnim2.png b/src/test/baseline/testSplineAnim2.png
new file mode 100644
index 0000000..e299221
--- /dev/null
+++ b/src/test/baseline/testSplineAnim2.png
Binary files differ
diff --git a/src/test/baseline/testSplineAnim3.png b/src/test/baseline/testSplineAnim3.png
new file mode 100644
index 0000000..36a6afc
--- /dev/null
+++ b/src/test/baseline/testSplineAnim3.png
Binary files differ
diff --git a/src/test/baseline/testStateAnim1.png b/src/test/baseline/testStateAnim1.png
new file mode 100644
index 0000000..19ad729
--- /dev/null
+++ b/src/test/baseline/testStateAnim1.png
Binary files differ
diff --git a/src/test/baseline/testStateAnim2.png b/src/test/baseline/testStateAnim2.png
new file mode 100644
index 0000000..92a98a5
--- /dev/null
+++ b/src/test/baseline/testStateAnim2.png
Binary files differ
diff --git a/src/test/baseline/testStateAnim3.png b/src/test/baseline/testStateAnim3.png
new file mode 100644
index 0000000..92a98a5
--- /dev/null
+++ b/src/test/baseline/testStateAnim3.png
Binary files differ
diff --git a/src/test/baseline/testStateAnim4.png b/src/test/baseline/testStateAnim4.png
new file mode 100644
index 0000000..19ad729
--- /dev/null
+++ b/src/test/baseline/testStateAnim4.png
Binary files differ
diff --git a/src/test/baseline/testStateAnim5.png b/src/test/baseline/testStateAnim5.png
new file mode 100644
index 0000000..92a98a5
--- /dev/null
+++ b/src/test/baseline/testStateAnim5.png
Binary files differ
diff --git a/src/test/baseline/testStateAnimC1.png b/src/test/baseline/testStateAnimC1.png
new file mode 100644
index 0000000..02f0389
--- /dev/null
+++ b/src/test/baseline/testStateAnimC1.png
Binary files differ
diff --git a/src/test/baseline/testStateAnimC2.png b/src/test/baseline/testStateAnimC2.png
new file mode 100644
index 0000000..2126c02
--- /dev/null
+++ b/src/test/baseline/testStateAnimC2.png
Binary files differ
diff --git a/src/test/baseline/testStateAnimC3.png b/src/test/baseline/testStateAnimC3.png
new file mode 100644
index 0000000..dc43edc
--- /dev/null
+++ b/src/test/baseline/testStateAnimC3.png
Binary files differ
diff --git a/src/test/baseline/testStateAnimC4.png b/src/test/baseline/testStateAnimC4.png
new file mode 100644
index 0000000..2126c02
--- /dev/null
+++ b/src/test/baseline/testStateAnimC4.png
Binary files differ
diff --git a/src/test/baseline/testStateAnimC5.png b/src/test/baseline/testStateAnimC5.png
new file mode 100644
index 0000000..2126c02
--- /dev/null
+++ b/src/test/baseline/testStateAnimC5.png
Binary files differ
diff --git a/src/test/baseline/testSvgBmp.png b/src/test/baseline/testSvgBmp.png
new file mode 100644
index 0000000..8020a67
--- /dev/null
+++ b/src/test/baseline/testSvgBmp.png
Binary files differ
diff --git a/src/test/baseline/testSvgNode.png b/src/test/baseline/testSvgNode.png
new file mode 100644
index 0000000..76d1632
--- /dev/null
+++ b/src/test/baseline/testSvgNode.png
Binary files differ
diff --git a/src/test/baseline/testSvgPosBmp.png b/src/test/baseline/testSvgPosBmp.png
new file mode 100644
index 0000000..6eb83fe
--- /dev/null
+++ b/src/test/baseline/testSvgPosBmp.png
Binary files differ
diff --git a/src/test/baseline/testSvgScaleBmp1.png b/src/test/baseline/testSvgScaleBmp1.png
new file mode 100644
index 0000000..ba46499
--- /dev/null
+++ b/src/test/baseline/testSvgScaleBmp1.png
Binary files differ
diff --git a/src/test/baseline/testSvgScaleBmp2.png b/src/test/baseline/testSvgScaleBmp2.png
new file mode 100644
index 0000000..eb038d5
--- /dev/null
+++ b/src/test/baseline/testSvgScaleBmp2.png
Binary files differ
diff --git a/src/test/baseline/testSvgScaledNode1.png b/src/test/baseline/testSvgScaledNode1.png
new file mode 100644
index 0000000..7c78fb5
--- /dev/null
+++ b/src/test/baseline/testSvgScaledNode1.png
Binary files differ
diff --git a/src/test/baseline/testSvgScaledNode2.png b/src/test/baseline/testSvgScaledNode2.png
new file mode 100644
index 0000000..3cdff7f
--- /dev/null
+++ b/src/test/baseline/testSvgScaledNode2.png
Binary files differ
diff --git a/src/test/baseline/testTexCompression1.png b/src/test/baseline/testTexCompression1.png
new file mode 100644
index 0000000..8629a85
--- /dev/null
+++ b/src/test/baseline/testTexCompression1.png
Binary files differ
diff --git a/src/test/baseline/testTexCompression2.png b/src/test/baseline/testTexCompression2.png
new file mode 100644
index 0000000..51acdba
--- /dev/null
+++ b/src/test/baseline/testTexCompression2.png
Binary files differ
diff --git a/src/test/baseline/testTextArea1.png b/src/test/baseline/testTextArea1.png
new file mode 100644
index 0000000..53f03a1
--- /dev/null
+++ b/src/test/baseline/testTextArea1.png
Binary files differ
diff --git a/src/test/baseline/testTextArea2.png b/src/test/baseline/testTextArea2.png
new file mode 100644
index 0000000..07349af
--- /dev/null
+++ b/src/test/baseline/testTextArea2.png
Binary files differ
diff --git a/src/test/baseline/testTexturedCurve1.png b/src/test/baseline/testTexturedCurve1.png
new file mode 100644
index 0000000..dc626fd
--- /dev/null
+++ b/src/test/baseline/testTexturedCurve1.png
Binary files differ
diff --git a/src/test/baseline/testTexturedCurve2.png b/src/test/baseline/testTexturedCurve2.png
new file mode 100644
index 0000000..f75a670
--- /dev/null
+++ b/src/test/baseline/testTexturedCurve2.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolyLine1.png b/src/test/baseline/testTexturedPolyLine1.png
new file mode 100644
index 0000000..1fd2e84
--- /dev/null
+++ b/src/test/baseline/testTexturedPolyLine1.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolyLine2.png b/src/test/baseline/testTexturedPolyLine2.png
new file mode 100644
index 0000000..ccbe01d
--- /dev/null
+++ b/src/test/baseline/testTexturedPolyLine2.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolyLine3.png b/src/test/baseline/testTexturedPolyLine3.png
new file mode 100644
index 0000000..65c59eb
--- /dev/null
+++ b/src/test/baseline/testTexturedPolyLine3.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolyLine4.png b/src/test/baseline/testTexturedPolyLine4.png
new file mode 100644
index 0000000..83c0b4a
--- /dev/null
+++ b/src/test/baseline/testTexturedPolyLine4.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolygon1.png b/src/test/baseline/testTexturedPolygon1.png
new file mode 100644
index 0000000..7064f8d
--- /dev/null
+++ b/src/test/baseline/testTexturedPolygon1.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolygon2.png b/src/test/baseline/testTexturedPolygon2.png
new file mode 100644
index 0000000..05f67c2
--- /dev/null
+++ b/src/test/baseline/testTexturedPolygon2.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolygon3.png b/src/test/baseline/testTexturedPolygon3.png
new file mode 100644
index 0000000..31730e0
--- /dev/null
+++ b/src/test/baseline/testTexturedPolygon3.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolygon4.png b/src/test/baseline/testTexturedPolygon4.png
new file mode 100644
index 0000000..333ada7
--- /dev/null
+++ b/src/test/baseline/testTexturedPolygon4.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolygon5.png b/src/test/baseline/testTexturedPolygon5.png
new file mode 100644
index 0000000..e7f7cc4
--- /dev/null
+++ b/src/test/baseline/testTexturedPolygon5.png
Binary files differ
diff --git a/src/test/baseline/testTexturedPolygon6.png b/src/test/baseline/testTexturedPolygon6.png
new file mode 100644
index 0000000..1222a19
--- /dev/null
+++ b/src/test/baseline/testTexturedPolygon6.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect1.png b/src/test/baseline/testTexturedRect1.png
new file mode 100644
index 0000000..35edac3
--- /dev/null
+++ b/src/test/baseline/testTexturedRect1.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect2.png b/src/test/baseline/testTexturedRect2.png
new file mode 100644
index 0000000..5d2a0ba
--- /dev/null
+++ b/src/test/baseline/testTexturedRect2.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect3.png b/src/test/baseline/testTexturedRect3.png
new file mode 100644
index 0000000..f5f2b77
--- /dev/null
+++ b/src/test/baseline/testTexturedRect3.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect4.png b/src/test/baseline/testTexturedRect4.png
new file mode 100644
index 0000000..795a7ad
--- /dev/null
+++ b/src/test/baseline/testTexturedRect4.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect5.png b/src/test/baseline/testTexturedRect5.png
new file mode 100644
index 0000000..38d6e56
--- /dev/null
+++ b/src/test/baseline/testTexturedRect5.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect6.png b/src/test/baseline/testTexturedRect6.png
new file mode 100644
index 0000000..b124377
--- /dev/null
+++ b/src/test/baseline/testTexturedRect6.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect7.png b/src/test/baseline/testTexturedRect7.png
new file mode 100644
index 0000000..ed51fa1
--- /dev/null
+++ b/src/test/baseline/testTexturedRect7.png
Binary files differ
diff --git a/src/test/baseline/testTexturedRect8.png b/src/test/baseline/testTexturedRect8.png
new file mode 100644
index 0000000..ddf74a2
--- /dev/null
+++ b/src/test/baseline/testTexturedRect8.png
Binary files differ
diff --git a/src/test/baseline/testUIButtonDisabled.png b/src/test/baseline/testUIButtonDisabled.png
new file mode 100644
index 0000000..9e00094
--- /dev/null
+++ b/src/test/baseline/testUIButtonDisabled.png
Binary files differ
diff --git a/src/test/baseline/testUIButtonDown.png b/src/test/baseline/testUIButtonDown.png
new file mode 100644
index 0000000..c9e3369
--- /dev/null
+++ b/src/test/baseline/testUIButtonDown.png
Binary files differ
diff --git a/src/test/baseline/testUIButtonUp.png b/src/test/baseline/testUIButtonUp.png
new file mode 100644
index 0000000..f385f38
--- /dev/null
+++ b/src/test/baseline/testUIButtonUp.png
Binary files differ
diff --git a/src/test/baseline/testUIKeyboard.png b/src/test/baseline/testUIKeyboard.png
new file mode 100644
index 0000000..9e1a4cd
--- /dev/null
+++ b/src/test/baseline/testUIKeyboard.png
Binary files differ
diff --git a/src/test/baseline/testUIKeyboardDownA1.png b/src/test/baseline/testUIKeyboardDownA1.png
new file mode 100644
index 0000000..51c001e
--- /dev/null
+++ b/src/test/baseline/testUIKeyboardDownA1.png
Binary files differ
diff --git a/src/test/baseline/testUIKeyboardDownA111S1.png b/src/test/baseline/testUIKeyboardDownA111S1.png
new file mode 100644
index 0000000..d05d7a6
--- /dev/null
+++ b/src/test/baseline/testUIKeyboardDownA111S1.png
Binary files differ
diff --git a/src/test/baseline/testUIKeyboardDownA212S2.png b/src/test/baseline/testUIKeyboardDownA212S2.png
new file mode 100644
index 0000000..b7b5492
--- /dev/null
+++ b/src/test/baseline/testUIKeyboardDownA212S2.png
Binary files differ
diff --git a/src/test/baseline/testUIKeyboardDownS1.png b/src/test/baseline/testUIKeyboardDownS1.png
new file mode 100644
index 0000000..deef9fc
--- /dev/null
+++ b/src/test/baseline/testUIKeyboardDownS1.png
Binary files differ
diff --git a/src/test/baseline/testVideo-h264-48x48.h2641.png b/src/test/baseline/testVideo-h264-48x48.h2641.png
new file mode 100644
index 0000000..5adc733
--- /dev/null
+++ b/src/test/baseline/testVideo-h264-48x48.h2641.png
Binary files differ
diff --git a/src/test/baseline/testVideo-mjpeg-48x48.avi1.png b/src/test/baseline/testVideo-mjpeg-48x48.avi1.png
new file mode 100644
index 0000000..a16beec
--- /dev/null
+++ b/src/test/baseline/testVideo-mjpeg-48x48.avi1.png
Binary files differ
diff --git a/src/test/baseline/testVideo-mpeg1-48x48-sound.avi1.png b/src/test/baseline/testVideo-mpeg1-48x48-sound.avi1.png
new file mode 100644
index 0000000..043fa46
--- /dev/null
+++ b/src/test/baseline/testVideo-mpeg1-48x48-sound.avi1.png
Binary files differ
diff --git a/src/test/baseline/testVideo-mpeg1-48x48.mpg1.png b/src/test/baseline/testVideo-mpeg1-48x48.mpg1.png
new file mode 100644
index 0000000..ad9dcf8
--- /dev/null
+++ b/src/test/baseline/testVideo-mpeg1-48x48.mpg1.png
Binary files differ
diff --git a/src/test/baseline/testVideo-rgba-48x48.mov1.png b/src/test/baseline/testVideo-rgba-48x48.mov1.png
new file mode 100644
index 0000000..700b042
--- /dev/null
+++ b/src/test/baseline/testVideo-rgba-48x48.mov1.png
Binary files differ
diff --git a/src/test/baseline/testVideo-vp6a-yuva-48x48.flv1.png b/src/test/baseline/testVideo-vp6a-yuva-48x48.flv1.png
new file mode 100644
index 0000000..970e6a4
--- /dev/null
+++ b/src/test/baseline/testVideo-vp6a-yuva-48x48.flv1.png
Binary files differ
diff --git a/src/test/baseline/testVideoActive1.png b/src/test/baseline/testVideoActive1.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testVideoActive1.png
Binary files differ
diff --git a/src/test/baseline/testVideoActive2.png b/src/test/baseline/testVideoActive2.png
new file mode 100644
index 0000000..0f1b555
--- /dev/null
+++ b/src/test/baseline/testVideoActive2.png
Binary files differ
diff --git a/src/test/baseline/testVideoDynamics1.png b/src/test/baseline/testVideoDynamics1.png
new file mode 100644
index 0000000..3eca9a4
--- /dev/null
+++ b/src/test/baseline/testVideoDynamics1.png
Binary files differ
diff --git a/src/test/baseline/testVideoDynamics2.png b/src/test/baseline/testVideoDynamics2.png
new file mode 100644
index 0000000..8e8716c
--- /dev/null
+++ b/src/test/baseline/testVideoDynamics2.png
Binary files differ
diff --git a/src/test/baseline/testVideoDynamics3.png b/src/test/baseline/testVideoDynamics3.png
new file mode 100644
index 0000000..90bde83
--- /dev/null
+++ b/src/test/baseline/testVideoDynamics3.png
Binary files differ
diff --git a/src/test/baseline/testVideoDynamics4.png b/src/test/baseline/testVideoDynamics4.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testVideoDynamics4.png
Binary files differ
diff --git a/src/test/baseline/testVideoDynamics5.png b/src/test/baseline/testVideoDynamics5.png
new file mode 100644
index 0000000..3eca9a4
--- /dev/null
+++ b/src/test/baseline/testVideoDynamics5.png
Binary files differ
diff --git a/src/test/baseline/testVideoFPS.png b/src/test/baseline/testVideoFPS.png
new file mode 100644
index 0000000..70e60fd
--- /dev/null
+++ b/src/test/baseline/testVideoFPS.png
Binary files differ
diff --git a/src/test/baseline/testVideoHRef1.png b/src/test/baseline/testVideoHRef1.png
new file mode 100644
index 0000000..c463313
--- /dev/null
+++ b/src/test/baseline/testVideoHRef1.png
Binary files differ
diff --git a/src/test/baseline/testVideoLoop.png b/src/test/baseline/testVideoLoop.png
new file mode 100644
index 0000000..ad9dcf8
--- /dev/null
+++ b/src/test/baseline/testVideoLoop.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskRGBA1.png b/src/test/baseline/testVideoMaskRGBA1.png
new file mode 100644
index 0000000..2ddf341
--- /dev/null
+++ b/src/test/baseline/testVideoMaskRGBA1.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskRGBA2.png b/src/test/baseline/testVideoMaskRGBA2.png
new file mode 100644
index 0000000..12fccc3
--- /dev/null
+++ b/src/test/baseline/testVideoMaskRGBA2.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskRGBA3.png b/src/test/baseline/testVideoMaskRGBA3.png
new file mode 100644
index 0000000..9241d08
--- /dev/null
+++ b/src/test/baseline/testVideoMaskRGBA3.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskRGBA4.png b/src/test/baseline/testVideoMaskRGBA4.png
new file mode 100644
index 0000000..2b00886
--- /dev/null
+++ b/src/test/baseline/testVideoMaskRGBA4.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUV1.png b/src/test/baseline/testVideoMaskYUV1.png
new file mode 100644
index 0000000..9b3cb7b
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUV1.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUV2.png b/src/test/baseline/testVideoMaskYUV2.png
new file mode 100644
index 0000000..978f3a6
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUV2.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUV3.png b/src/test/baseline/testVideoMaskYUV3.png
new file mode 100644
index 0000000..238edc4
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUV3.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUV4.png b/src/test/baseline/testVideoMaskYUV4.png
new file mode 100644
index 0000000..e4379a3
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUV4.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUVJ1.png b/src/test/baseline/testVideoMaskYUVJ1.png
new file mode 100644
index 0000000..ccb7e0d
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUVJ1.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUVJ2.png b/src/test/baseline/testVideoMaskYUVJ2.png
new file mode 100644
index 0000000..bfbd99c
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUVJ2.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUVJ3.png b/src/test/baseline/testVideoMaskYUVJ3.png
new file mode 100644
index 0000000..bf95a39
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUVJ3.png
Binary files differ
diff --git a/src/test/baseline/testVideoMaskYUVJ4.png b/src/test/baseline/testVideoMaskYUVJ4.png
new file mode 100644
index 0000000..b0f6e66
--- /dev/null
+++ b/src/test/baseline/testVideoMaskYUVJ4.png
Binary files differ
diff --git a/src/test/baseline/testVideoNullFX.png b/src/test/baseline/testVideoNullFX.png
new file mode 100644
index 0000000..9c1a999
--- /dev/null
+++ b/src/test/baseline/testVideoNullFX.png
Binary files differ
diff --git a/src/test/baseline/testVideoOpacityRGBA1.png b/src/test/baseline/testVideoOpacityRGBA1.png
new file mode 100644
index 0000000..e98478f
--- /dev/null
+++ b/src/test/baseline/testVideoOpacityRGBA1.png
Binary files differ
diff --git a/src/test/baseline/testVideoOpacityRGBA2.png b/src/test/baseline/testVideoOpacityRGBA2.png
new file mode 100644
index 0000000..00cf166
--- /dev/null
+++ b/src/test/baseline/testVideoOpacityRGBA2.png
Binary files differ
diff --git a/src/test/baseline/testVideoOpacityYUV1.png b/src/test/baseline/testVideoOpacityYUV1.png
new file mode 100644
index 0000000..d27fda0
--- /dev/null
+++ b/src/test/baseline/testVideoOpacityYUV1.png
Binary files differ
diff --git a/src/test/baseline/testVideoOpacityYUV2.png b/src/test/baseline/testVideoOpacityYUV2.png
new file mode 100644
index 0000000..152df47
--- /dev/null
+++ b/src/test/baseline/testVideoOpacityYUV2.png
Binary files differ
diff --git a/src/test/baseline/testVideoSeek0.png b/src/test/baseline/testVideoSeek0.png
new file mode 100644
index 0000000..e0046ba
--- /dev/null
+++ b/src/test/baseline/testVideoSeek0.png
Binary files differ
diff --git a/src/test/baseline/testVideoSeek1.png b/src/test/baseline/testVideoSeek1.png
new file mode 100644
index 0000000..6f658da
--- /dev/null
+++ b/src/test/baseline/testVideoSeek1.png
Binary files differ
diff --git a/src/test/baseline/testVideoSeek2.png b/src/test/baseline/testVideoSeek2.png
new file mode 100644
index 0000000..6a48ed4
--- /dev/null
+++ b/src/test/baseline/testVideoSeek2.png
Binary files differ
diff --git a/src/test/baseline/testVideoSeek3.png b/src/test/baseline/testVideoSeek3.png
new file mode 100644
index 0000000..c436802
--- /dev/null
+++ b/src/test/baseline/testVideoSeek3.png
Binary files differ
diff --git a/src/test/baseline/testVideoState1.png b/src/test/baseline/testVideoState1.png
new file mode 100644
index 0000000..ad9dcf8
--- /dev/null
+++ b/src/test/baseline/testVideoState1.png
Binary files differ
diff --git a/src/test/baseline/testVideoState2.png b/src/test/baseline/testVideoState2.png
new file mode 100644
index 0000000..fed9567
--- /dev/null
+++ b/src/test/baseline/testVideoState2.png
Binary files differ
diff --git a/src/test/baseline/testVideoState3.png b/src/test/baseline/testVideoState3.png
new file mode 100644
index 0000000..b7bc073
--- /dev/null
+++ b/src/test/baseline/testVideoState3.png
Binary files differ
diff --git a/src/test/baseline/testVideoState4.png b/src/test/baseline/testVideoState4.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testVideoState4.png
Binary files differ
diff --git a/src/test/baseline/testVideoState5.png b/src/test/baseline/testVideoState5.png
new file mode 100644
index 0000000..ad9dcf8
--- /dev/null
+++ b/src/test/baseline/testVideoState5.png
Binary files differ
diff --git a/src/test/baseline/testVideoWriter1.png b/src/test/baseline/testVideoWriter1.png
new file mode 100644
index 0000000..6a9f728
--- /dev/null
+++ b/src/test/baseline/testVideoWriter1.png
Binary files differ
diff --git a/src/test/baseline/testVideoWriterCanvas1.png b/src/test/baseline/testVideoWriterCanvas1.png
new file mode 100644
index 0000000..b319da2
--- /dev/null
+++ b/src/test/baseline/testVideoWriterCanvas1.png
Binary files differ
diff --git a/src/test/baseline/testWarp1.png b/src/test/baseline/testWarp1.png
new file mode 100644
index 0000000..99ddc2f
--- /dev/null
+++ b/src/test/baseline/testWarp1.png
Binary files differ
diff --git a/src/test/baseline/testWarp2.png b/src/test/baseline/testWarp2.png
new file mode 100644
index 0000000..0dca03a
--- /dev/null
+++ b/src/test/baseline/testWarp2.png
Binary files differ
diff --git a/src/test/baseline/testWarp3.png b/src/test/baseline/testWarp3.png
new file mode 100644
index 0000000..357a1b3
--- /dev/null
+++ b/src/test/baseline/testWarp3.png
Binary files differ
diff --git a/src/test/baseline/testWordsBR.png b/src/test/baseline/testWordsBR.png
new file mode 100644
index 0000000..82df070
--- /dev/null
+++ b/src/test/baseline/testWordsBR.png
Binary files differ
diff --git a/src/test/baseline/testWordsDynamics1.png b/src/test/baseline/testWordsDynamics1.png
new file mode 100644
index 0000000..c68081b
--- /dev/null
+++ b/src/test/baseline/testWordsDynamics1.png
Binary files differ
diff --git a/src/test/baseline/testWordsDynamics2.png b/src/test/baseline/testWordsDynamics2.png
new file mode 100644
index 0000000..ff6c80f
--- /dev/null
+++ b/src/test/baseline/testWordsDynamics2.png
Binary files differ
diff --git a/src/test/baseline/testWordsDynamics3.png b/src/test/baseline/testWordsDynamics3.png
new file mode 100644
index 0000000..ff6c80f
--- /dev/null
+++ b/src/test/baseline/testWordsDynamics3.png
Binary files differ
diff --git a/src/test/baseline/testWordsDynamics4.png b/src/test/baseline/testWordsDynamics4.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testWordsDynamics4.png
Binary files differ
diff --git a/src/test/baseline/testWordsDynamics5.png b/src/test/baseline/testWordsDynamics5.png
new file mode 100644
index 0000000..c68081b
--- /dev/null
+++ b/src/test/baseline/testWordsDynamics5.png
Binary files differ
diff --git a/src/test/baseline/testWordsMask1.png b/src/test/baseline/testWordsMask1.png
new file mode 100644
index 0000000..10affb2
--- /dev/null
+++ b/src/test/baseline/testWordsMask1.png
Binary files differ
diff --git a/src/test/baseline/testWordsMask2.png b/src/test/baseline/testWordsMask2.png
new file mode 100644
index 0000000..093b6a3
--- /dev/null
+++ b/src/test/baseline/testWordsMask2.png
Binary files differ
diff --git a/src/test/baseline/testWordsMask3.png b/src/test/baseline/testWordsMask3.png
new file mode 100644
index 0000000..2a6e464
--- /dev/null
+++ b/src/test/baseline/testWordsMask3.png
Binary files differ
diff --git a/src/test/baseline/testWordsMask4.png b/src/test/baseline/testWordsMask4.png
new file mode 100644
index 0000000..a65df77
--- /dev/null
+++ b/src/test/baseline/testWordsMask4.png
Binary files differ
diff --git a/src/test/baseline/testWordsMask5.png b/src/test/baseline/testWordsMask5.png
new file mode 100644
index 0000000..3df07d1
--- /dev/null
+++ b/src/test/baseline/testWordsMask5.png
Binary files differ
diff --git a/src/test/baseline/testWordsMask6.png b/src/test/baseline/testWordsMask6.png
new file mode 100644
index 0000000..7c592c6
--- /dev/null
+++ b/src/test/baseline/testWordsMask6.png
Binary files differ
diff --git a/src/test/baseline/testWordsNullFX.png b/src/test/baseline/testWordsNullFX.png
new file mode 100644
index 0000000..3197c3d
--- /dev/null
+++ b/src/test/baseline/testWordsNullFX.png
Binary files differ
diff --git a/src/test/baseline/testWordsShadowFX1.png b/src/test/baseline/testWordsShadowFX1.png
new file mode 100644
index 0000000..bd50822
--- /dev/null
+++ b/src/test/baseline/testWordsShadowFX1.png
Binary files differ
diff --git a/src/test/baseline/testWordsShadowFX2.png b/src/test/baseline/testWordsShadowFX2.png
new file mode 100644
index 0000000..84b503c
--- /dev/null
+++ b/src/test/baseline/testWordsShadowFX2.png
Binary files differ
diff --git a/src/test/baseline/testWrapMode1.png b/src/test/baseline/testWrapMode1.png
new file mode 100644
index 0000000..cff05d0
--- /dev/null
+++ b/src/test/baseline/testWrapMode1.png
Binary files differ
diff --git a/src/test/baseline/testWrapMode2.png b/src/test/baseline/testWrapMode2.png
new file mode 100644
index 0000000..596cdb6
--- /dev/null
+++ b/src/test/baseline/testWrapMode2.png
Binary files differ
diff --git a/src/test/baseline/testWrapMode3.png b/src/test/baseline/testWrapMode3.png
new file mode 100644
index 0000000..cff05d0
--- /dev/null
+++ b/src/test/baseline/testWrapMode3.png
Binary files differ
diff --git a/src/test/baseline/testWrapMode4.png b/src/test/baseline/testWrapMode4.png
new file mode 100644
index 0000000..6d17b93
--- /dev/null
+++ b/src/test/baseline/testWrapMode4.png
Binary files differ
diff --git a/src/test/baseline/testbasics.png b/src/test/baseline/testbasics.png
new file mode 100644
index 0000000..4c1afa7
--- /dev/null
+++ b/src/test/baseline/testbasics.png
Binary files differ
diff --git a/src/test/baseline/testline1.png b/src/test/baseline/testline1.png
new file mode 100644
index 0000000..b499abd
--- /dev/null
+++ b/src/test/baseline/testline1.png
Binary files differ
diff --git a/src/test/baseline/testline2.png b/src/test/baseline/testline2.png
new file mode 100644
index 0000000..c307bd7
--- /dev/null
+++ b/src/test/baseline/testline2.png
Binary files differ
diff --git a/src/test/baseline/testline3.png b/src/test/baseline/testline3.png
new file mode 100644
index 0000000..c1a7795
--- /dev/null
+++ b/src/test/baseline/testline3.png
Binary files differ
diff --git a/src/test/baseline/testline4.png b/src/test/baseline/testline4.png
new file mode 100644
index 0000000..b086840
--- /dev/null
+++ b/src/test/baseline/testline4.png
Binary files differ
diff --git a/src/test/baseline/testlineopacity1.png b/src/test/baseline/testlineopacity1.png
new file mode 100644
index 0000000..0c11d1c
--- /dev/null
+++ b/src/test/baseline/testlineopacity1.png
Binary files differ
diff --git a/src/test/baseline/testlineopacity2.png b/src/test/baseline/testlineopacity2.png
new file mode 100644
index 0000000..ee9b3e7
--- /dev/null
+++ b/src/test/baseline/testlineopacity2.png
Binary files differ
diff --git a/src/test/baseline/testlotsoflines.png b/src/test/baseline/testlotsoflines.png
new file mode 100644
index 0000000..485d9c5
--- /dev/null
+++ b/src/test/baseline/testlotsoflines.png
Binary files differ
diff --git a/src/test/baseline/testplugin1.png b/src/test/baseline/testplugin1.png
new file mode 100644
index 0000000..e06639d
--- /dev/null
+++ b/src/test/baseline/testplugin1.png
Binary files differ
diff --git a/src/test/baseline/testplugin2.png b/src/test/baseline/testplugin2.png
new file mode 100644
index 0000000..fc47a3c
--- /dev/null
+++ b/src/test/baseline/testplugin2.png
Binary files differ
diff --git a/src/test/baseline/testtexturedline1.png b/src/test/baseline/testtexturedline1.png
new file mode 100644
index 0000000..d4b3719
--- /dev/null
+++ b/src/test/baseline/testtexturedline1.png
Binary files differ
diff --git a/src/test/baseline/testtexturedline2.png b/src/test/baseline/testtexturedline2.png
new file mode 100644
index 0000000..174636b
--- /dev/null
+++ b/src/test/baseline/testtexturedline2.png
Binary files differ
diff --git a/src/test/baseline/testtexturedline3.png b/src/test/baseline/testtexturedline3.png
new file mode 100644
index 0000000..7ac3757
--- /dev/null
+++ b/src/test/baseline/testtexturedline3.png
Binary files differ
diff --git a/src/test/baseline/testtexturedline4.png b/src/test/baseline/testtexturedline4.png
new file mode 100644
index 0000000..07b7750
--- /dev/null
+++ b/src/test/baseline/testtexturedline4.png
Binary files differ
diff --git a/src/test/baseline/testtexturedline5.png b/src/test/baseline/testtexturedline5.png
new file mode 100644
index 0000000..7ffeed2
--- /dev/null
+++ b/src/test/baseline/testtexturedline5.png
Binary files differ
diff --git a/src/test/button_check.png b/src/test/button_check.png
new file mode 100644
index 0000000..b0aa4a9
--- /dev/null
+++ b/src/test/button_check.png
Binary files differ
diff --git a/src/test/button_disabled.png b/src/test/button_disabled.png
new file mode 100644
index 0000000..dbf1309
--- /dev/null
+++ b/src/test/button_disabled.png
Binary files differ
diff --git a/src/test/button_down.png b/src/test/button_down.png
new file mode 100644
index 0000000..88ee5f5
--- /dev/null
+++ b/src/test/button_down.png
Binary files differ
diff --git a/src/test/button_over.png b/src/test/button_over.png
new file mode 100644
index 0000000..0837e8e
--- /dev/null
+++ b/src/test/button_over.png
Binary files differ
diff --git a/src/test/button_up.png b/src/test/button_up.png
new file mode 100644
index 0000000..aa7d33a
--- /dev/null
+++ b/src/test/button_up.png
Binary files differ
diff --git a/src/test/camcfgs.py b/src/test/camcfgs.py
new file mode 100644
index 0000000..ef0d5d6
--- /dev/null
+++ b/src/test/camcfgs.py
@@ -0,0 +1,133 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+class CameraTestCfg:
+ def __init__(self, driver, device, unit, fw800, formats, illegalFormat, paramTests,
+ defaultParams):
+ self.driver = driver
+ self.device = device
+ self.unit = unit
+ self.fw800 = fw800
+
+ self.formats = formats
+ self.illegalFormat = illegalFormat
+ self.paramTests = paramTests
+ self.defaultParams = defaultParams
+
+class CameraFormatCfg:
+ def __init__(self, size, pixelformat, framerate):
+ self.size = size
+ self.pixelformat = pixelformat
+ self.framerate = framerate
+
+class ParamTestCfg:
+ def __init__(self, name, testValues, minMedDiff, medMaxDiff):
+ self.name = name
+ self.testValues = testValues
+ self.minMedDiff = minMedDiff
+ self.medMaxDiff = medMaxDiff
+
+DFx31BF03Cfg = CameraTestCfg('firewire', '', -1, False,
+ [CameraFormatCfg((1024,768), 'BAYER8', 30),
+ CameraFormatCfg((1024,768), 'I8', 30),
+ CameraFormatCfg((1024,768), 'YUV422', 15),
+ CameraFormatCfg((1024,768), 'YUV422', 7.5)],
+ CameraFormatCfg((320,240), 'BAYER8', 30),
+ [ParamTestCfg('gain', (180, 800, 1023), 6, 6),
+ ParamTestCfg('camgamma', (10, 16, 22), 15, 15),
+ ParamTestCfg('brightness', (0, 127, 254), 8, 8)],
+ {'gain':300, 'shutter':220, 'saturation':1200, 'camgamma':16,
+ 'brightness':120, 'setWhitebalance':[450, 450]}
+ )
+
+FireflyMV = CameraTestCfg('firewire', '', -1, False,
+ [CameraFormatCfg((640, 480), 'I8', 7.5),
+ CameraFormatCfg((640, 480), 'I8', 15),
+ CameraFormatCfg((640, 480), 'I8', 60),
+ CameraFormatCfg((640, 480), 'I16', 7.5),
+ CameraFormatCfg((640, 480), 'I16', 15),
+ CameraFormatCfg((640, 480), 'I16', 30)],
+ CameraFormatCfg((640, 480), 'I8', 30),
+ [ParamTestCfg('gain', (16, 30, 64), 15, 15),
+ ParamTestCfg('shutter', (1, 150, 531), 50, 20),
+ ParamTestCfg('brightness', (1, 130, 255), 10, 10)],
+ {'gain':16, 'shutter':100, 'brightness':130}
+ )
+
+Dragonfly2 = CameraTestCfg('firewire', '', -1, False,
+ [CameraFormatCfg((640,480), 'RGB', 30),
+ CameraFormatCfg((1024,768), 'I8', 15),
+ CameraFormatCfg((1024,768), 'I16', 15),
+ CameraFormatCfg((1024,768), 'BAYER8', 30),
+ CameraFormatCfg((1024,768), 'YUV422', 7.5)],
+ CameraFormatCfg((123,456), 'RGB', 30),
+ [ParamTestCfg('gain', (0, 346, 683), 10, 30),
+ ParamTestCfg('camgamma', (0, 1278, 4095), 30, 50),
+ ParamTestCfg('brightness', (0, 127, 254), 8, 8)],
+ {'gain':300, 'shutter':220, 'saturation':1200, 'camgamma':1200,
+ 'brightness':120, 'setWhitebalance':[450, 450]}
+ )
+
+Firei = CameraTestCfg('firewire', '', -1, False,
+ [CameraFormatCfg((640,480), 'YUV411', 30),
+ CameraFormatCfg((640,480), 'RGB', 15),
+ CameraFormatCfg((640,480), 'YUV422', 15),
+ CameraFormatCfg((640,480), 'I8', 30),
+ CameraFormatCfg((320,240), 'YUV422', 7.5)],
+ CameraFormatCfg((123,456), 'RGB', 30),
+ #To check: there is something strange with shutter and gain in this camera.
+ [ParamTestCfg('gain', (1, 100, 255), 10, 30),
+ ParamTestCfg('brightness', (128, 255, 383), 8, 8),
+ ParamTestCfg('shutter', (4, 4, 4), 8, 8)],
+ {'gain':87, 'shutter':6, 'brightness':304, 'setWhitebalance':[95, 87]}
+ )
+
+QuickCamProLinux = CameraTestCfg('video4linux', '', -1, False,
+ [CameraFormatCfg((352,288), 'YUYV422', 30),
+ CameraFormatCfg((320,240), 'YUYV422', 15),
+ CameraFormatCfg((176,144), 'YUYV422', 30),
+ CameraFormatCfg((640,480), 'YUYV422', 30)],
+ CameraFormatCfg((123,456), 'I16', 30),
+ [ParamTestCfg('brightness', (0, 127, 254), 40, 50)],
+ {'brightness':-1}
+ )
+
+QuickCamPro9Win = CameraTestCfg('directshow', '', -1, False,
+ [CameraFormatCfg((352,288), 'YUYV422', 30),
+ CameraFormatCfg((320,240), 'YUYV422', 15),
+ CameraFormatCfg((640,480), 'YUYV422', 30),
+ CameraFormatCfg((176,144), 'YUYV422', 30)],
+ CameraFormatCfg((123,456), 'RGB', 30),
+ [ParamTestCfg('brightness', (0, 127, 254), 40, 50)],
+ {'brightness': 60}
+ )
+
+QuickCamProBGRWin = CameraTestCfg('directshow', '', -1, False,
+ [CameraFormatCfg((352,288), 'BGR', 30),
+ CameraFormatCfg((320,240), 'BGR', 15),
+ CameraFormatCfg((640,480), 'BGR', 30),
+ CameraFormatCfg((176,144), 'BGR', 30)],
+ CameraFormatCfg((123,456), 'YUYV422', 30),
+ [ParamTestCfg('brightness', (0, 127, 254), 40, 50)],
+ {'brightness': 60}
+ )
+
diff --git a/src/test/checkcamera.py b/src/test/checkcamera.py
new file mode 100755
index 0000000..936993d
--- /dev/null
+++ b/src/test/checkcamera.py
@@ -0,0 +1,227 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Robert Parcus <betoparcus@gmail.com>
+#
+
+from libavg import *
+import camcfgs
+import optparse
+
+from testcase import *
+
+g_Player = avg.Player.get()
+
+def parseCmdLine():
+ global g_TestParams
+
+ validCameras = ('Dragonfly', 'FireflyMV', 'Firei', 'DFx31BF03', 'QuickCamProLinux',
+ 'QuickCamProBGRWin', 'QuickCamPro9Win')
+ parser = optparse.OptionParser(usage=
+"""%prog cameraname [option].
+A test to check camera features support by libavg. Supported cameras are """
++ str(validCameras))
+# parser.add_argument(dest='camera', action='store', type=str,
+# choices=validCameras, help = 'Select which camera model to test.')
+ parser.add_option('--test-params', '-p', dest='testParams', action='store_true',
+ default=False,
+ help='Execute optional tests for camera params like gain, shutter, etc.')
+ (options, args) = parser.parse_args()
+ g_TestParams = options.testParams
+ if len(args) != 1:
+ parser.error("Must be invoked with camera name as argument")
+ cameraName = args[0]
+ if cameraName == 'Dragonfly':
+ return camcfgs.Dragonfly2
+ elif cameraName == 'FireflyMV':
+ return camcfgs.FireflyMV
+ elif cameraName == 'Firei':
+ return camcfgs.Firei
+ elif cameraName == 'DFx31BF03':
+ return camcfgs.DFx31BF03Cfg
+ elif cameraName == 'QuickCamProLinux':
+ return camcfgs.QuickCamProLinux
+ elif cameraName == 'QuickCamPro9Win':
+ return camcfgs.QuickCamPro9Win
+ elif cameraName == 'QuickCamProBGRWin':
+ return camcfgs.QuickCamProBGRWin
+ else:
+ parser.error("Unknown camera name '" + cameraName + "'.")
+
+class CameraTestCase(AVGTestCase):
+ def __init__(self, cameraCfg, fmt, testFuncName, *testFuncArgs):
+ self.cameraCfg = cameraCfg
+ self.fmt = fmt
+ self.testFuncArgs = testFuncArgs
+ AVGTestCase.__init__(self, testFuncName)
+
+ def testFormat(self):
+ self.__dumpFormat()
+ self.loadEmptyScene()
+ self.__openCamera()
+ self.actions = [None, None]
+ g_Player.setOnFrameHandler(self.__onFrame)
+ g_Player.play()
+ self.assertEqual(self.cam.framenum, 2)
+ self.cam = None
+
+ def testIllegalFormat(self):
+ self.loadEmptyScene()
+ self.assertException(lambda: self.__openCamera())
+
+ def testCreateDelete(self):
+ # Create and delete without ever calling play.
+ self.__openCamera()
+ self.cam.unlink(True)
+
+ def testParams(self):
+ def buildParamActionList(testCfg):
+ actions = []
+ actions.append(setDefaultParams)
+ actions.append(None)
+ for val in testCfg.testValues:
+ actions.append(lambda paramName=testCfg.name, val=val:
+ setCamParam(paramName, val))
+ actions.append(None)
+ actions.append(None)
+ actions.append(None)
+ actions.append(lambda name=testCfg.name: calcCamImgAverage(name))
+ actions.append(lambda testCfg=testCfg: checkCamImageChange(testCfg))
+ return actions
+
+ def setDefaultParams():
+ for (paramName, val) in cameraCfg.defaultParams.iteritems():
+ if paramName == "setWhitebalance":
+ self.cam.setWhitebalance(*val)
+ else:
+ setattr(self.cam, paramName, val)
+
+ def setCamParam(paramName, val):
+ if paramName == 'setwhitebalance':
+ self.cam.setWhitebalance(*val)
+ else:
+ setattr(self.cam, paramName, val)
+
+ def calcCamImgAverage(param):
+ bmp = self.cam.getBitmap()
+ self.camBmps.append(bmp)
+ if isColorParam(param):
+ colour = []
+ colour.append(bmp.getChannelAvg(0))
+ colour.append(bmp.getChannelAvg(1))
+ colour.append(bmp.getChannelAvg(2))
+ self.averages.append(colour)
+ else:
+ self.averages.append(bmp.getAvg())
+
+ def checkCamImageChange(testCfg):
+
+ def saveCamImages():
+ print
+ print "Average image brightnesses: ",minAverages, medAverages, maxAverages
+ dir = AVGTestCase.getImageResultDir()
+ for (i, category) in enumerate(("min", "med", "max")):
+ self.camBmps[i].save(dir+"/cam"+testCfg.name+category+".png")
+
+ minAverages = self.averages[0]
+ medAverages = self.averages[1]
+ maxAverages = self.averages[2]
+ ok = False
+ if isColorParam(testCfg.name):
+ pass
+ else:
+ if minAverages+testCfg.minMedDiff > medAverages:
+ saveCamImages()
+ self.fail()
+ if medAverages+testCfg.medMaxDiff > maxAverages:
+ saveCamImages()
+ self.fail()
+ self.averages = []
+ self.camBmps = []
+
+ def isColorParam(paramName):
+ return paramName in ['saturation', 'setwhitebalance']
+
+ testCfg = self.testFuncArgs[0]
+ print >>sys.stderr, testCfg.name, " ",
+ self.loadEmptyScene()
+ self.__openCamera()
+ self.actions = buildParamActionList(testCfg)
+ g_Player.setOnFrameHandler(self.__onFrame)
+ self.averages = []
+ self.camBmps = []
+ g_Player.play()
+ self.cam = None
+
+ def __openCamera(self):
+ self.cam = avg.CameraNode(driver=self.cameraCfg.driver,
+ device=self.cameraCfg.device, unit=self.cameraCfg.unit,
+ fw800=self.cameraCfg.fw800, framerate=self.fmt.framerate,
+ capturewidth=self.fmt.size[0], captureheight=self.fmt.size[1],
+ pixelformat=self.fmt.pixelformat,
+ parent=g_Player.getRootNode())
+ self.cam.play()
+ self.lastCameraFrame = -1
+ self.assert_(self.cam.isAvailable())
+
+ def __onFrame(self):
+ # We execute one action per camera frame.
+# print self.cam.framenum
+ if self.cam.framenum != self.lastCameraFrame:
+ self.lastCameraFrame += 1
+ if len(self.actions) == self.lastCameraFrame:
+ g_Player.stop()
+ else:
+ action = self.actions[self.lastCameraFrame]
+ if action != None:
+ action()
+
+ def __dumpFormat(self):
+ print >>sys.stderr, str(self.fmt.size)+", "+str(self.fmt.pixelformat)+ \
+ ", "+str(self.fmt.framerate)+" ",
+
+def dumpCameraCfg(cfg):
+ print >>sys.stderr, "Camera config: driver="+cfg.driver+", device="+cfg.device+ \
+ ", unit="+str(cfg.unit)
+
+
+cameraCfg = parseCmdLine()
+AVGTestCase.cleanResultDir()
+suite = unittest.TestSuite()
+dumpCameraCfg(cameraCfg)
+for fmt in cameraCfg.formats:
+ suite.addTest(CameraTestCase(cameraCfg, fmt, "testFormat"))
+suite.addTest(CameraTestCase(cameraCfg, cameraCfg.illegalFormat, "testIllegalFormat"))
+suite.addTest(CameraTestCase(cameraCfg, cameraCfg.formats[0], "testCreateDelete"))
+if g_TestParams:
+ for testCfg in cameraCfg.paramTests:
+ suite.addTest(CameraTestCase(cameraCfg, cameraCfg.formats[0], "testParams",
+ testCfg))
+testRunner = unittest.TextTestRunner(verbosity = 2)
+testResult = testRunner.run(suite)
+
+if testResult.wasSuccessful():
+ exitCode = 0
+else:
+ exitCode = 1
+sys.exit(exitCode)
+
+
diff --git a/src/test/checker.png b/src/test/checker.png
new file mode 100644
index 0000000..4f100c5
--- /dev/null
+++ b/src/test/checker.png
Binary files differ
diff --git a/src/test/checkspeed.py b/src/test/checkspeed.py
new file mode 100755
index 0000000..0f72202
--- /dev/null
+++ b/src/test/checkspeed.py
@@ -0,0 +1,105 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Robert Parcus <betoparcus@gmail.com>
+#
+
+from libavg import *
+import optparse
+import random
+
+g_Player = avg.Player.get()
+
+def parseCmdLine():
+ parser = optparse.OptionParser(usage=
+"""%prog [option].
+Checks libavg performance by creating lots of nodes. Displays a frame time graph, executes for 20 secs and dumps profile statistics at the end of program execution.""")
+ parser.add_option('--use-fx', '-f', dest='useFX', action='store_true', default=False,
+ help='Display everything using a NullFX to test FX overhead.')
+ parser.add_option('--video', '-v', dest='video', action='store_true', default=False,
+ help='Show videos instead of images.')
+ parser.add_option('--create-nodes', '-c', dest='createNodes', action='store_true',
+ default=False,
+ help='Destroy and recreate all nodes every 400 ms.')
+ parser.add_option('--move', '-m', dest='move', action='store_true',
+ default=False,
+ help='Move nodes every frame.')
+ parser.add_option('--vsync', '-s', dest='vsync', action='store_true',
+ default=False,
+ help='Sync output to vertical refresh.')
+ parser.add_option('--num-objs', '-n', dest='numObjs', type='int', default=-1,
+ help='Number of objects to create. Default is 200 images or 40 videos.')
+
+ (options, args) = parser.parse_args()
+
+ return options
+
+
+class SpeedApp(AVGApp):
+ def init(self):
+ self.__createNodes()
+ self._starter.showFrameRate()
+ if options.createNodes:
+ g_Player.setInterval(400, self.__createNodes)
+ g_Player.setTimeout(20000, g_Player.stop)
+ if options.move:
+ g_Player.setOnFrameHandler(self.__moveNodes)
+
+ def __createNodes(self):
+ self.__nodes = []
+ for i in xrange(options.numObjs):
+ pos = (random.randrange(800-64), random.randrange(600-64))
+ if options.video:
+ node = avg.VideoNode(pos=pos, href="../video/testfiles/mpeg1-48x48.mpg",
+ loop=True, parent=self._parentNode)
+ node.play()
+ else:
+ node = avg.ImageNode(pos=pos, href="rgb24alpha-64x64.png",
+ parent=self._parentNode)
+ if options.useFX:
+ node.setEffect(avg.NullFXNode())
+ self.__nodes.append(node)
+ if options.createNodes:
+ g_Player.setTimeout(300, self.__deleteNodes)
+
+ def __deleteNodes(self):
+ for node in self.__nodes:
+ node.unlink(True)
+ self.__nodes = []
+
+ def __moveNodes(self):
+ for node in self.__nodes:
+ node.pos = (random.randrange(800-64), random.randrange(600-64))
+
+
+options = parseCmdLine()
+if not(options.vsync):
+ g_Player.setFramerate(1000)
+if options.numObjs == -1:
+ if options.video:
+ options.numObjs = 40
+ else:
+ options.numObjs = 200
+
+log = avg.Logger.get()
+log.setCategories(log.PROFILE | log.CONFIG | log.WARNING | log.ERROR)
+SpeedApp.start(resolution=(800,600))
+
diff --git a/src/test/colorramp.png b/src/test/colorramp.png
new file mode 100644
index 0000000..da12725
--- /dev/null
+++ b/src/test/colorramp.png
Binary files differ
diff --git a/src/test/crop_bkgd.png b/src/test/crop_bkgd.png
new file mode 100644
index 0000000..89f9e95
--- /dev/null
+++ b/src/test/crop_bkgd.png
Binary files differ
diff --git a/src/test/extrafonts/.svn/entries b/src/test/extrafonts/.svn/entries
new file mode 100644
index 0000000..db28fcb
--- /dev/null
+++ b/src/test/extrafonts/.svn/entries
@@ -0,0 +1,62 @@
+10
+
+dir
+7007
+https://www.libavg.de/svn/branches/release1.7.x/src/test/extrafonts
+https://www.libavg.de/svn
+
+
+
+2009-05-18T18:25:22.096076Z
+3872
+coder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+44470bb9-56e9-0310-a0f8-c586564d3dc6
+
+testaddfontdir.ttf
+file
+
+
+
+
+2011-12-07T12:58:46.191560Z
+f2b76dafe01a3f6316e5aa9d16854d57
+2009-05-18T18:25:22.096076Z
+3872
+coder
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+1736
+
diff --git a/src/test/extrafonts/.svn/prop-base/testaddfontdir.ttf.svn-base b/src/test/extrafonts/.svn/prop-base/testaddfontdir.ttf.svn-base
new file mode 100644
index 0000000..5e9587e
--- /dev/null
+++ b/src/test/extrafonts/.svn/prop-base/testaddfontdir.ttf.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 24
+application/octet-stream
+END
diff --git a/src/test/extrafonts/.svn/text-base/testaddfontdir.ttf.svn-base b/src/test/extrafonts/.svn/text-base/testaddfontdir.ttf.svn-base
new file mode 100644
index 0000000..d57eda6
--- /dev/null
+++ b/src/test/extrafonts/.svn/text-base/testaddfontdir.ttf.svn-base
Binary files differ
diff --git a/src/test/extrafonts/testaddfontdir.ttf b/src/test/extrafonts/testaddfontdir.ttf
new file mode 100644
index 0000000..d57eda6
--- /dev/null
+++ b/src/test/extrafonts/testaddfontdir.ttf
Binary files differ
diff --git a/src/test/fonts/.svn/entries b/src/test/fonts/.svn/entries
new file mode 100644
index 0000000..01974a4
--- /dev/null
+++ b/src/test/fonts/.svn/entries
@@ -0,0 +1,164 @@
+10
+
+dir
+7007
+https://www.libavg.de/svn/branches/release1.7.x/src/test/fonts
+https://www.libavg.de/svn
+
+
+
+2008-06-21T14:08:49.239477Z
+2933
+coder
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+44470bb9-56e9-0310-a0f8-c586564d3dc6
+
+VeraBd.ttf
+file
+
+
+
+
+2011-12-07T12:58:17.713947Z
+4ebf664c986099acf6d151c62bdb24eb
+2008-06-21T14:08:49.239477Z
+2933
+coder
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+58716
+
+VeraBI.ttf
+file
+
+
+
+
+2011-12-07T12:58:17.713947Z
+a99f3482bfc2d9c37b509e68d20d016a
+2008-06-21T14:08:49.239477Z
+2933
+coder
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+63208
+
+VeraIt.ttf
+file
+
+
+
+
+2011-12-07T12:58:17.713947Z
+06ee45608b225ef0f22e94995bc981b2
+2008-06-21T14:08:49.239477Z
+2933
+coder
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+63684
+
+Vera.ttf
+file
+
+
+
+
+2011-12-07T12:58:17.713947Z
+785d2fd45984c6548763ae6702d83e20
+2008-06-21T14:08:49.239477Z
+2933
+coder
+has-props
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+65932
+
diff --git a/src/test/fonts/.svn/prop-base/Vera.ttf.svn-base b/src/test/fonts/.svn/prop-base/Vera.ttf.svn-base
new file mode 100644
index 0000000..5e9587e
--- /dev/null
+++ b/src/test/fonts/.svn/prop-base/Vera.ttf.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 24
+application/octet-stream
+END
diff --git a/src/test/fonts/.svn/prop-base/VeraBI.ttf.svn-base b/src/test/fonts/.svn/prop-base/VeraBI.ttf.svn-base
new file mode 100644
index 0000000..5e9587e
--- /dev/null
+++ b/src/test/fonts/.svn/prop-base/VeraBI.ttf.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 24
+application/octet-stream
+END
diff --git a/src/test/fonts/.svn/prop-base/VeraBd.ttf.svn-base b/src/test/fonts/.svn/prop-base/VeraBd.ttf.svn-base
new file mode 100644
index 0000000..5e9587e
--- /dev/null
+++ b/src/test/fonts/.svn/prop-base/VeraBd.ttf.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 24
+application/octet-stream
+END
diff --git a/src/test/fonts/.svn/prop-base/VeraIt.ttf.svn-base b/src/test/fonts/.svn/prop-base/VeraIt.ttf.svn-base
new file mode 100644
index 0000000..5e9587e
--- /dev/null
+++ b/src/test/fonts/.svn/prop-base/VeraIt.ttf.svn-base
@@ -0,0 +1,5 @@
+K 13
+svn:mime-type
+V 24
+application/octet-stream
+END
diff --git a/src/test/fonts/.svn/text-base/Vera.ttf.svn-base b/src/test/fonts/.svn/text-base/Vera.ttf.svn-base
new file mode 100644
index 0000000..58cd6b5
--- /dev/null
+++ b/src/test/fonts/.svn/text-base/Vera.ttf.svn-base
Binary files differ
diff --git a/src/test/fonts/.svn/text-base/VeraBI.ttf.svn-base b/src/test/fonts/.svn/text-base/VeraBI.ttf.svn-base
new file mode 100644
index 0000000..b55eee3
--- /dev/null
+++ b/src/test/fonts/.svn/text-base/VeraBI.ttf.svn-base
Binary files differ
diff --git a/src/test/fonts/.svn/text-base/VeraBd.ttf.svn-base b/src/test/fonts/.svn/text-base/VeraBd.ttf.svn-base
new file mode 100644
index 0000000..51d6111
--- /dev/null
+++ b/src/test/fonts/.svn/text-base/VeraBd.ttf.svn-base
Binary files differ
diff --git a/src/test/fonts/.svn/text-base/VeraIt.ttf.svn-base b/src/test/fonts/.svn/text-base/VeraIt.ttf.svn-base
new file mode 100644
index 0000000..cc23c9e
--- /dev/null
+++ b/src/test/fonts/.svn/text-base/VeraIt.ttf.svn-base
Binary files differ
diff --git a/src/test/fonts/Vera.ttf b/src/test/fonts/Vera.ttf
new file mode 100644
index 0000000..58cd6b5
--- /dev/null
+++ b/src/test/fonts/Vera.ttf
Binary files differ
diff --git a/src/test/fonts/VeraBI.ttf b/src/test/fonts/VeraBI.ttf
new file mode 100644
index 0000000..b55eee3
--- /dev/null
+++ b/src/test/fonts/VeraBI.ttf
Binary files differ
diff --git a/src/test/fonts/VeraBd.ttf b/src/test/fonts/VeraBd.ttf
new file mode 100644
index 0000000..51d6111
--- /dev/null
+++ b/src/test/fonts/VeraBd.ttf
Binary files differ
diff --git a/src/test/fonts/VeraIt.ttf b/src/test/fonts/VeraIt.ttf
new file mode 100644
index 0000000..cc23c9e
--- /dev/null
+++ b/src/test/fonts/VeraIt.ttf
Binary files differ
diff --git a/src/test/freidrehen.jpg b/src/test/freidrehen.jpg
new file mode 100644
index 0000000..7f93bf0
--- /dev/null
+++ b/src/test/freidrehen.jpg
Binary files differ
diff --git a/src/test/greyscale.png b/src/test/greyscale.png
new file mode 100644
index 0000000..f86a18b
--- /dev/null
+++ b/src/test/greyscale.png
Binary files differ
diff --git a/src/test/illustratorRect.svg b/src/test/illustratorRect.svg
new file mode 100644
index 0000000..37a4a6d
--- /dev/null
+++ b/src/test/illustratorRect.svg
@@ -0,0 +1,7 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
+ <rect id="pos_x5F_rect" x="5" y="15" width="8" height="12" style="fill:rgb(255,0,0);stroke-width:1; stroke:rgb(0,0,255)"/>
+</svg>
+
diff --git a/src/test/image.avg b/src/test/image.avg
new file mode 100644
index 0000000..f2dbace
--- /dev/null
+++ b/src/test/image.avg
@@ -0,0 +1,8 @@
+<avg id="imageavg" width="160" height="120">
+ <image id="testtiles" pos="(0, 30)" size=" ( 65 , 65 ) "
+ opacity="1" href="rgb24-65x65.png" maxtilewidth="16" maxtileheight="32"/>
+ <image id="test" x="64" y="30"
+ opacity="1" href="rgb24-65x65.png" pivot="(0, 0)" angle="0.274"/>
+ <image id="test1" x="129" y="30"
+ opacity="1" href="rgb24-65x65.png"/>
+</avg>
diff --git a/src/test/keyboard_bg.png b/src/test/keyboard_bg.png
new file mode 100644
index 0000000..a767d06
--- /dev/null
+++ b/src/test/keyboard_bg.png
Binary files differ
diff --git a/src/test/keyboard_ovl.png b/src/test/keyboard_ovl.png
new file mode 100644
index 0000000..f3ead71
--- /dev/null
+++ b/src/test/keyboard_ovl.png
Binary files differ
diff --git a/src/test/mask.png b/src/test/mask.png
new file mode 100644
index 0000000..031b39a
--- /dev/null
+++ b/src/test/mask.png
Binary files differ
diff --git a/src/test/mask1.png b/src/test/mask1.png
new file mode 100644
index 0000000..ffe5618
--- /dev/null
+++ b/src/test/mask1.png
Binary files differ
diff --git a/src/test/mask2.png b/src/test/mask2.png
new file mode 100644
index 0000000..92975df
--- /dev/null
+++ b/src/test/mask2.png
Binary files differ
diff --git a/src/test/oe.png b/src/test/oe.png
new file mode 100644
index 0000000..3527967
--- /dev/null
+++ b/src/test/oe.png
Binary files differ
diff --git a/src/test/panoimage.png b/src/test/panoimage.png
new file mode 100644
index 0000000..118b573
--- /dev/null
+++ b/src/test/panoimage.png
Binary files differ
diff --git a/src/test/plugin/ColorNode.cpp b/src/test/plugin/ColorNode.cpp
new file mode 100644
index 0000000..7231c48
--- /dev/null
+++ b/src/test/plugin/ColorNode.cpp
@@ -0,0 +1,163 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Jan Boelsche (regular.gonzales@googlemail.com).
+//
+
+#define AVG_PLUGIN
+#include "../../api.h"
+
+#include "../../player/Player.h"
+#include "../../player/AreaNode.h"
+#include "../../player/NodeDefinition.h"
+
+#include "../../base/Logger.h"
+#include "../../graphics/OGLHelper.h"
+#include "../../wrapper/WrapHelper.h"
+#include "../../wrapper/raw_constructor.hpp"
+
+#include <string>
+#include <iostream>
+#include <sstream>
+#include <iomanip>
+
+using namespace std;
+using namespace boost::python;
+
+namespace avg {
+
+class ColorNode : public AreaNode
+{
+public:
+ static NodeDefinition createNodeDefinition();
+
+ ColorNode(const ArgList& Args);
+
+ void setFillColor(const std::string& sColor);
+ const std::string& getFillColor() const;
+
+ float getFloat() const;
+ void setFloat(float f);
+
+ virtual void maybeRender(const DRect& Rect);
+ virtual void render (const DRect& Rect);
+
+protected:
+ void parseColor(const std::string& sColorSreing);
+
+ std::string m_sFillColorName;
+ float m_r, m_g, m_b;
+ float m_FloatParam;
+};
+
+ColorNode::ColorNode(const ArgList& Args) :
+ m_sFillColorName("FFFFFF")
+{
+ AVG_TRACE(Logger::PLUGIN, "ColorNode c'tor gets Argument fillcolor= " << Args.getArgVal<string>("fillcolor"));
+
+ Args.setMembers(this);
+ AVG_TRACE(Logger::PLUGIN, "ColorNode constructed with " << m_sFillColorName);
+
+ parseColor(m_sFillColorName);
+}
+
+void ColorNode::setFillColor(const string& sFillColor)
+{
+ AVG_TRACE(Logger::PLUGIN, "setFillColor called with " << sFillColor);
+ m_sFillColorName = sFillColor;
+ parseColor(m_sFillColorName);
+}
+
+const std::string& ColorNode::getFillColor() const
+{
+ return m_sFillColorName;
+}
+
+float ColorNode::getFloat() const
+{
+ return m_FloatParam;
+}
+
+void ColorNode::setFloat(float f)
+{
+ m_FloatParam = f;
+}
+
+
+void ColorNode::parseColor(const std::string& sColorSreing)
+{
+ istringstream(sColorSreing.substr(0,2)) >> hex >> m_r;
+ istringstream(sColorSreing.substr(2,2)) >> hex >> m_g;
+ istringstream(sColorSreing.substr(4,2)) >> hex >> m_b;
+}
+
+
+void ColorNode::maybeRender(const DRect& rect)
+{
+ render(rect);
+}
+
+void ColorNode::render(const DRect& rect)
+{
+ //AVG_TRACE(Logger::PLUGIN, "ColorNode::render");
+
+ glClearColor(m_r, m_g, m_b, 1.0);
+ glClear(GL_COLOR_BUFFER_BIT);
+}
+
+char colorNodeName[] = "colornode";
+
+NodeDefinition ColorNode::createNodeDefinition()
+{
+ return NodeDefinition("colornode", Node::buildNode<ColorNode>)
+ .extendDefinition(AreaNode::createDefinition())
+ .addArg(Arg<float>("floatparam", 0.0f, false,
+ offsetof(ColorNode, m_FloatParam)))
+ .addArg(Arg<string>("fillcolor", "0F0F0F", false,
+ offsetof(ColorNode, m_sFillColorName)));
+}
+
+}
+
+using namespace avg;
+
+BOOST_PYTHON_MODULE(colorplugin)
+{
+ class_<ColorNode, bases<AreaNode>, boost::noncopyable>("ColorNode", no_init)
+ .def("__init__", raw_constructor(createNode<colorNodeName>))
+ .add_property("floatparam", &ColorNode::getFloat, &ColorNode::setFloat)
+ .add_property("fillcolor", make_function(&ColorNode::getFillColor,
+ return_value_policy<copy_const_reference>()), &ColorNode::setFillColor);
+}
+
+AVG_PLUGIN_API void registerPlugin()
+{
+ initcolorplugin();
+ object mainModule(handle<>(borrowed(PyImport_AddModule("__builtin__"))));
+ object colorModule(handle<>(PyImport_ImportModule("colorplugin")));
+ mainModule.attr("colorplugin") = colorModule;
+
+ avg::NodeDefinition myNodeDefinition = avg::ColorNode::createNodeDefinition();
+ const char* allowedParentNodeNames[] = {"avg", 0};
+
+ // Register this node type
+ avg::Player::get()->registerNodeType(myNodeDefinition, allowedParentNodeNames);
+}
+
diff --git a/src/test/plugin/Makefile.am b/src/test/plugin/Makefile.am
new file mode 100644
index 0000000..7d2cd34
--- /dev/null
+++ b/src/test/plugin/Makefile.am
@@ -0,0 +1,19 @@
+
+INCLUDES = -I. -I../player \
+ @XML2_CFLAGS@ @PTHREAD_CFLAGS@ @PANGOFT2_CFLAGS@ @PYTHON_INCLUDES@ @DC1394_2_CFLAGS@
+
+ALL_H =
+
+if APPLE
+ XGL_LIBS =
+ EXTRA_LDFLAGS=-read_only_relocs suppress
+else
+ XGL_LIBS = -lXxf86vm
+ EXTRA_LDFLAGS=-XCClinker ../../wrapper/.libs/avg.so
+endif
+
+ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
+
+pkgpyexec_LTLIBRARIES = colorplugin.la
+colorplugin_la_SOURCES = ColorNode.cpp
+colorplugin_la_LDFLAGS = $(EXTRA_LDFLAGS) -module
diff --git a/src/test/plugin/Makefile.in b/src/test/plugin/Makefile.in
new file mode 100644
index 0000000..adac1e9
--- /dev/null
+++ b/src/test/plugin/Makefile.in
@@ -0,0 +1,619 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/test/plugin
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkgpyexecdir)"
+LTLIBRARIES = $(pkgpyexec_LTLIBRARIES)
+colorplugin_la_LIBADD =
+am_colorplugin_la_OBJECTS = ColorNode.lo
+colorplugin_la_OBJECTS = $(am_colorplugin_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+colorplugin_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX \
+ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CXXLD) \
+ $(AM_CXXFLAGS) $(CXXFLAGS) $(colorplugin_la_LDFLAGS) \
+ $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(colorplugin_la_SOURCES)
+DIST_SOURCES = $(colorplugin_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I. -I../player \
+ @XML2_CFLAGS@ @PTHREAD_CFLAGS@ @PANGOFT2_CFLAGS@ @PYTHON_INCLUDES@ @DC1394_2_CFLAGS@
+
+ALL_H =
+@APPLE_FALSE@XGL_LIBS = -lXxf86vm
+@APPLE_TRUE@XGL_LIBS =
+@APPLE_FALSE@EXTRA_LDFLAGS = -XCClinker ../../wrapper/.libs/avg.so
+@APPLE_TRUE@EXTRA_LDFLAGS = -read_only_relocs suppress
+ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
+pkgpyexec_LTLIBRARIES = colorplugin.la
+colorplugin_la_SOURCES = ColorNode.cpp
+colorplugin_la_LDFLAGS = $(EXTRA_LDFLAGS) -module
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/test/plugin/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/test/plugin/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkgpyexecLTLIBRARIES: $(pkgpyexec_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgpyexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgpyexecdir)"
+ @list='$(pkgpyexec_LTLIBRARIES)'; test -n "$(pkgpyexecdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkgpyexecdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkgpyexecdir)"; \
+ }
+
+uninstall-pkgpyexecLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgpyexec_LTLIBRARIES)'; test -n "$(pkgpyexecdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkgpyexecdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkgpyexecdir)/$$f"; \
+ done
+
+clean-pkgpyexecLTLIBRARIES:
+ -test -z "$(pkgpyexec_LTLIBRARIES)" || rm -f $(pkgpyexec_LTLIBRARIES)
+ @list='$(pkgpyexec_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+colorplugin.la: $(colorplugin_la_OBJECTS) $(colorplugin_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(colorplugin_la_LINK) -rpath $(pkgpyexecdir) $(colorplugin_la_OBJECTS) $(colorplugin_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ColorNode.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkgpyexecdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkgpyexecLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkgpyexecLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkgpyexecLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkgpyexecLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkgpyexecLTLIBRARIES \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-pkgpyexecLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/test/rect.svg b/src/test/rect.svg
new file mode 100644
index 0000000..136b061
--- /dev/null
+++ b/src/test/rect.svg
@@ -0,0 +1,8 @@
+<?xml version="1.0" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+
+<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
+ <rect id="rect" x="1" y="1" width="20" height="10" style="fill:rgb(255,0,0);stroke-width:1; stroke:rgb(0,0,255)"/>
+ <rect id="pos_rect" x="5" y="15" width="8" height="12" style="fill:rgb(255,0,0);stroke-width:1; stroke:rgb(0,0,255)"/>
+</svg>
+
diff --git a/src/test/rectborder.png b/src/test/rectborder.png
new file mode 100644
index 0000000..1675688
--- /dev/null
+++ b/src/test/rectborder.png
Binary files differ
diff --git a/src/test/rgb24-32x32.png b/src/test/rgb24-32x32.png
new file mode 100644
index 0000000..c5d6711
--- /dev/null
+++ b/src/test/rgb24-32x32.png
Binary files differ
diff --git a/src/test/rgb24-64x64.png b/src/test/rgb24-64x64.png
new file mode 100644
index 0000000..cca71fe
--- /dev/null
+++ b/src/test/rgb24-64x64.png
Binary files differ
diff --git a/src/test/rgb24-65x65.png b/src/test/rgb24-65x65.png
new file mode 100644
index 0000000..ada2689
--- /dev/null
+++ b/src/test/rgb24-65x65.png
Binary files differ
diff --git a/src/test/rgb24alpha-32x32.png b/src/test/rgb24alpha-32x32.png
new file mode 100644
index 0000000..2e9e6af
--- /dev/null
+++ b/src/test/rgb24alpha-32x32.png
Binary files differ
diff --git a/src/test/rgb24alpha-64x64.png b/src/test/rgb24alpha-64x64.png
new file mode 100644
index 0000000..41b69c3
--- /dev/null
+++ b/src/test/rgb24alpha-64x64.png
Binary files differ
diff --git a/src/test/rgb24alpha.tif b/src/test/rgb24alpha.tif
new file mode 100644
index 0000000..b37829d
--- /dev/null
+++ b/src/test/rgb24alpha.tif
Binary files differ
diff --git a/src/test/shadow.png b/src/test/shadow.png
new file mode 100644
index 0000000..0a4563f
--- /dev/null
+++ b/src/test/shadow.png
Binary files differ
diff --git a/src/test/testapp.py b/src/test/testapp.py
new file mode 100644
index 0000000..e5bc46d
--- /dev/null
+++ b/src/test/testapp.py
@@ -0,0 +1,168 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import unittest
+
+import optparse
+import os
+
+import libavg
+import testcase
+
+
+class TestApp:
+ EXIT_OK = 0
+ EXIT_FAILURE = 1
+
+ def __init__(self):
+ self.__exitOk = TestApp.EXIT_FAILURE
+
+ self.__registeredSuiteFactories = []
+ self.__registerdSuiteFactoriesDict = {}
+
+ self.__suitesToRun = []
+ self.__suitesTestSubsets = []
+
+ self.__testSuite = unittest.TestSuite()
+ self.__optionParser = None
+ self.__commandlineOptions = None
+ self.__player = libavg.avg.Player.get()
+
+ def getSuiteFactory(self, name):
+ return self.__registerdSuiteFactoriesDict[name]
+
+ def isSuiteFactoryRegistered(self, name):
+ return name in self.__registeredSuiteFactories
+
+ def getSuiteFactoryNames(self):
+ return list(self.__registeredSuiteFactories)
+
+ def getSuiteFactories(self):
+ return [ self.__registerdSuiteFactoriesDict[name]
+ for name in self.__registeredSuiteFactories ]
+
+ def registerSuiteFactory(self, name, suite):
+ self.__registeredSuiteFactories.append(name)
+ self.__registerdSuiteFactoriesDict[name] = suite
+
+ def run(self):
+ hasAVGConsoleTest = os.getenv("AVG_CONSOLE_TEST")
+ if hasAVGConsoleTest:
+ self.__runVideoTest()
+ else:
+ self.__setupTestApp()
+ self.__run()
+
+ def exitCode(self):
+ return self.__exitOk
+
+ def __iter__(self):
+ for name in self.__registeredSuiteFactories:
+ yield self.__RegisterdSuitesDict[name]
+
+ def __runVideoTest(self):
+ self.__player.loadFile("image.avg")
+
+ def __run(self):
+ testRunner = unittest.TextTestRunner(verbosity = 2)
+ testcase.AVGTestCase.cleanResultDir()
+ testResult = testRunner.run(self.__testSuite)
+
+ numSkipped = 0
+ for suite in self.__testSuite:
+ for test in suite:
+ if test.skipped():
+ numSkipped += 1
+ print "Skipped", numSkipped, "tests."
+
+ if testResult.wasSuccessful():
+ self.__exitOk = TestApp.EXIT_OK
+
+ def __setupTestApp(self):
+ self.__setupCommandlineParser()
+ self.__parseCommandline()
+ self.__setupGlobalPlayerOptions()
+ self.__dumpConfig()
+ self.__populateTestSuite()
+
+ def __setupGlobalPlayerOptions(self):
+ self.__player.setOGLOptions(self.__commandlineOptions.usepow2textures,
+ self.__commandlineOptions.useshaders,
+ self.__commandlineOptions.usepixelbuffers,
+ 1)
+
+ def __setupCommandlineParser(self):
+ self.__optionParser = optparse.OptionParser(
+ usage = '%prog [options] [<suite> [testcase] [testcase] [...]]')
+
+ self.__optionParser.add_option("--usepow2textures",
+ dest = "usepow2textures",
+ action = 'store_true',
+ default = False,
+ help = "Use power of 2 textures")
+
+ self.__optionParser.add_option("--noshaders",
+ dest = "useshaders",
+ action = 'store_false',
+ default = True,
+ help = "Use shaders")
+
+ self.__optionParser.add_option("--nopixelbuffers",
+ dest = "usepixelbuffers",
+ action = 'store_false',
+ default = True,
+ help = "Use pixel buffers")
+
+ def __parseCommandline(self):
+ self.__commandlineOptions, args = self.__optionParser.parse_args()
+
+ if len(args): # suite
+ suiteFactory = args.pop(0)
+ if not(self.isSuiteFactoryRegistered(suiteFactory)):
+ print "Unknown test suite, registered suites:"
+ for factory in self.getSuiteFactoryNames():
+ print factory
+ print ''
+ self.__optionParser.print_usage()
+
+ self.__suitesToRun.append(self.getSuiteFactory(suiteFactory))
+ self.__suitesTestSubsets = args
+
+ else:
+ self.__suitesToRun = self.getSuiteFactories()
+
+ def __populateTestSuite(self):
+ for suite in self.__suitesToRun:
+ self.__testSuite.addTest(suite(self.__suitesTestSubsets))
+
+ def __dumpConfig(self):
+ log = libavg.avg.Logger.get()
+ log.pushCategories()
+ log.setCategories(log.APP | log.WARNING | log.CONFIG | 0)
+ self.__player.loadString("""
+ <avg id="avg" width="160" height="120">
+ </avg>
+ """)
+ self.__player.setTimeout(0, self.__player.stop)
+ self.__player.setFramerate(10000)
+ self.__player.play()
+ log.popCategories()
diff --git a/src/test/testcase.py b/src/test/testcase.py
new file mode 100644
index 0000000..f9044a3
--- /dev/null
+++ b/src/test/testcase.py
@@ -0,0 +1,327 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import unittest
+
+import sys
+import os
+import math
+
+from libavg import avg
+
+g_HasShaderSupport = None
+
+def almostEqual(a, b, epsilon):
+ try:
+ bOk = True
+ for i in range(len(a)):
+ if not(almostEqual(a[i], b[i], epsilon)):
+ bOk = False
+ return bOk
+ except:
+ return math.fabs(a-b) < epsilon
+
+def flatten(l):
+ ltype = type(l)
+ l = list(l)
+ i = 0
+ while i < len(l):
+ while isinstance(l[i], (list, tuple)):
+ if not l[i]:
+ l.pop(i)
+ i -= 1
+ break
+ else:
+ l[i:i + 1] = l[i]
+ i += 1
+ return ltype(l)
+
+
+class AVGTestCase(unittest.TestCase):
+ imageResultDirectory = "resultimages"
+ baselineImageResultDirectory = "baseline"
+
+ def __init__(self, testFuncName):
+ unittest.TestCase.__init__(self, testFuncName)
+
+ self.__player = avg.Player.get()
+ self.__testFuncName = testFuncName
+ self.__logger = avg.Logger.get()
+ self.__skipped = False
+
+ def __setupPlayer(self):
+ self.__player.setMultiSampleSamples(1)
+ self.__player.setResolution(0, 0, 0, 0)
+
+ @staticmethod
+ def setImageResultDirectory(name):
+ AVGTestCase.imageResultDirectory = name
+
+ @staticmethod
+ def getImageResultDir():
+ return AVGTestCase.imageResultDirectory
+
+ @staticmethod
+ def cleanResultDir():
+ dir = AVGTestCase.getImageResultDir()
+ try:
+ files = os.listdir(dir)
+ for file in files:
+ os.remove(dir+"/"+file)
+ except OSError:
+ try:
+ os.mkdir(dir)
+ except OSError:
+ pass
+
+ @staticmethod
+ def setBaselineImageDirectory(name):
+ AVGTestCase.baselineImageResultDirectory = name
+
+ @staticmethod
+ def getBaselineImageDir():
+ return AVGTestCase.baselineImageResultDirectory
+
+ def start(self, actions):
+ self.__setupPlayer()
+ self.__dumpTestFrames = (os.getenv("AVG_DUMP_TEST_FRAMES") != None)
+ self.__delaying = False
+
+ self.assert_(self.__player.isPlaying() == 0)
+ self.actions = flatten(actions)
+ self.curFrame = 0
+ self.__player.setOnFrameHandler(self.__nextAction)
+ self.__player.setFramerate(10000)
+ self.__player.play()
+ self.assert_(self.__player.isPlaying() == 0)
+
+ def delay(self, time):
+ def timeout():
+ self.__delaying = False
+ self.__delaying = True
+ self.__player.setTimeout(time, timeout)
+
+ def compareImage(self, fileName, warn):
+ bmp = self.__player.screenshot()
+ self.compareBitmapToFile(bmp, fileName, warn)
+
+ def compareBitmapToFile(self, bmp, fileName, warn):
+ try:
+ baselineBmp = avg.Bitmap(AVGTestCase.getBaselineImageDir() + "/" + fileName
+ + ".png")
+ diffBmp = bmp.subtract(baselineBmp)
+ average = diffBmp.getAvg()
+ stdDev = diffBmp.getStdDev()
+ if (average > 0.1 or stdDev > 0.5):
+ if self._isCurrentDirWriteable():
+ bmp.save(AVGTestCase.getImageResultDir() + "/" + fileName + ".png")
+ baselineBmp.save(AVGTestCase.getImageResultDir() + "/" + fileName
+ + "_baseline.png")
+ diffBmp.save(AVGTestCase.getImageResultDir() + "/" + fileName
+ + "_diff.png")
+ if (average > 2 or stdDev > 6):
+ msg = (" "+fileName+
+ ": Difference image has avg=%(avg).2f, std dev=%(stddev).2f"%
+ {'avg':average, 'stddev':stdDev})
+ if warn:
+ print msg
+ else:
+ self.fail(msg)
+ except RuntimeError:
+ bmp.save(AVGTestCase.getImageResultDir()+"/"+fileName+".png")
+ self.__logger.trace(self.__logger.WARNING,
+ "Could not load image "+fileName+".png")
+ raise
+
+ def areSimilarBmps(self, bmp1, bmp2, maxAvg, maxStdDev):
+ diffBmp = bmp1.subtract(bmp2)
+ avg = diffBmp.getAvg()
+ stdDev = diffBmp.getStdDev()
+ return avg <= maxAvg and stdDev <= maxStdDev
+
+ def assertException(self, code):
+ exceptionRaised = False
+ try:
+ code()
+ except:
+ exceptionRaised = True
+ self.assert_(exceptionRaised)
+
+ def assertAlmostEqual(self, a, b, epsilon=0.000001):
+ if not(almostEqual(a, b, epsilon)):
+ msg = "almostEqual: " + str(a) + " != " + str(b)
+ self.fail(msg)
+
+ def loadEmptyScene(self, resolution=(160,120)):
+ self.__player.createMainCanvas(size=resolution)
+ return self.__player.getRootNode()
+
+ def initDefaultImageScene(self):
+ root = self.loadEmptyScene()
+ avg.ImageNode(id="testtiles", pos=(0,30), size=(65,65), href="rgb24-65x65.png",
+ maxtilewidth=16, maxtileheight=32, parent=root)
+ avg.ImageNode(id="test", pos=(64,30), href="rgb24-65x65.png", pivot=(0,0),
+ angle=0.274, parent=root)
+ avg.ImageNode(id="test1", pos=(129,30), href="rgb24-65x65.png", parent=root)
+
+ def fakeClick(self, x, y):
+ helper = self.__player.getTestHelper()
+ helper.fakeMouseEvent(avg.CURSORDOWN, True, False, False, x, y, 1)
+ helper.fakeMouseEvent(avg.CURSORUP, False, False, False, x, y, 1)
+
+ def skip(self, message):
+ sys.stderr.write("skipping: " + str(message) + " ... ")
+ self.__skipped = True
+
+ def skipped(self):
+ return self.__skipped
+
+ def _sendMouseEvent(self, type, x, y):
+ helper = self.__player.getTestHelper()
+ if type == avg.CURSORUP:
+ button = False
+ else:
+ button = True
+ helper.fakeMouseEvent(type, button, False, False, x, y, 1)
+
+ def _sendTouchEvent(self, id, type, x, y):
+ helper = self.__player.getTestHelper()
+ helper.fakeTouchEvent(id, type, avg.TOUCH, avg.Point2D(x, y))
+
+ def _sendTouchEvents(self, eventData):
+ helper = self.__player.getTestHelper()
+ for (id, type, x, y) in eventData:
+ helper.fakeTouchEvent(id, type, avg.TOUCH, avg.Point2D(x, y))
+
+
+ def _isCurrentDirWriteable(self):
+ return bool(os.access('.', os.W_OK))
+
+ def _hasShaderSupport(self):
+ # XXX Duplicated code with FXTest.areFXSupported()
+ def checkShaderSupport():
+ global g_HasShaderSupport
+ g_HasShaderSupport = self.__player.isUsingShaders()
+
+ global g_HasShaderSupport
+ if g_HasShaderSupport == None:
+ self.loadEmptyScene()
+ self.start([checkShaderSupport,])
+ if not(g_HasShaderSupport):
+ self.skip("no shader support")
+ return g_HasShaderSupport
+
+ def __nextAction(self):
+ if not(self.__delaying):
+ if self.__dumpTestFrames:
+ self.__logger.trace(self.__logger.APP, "Frame "+str(self.curFrame))
+ if len(self.actions) == self.curFrame:
+ self.__player.stop()
+ else:
+ action = self.actions[self.curFrame]
+ if action != None:
+ action()
+ self.curFrame += 1
+
+
+def createAVGTestSuite(availableTests, AVGTestCaseClass, testSubset):
+ testNames = []
+ if testSubset:
+ for testName in testSubset:
+ if testName in availableTests:
+ testNames.append(testName)
+ else:
+ print "no test named %s" % testName
+ sys.exit(1)
+ else:
+ testNames = availableTests
+
+ suite = unittest.TestSuite()
+ for testName in testNames:
+ suite.addTest(AVGTestCaseClass(testName))
+
+ return suite
+
+
+class NodeHandlerTester:
+ def __init__(self, testCase, node):
+ self.__testCase=testCase
+ self.reset()
+ self.__node = node
+ self.setHandlers()
+
+ def assertState(self, down, up, over, out, move):
+ self.__testCase.assert_(down == self.__downCalled)
+ self.__testCase.assert_(up == self.__upCalled)
+ self.__testCase.assert_(over == self.__overCalled)
+ self.__testCase.assert_(out == self.__outCalled)
+ self.__testCase.assert_(move == self.__moveCalled)
+ self.__testCase.assert_(not(self.__touchDownCalled))
+ self.reset()
+
+ def reset(self):
+ self.__upCalled=False
+ self.__downCalled=False
+ self.__overCalled=False
+ self.__outCalled=False
+ self.__moveCalled=False
+ self.__touchDownCalled=False
+
+ def setHandlers(self):
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.MOUSE, self.__onDown)
+ self.__node.setEventHandler(avg.CURSORUP, avg.MOUSE, self.__onUp)
+ self.__node.setEventHandler(avg.CURSOROVER, avg.MOUSE, self.__onOver)
+ self.__node.setEventHandler(avg.CURSOROUT, avg.MOUSE, self.__onOut)
+ self.__node.setEventHandler(avg.CURSORMOTION, avg.MOUSE, self.__onMove)
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.TOUCH, self.__onTouchDown)
+
+ def clearHandlers(self):
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.MOUSE, None)
+ self.__node.setEventHandler(avg.CURSORUP, avg.MOUSE, None)
+ self.__node.setEventHandler(avg.CURSOROVER, avg.MOUSE, None)
+ self.__node.setEventHandler(avg.CURSOROUT, avg.MOUSE, None)
+ self.__node.setEventHandler(avg.CURSORMOTION, avg.MOUSE, None)
+ self.__node.setEventHandler(avg.CURSORDOWN, avg.TOUCH, None)
+
+ def __onDown(self, Event):
+ self.__testCase.assert_(Event.type == avg.CURSORDOWN)
+ self.__downCalled = True
+
+ def __onUp(self, Event):
+ self.__testCase.assert_(Event.type == avg.CURSORUP)
+ self.__upCalled = True
+
+ def __onOver(self, Event):
+ self.__testCase.assert_(Event.type == avg.CURSOROVER)
+ self.__overCalled = True
+
+ def __onOut(self, Event):
+ self.__testCase.assert_(Event.type == avg.CURSOROUT)
+ self.__outCalled = True
+
+ def __onMove(self, Event):
+ self.__testCase.assert_(Event.type == avg.CURSORMOTION)
+ self.__moveCalled = True
+
+ def __onTouchDown(self, Event):
+ self.__touchDownCalled = True
+
diff --git a/src/test/testmediadir/mjpeg-48x48.avi b/src/test/testmediadir/mjpeg-48x48.avi
new file mode 100644
index 0000000..d62180a
--- /dev/null
+++ b/src/test/testmediadir/mjpeg-48x48.avi
Binary files differ
diff --git a/src/test/testmediadir/rgb24-64x64a.png b/src/test/testmediadir/rgb24-64x64a.png
new file mode 100644
index 0000000..41b69c3
--- /dev/null
+++ b/src/test/testmediadir/rgb24-64x64a.png
Binary files differ
diff --git a/src/test/widebmp.jpg b/src/test/widebmp.jpg
new file mode 100644
index 0000000..8304e3d
--- /dev/null
+++ b/src/test/widebmp.jpg
Binary files differ
diff --git a/src/utils/Makefile.am b/src/utils/Makefile.am
new file mode 100644
index 0000000..f9e96c7
--- /dev/null
+++ b/src/utils/Makefile.am
@@ -0,0 +1,5 @@
+
+bin_SCRIPTS = avg_audioplayer.py avg_chromakey.py avg_showcamera.py avg_showfile.py \
+ avg_showfont.py avg_videoinfo.py avg_videoplayer.py avg_checkvsync.py \
+ avg_checktouch.py avg_showsvg.py
+pkgpyexec_PYTHON = $(bin_SCRIPTS)
diff --git a/src/utils/Makefile.in b/src/utils/Makefile.in
new file mode 100644
index 0000000..09d062d
--- /dev/null
+++ b/src/utils/Makefile.in
@@ -0,0 +1,536 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/utils
+DIST_COMMON = $(pkgpyexec_PYTHON) $(srcdir)/Makefile.am \
+ $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgpyexecdir)"
+SCRIPTS = $(bin_SCRIPTS)
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+SOURCES =
+DIST_SOURCES =
+py_compile = $(top_srcdir)/py-compile
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+bin_SCRIPTS = avg_audioplayer.py avg_chromakey.py avg_showcamera.py avg_showfile.py \
+ avg_showfont.py avg_videoinfo.py avg_videoplayer.py avg_checkvsync.py \
+ avg_checktouch.py avg_showsvg.py
+
+pkgpyexec_PYTHON = $(bin_SCRIPTS)
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/utils/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/utils/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binSCRIPTS: $(bin_SCRIPTS)
+ @$(NORMAL_INSTALL)
+ test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+ done | \
+ sed -e 'p;s,.*/,,;n' \
+ -e 'h;s|.*|.|' \
+ -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+ if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+ if (++n[d] == $(am__install_max)) { \
+ print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+ else { print "f", d "/" $$4, $$1 } } \
+ END { for (d in files) print "f", d, files[d] }' | \
+ while read type dir files; do \
+ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+ test -z "$$files" || { \
+ echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+ $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+ } \
+ ; done
+
+uninstall-binSCRIPTS:
+ @$(NORMAL_UNINSTALL)
+ @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+ files=`for p in $$list; do echo "$$p"; done | \
+ sed -e 's,.*/,,;$(transform)'`; \
+ test -n "$$list" || exit 0; \
+ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+install-pkgpyexecPYTHON: $(pkgpyexec_PYTHON)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgpyexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgpyexecdir)"
+ @list='$(pkgpyexec_PYTHON)'; dlist=; list2=; test -n "$(pkgpyexecdir)" || list=; \
+ for p in $$list; do \
+ if test -f "$$p"; then b=; else b="$(srcdir)/"; fi; \
+ if test -f $$b$$p; then \
+ $(am__strip_dir) \
+ dlist="$$dlist $$f"; \
+ list2="$$list2 $$b$$p"; \
+ else :; fi; \
+ done; \
+ for file in $$list2; do echo $$file; done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgpyexecdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgpyexecdir)" || exit $$?; \
+ done || exit $$?; \
+ if test -n "$$dlist"; then \
+ if test -z "$(DESTDIR)"; then \
+ PYTHON=$(PYTHON) $(py_compile) --basedir "$(pkgpyexecdir)" $$dlist; \
+ else \
+ PYTHON=$(PYTHON) $(py_compile) --destdir "$(DESTDIR)" --basedir "$(pkgpyexecdir)" $$dlist; \
+ fi; \
+ else :; fi
+
+uninstall-pkgpyexecPYTHON:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgpyexec_PYTHON)'; test -n "$(pkgpyexecdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ test -n "$$files" || exit 0; \
+ filesc=`echo "$$files" | sed 's|$$|c|'`; \
+ fileso=`echo "$$files" | sed 's|$$|o|'`; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$files ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$files || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$filesc ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$filesc || exit $$?; \
+ echo " ( cd '$(DESTDIR)$(pkgpyexecdir)' && rm -f" $$fileso ")"; \
+ cd "$(DESTDIR)$(pkgpyexecdir)" && rm -f $$fileso
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS)
+installdirs:
+ for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(pkgpyexecdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+ -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binSCRIPTS install-pkgpyexecPYTHON
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binSCRIPTS uninstall-pkgpyexecPYTHON
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+ distclean distclean-generic distclean-libtool distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-binSCRIPTS install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkgpyexecPYTHON install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+ ps ps-am uninstall uninstall-am uninstall-binSCRIPTS \
+ uninstall-pkgpyexecPYTHON
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/utils/avg_audioplayer.py b/src/utils/avg_audioplayer.py
new file mode 100755
index 0000000..3f587a6
--- /dev/null
+++ b/src/utils/avg_audioplayer.py
@@ -0,0 +1,51 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import sys
+from libavg import avg, AVGApp
+import time
+
+g_Player = avg.Player.get()
+
+def onFrame():
+ curTime = node.getCurTime()
+ g_Player.getElementByID("curtime").text = "Time: "+str(curTime/1000.0)
+
+class AudioPlayer(AVGApp):
+ def init(self):
+ global node
+ self._parentNode.appendChild(node)
+ avg.WordsNode(parent=self._parentNode, id="curtime", pos=(10, 22),
+ font="arial", fontsize=10)
+
+ g_Player.setOnFrameHandler(onFrame)
+
+
+if len(sys.argv) ==1:
+ print "Usage: avg_audioplayer.py <filename>"
+ sys.exit(1)
+
+node = avg.SoundNode(href=sys.argv[1])
+node.play()
+AudioPlayer.start(resolution=(320,200))
+
diff --git a/src/utils/avg_checktouch.py b/src/utils/avg_checktouch.py
new file mode 100755
index 0000000..35b40da
--- /dev/null
+++ b/src/utils/avg_checktouch.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from libavg import *
+
+g_player = avg.Player.get()
+
+class TouchApp(AVGApp):
+ multitouch = True
+
+ def init(self):
+ self._parentNode.connectEventHandler(avg.CURSORDOWN, avg.MOUSE|avg.TOUCH, self,
+ self.__onDown)
+ self.getStarter().setTouchVisualization(apphelpers.TouchVisualization)
+
+ def __onDown(self, event):
+# if event.source == avg.MOUSE:
+# print event.type, event.button
+# else:
+# print event.type
+ if (event.contact):
+ event.contact.connectListener(self.__onContact, self.__onContact)
+ contact = event.contact
+# print "new contact: ", contact.id, event.pos, contact.age, \
+# contact.distancefromstart, contact.motionangle, contact.motionvec, \
+# contact.distancetravelled
+
+ def __onContact(self, event):
+ contact = event.contact
+# print event.type, contact.id, event.pos, contact.age, \
+# contact.distancefromstart, contact.motionangle, contact.motionvec, \
+# contact.distancetravelled, event.speed
+
+TouchApp.start(resolution=(1280,800))
+
diff --git a/src/utils/avg_checkvsync.py b/src/utils/avg_checkvsync.py
new file mode 100755
index 0000000..576c59a
--- /dev/null
+++ b/src/utils/avg_checkvsync.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+# Original author of this file is Robert Parcus <betoparcus@gmail.com>
+#
+
+from libavg import *
+
+g_Player = avg.Player.get()
+
+class VSyncApp(AVGApp):
+
+ def init(self):
+ self.__line = avg.LineNode(pos1=(0,0), pos2=(0,1199), color="FFFFFF",
+ parent=self._parentNode)
+ self.__x = 0
+ g_Player.setOnFrameHandler(self.onFrame)
+
+ def onFrame(self):
+ self.__x += 1
+ if self.__x == 800:
+ self.__x = 0
+ self.__line.pos1 = (self.__x, 0)
+ self.__line.pos2 = (self.__x, 599)
+
+VSyncApp.start(resolution=(800,600))
diff --git a/src/utils/avg_chromakey.py b/src/utils/avg_chromakey.py
new file mode 100755
index 0000000..7676c58
--- /dev/null
+++ b/src/utils/avg_chromakey.py
@@ -0,0 +1,246 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import optparse
+from libavg import avg, AVGApp
+from libavg.ui import button
+from libavg import parsecamargs
+
+GUI_SIZE=(300, 200)
+
+g_Player = avg.Player.get()
+
+class Slider(avg.DivNode):
+ def __init__(self, width, min, max, onChange, **kwargs):
+ avg.DivNode.__init__(self, **kwargs)
+ self.__onChange = onChange
+ self.size = (width, 20)
+ self.__min = min
+ self.__max = max
+ self.__val = min
+ avg.LineNode(pos1=(7,14), pos2=(width-7,14), color="FFFFFF", strokewidth=2,
+ parent=self)
+ self.__slider = avg.DivNode(pos=(0,0), size=(14,20), parent=self)
+ avg.PolygonNode(pos=((1,0), (13,0), (7,18)), fillopacity=1, fillcolor="FFFFFF",
+ color="808080", parent=self.__slider)
+ self.__slider.setEventHandler(avg.CURSORDOWN, avg.MOUSE,
+ self.__onSliderDown)
+ self.setEventHandler(avg.CURSORDOWN, avg.MOUSE, self.__onBarDown)
+ self.__isDragging = False
+
+ def getVal(self):
+ return self.__val
+
+ def setVal(self, val):
+ self.__val = val
+ self.__positionSlider()
+
+ val = property(getVal, setVal)
+
+ def __onSliderDown(self, event):
+ self.__slider.setEventCapture()
+ self.__slider.setEventHandler(avg.CURSORMOTION, avg.MOUSE, self.__onSliderMove)
+ self.__slider.setEventHandler(avg.CURSORUP, avg.MOUSE, self.__onSliderUp)
+ self.__sliderDownPos = event.pos
+ self.__isDragging = True
+ self.__dragStartVal = self.__val
+
+ def __onSliderMove(self, event):
+ numPixelsMoved = float(event.pos.x-self.__sliderDownPos.x)
+ self.__val = (self.__dragStartVal+numPixelsMoved/(self.size.x-14)
+ *(self.__max-self.__min))
+ self.__positionSlider()
+
+ def __onSliderUp(self, event):
+ self.__onSliderMove(event)
+ self.__slider.releaseEventCapture()
+ self.__slider.setEventHandler(avg.CURSORMOTION, avg.MOUSE, None)
+ self.__slider.setEventHandler(avg.CURSORUP, avg.MOUSE, None)
+ self.__isDragging = False
+
+ def __onBarDown(self, event):
+ if not(self.__isDragging):
+ localPos = self.getRelPos(event.pos)
+ ratio = (localPos.x-7)/(self.size.x-14)
+ self.__val = self.__min+ratio*(self.__max-self.__min)
+ print localPos, ", ", ratio, ", ", self.__val
+ self.__positionSlider()
+
+ def __positionSlider(self):
+ if self.__val < self.__min:
+ self.__val = self.__min
+ elif self.__val > self.__max:
+ self.__val = self.__max
+ ratio = ((self.__val-self.__min)/(self.__max-self.__min))
+ self.__slider.pos = (ratio*(self.size.x-14), 0)
+ self.__onChange()
+
+
+class FXSlider(avg.DivNode):
+ def __init__(self, row, min, max, fxNode, fxAttrName, caption, isInt, **kwargs):
+ avg.DivNode.__init__(self, **kwargs)
+ avg.RectNode(pos=(0,8), size=(280,38), color="808080", strokewidth=2,
+ parent=self)
+ textBgRect = avg.RectNode(pos=(8,2), fillcolor="000000", fillopacity=1,
+ strokewidth=0, parent=self)
+ caption = avg.WordsNode(pos=(10,0), text=caption, parent=self)
+ textBgRect.size = caption.getMediaSize()+(4, 2)
+ self.__words = avg.WordsNode(pos=(240,23), parent=self)
+ self.__slider = Slider(220, min, max, self.__onSliderMove, pos=(15,20),
+ parent=self)
+ self.pos = (0, row*46)
+ self.__fxNode = fxNode
+ self.__fxAttrName = fxAttrName
+ self.__caption = caption
+ self.__isInt = isInt
+ self.__slider.val = getattr(self.__fxNode, fxAttrName)
+
+ def __onSliderMove(self):
+ if self.__isInt:
+ setattr(self.__fxNode, self.__fxAttrName, int(self.__slider.val))
+ self.__words.text = "%i"%self.__slider.val
+ else:
+ setattr(self.__fxNode, self.__fxAttrName, self.__slider.val)
+ self.__words.text = "%.2f"%self.__slider.val
+
+
+class TextButton(button.Button):
+ def __init__(self, text, **kwargs):
+ size = kwargs["size"]
+ upNode = avg.DivNode()
+ avg.RectNode(size=size, fillcolor="FFFFFF", fillopacity=1, color="FFFFFF",
+ parent=upNode)
+ avg.WordsNode(pos=(4,3), text=text, color="000000", parent=upNode)
+ downNode = avg.DivNode()
+ avg.RectNode(size=size, fillcolor="000000", fillopacity=1, color="FFFFFF",
+ parent=downNode)
+ avg.WordsNode(pos=(4,3), text=text, color="FFFFFF", parent=downNode)
+ kwargs["upNode"] = upNode
+ kwargs["downNode"] = downNode
+ button.Button.__init__(self, **kwargs)
+
+
+def colorToString(colorTuple):
+ s = "%02X%02X%02X"%colorTuple[:-1]
+ return s
+
+class Chromakey(AVGApp):
+ def init(self):
+ avg.RectNode(size=(options.width,options.height), fillcolor="FF0000",
+ fillopacity=1, strokewidth=0, parent=self._parentNode)
+ self.__camNode = avg.CameraNode(driver=options.driver, device=options.device,
+ unit=options.unit, fw800=options.fw800,
+ capturewidth=options.width, captureheight=options.height,
+ pixelformat=options.pixelFormat, framerate=options.framerate,
+ width=options.width, height=options.height, parent=self._parentNode)
+ self.__camNode.play()
+ self.__filter = avg.ChromaKeyFXNode()
+ self.__camNode.setEffect(self.__filter)
+ self.__filter.color = "0000FF"
+ self.__filter.htolerance = 0.05
+ self.__filter.stolerance = 1.0
+ self.__filter.ltolerance = 1.0
+ self.__filter.softness = 0.0
+
+ self.__createGUI()
+
+ def __createGUI(self):
+ self.__guiDiv = avg.DivNode(pos=(options.width+10,10), parent=self._parentNode)
+
+ self.__colorWords = avg.WordsNode(pos=(0,14), parent=self.__guiDiv)
+ self.__colorWords.text = "Key Color: "+self.__filter.color
+ self.__colorRect = avg.RectNode(pos=(200,12), size=(20, 20),
+ fillcolor=self.__filter.color, fillopacity=1,
+ color="FFFFFF", parent=self.__guiDiv)
+ self.__camNode.setEventHandler(avg.CURSORDOWN, avg.MOUSE,
+ self.__onColorDown)
+
+ FXSlider(1, 0.0, 1.0, self.__filter, "htolerance", "Hue Tolerance",
+ False, parent=self.__guiDiv)
+ FXSlider(2, 0.0, 1.0, self.__filter, "stolerance", "Saturation Tolerance",
+ False, parent=self.__guiDiv)
+ FXSlider(3, 0.0, 1.0, self.__filter, "ltolerance", "Lightness Tolerance",
+ False, parent=self.__guiDiv)
+ FXSlider(4, 0.0, 1.0, self.__filter, "softness", "Softness",
+ False, parent=self.__guiDiv)
+ FXSlider(5, 0, 8, self.__filter, "erosion", "Erosion",
+ True, parent=self.__guiDiv)
+ FXSlider(6, 0.0, 1.0, self.__filter, "spillthreshold", "Spill Suppression",
+ False, parent=self.__guiDiv)
+
+ TextButton(pos=(0,332), text="Whitebalance", size=(100,22),
+ clickHandler=self.__onWhitebalance, parent=self.__guiDiv)
+ TextButton(pos=(110,332), text="Dump Config", size=(100,22),
+ clickHandler=self.__dumpConfig, parent=self.__guiDiv)
+
+ FXSlider(9, 0, 500, self.__camNode, "shutter", "Shutter",
+ True, parent=self.__guiDiv)
+ FXSlider(10, 128, 1023, self.__camNode, "gain", "Gain",
+ True, parent=self.__guiDiv)
+
+
+ def __onColorDown(self, event):
+ pos = self.__camNode.getRelPos(event.pos)
+ bmp = self.__camNode.getBitmap()
+ color = bmp.getPixel(pos)
+ colorString = colorToString(color)
+ self.__filter.color = colorString
+ self.__colorWords.text = "Key Color: "+colorString
+ self.__colorRect.fillcolor = colorString
+
+ def __onWhitebalance(self, event):
+ self.__camNode.setWhitebalance(
+ self.__camNode.getWhitebalanceU(), self.__camNode.getWhitebalanceV())
+ self.__camNode.doOneShotWhitebalance()
+
+ def __dumpConfig(self, event):
+ print "Camera:"
+ print " device=", self.__camNode.device
+ print " shutter=", self.__camNode.shutter
+ print " gain=", self.__camNode.gain
+ print " White Balance: (u=", self.__camNode.getWhitebalanceU(), ", v=", \
+ self.__camNode.getWhitebalanceV()
+
+ print "Chromakey:"
+ print " color=", self.__filter.color
+ print " htolerance=", self.__filter.htolerance
+ print " stolerance=", self.__filter.stolerance
+ print " ltolerance=", self.__filter.ltolerance
+ print " softness=", self.__filter.softness
+ print " erosion=", self.__filter.erosion
+ print " spillthreshold=", self.__filter.spillthreshold
+
+parser = optparse.OptionParser()
+parsecamargs.addOptions(parser)
+
+(options, args) = parser.parse_args()
+if options.driver is None:
+ parser.print_help()
+ print
+ print "ERROR: at least '--driver' must be specified"
+ exit()
+
+resolution=(GUI_SIZE[0]+options.width, max(GUI_SIZE[1],options.height))
+
+Chromakey.start(resolution=resolution)
+
diff --git a/src/utils/avg_showcamera.py b/src/utils/avg_showcamera.py
new file mode 100755
index 0000000..817d80d
--- /dev/null
+++ b/src/utils/avg_showcamera.py
@@ -0,0 +1,165 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import optparse
+import time
+from libavg import avg
+from libavg import parsecamargs
+
+def checkCamera():
+ if not(camNode.isAvailable()):
+ Log.trace(Log.APP, "Could not open camera")
+ exit(1)
+
+
+def onKey(event):
+ def addWhitebalance(du = 0, dv = 0):
+ camNode.setWhitebalance(camNode.getWhitebalanceU() + du,
+ camNode.getWhitebalanceV() + dv)
+ print "u:", camNode.getWhitebalanceU(), "v:", camNode.getWhitebalanceV()
+
+ def addGain(gain):
+ camNode.gain += gain
+ print "gain:", camNode.gain
+
+ def addShutter(shutter):
+ camNode.shutter += shutter
+ print "shutter:", camNode.shutter
+
+ if event.keystring == "w":
+ print "Setting Whitebalance"
+ camNode.doOneShotWhitebalance()
+
+ elif event.keystring == "1":
+ addWhitebalance(du = -1)
+
+ elif event.keystring == "2":
+ addWhitebalance(du = 1)
+
+ elif event.keystring == "3":
+ addWhitebalance(dv = -1)
+
+ elif event.keystring == "4":
+ addWhitebalance(dv = 1)
+
+ elif event.keystring == "s":
+ print "Saving camera image to camimage.png"
+ camNode.getBitmap().save("camimage.png")
+
+ elif event.keystring == "left":
+ addShutter(shutter = -1)
+
+ elif event.keystring == "right":
+ addShutter(shutter = 1)
+
+ elif event.keystring == "up":
+ addGain(gain = 1)
+
+ elif event.keystring == "down":
+ addGain(gain = -1)
+
+curFrame = 0
+
+def updateFrameDisplay(node):
+ global curFrame
+ curFrame += 1
+ node.text = "%(cam)d/%(player)d"%{"cam":camNode.framenum, "player":curFrame}
+
+parser = optparse.OptionParser()
+parsecamargs.addOptions(parser)
+parser.add_option("-l", "--dump", dest="dump", action="store_true", default=False,
+ help="dump a list of detected cameras")
+parser.add_option("-s", "--noinfo", dest="noinfo", action="store_true", default=False,
+ help="don't show any info overlayed on the screen")
+parser.add_option("-r", "--resetbus", dest="resetbus", action="store_true", default=False,
+ help="reset the firewire bus.")
+
+(options, args) = parser.parse_args()
+
+if options.driver is None and not options.dump and not options.resetbus:
+ parser.print_help()
+ print
+ print "Keys available when image is being displayed:"
+ print " w: Execute whitebalance."
+ print " 1/2: Decrease/Increase whitebalance u."
+ print " 3/4: Decrease/Increase whitebalance v."
+ print " s: Take screenshot."
+ print
+ print "ERROR: at least '--driver', '--dump' or '--resetbus' options must be specified"
+ exit()
+
+optdict = {}
+for attr in dir(options):
+ if attr[0] != '_':
+ optdict[attr] = eval("options.%s" %attr)
+
+Log = avg.Logger.get()
+
+Player = avg.Player.get()
+
+Player.loadString("""
+<?xml version="1.0"?>
+<!DOCTYPE avg SYSTEM "../../doc/avg.dtd">
+<avg width="%(width)d" height="%(height)d">
+</avg>
+""" %optdict)
+Player.getRootNode().setEventHandler(avg.KEYDOWN, avg.NONE, onKey)
+
+if options.dump:
+ avg.CameraNode.dumpCameras()
+ exit(0)
+
+if options.resetbus:
+ Log.trace(Log.APP, "Resetting firewire bus.")
+ avg.CameraNode.resetFirewireBus()
+ time.sleep(1)
+ if not options.driver:
+ exit(0)
+
+Log.trace(Log.APP, "Creating camera:")
+Log.trace(Log.APP, "driver=%(driver)s device=%(device)s" %optdict)
+Log.trace(Log.APP, "width=%(width)d height=%(height)d pixelformat=%(pixelFormat)s"
+ %optdict)
+Log.trace(Log.APP, "unit=%(unit)d framerate=%(framerate)d fw800=%(fw800)s" %optdict)
+
+camNode = Player.createNode("camera",
+ {"driver": options.driver, "device": options.device, "unit": options.unit,
+ "fw800": options.fw800,
+ "capturewidth": options.width, "captureheight": options.height,
+ "pixelformat": options.pixelFormat, "framerate": options.framerate,
+ "width": options.width, "height": options.height})
+
+Player.getRootNode().appendChild(camNode)
+
+if not options.noinfo:
+ infoText = "Driver=%(driver)s (dev=%(device)s unit=%(unit)d) %(width)dx%(height)d@%(framerate)f" %optdict
+ avg.WordsNode(text=infoText, color="ff3333", pos=(5,5), fontsize=14,
+ parent=Player.getRootNode())
+ frameText = avg.WordsNode(color="ff3333", pos=(5,25), fontsize=14,
+ parent=Player.getRootNode())
+ Player.setOnFrameHandler(lambda:updateFrameDisplay(frameText))
+
+camNode.play()
+Player.setTimeout(100, checkCamera)
+Player.play()
+
diff --git a/src/utils/avg_showfile.py b/src/utils/avg_showfile.py
new file mode 100755
index 0000000..3890584
--- /dev/null
+++ b/src/utils/avg_showfile.py
@@ -0,0 +1,40 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import sys
+from libavg import avg
+import time
+
+Player = avg.Player.get()
+
+if len(sys.argv) ==1:
+ print
+ print "Usage: avg_showfile.py <avgfile>"
+ print
+ sys.exit(1)
+
+Player.loadFile(sys.argv[1])
+Player.setVBlankFramerate(1)
+Player.play()
+
+
diff --git a/src/utils/avg_showfont.py b/src/utils/avg_showfont.py
new file mode 100755
index 0000000..23bf9ac
--- /dev/null
+++ b/src/utils/avg_showfont.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import sys
+from libavg import avg
+import time
+
+Player = avg.Player.get()
+
+Player.loadString("""
+<?xml version="1.0"?>
+<!DOCTYPE avg SYSTEM "../../doc/avg.dtd">
+<avg width="640" height="480">
+</avg>
+""")
+if len(sys.argv) ==1:
+ print "Available fonts: "
+ fontList = avg.WordsNode.getFontFamilies()
+ print fontList
+ print
+ print "Usage: showfont.py <fontname> [<text>]"
+ print
+ print " Shows all available variants of a font. If <text> is given, displays the"
+ print " text. If <fontname> is not given, dumps a list of all fonts available."
+ sys.exit(1)
+else:
+ fontname=sys.argv[1]
+ if len(sys.argv) > 2:
+ displayText=sys.argv[2]
+ else:
+ displayText=""
+variants = avg.WordsNode.getFontVariants(fontname)
+print variants
+rootNode = Player.getRootNode()
+y = 10
+for variant in variants:
+ if displayText == "":
+ text = fontname+": "+variant
+ else:
+ text = displayText
+ node = Player.createNode("words",
+ { "text": text,
+ "font": fontname,
+ "variant": variant,
+ "fontsize": 24,
+ "x": 10,
+ "y": y
+ })
+ rootNode.appendChild(node)
+ y += 50
+Player.setVBlankFramerate(1)
+Player.play()
+
+
diff --git a/src/utils/avg_showsvg.py b/src/utils/avg_showsvg.py
new file mode 100755
index 0000000..0c16b27
--- /dev/null
+++ b/src/utils/avg_showsvg.py
@@ -0,0 +1,58 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import optparse
+import sys
+
+from libavg import avg, AVGApp
+
+g_player = avg.Player.get()
+g_log = avg.Logger.get()
+
+parser = optparse.OptionParser("Usage: %prog <svgFileName> <elementID> [options]")
+parser.add_option("-s", "--size", action="store", type="float", dest="size", default=1,
+ help="Specify a factor for the size of the element.")
+parser.add_option("--save-image", action="store_true", dest="saveImage", default=False,
+ help="Save the image rendered to a png file.")
+
+(options, args) = parser.parse_args()
+if len(args) < 2:
+ parser.print_help()
+ sys.exit(1)
+svgFName = args[0]
+svgID = args[1]
+
+class ShowSVG(AVGApp):
+ def init(self):
+ self.svg = avg.SVG(svgFName, True)
+ img = self.svg.createImageNode(svgID, {"pos":(1,1), "parent":self._parentNode},
+ options.size)
+ rect = avg.RectNode(fillcolor="808080", color="FFFFFF", fillopacity=1,
+ pos=(0.5, 0.5), size=img.size+(1,1))
+ self._parentNode.insertChild(rect, 0)
+ if options.saveImage:
+ bmp = self.svg.renderElement(svgID, options.size)
+ bmp.save(svgID+".png")
+
+if __name__ == '__main__':
+ ShowSVG.start(resolution=(1024, 768))
+
diff --git a/src/utils/avg_videoinfo.py b/src/utils/avg_videoinfo.py
new file mode 100755
index 0000000..41fb51d
--- /dev/null
+++ b/src/utils/avg_videoinfo.py
@@ -0,0 +1,219 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+from optparse import OptionParser, OptionValueError
+import sys, traceback
+from libavg import avg
+import time
+from xml.dom import minidom
+from xml import dom
+import os
+
+parser = OptionParser("usage: %prog <videofilename> [options]")
+parser.add_option("-x", "--xml", dest = "xml", action="store_true",
+ help = "Set to enable output as xml")
+parser.add_option("-c", "--csv", dest = "csv", action="store_true",
+ help = "Set to enable output as csv")
+options, args = parser.parse_args()
+
+Player = avg.Player.get()
+
+Player.loadString("""
+ <?xml version="1.0"?>
+ <!DOCTYPE avg SYSTEM "../../doc/avg.dtd">
+ <avg width="1280" height="720">
+ <video id="video" x="0" y="0" threaded="true"/>
+ </avg>
+""")
+node = Player.getElementByID("video")
+impl = minidom.getDOMImplementation()
+doc = impl.createDocument(None, "videodict", None)
+rootElement = doc.documentElement
+CSV_video = ''
+VideoList = []
+len_filename = 0
+
+def appendXMLChild(node):
+ node.play()
+ videoinfo = doc.createElement("videoinfo")
+ videoinfo.setAttribute("file", node.href)
+ videoinfo.setAttribute("duration", str(node.getDuration()/1000.))
+ videoinfo.setAttribute("bitrate", str(node.getBitrate()))
+ rootElement.appendChild(videoinfo)
+ videoNode = doc.createElement("video")
+ videoNode.setAttribute("codec", node.getVideoCodec())
+ videoNode.setAttribute("size", str(node.getMediaSize()))
+ videoNode.setAttribute("pixelformat", node.getStreamPixelFormat())
+ videoNode.setAttribute("fps", str(node.fps))
+ videoinfo.appendChild(videoNode)
+ if node.hasAudio():
+ audioNode = doc.createElement("audio")
+ audioNode.setAttribute("codec", node.getAudioCodec())
+ audioNode.setAttribute("samplerate", str(node.getAudioSampleRate()))
+ audioNode.setAttribute("channels", str(node.getNumAudioChannels()))
+ videoinfo.appendChild(audioNode)
+
+def singleVideoInfo(node):
+ node.play()
+ print "File: " + node.href
+ print ("Duration: " + str(node.getDuration()/1000.) + " s ("
+ + str(node.getNumFrames()) + " frames)")
+ print "Bitrate: " + str(node.getBitrate()) + " b/s"
+ print "Video stream: "
+ print " Codec: " + node.getVideoCodec()
+ print " Size: " + str(node.getMediaSize()) + " pixels"
+ print " Pixel format: " + node.getStreamPixelFormat()
+ print " FPS: " + str(node.fps)
+ if node.hasAudio():
+ print "Audio stream: "
+ print " Codec: " + node.getAudioCodec()
+ print " Sample rate: " + str(node.getAudioSampleRate()) + " Hz"
+ print " Number of channels: " + str(node.getNumAudioChannels())
+
+def CSVtable(node):
+ global CSV_video
+
+ node.play()
+ if CSV_video == '':
+ CSV_head = ("File\tDuration\tBitrate\tVideoCodec\t" + \
+ "VideoSize\tPixel format\tFPS\tAudioCodec\t" + \
+ "Audio Sample rate\t Audio channels"+"\n")
+ CSV_video = CSV_head
+ CSV_video += \
+ str(node.href)+'\t'+\
+ str(node.getDuration()/1000.) + " s (" + str(node.getNumFrames()) + \
+ " frames)"+'\t'+\
+ str(node.getBitrate()) + " b/s" + '\t' + \
+ str(node.getVideoCodec()) + '\t' + \
+ str(node.getMediaSize()) + " pixels" + '\t' + \
+ str(node.getStreamPixelFormat()) + '\t' + \
+ str(node.fps) + '\t'
+ if node.hasAudio():
+ CSV_video += \
+ str(node.getAudioCodec()) + '\t' + \
+ str(node.getAudioSampleRate()) + " Hz" + '\t' + \
+ str(node.getNumAudioChannels()) + '\n'
+ else:
+ CSV_video += ' \t \t \n'
+
+def showInfo(node):
+ global len_filename
+ node.play()
+ if node.hasAudio():
+ vFile = os.path.basename(node.href).ljust(len_filename+2)
+ vDuration = str(node.getDuration()/1000.).ljust(12)
+ vBitrate = str(node.getBitrate()).ljust(15)
+ vVideoCodec = str(node.getVideoCodec()).ljust(13)
+ vVideoSize = str(node.getMediaSize()).ljust(11)
+ vPixel = str(node.getStreamPixelFormat()).ljust(14)
+ vFPS = str(round(node.fps, 2)).ljust(10)
+ vAudioCodec = str(node.getAudioCodec()).ljust(12)
+ vSampleRate = str(node.getAudioSampleRate()).ljust(13)
+ vChannels = str(node.getNumAudioChannels()).ljust(8)
+
+ info = vFile + vDuration + vVideoCodec + vVideoSize + vPixel + vFPS + vAudioCodec + vSampleRate + vChannels
+
+ print info
+ else:
+ vFile = os.path.basename(node.href).ljust(len_filename+2)
+ vDuration = str(node.getDuration()/1000.).ljust(12)
+ vBitrate = str(node.getBitrate()).ljust(15)
+ vVideoCodec = str(node.getVideoCodec()).ljust(13)
+ vVideoSize = str(node.getMediaSize()).ljust(11)
+ vPixel = str(node.getStreamPixelFormat()).ljust(14)
+ vFPS = str(round(node.fps,2)).ljust(10)
+ vAudioCodec = "".ljust(12)
+ vSampleRate = "".ljust(13)
+ vChannels = "".ljust(8)
+
+ info = vFile + vDuration + vVideoCodec + vVideoSize + vPixel + vFPS + vAudioCodec + vSampleRate + vChannels
+
+ print info
+
+
+
+if len(sys.argv) ==1:
+ parser.print_help()
+ sys.exit(1)
+
+if len(args) == 1:
+ node.href = sys.argv[1]
+ if options.xml:
+ appendXMLChild(node)
+ print doc.toprettyxml(indent=" ",encoding="utf-8")
+ elif options.csv:
+ CSVtable(node)
+ print CSV_video
+ else:
+ singleVideoInfo(node)
+
+else:
+ for file in args:
+ try:
+ node.href = str(os.path.abspath(str(file)))
+ #node.href = str(os.path.join(os.path.normpath(os.getcwd() + "/" +str(file))))
+ node.play()
+ VideoList.append(node.href)
+ except:
+ sys.stderr.write("Error in getting Videoinfo: " + str(node.href) + "\n")
+
+ for i in xrange(0, len(VideoList)):
+ curLen = len(os.path.basename(VideoList[i]))
+ if len_filename < curLen:
+ len_filename = curLen
+
+ for i in xrange(0, len(VideoList)):
+ node.href = VideoList[i]
+ if options.xml:
+ appendXMLChild(node)
+ elif options.csv:
+ CSVtable(node)
+ else:
+ if i == 0:
+ vFile = "File".ljust(len_filename+2)
+ vDuration = "Duration[s]".ljust(12)
+ vBitrate = "Bitrate [b/s]".ljust(15)
+ vVideoCodec = "VideoCodec".ljust(13)
+ vVideoSize = "VideoSize".ljust(11)
+ vPixel = "Pixel format".ljust(14)
+ vFPS = "FPS".ljust(10)
+ vAudioCodec = "AudioCodec".ljust(12)
+ vSampleRate = "Sample rate".ljust(13)
+ vChannels = "Channels".ljust(8)
+
+ title = vFile + vDuration + vVideoCodec + vVideoSize + vPixel + vFPS + vAudioCodec + vSampleRate + vChannels
+
+ print title
+
+ showInfo(node)
+ else:
+ showInfo(node)
+ if options.xml:
+ print doc.toprettyxml(indent=" ",encoding="utf-8")
+
+ elif options.csv:
+ print CSV_video
+
+
+
+
diff --git a/src/utils/avg_videoplayer.py b/src/utils/avg_videoplayer.py
new file mode 100755
index 0000000..029d562
--- /dev/null
+++ b/src/utils/avg_videoplayer.py
@@ -0,0 +1,101 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+#
+# libavg - Media Playback Engine.
+# Copyright (C) 2003-2011 Ulrich von Zadow
+#
+# This library 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 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# Current versions can be found at www.libavg.de
+#
+
+import sys
+import optparse
+from libavg import avg, AVGApp
+
+g_Player = avg.Player.get()
+
+class VideoPlayer(AVGApp):
+
+ def __init__(self, parentNode):
+ if options.fullscreen:
+ g_Player.setResolution(True, 1920, 1200, 0)
+ AVGApp.__init__(self, parentNode)
+
+ def init(self):
+ self.node = avg.VideoNode(href=args[0], loop=True,
+ accelerated=not(options.disableAccel))
+ self.node.play()
+ if self.node.hasAlpha():
+ self.__makeAlphaBackground()
+ self._parentNode.appendChild(self.node)
+ avg.WordsNode(parent=self._parentNode, id="curframe", pos=(10, 10),
+ font="arial", fontsize=10)
+ avg.WordsNode(parent=self._parentNode, id="curtime", pos=(10, 22),
+ font="arial", fontsize=10)
+ avg.WordsNode(parent=self._parentNode, id="framesqueued", pos=(10, 34),
+ font="arial", fontsize=10)
+
+ g_Player.setOnFrameHandler(self.onFrame)
+
+ def onKeyDown(self, event):
+ curTime = self.node.getCurTime()
+ if event.keystring == "right":
+ self.node.seekToTime(curTime+10000)
+ elif event.keystring == "left":
+ if curTime > 10000:
+ self.node.seekToTime(curTime-10000)
+ else:
+ self.node.seekToTime(0)
+ return False
+
+ def onFrame(self):
+ curFrame = self.node.getCurFrame()
+ numFrames = self.node.getNumFrames()
+ g_Player.getElementByID("curframe").text = "Frame: %i/%i"%(curFrame, numFrames)
+ curVideoTime = self.node.getCurTime()
+ g_Player.getElementByID("curtime").text = "Time: "+str(curVideoTime/1000.0)
+ framesQueued = self.node.getNumFramesQueued()
+ g_Player.getElementByID("framesqueued").text = "Frames queued: "+str(framesQueued)
+
+ def __makeAlphaBackground(self):
+ SQUARESIZE=40
+ size = self.node.getMediaSize()
+ avg.RectNode(parent=self._parentNode, size=self.node.getMediaSize(),
+ strokewidth=0, fillcolor="FFFFFF", fillopacity=1)
+ for y in xrange(0, int(size.y)/SQUARESIZE):
+ for x in xrange(0, int(size.x)/(SQUARESIZE*2)):
+ pos = avg.Point2D(x*SQUARESIZE*2, y*SQUARESIZE)
+ if y%2==1:
+ pos += (SQUARESIZE, 0)
+ avg.RectNode(parent=self._parentNode, pos=pos,
+ size=(SQUARESIZE, SQUARESIZE), strokewidth=0, fillcolor="C0C0C0",
+ fillopacity=1)
+
+parser = optparse.OptionParser("Usage: %prog <filename> [options]")
+parser.add_option("-d", "--disable-accel", dest="disableAccel", action="store_true",
+ default=False, help="disable vdpau acceleration")
+parser.add_option("-f", "--fullscreen", dest="fullscreen", action="store_true",
+ default=False)
+(options, args) = parser.parse_args()
+
+if len(args) == 0:
+ parser.print_help()
+ sys.exit(1)
+
+argsNode = avg.VideoNode(href=args[0], loop=True, accelerated=False)
+argsNode.pause()
+VideoPlayer.start(resolution=argsNode.getMediaSize())
+
diff --git a/src/video/AVCCOpaque.cpp b/src/video/AVCCOpaque.cpp
new file mode 100644
index 0000000..fdd7fc8
--- /dev/null
+++ b/src/video/AVCCOpaque.cpp
@@ -0,0 +1,48 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#include "AVCCOpaque.h"
+
+
+namespace avg{
+
+AVCCOpaque::AVCCOpaque(VDPAU* pVDPAU, FrameAge* pFrameAge)
+ : m_pVDPAU(pVDPAU),
+ m_pFrameAge(pFrameAge)
+{
+}
+
+FrameAge* AVCCOpaque::getFrameAge()
+{
+ return m_pFrameAge;
+}
+
+void AVCCOpaque::setFrameAge(FrameAge* pFrameAge)
+{
+ m_pFrameAge = pFrameAge;
+}
+
+VDPAU* AVCCOpaque::getVDPAU()
+{
+ return m_pVDPAU;
+}
+
+}
+
diff --git a/src/video/AVCCOpaque.h b/src/video/AVCCOpaque.h
new file mode 100644
index 0000000..8d909d1
--- /dev/null
+++ b/src/video/AVCCOpaque.h
@@ -0,0 +1,45 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#ifndef _AVCCOpaque_H_
+#define _AVCCOpaque_H_
+
+#include "VDPAU.h"
+#include "FrameAge.h"
+
+namespace avg{
+
+class AVCCOpaque
+{
+public:
+ AVCCOpaque(VDPAU* pVDPAU, FrameAge* pFrameAge = 0);
+ FrameAge* getFrameAge();
+ void setFrameAge(FrameAge* pFrameAge);
+ VDPAU* getVDPAU();
+
+private:
+ VDPAU* m_pVDPAU;
+ FrameAge* m_pFrameAge;
+};
+
+}
+
+#endif
+
diff --git a/src/video/AsyncDemuxer.cpp b/src/video/AsyncDemuxer.cpp
new file mode 100644
index 0000000..9dd5d12
--- /dev/null
+++ b/src/video/AsyncDemuxer.cpp
@@ -0,0 +1,152 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "AsyncDemuxer.h"
+
+#include "../base/ScopeTimer.h"
+#include "../base/Exception.h"
+#include "../base/ObjectCounter.h"
+
+#include <boost/bind.hpp>
+
+#include <iostream>
+
+#define PACKET_QUEUE_LENGTH 50
+
+using namespace std;
+
+typedef boost::mutex::scoped_lock scoped_lock;
+
+namespace avg {
+
+AsyncDemuxer::AsyncDemuxer(AVFormatContext * pFormatContext, vector<int> streamIndexes)
+ : m_pCmdQ(new VideoDemuxerThread::CQueue),
+ m_bSeekPending(false),
+ m_pFormatContext(pFormatContext)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ for (unsigned i = 0; i < streamIndexes.size(); ++i) {
+ enableStream(streamIndexes[i]);
+ }
+ m_pDemuxThread = new boost::thread(VideoDemuxerThread(*m_pCmdQ, m_pFormatContext,
+ m_PacketQs));
+}
+
+AsyncDemuxer::~AsyncDemuxer()
+{
+ if (m_pDemuxThread) {
+ waitForSeekDone();
+ m_pCmdQ->pushCmd(boost::bind(&VideoDemuxerThread::stop, _1));
+ map<int, VideoPacketQueuePtr>::iterator it;
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); ++it) {
+ // If the Queue is full, this breaks the lock in the thread.
+ PacketVideoMsgPtr pPacketMsg;
+ pPacketMsg = it->second->pop(false);
+ if (pPacketMsg) {
+ pPacketMsg->freePacket();
+ }
+ }
+ m_pDemuxThread->join();
+ delete m_pDemuxThread;
+ m_pDemuxThread = 0;
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); it++) {
+ VideoPacketQueuePtr pPacketQ = it->second;
+ PacketVideoMsgPtr pPacketMsg;
+ pPacketMsg = pPacketQ->pop(false);
+ while (pPacketMsg) {
+ pPacketMsg->freePacket();
+ pPacketMsg = pPacketQ->pop(false);
+ }
+ }
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+AVPacket * AsyncDemuxer::getPacket(int streamIndex)
+{
+ waitForSeekDone();
+ // TODO: This blocks if there is no packet. Is that ok?
+ PacketVideoMsgPtr pPacketMsg = m_PacketQs[streamIndex]->pop(true);
+ AVG_ASSERT(!pPacketMsg->isSeekDone());
+
+ return pPacketMsg->getPacket();
+}
+
+void AsyncDemuxer::seek(double destTime)
+{
+ // TODO: There is a (theoretical) race condition here - getPacket() and seek() can
+ // be called from different threads. Among other things, this can cause the assert in
+ // getPacket() to trigger.
+ waitForSeekDone();
+ scoped_lock Lock(m_SeekMutex);
+ m_pCmdQ->pushCmd(boost::bind(&VideoDemuxerThread::seek, _1, destTime));
+ m_bSeekPending = true;
+ bool bAllSeeksDone = true;
+ map<int, VideoPacketQueuePtr>::iterator it;
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); it++) {
+ VideoPacketQueuePtr pPacketQ = it->second;
+ PacketVideoMsgPtr pPacketMsg;
+ map<int, bool>::iterator itSeekDone = m_bSeekDone.find(it->first);
+ itSeekDone->second = false;
+ pPacketMsg = pPacketQ->pop(false);
+ while (pPacketMsg && !itSeekDone->second) {
+ itSeekDone->second = pPacketMsg->isSeekDone();
+ pPacketMsg->freePacket();
+ if (!itSeekDone->second) {
+ pPacketMsg = pPacketQ->pop(false);
+ }
+ }
+ if (!itSeekDone->second) {
+ bAllSeeksDone = false;
+ }
+ }
+ if (bAllSeeksDone) {
+ m_bSeekPending = false;
+ }
+}
+
+void AsyncDemuxer::enableStream(int streamIndex)
+{
+ VideoPacketQueuePtr pPacketQ(new VideoPacketQueue(PACKET_QUEUE_LENGTH));
+ m_PacketQs[streamIndex] = pPacketQ;
+ m_bSeekDone[streamIndex] = true;
+}
+
+void AsyncDemuxer::waitForSeekDone()
+{
+ scoped_lock Lock(m_SeekMutex);
+ if (m_bSeekPending) {
+ m_bSeekPending = false;
+ map<int, VideoPacketQueuePtr>::iterator it;
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); it++) {
+ VideoPacketQueuePtr pPacketQ = it->second;
+ PacketVideoMsgPtr pPacketMsg;
+ map<int, bool>::iterator itSeekDone = m_bSeekDone.find(it->first);
+ while (!itSeekDone->second) {
+ pPacketMsg = pPacketQ->pop(true);
+ itSeekDone->second = pPacketMsg->isSeekDone();
+ pPacketMsg->freePacket();
+ }
+ }
+ }
+}
+
+}
diff --git a/src/video/AsyncDemuxer.h b/src/video/AsyncDemuxer.h
new file mode 100644
index 0000000..ced2ca3
--- /dev/null
+++ b/src/video/AsyncDemuxer.h
@@ -0,0 +1,63 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _AsyncDemuxer_H_
+#define _AsyncDemuxer_H_
+
+#include "../avgconfigwrapper.h"
+#include "IDemuxer.h"
+#include "VideoDemuxerThread.h"
+
+#include <map>
+#include <vector>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread.hpp>
+
+namespace avg {
+
+ class AVG_API AsyncDemuxer: public IDemuxer {
+ public:
+ AsyncDemuxer(AVFormatContext * pFormatContext,
+ std::vector<int> streamIndexes);
+ virtual ~AsyncDemuxer();
+
+ AVPacket * getPacket(int streamIndex);
+ void seek(double destTime);
+
+ private:
+ void enableStream(int streamIndex);
+ void waitForSeekDone();
+
+ boost::thread* m_pDemuxThread;
+
+ VideoDemuxerThread::CQueuePtr m_pCmdQ;
+ std::map<int, VideoPacketQueuePtr> m_PacketQs;
+ std::map<int, bool> m_bSeekDone;
+
+ bool m_bSeekPending;
+ AVFormatContext * m_pFormatContext;
+ boost::mutex m_SeekMutex;
+ };
+ typedef boost::shared_ptr<AsyncDemuxer> AsyncDemuxerPtr;
+}
+
+#endif
diff --git a/src/video/AsyncVideoDecoder.cpp b/src/video/AsyncVideoDecoder.cpp
new file mode 100644
index 0000000..98be6ec
--- /dev/null
+++ b/src/video/AsyncVideoDecoder.cpp
@@ -0,0 +1,494 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "AsyncVideoDecoder.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "FFMpegDecoder.h"
+
+#include <boost/thread/thread.hpp>
+#include <boost/bind.hpp>
+
+#include <math.h>
+#include <iostream>
+
+using namespace boost;
+using namespace std;
+
+namespace avg {
+
+AsyncVideoDecoder::AsyncVideoDecoder(VideoDecoderPtr pSyncDecoder, int queueLength)
+ : m_State(CLOSED),
+ m_pSyncDecoder(pSyncDecoder),
+ m_QueueLength(queueLength),
+ m_pVDecoderThread(0),
+ m_pADecoderThread(0),
+ m_PF(NO_PIXELFORMAT),
+ m_bAudioEOF(false),
+ m_bVideoEOF(false),
+ m_bSeekPending(false),
+ m_Volume(1.0),
+ m_LastVideoFrameTime(-1),
+ m_LastAudioFrameTime(-1)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+AsyncVideoDecoder::~AsyncVideoDecoder()
+{
+ if (m_pVDecoderThread || m_pADecoderThread) {
+ close();
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void AsyncVideoDecoder::open(const std::string& sFilename, bool bThreadedDemuxer,
+ bool bUseHardwareAccelleration)
+{
+ m_bAudioEOF = false;
+ m_bVideoEOF = false;
+ m_bSeekPending = false;
+ m_sFilename = sFilename;
+
+ m_pSyncDecoder->open(m_sFilename, bThreadedDemuxer, bUseHardwareAccelleration);
+ m_VideoInfo = m_pSyncDecoder->getVideoInfo();
+ // Temporary pf - always assumes shaders will be available.
+ m_PF = m_pSyncDecoder->getPixelFormat();
+ m_State = OPENED;
+}
+
+void AsyncVideoDecoder::startDecoding(bool bDeliverYCbCr, const AudioParams* pAP)
+{
+ AVG_ASSERT(m_State == OPENED);
+ m_pSyncDecoder->setVolume(m_Volume);
+ m_pSyncDecoder->startDecoding(bDeliverYCbCr, pAP);
+ m_VideoInfo = m_pSyncDecoder->getVideoInfo();
+ if (m_VideoInfo.m_bHasVideo) {
+ m_LastVideoFrameTime = -1;
+ m_PF = m_pSyncDecoder->getPixelFormat();
+ m_pVCmdQ = VideoDecoderThread::CQueuePtr(new VideoDecoderThread::CQueue);
+ m_pVMsgQ = VideoMsgQueuePtr(new VideoMsgQueue(m_QueueLength));
+ m_pVDecoderThread = new boost::thread(
+ VideoDecoderThread(*m_pVCmdQ, *m_pVMsgQ, m_pSyncDecoder));
+ }
+
+ if (m_VideoInfo.m_bHasAudio) {
+ m_pACmdQ = AudioDecoderThread::CQueuePtr(new AudioDecoderThread::CQueue);
+ m_pAMsgQ = VideoMsgQueuePtr(new VideoMsgQueue(8));
+ m_pADecoderThread = new boost::thread(
+ AudioDecoderThread(*m_pACmdQ, *m_pAMsgQ, m_pSyncDecoder, *pAP));
+ m_AudioMsgData = 0;
+ m_AudioMsgSize = 0;
+ m_LastAudioFrameTime = 0;
+ }
+ m_State = DECODING;
+}
+
+void AsyncVideoDecoder::close()
+{
+ AVG_ASSERT(m_State != CLOSED);
+ if (m_pVDecoderThread) {
+ m_pVCmdQ->pushCmd(boost::bind(&VideoDecoderThread::stop, _1));
+ getNextBmps(false); // If the Queue is full, this breaks the lock in the thread.
+ m_pVDecoderThread->join();
+ delete m_pVDecoderThread;
+ m_pVDecoderThread = 0;
+ m_pVMsgQ = VideoMsgQueuePtr();
+ }
+ {
+ scoped_lock lock1(m_AudioMutex);
+ if (m_pADecoderThread) {
+ m_pACmdQ->pushCmd(boost::bind(&AudioDecoderThread::stop, _1));
+ m_pAMsgQ->pop(false);
+ m_pAMsgQ->pop(false);
+ m_pADecoderThread->join();
+ delete m_pADecoderThread;
+ m_pADecoderThread = 0;
+ m_pAMsgQ = VideoMsgQueuePtr();
+ }
+ m_pSyncDecoder->close();
+ }
+}
+
+VideoDecoder::DecoderState AsyncVideoDecoder::getState() const
+{
+ return m_State;
+}
+
+VideoInfo AsyncVideoDecoder::getVideoInfo() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_VideoInfo;
+}
+
+void AsyncVideoDecoder::seek(double destTime)
+{
+ AVG_ASSERT(m_State == DECODING);
+ waitForSeekDone();
+ scoped_lock lock1(m_AudioMutex);
+ scoped_lock Lock2(m_SeekMutex);
+ m_bAudioEOF = false;
+ m_bVideoEOF = false;
+ m_bSeekPending = false;
+ m_bSeekPending = true;
+ if (m_pVCmdQ) {
+ m_pVCmdQ->pushCmd(boost::bind(&VideoDecoderThread::seek, _1, destTime));
+ } else {
+ m_pACmdQ->pushCmd(boost::bind(&AudioDecoderThread::seek, _1, destTime));
+ }
+ bool bDone = false;
+ while (!bDone && m_bSeekPending) {
+ VideoMsgPtr pMsg;
+ if (m_pVCmdQ) {
+ pMsg = m_pVMsgQ->pop(false);
+ } else {
+ pMsg = m_pAMsgQ->pop(false);
+ }
+ if (pMsg) {
+ switch (pMsg->getType()) {
+ case VideoMsg::SEEK_DONE:
+ m_bSeekPending = false;
+ m_LastVideoFrameTime = pMsg->getSeekVideoFrameTime();
+ m_LastAudioFrameTime = pMsg->getSeekAudioFrameTime();
+ break;
+ case VideoMsg::FRAME:
+ returnFrame(pMsg);
+ break;
+ default:
+ break;
+ }
+ } else {
+ bDone = true;
+ }
+ }
+}
+
+void AsyncVideoDecoder::loop()
+{
+ m_LastVideoFrameTime = -1;
+ m_bAudioEOF = false;
+ m_bVideoEOF = false;
+ if (getVideoInfo().m_bHasAudio) {
+ seek(0);
+ }
+}
+
+IntPoint AsyncVideoDecoder::getSize() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_VideoInfo.m_Size;
+}
+
+int AsyncVideoDecoder::getCurFrame() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return int(getCurTime(SS_VIDEO)*m_VideoInfo.m_StreamFPS+0.5);
+}
+
+int AsyncVideoDecoder::getNumFramesQueued() const
+{
+ AVG_ASSERT(m_State == DECODING);
+ return m_pVMsgQ->size();
+}
+
+double AsyncVideoDecoder::getCurTime(StreamSelect stream) const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ switch (stream) {
+ case SS_DEFAULT:
+ case SS_VIDEO:
+ AVG_ASSERT(m_VideoInfo.m_bHasVideo);
+ return m_LastVideoFrameTime;
+ break;
+ case SS_AUDIO:
+ AVG_ASSERT(m_VideoInfo.m_bHasAudio);
+ return m_LastAudioFrameTime;
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ return -1;
+}
+
+double AsyncVideoDecoder::getNominalFPS() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_VideoInfo.m_StreamFPS;
+}
+
+double AsyncVideoDecoder::getFPS() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_VideoInfo.m_FPS;
+}
+
+void AsyncVideoDecoder::setFPS(double fps)
+{
+ AVG_ASSERT(!m_pADecoderThread);
+ m_pVCmdQ->pushCmd(boost::bind(&VideoDecoderThread::setFPS, _1, fps));
+ if (fps != 0) {
+ m_VideoInfo.m_FPS = fps;
+ }
+}
+
+double AsyncVideoDecoder::getVolume() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_Volume;
+}
+
+void AsyncVideoDecoder::setVolume(double volume)
+{
+ m_Volume = volume;
+ if (m_State != CLOSED && m_VideoInfo.m_bHasAudio && m_pACmdQ) {
+ m_pACmdQ->pushCmd(boost::bind(&AudioDecoderThread::setVolume, _1, volume));
+ }
+}
+
+PixelFormat AsyncVideoDecoder::getPixelFormat() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_PF;
+}
+
+static ProfilingZoneID VDPAUDecodeProfilingZone("AsyncVideoDecoder: VDPAU");
+
+FrameAvailableCode AsyncVideoDecoder::renderToBmps(vector<BitmapPtr>& pBmps,
+ double timeWanted)
+{
+ AVG_ASSERT(m_State == DECODING);
+ FrameAvailableCode frameAvailable;
+ VideoMsgPtr pFrameMsg = getBmpsForTime(timeWanted, frameAvailable);
+ if (frameAvailable == FA_NEW_FRAME) {
+ AVG_ASSERT(pFrameMsg);
+ if (pFrameMsg->getType() == VideoMsg::VDPAU_FRAME) {
+#ifdef AVG_ENABLE_VDPAU
+ ScopeTimer timer(VDPAUDecodeProfilingZone);
+ vdpau_render_state* pRenderState = pFrameMsg->getRenderState();
+ if (pixelFormatIsPlanar(m_PF)) {
+ getPlanesFromVDPAU(pRenderState, pBmps[0], pBmps[1], pBmps[2]);
+ } else {
+ getBitmapFromVDPAU(pRenderState, pBmps[0]);
+ }
+#endif
+ } else {
+ for (unsigned i = 0; i < pBmps.size(); ++i) {
+ pBmps[i]->copyPixels(*(pFrameMsg->getFrameBitmap(i)));
+ }
+ returnFrame(pFrameMsg);
+ }
+ }
+ return frameAvailable;
+}
+
+bool AsyncVideoDecoder::isEOF(StreamSelect stream) const
+{
+ AVG_ASSERT(m_State == DECODING);
+ switch(stream) {
+ case SS_AUDIO:
+ return (!m_VideoInfo.m_bHasAudio || m_bAudioEOF);
+ case SS_VIDEO:
+ return (!m_VideoInfo.m_bHasVideo || m_bVideoEOF);
+ case SS_ALL:
+ return isEOF(SS_VIDEO) && isEOF(SS_AUDIO);
+ default:
+ return false;
+ }
+}
+
+void AsyncVideoDecoder::throwAwayFrame(double timeWanted)
+{
+ AVG_ASSERT(m_State == DECODING);
+ FrameAvailableCode frameAvailable;
+ VideoMsgPtr pFrameMsg = getBmpsForTime(timeWanted, frameAvailable);
+}
+
+int AsyncVideoDecoder::fillAudioBuffer(AudioBufferPtr pBuffer)
+{
+ AVG_ASSERT(m_State == DECODING);
+ AVG_ASSERT (m_pADecoderThread);
+ if (m_bAudioEOF) {
+ return 0;
+ }
+ scoped_lock lock(m_AudioMutex);
+ waitForSeekDone();
+
+ unsigned char* pDest = (unsigned char *)(pBuffer->getData());
+ int bufferLeftToFill = pBuffer->getNumBytes();
+ VideoMsgPtr pMsg;
+ while (bufferLeftToFill > 0) {
+ while (m_AudioMsgSize > 0 && bufferLeftToFill > 0) {
+ int copyBytes = min(bufferLeftToFill, m_AudioMsgSize);
+ memcpy(pDest, m_AudioMsgData, copyBytes);
+ m_AudioMsgSize -= copyBytes;
+ m_AudioMsgData += copyBytes;
+ bufferLeftToFill -= copyBytes;
+ pDest += copyBytes;
+
+ m_LastAudioFrameTime += copyBytes /
+ (pBuffer->getFrameSize() * pBuffer->getRate());
+ }
+ if (bufferLeftToFill != 0) {
+ pMsg = m_pAMsgQ->pop(false);
+ if (pMsg) {
+ if (pMsg->getType() == VideoMsg::END_OF_FILE) {
+ m_bAudioEOF = true;
+ return pBuffer->getNumFrames()-bufferLeftToFill/
+ pBuffer->getFrameSize();
+ }
+ AVG_ASSERT(pMsg->getType() == VideoMsg::AUDIO);
+
+ m_AudioMsgSize = pMsg->getAudioBuffer()->getNumFrames()
+ *pBuffer->getFrameSize();
+ m_AudioMsgData = (unsigned char *)(pMsg->getAudioBuffer()->getData());
+ m_LastAudioFrameTime = pMsg->getAudioTime();
+ } else {
+ return pBuffer->getNumFrames()-bufferLeftToFill/pBuffer->getFrameSize();
+ }
+ }
+ }
+ return pBuffer->getNumFrames();
+}
+
+VideoMsgPtr AsyncVideoDecoder::getBmpsForTime(double timeWanted,
+ FrameAvailableCode& frameAvailable)
+{
+ if (timeWanted < 0 && timeWanted != -1) {
+ cerr << "Illegal timeWanted: " << timeWanted << endl;
+ AVG_ASSERT(false);
+ }
+ // XXX: This code is sort-of duplicated in FFMpegDecoder::readFrameForTime()
+ double frameTime = -1;
+ VideoMsgPtr pFrameMsg;
+ if (timeWanted == -1) {
+ pFrameMsg = getNextBmps(true);
+ frameAvailable = FA_NEW_FRAME;
+ } else {
+ double timePerFrame = 1.0/getFPS();
+ if (fabs(double(timeWanted-m_LastVideoFrameTime)) < 0.5*timePerFrame ||
+ m_LastVideoFrameTime > timeWanted+timePerFrame) {
+ // The last frame is still current. Display it again.
+ frameAvailable = FA_USE_LAST_FRAME;
+ return VideoMsgPtr();
+ } else {
+ if (m_bVideoEOF) {
+ frameAvailable = FA_USE_LAST_FRAME;
+ return VideoMsgPtr();
+ }
+ while (frameTime-timeWanted < -0.5*timePerFrame && !m_bVideoEOF) {
+ if (pFrameMsg) {
+ if (pFrameMsg->getType() == VideoMsg::FRAME) {
+ returnFrame(pFrameMsg);
+ } else {
+#if AVG_ENABLE_VDPAU
+ vdpau_render_state* pRenderState = pFrameMsg->getRenderState();
+ VDPAU::unlockSurface(pRenderState);
+#endif
+ }
+ }
+ pFrameMsg = getNextBmps(false);
+ if (pFrameMsg) {
+ frameTime = pFrameMsg->getFrameTime();
+ } else {
+ frameAvailable = FA_STILL_DECODING;
+ return VideoMsgPtr();
+ }
+ }
+ if (!pFrameMsg) {
+ cerr << "frameTime=" << frameTime << ", timeWanted=" << timeWanted
+ << ", timePerFrame=" << timePerFrame << ", m_bVideoEOF="
+ << m_bVideoEOF << endl;
+ AVG_ASSERT(false);
+ }
+ frameAvailable = FA_NEW_FRAME;
+ }
+ }
+ if (pFrameMsg) {
+ m_LastVideoFrameTime = pFrameMsg->getFrameTime();
+ }
+ return pFrameMsg;
+}
+
+VideoMsgPtr AsyncVideoDecoder::getNextBmps(bool bWait)
+{
+ waitForSeekDone();
+ VideoMsgPtr pMsg = m_pVMsgQ->pop(bWait);
+ if (pMsg) {
+ switch (pMsg->getType()) {
+ case VideoMsg::FRAME:
+ case VideoMsg::VDPAU_FRAME:
+ return pMsg;
+ case VideoMsg::END_OF_FILE:
+ m_bVideoEOF = true;
+ return VideoMsgPtr();
+ case VideoMsg::ERROR:
+ m_bVideoEOF = true;
+ return VideoMsgPtr();
+ default:
+ // Unhandled message type.
+ AVG_ASSERT(false);
+ return VideoMsgPtr();
+ }
+ } else {
+ return pMsg;
+ }
+}
+
+void AsyncVideoDecoder::waitForSeekDone()
+{
+ scoped_lock lock(m_SeekMutex);
+ if (m_bSeekPending) {
+ do {
+ VideoMsgPtr pMsg;
+ if (m_pVCmdQ) {
+ pMsg = m_pVMsgQ->pop(true);
+ } else {
+ pMsg = m_pAMsgQ->pop(true);
+ }
+ switch (pMsg->getType()) {
+ case VideoMsg::SEEK_DONE:
+ m_bSeekPending = false;
+ m_LastVideoFrameTime = pMsg->getSeekVideoFrameTime();
+ m_LastAudioFrameTime = pMsg->getSeekAudioFrameTime();
+ break;
+ case VideoMsg::FRAME:
+ returnFrame(pMsg);
+ break;
+ case VideoMsg::VDPAU_FRAME:
+ break;
+ default:
+ // TODO: Handle ERROR messages here.
+ break;
+ }
+ } while (m_bSeekPending);
+ }
+}
+
+void AsyncVideoDecoder::returnFrame(VideoMsgPtr& pFrameMsg)
+{
+ if (pFrameMsg) {
+ m_pVCmdQ->pushCmd(boost::bind(&VideoDecoderThread::returnFrame, _1, pFrameMsg));
+ }
+}
+
+}
diff --git a/src/video/AsyncVideoDecoder.h b/src/video/AsyncVideoDecoder.h
new file mode 100644
index 0000000..b90c35b
--- /dev/null
+++ b/src/video/AsyncVideoDecoder.h
@@ -0,0 +1,115 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _AsyncVideoDecoder_H_
+#define _AsyncVideoDecoder_H_
+
+#include "../api.h"
+#include "VideoDecoder.h"
+#include "VideoDecoderThread.h"
+#include "AudioDecoderThread.h"
+#include "VideoMsg.h"
+
+#include "../graphics/Bitmap.h"
+#include "../audio/AudioParams.h"
+
+#include <boost/thread/mutex.hpp>
+
+#include <string>
+
+namespace avg {
+
+class AVG_API AsyncVideoDecoder: public VideoDecoder
+{
+public:
+ AsyncVideoDecoder(VideoDecoderPtr pSyncDecoder, int queueLength);
+ virtual ~AsyncVideoDecoder();
+ virtual void open(const std::string& sFilename, bool bSyncDemuxer,
+ bool bUseHardwareAccelleration);
+ virtual void startDecoding(bool bDeliverYCbCr, const AudioParams* pAP);
+ virtual void close();
+ virtual DecoderState getState() const;
+ virtual VideoInfo getVideoInfo() const;
+ virtual void seek(double destTime);
+ virtual void loop();
+ virtual IntPoint getSize() const;
+ virtual int getCurFrame() const;
+ virtual int getNumFramesQueued() const;
+ virtual double getCurTime(StreamSelect stream = SS_DEFAULT) const;
+ virtual double getNominalFPS() const;
+ virtual double getFPS() const;
+ virtual void setFPS(double fps);
+ virtual double getVolume() const;
+ virtual void setVolume(double volume);
+ virtual PixelFormat getPixelFormat() const;
+
+ virtual FrameAvailableCode renderToBmps(std::vector<BitmapPtr>& pBmps,
+ double timeWanted);
+ virtual bool isEOF(StreamSelect stream = SS_ALL) const;
+ virtual void throwAwayFrame(double timeWanted);
+
+ virtual int fillAudioBuffer(AudioBufferPtr pBuffer);
+
+private:
+ VideoMsgPtr getBmpsForTime(double timeWanted, FrameAvailableCode& frameAvailable);
+ VideoMsgPtr getNextBmps(bool bWait);
+ void waitForSeekDone();
+ void returnFrame(VideoMsgPtr& pFrameMsg);
+
+ DecoderState m_State;
+ VideoDecoderPtr m_pSyncDecoder;
+ std::string m_sFilename;
+ int m_QueueLength;
+
+ boost::thread* m_pVDecoderThread;
+ VideoDecoderThread::CQueuePtr m_pVCmdQ;
+ VideoMsgQueuePtr m_pVMsgQ;
+
+ boost::thread* m_pADecoderThread;
+ boost::mutex m_AudioMutex;
+ AudioDecoderThread::CQueuePtr m_pACmdQ;
+ VideoMsgQueuePtr m_pAMsgQ;
+ VideoMsgPtr m_pAudioMsg;
+ unsigned char* m_AudioMsgData;
+ int m_AudioMsgSize;
+
+ VideoInfo m_VideoInfo;
+
+ IntPoint m_Size;
+ int m_NumFrames;
+ bool m_bUseStreamFPS;
+ PixelFormat m_PF;
+
+ bool m_bAudioEOF;
+ bool m_bVideoEOF;
+ bool m_bSeekPending;
+ boost::mutex m_SeekMutex;
+ double m_Volume;
+
+ double m_LastVideoFrameTime;
+ double m_LastAudioFrameTime;
+
+ bool m_bUsesVDPAU;
+};
+
+}
+#endif
+
diff --git a/src/video/AudioDecoderThread.cpp b/src/video/AudioDecoderThread.cpp
new file mode 100644
index 0000000..495b0da
--- /dev/null
+++ b/src/video/AudioDecoderThread.cpp
@@ -0,0 +1,93 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#include "AudioDecoderThread.h"
+
+#include "../base/Logger.h"
+#include "../base/TimeSource.h"
+
+// In Audio frames.
+#define AUDIO_BUFFER_SIZE 256
+
+using namespace std;
+
+namespace avg {
+
+AudioDecoderThread::AudioDecoderThread(CQueue& cmdQ, VideoMsgQueue& msgQ,
+ VideoDecoderPtr pDecoder, const AudioParams& ap)
+ : WorkerThread<AudioDecoderThread>(string("AudioDecoderThread"), cmdQ),
+ m_MsgQ(msgQ),
+ m_pDecoder(pDecoder),
+ m_AP(ap)
+{
+}
+
+AudioDecoderThread::~AudioDecoderThread()
+{
+}
+
+bool AudioDecoderThread::work()
+{
+ if (m_pDecoder->isEOF(SS_AUDIO)) {
+ // replace this with waitForMessage()
+ msleep(10);
+ } else {
+ AudioBufferPtr pBuffer(new AudioBuffer(AUDIO_BUFFER_SIZE, m_AP));
+ int framesWritten = m_pDecoder->fillAudioBuffer(pBuffer);
+ if (framesWritten != AUDIO_BUFFER_SIZE) {
+ AudioBufferPtr pOldBuffer = pBuffer;
+ pBuffer = AudioBufferPtr(new AudioBuffer(framesWritten, m_AP));
+ memcpy(pBuffer->getData(), pOldBuffer->getData(),
+ framesWritten*m_AP.m_Channels*sizeof(short));
+ }
+ VideoMsgPtr pVMsg = VideoMsgPtr(new VideoMsg());
+ pVMsg->setAudio(pBuffer, m_pDecoder->getCurTime(SS_AUDIO));
+ m_MsgQ.push(pVMsg);
+ if (m_pDecoder->isEOF(SS_AUDIO)) {
+ VideoMsgPtr pVMsg = VideoMsgPtr(new VideoMsg());
+ pVMsg->setEOF();
+ m_MsgQ.push(pVMsg);
+ }
+ ThreadProfiler::get()->reset();
+ }
+ return true;
+}
+
+void AudioDecoderThread::seek(double destTime)
+{
+ while (!m_MsgQ.empty()) {
+ m_MsgQ.pop(false);
+ }
+
+ m_pDecoder->seek(destTime);
+ VideoMsgPtr pVMsg = VideoMsgPtr(new VideoMsg());
+ pVMsg->setSeekDone(-1, m_pDecoder->getCurTime(SS_AUDIO));
+ m_MsgQ.push(pVMsg);
+}
+
+void AudioDecoderThread::setVolume(double volume)
+{
+ m_pDecoder->setVolume(volume);
+}
+
+}
diff --git a/src/video/AudioDecoderThread.h b/src/video/AudioDecoderThread.h
new file mode 100644
index 0000000..71a5d7b
--- /dev/null
+++ b/src/video/AudioDecoderThread.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+// Original author of this file is Nick Hebner (hebnern@gmail.com).
+//
+
+#ifndef _AudioDecoderThread_H_
+#define _AudioDecoderThread_H_
+
+#include "../avgconfigwrapper.h"
+#include "VideoDecoder.h"
+#include "VideoMsg.h"
+
+#include "../base/WorkerThread.h"
+#include "../base/Command.h"
+#include "../audio/AudioParams.h"
+
+#include <boost/thread.hpp>
+
+#include <string>
+
+namespace avg {
+
+class AVG_API AudioDecoderThread : public WorkerThread<AudioDecoderThread> {
+ public:
+ AudioDecoderThread(CQueue& cmdQ, VideoMsgQueue& msgQ,
+ VideoDecoderPtr pDecoder, const AudioParams& ap);
+ virtual ~AudioDecoderThread();
+
+ bool work();
+ void seek(double destTime);
+ void setVolume(double volume);
+
+ private:
+ VideoMsgQueue& m_MsgQ;
+ VideoDecoderPtr m_pDecoder;
+ AudioParams m_AP;
+};
+
+}
+#endif
+
diff --git a/src/video/FFMpegDecoder.cpp b/src/video/FFMpegDecoder.cpp
new file mode 100644
index 0000000..f705375
--- /dev/null
+++ b/src/video/FFMpegDecoder.cpp
@@ -0,0 +1,1208 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FFMpegDecoder.h"
+#include "AsyncDemuxer.h"
+#include "FFMpegDemuxer.h"
+
+#include "../base/Exception.h"
+#include "../base/Logger.h"
+#include "../base/ScopeTimer.h"
+#include "../base/ObjectCounter.h"
+
+#include "../graphics/Filterflipuv.h"
+#include "../graphics/Filterfliprgba.h"
+
+#include <iostream>
+#include <sstream>
+#ifndef _WIN32
+#include <unistd.h>
+#endif
+#include <errno.h>
+
+using namespace std;
+using namespace boost;
+
+#define SAMPLE_BUFFER_SIZE ((AVCODEC_MAX_AUDIO_FRAME_SIZE*3))
+#define VOLUME_FADE_SAMPLES 100
+
+namespace avg {
+
+bool FFMpegDecoder::s_bInitialized = false;
+mutex FFMpegDecoder::s_OpenMutex;
+
+FFMpegDecoder::FFMpegDecoder()
+ : m_State(CLOSED),
+ m_pFormatContext(0),
+ m_PF(NO_PIXELFORMAT),
+ m_pSwsContext(0),
+ m_Size(0,0),
+ m_bUseStreamFPS(true),
+ m_AStreamIndex(-1),
+ m_pSampleBuffer(0),
+ m_pResampleBuffer(0),
+ m_pAudioResampleContext(0),
+ m_Volume(1.0),
+ m_LastVolume(1.0),
+ m_pDemuxer(0),
+ m_pVStream(0),
+ m_pAStream(0),
+#ifdef AVG_ENABLE_VDPAU
+ m_VDPAU(),
+ m_Opaque(&m_VDPAU),
+#endif
+ m_VStreamIndex(-1),
+ m_bFirstPacket(false),
+ m_VideoStartTimestamp(-1),
+ m_LastVideoFrameTime(-1),
+ m_FPS(0)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ initVideoSupport();
+}
+
+FFMpegDecoder::~FFMpegDecoder()
+{
+ if (m_pFormatContext) {
+ close();
+ }
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void avcodecError(const string& sFilename, int err)
+{
+#if LIBAVFORMAT_VERSION_MAJOR > 52
+ char buf[256];
+ av_strerror(err, buf, 256);
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED, sFilename + ": " + buf);
+#else
+ switch(err) {
+ case AVERROR_NUMEXPECTED:
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ sFilename + ": Incorrect image filename syntax (use %%d to specify the image number:");
+ case AVERROR_INVALIDDATA:
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ sFilename + ": Error while parsing header");
+ case AVERROR_NOFMT:
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ sFilename + ": Unknown format");
+ default:
+ stringstream s;
+ s << "'" << sFilename << "': Error while opening file (Num:" << err << ")";
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED, s.str());
+ }
+#endif
+}
+
+int FFMpegDecoder::openCodec(int streamIndex, bool bUseHardwareAcceleration)
+{
+ AVCodecContext* pContext;
+ pContext = m_pFormatContext->streams[streamIndex]->codec;
+// pContext->debug = 0x0001; // see avcodec.h
+
+ AVCodec * pCodec = 0;
+#ifdef AVG_ENABLE_VDPAU
+ if (bUseHardwareAcceleration) {
+ pContext->opaque = &m_Opaque;
+ pCodec = m_VDPAU.openCodec(pContext);
+ } else {
+ pCodec = avcodec_find_decoder(pContext->codec_id);
+ }
+#else
+ pCodec = avcodec_find_decoder(pContext->codec_id);
+#endif
+ if (!pCodec || avcodec_open(pContext, pCodec) < 0) {
+ return -1;
+ }
+ return 0;
+}
+
+void FFMpegDecoder::open(const string& sFilename, bool bThreadedDemuxer,
+ bool bUseHardwareAcceleration)
+{
+ mutex::scoped_lock lock(s_OpenMutex);
+ m_bThreadedDemuxer = bThreadedDemuxer;
+ m_bAudioEOF = false;
+ m_bVideoEOF = false;
+ m_bEOFPending = false;
+ m_VideoStartTimestamp = -1;
+ int err;
+ m_sFilename = sFilename;
+
+ AVG_TRACE(Logger::MEMORY, "Opening " << sFilename);
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,2,0)
+ err = avformat_open_input(&m_pFormatContext, sFilename.c_str(), 0, 0);
+#else
+ AVFormatParameters params;
+ memset(&params, 0, sizeof(params));
+ err = av_open_input_file(&m_pFormatContext, sFilename.c_str(),
+ 0, 0, &params);
+#endif
+ if (err < 0) {
+ m_sFilename = "";
+ avcodecError(sFilename, err);
+ }
+
+ err = av_find_stream_info(m_pFormatContext);
+ if (err < 0) {
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ sFilename + ": Could not find codec parameters.");
+ }
+// dump_format(m_pFormatContext, 0, sFilename.c_str(), false);
+ av_read_play(m_pFormatContext);
+
+ // Find audio and video streams in the file
+ m_VStreamIndex = -1;
+ m_AStreamIndex = -1;
+ for (unsigned i = 0; i < m_pFormatContext->nb_streams; i++) {
+ AVCodecContext* pContext = m_pFormatContext->streams[i]->codec;
+ switch (pContext->codec_type) {
+ case AVMEDIA_TYPE_VIDEO:
+ if (m_VStreamIndex < 0) {
+ m_VStreamIndex = i;
+ }
+ break;
+ case AVMEDIA_TYPE_AUDIO:
+ // Ignore the audio stream if we're using sync demuxing.
+ if (m_AStreamIndex < 0 && bThreadedDemuxer) {
+ m_AStreamIndex = i;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ // Enable video stream demuxing
+ if (m_VStreamIndex >= 0) {
+ m_pVStream = m_pFormatContext->streams[m_VStreamIndex];
+ m_State = OPENED;
+
+ // Set video parameters
+ m_TimeUnitsPerSecond = 1.0/av_q2d(m_pVStream->time_base);
+ if (m_bUseStreamFPS) {
+ m_FPS = getNominalFPS();
+ }
+ m_Size = IntPoint(m_pVStream->codec->width, m_pVStream->codec->height);
+ m_bFirstPacket = true;
+ m_sFilename = sFilename;
+ m_LastVideoFrameTime = -1;
+
+ int rc = openCodec(m_VStreamIndex, bUseHardwareAcceleration);
+ if (rc == -1) {
+ m_VStreamIndex = -1;
+ char szBuf[256];
+ avcodec_string(szBuf, sizeof(szBuf), m_pVStream->codec, 0);
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ sFilename + ": unsupported codec ("+szBuf+").");
+ }
+ m_PF = calcPixelFormat(true);
+ }
+ // Enable audio stream demuxing.
+ if (m_AStreamIndex >= 0) {
+ m_pAStream = m_pFormatContext->streams[m_AStreamIndex];
+
+ m_AudioPacket = 0;
+ m_AudioPacketData = 0;
+ m_AudioPacketSize = 0;
+
+ m_LastAudioFrameTime = 0;
+ m_AudioStartTimestamp = 0;
+
+ if ((unsigned long long)m_pAStream->start_time != AV_NOPTS_VALUE) {
+ m_AudioStartTimestamp = double(av_q2d(m_pAStream->time_base))
+ *m_pAStream->start_time;
+ }
+ m_EffectiveSampleRate = (int)(m_pAStream->codec->sample_rate);
+ int rc = openCodec(m_AStreamIndex, bUseHardwareAcceleration);
+ if (rc == -1) {
+ m_AStreamIndex = -1;
+ char szBuf[256];
+ avcodec_string(szBuf, sizeof(szBuf), m_pAStream->codec, 0);
+ m_pAStream = 0;
+ AVG_TRACE(Logger::WARNING,
+ sFilename + ": unsupported codec ("+szBuf+"). Disabling audio.");
+ }
+ if (m_pAStream->codec->sample_fmt != SAMPLE_FMT_S16) {
+ m_AStreamIndex = -1;
+ m_pAStream = 0;
+ AVG_TRACE(Logger::WARNING,
+ sFilename + ": unsupported sample format (!= S16). Disabling audio.");
+ }
+ }
+
+ m_State = OPENED;
+}
+
+void FFMpegDecoder::startDecoding(bool bDeliverYCbCr, const AudioParams* pAP)
+{
+#ifdef AVG_ENABLE_VDPAU
+ m_VDPAU.init();
+#endif
+ AVG_ASSERT(m_State == OPENED);
+ if (m_VStreamIndex >= 0) {
+ m_PF = calcPixelFormat(bDeliverYCbCr);
+ }
+ bool bAudioEnabled = (pAP && m_bThreadedDemuxer);
+ if (bAudioEnabled) {
+ m_AP = *pAP;
+ } else {
+ m_AStreamIndex = -1;
+ if (m_pAStream) {
+ avcodec_close(m_pAStream->codec);
+ }
+ m_pAStream = 0;
+ }
+
+ if (m_AStreamIndex >= 0) {
+ if (m_pAStream->codec->channels > m_AP.m_Channels) {
+ AVG_TRACE(Logger::WARNING,
+ m_sFilename << ": unsupported number of channels (" <<
+ m_pAStream->codec->channels << "). Disabling audio.");
+ m_AStreamIndex = -1;
+ m_pAStream = 0;
+ } else {
+ m_pSampleBuffer = (char*)av_mallocz(SAMPLE_BUFFER_SIZE);
+ m_SampleBufferStart = 0;
+ m_SampleBufferEnd = 0;
+ m_SampleBufferLeft = SAMPLE_BUFFER_SIZE;
+
+ m_ResampleBufferSize = 0;
+ m_pResampleBuffer = 0;
+ m_ResampleBufferStart = 0;
+ m_ResampleBufferEnd = 0;
+ }
+ }
+
+ if (m_VStreamIndex < 0 && m_AStreamIndex < 0) {
+ throw Exception(AVG_ERR_VIDEO_INIT_FAILED,
+ m_sFilename + " does not contain any valid audio or video streams.");
+ }
+
+ // Create demuxer
+ AVG_ASSERT(!m_pDemuxer);
+ vector<int> streamIndexes;
+ if (m_VStreamIndex >= 0) {
+ streamIndexes.push_back(m_VStreamIndex);
+ }
+ if (m_AStreamIndex >= 0) {
+ streamIndexes.push_back(m_AStreamIndex);
+ }
+ if (m_bThreadedDemuxer) {
+ m_pDemuxer = new AsyncDemuxer(m_pFormatContext, streamIndexes);
+ } else {
+ m_pDemuxer = new FFMpegDemuxer(m_pFormatContext, streamIndexes);
+ }
+
+ m_State = DECODING;
+}
+
+void FFMpegDecoder::close()
+{
+ mutex::scoped_lock lock(s_OpenMutex);
+ mutex::scoped_lock lock2(m_AudioMutex);
+ AVG_TRACE(Logger::MEMORY, "Closing " << m_sFilename);
+
+ delete m_pDemuxer;
+ m_pDemuxer = 0;
+
+ // Close audio and video codecs
+ if (m_pVStream) {
+ avcodec_close(m_pVStream->codec);
+ m_pVStream = 0;
+ m_VStreamIndex = -1;
+ }
+
+ if (m_pAStream) {
+ avcodec_close(m_pAStream->codec);
+ if (m_AudioPacket) {
+ av_free_packet(m_AudioPacket);
+ delete m_AudioPacket;
+ m_AudioPacket = 0;
+ }
+ if (m_pAudioResampleContext) {
+ audio_resample_close(m_pAudioResampleContext);
+ m_pAudioResampleContext = 0;
+ }
+
+ if (m_pSampleBuffer) {
+ av_free(m_pSampleBuffer);
+ m_pSampleBuffer = 0;
+ }
+ if (m_pResampleBuffer) {
+ av_free(m_pResampleBuffer);
+ m_pResampleBuffer = 0;
+ }
+
+ m_AudioPacketData = 0;
+ m_AudioPacketSize = 0;
+
+ m_SampleBufferStart = 0;
+ m_SampleBufferEnd = 0;
+ m_SampleBufferLeft = 0;
+
+ m_ResampleBufferStart = 0;
+ m_ResampleBufferEnd = 0;
+ m_ResampleBufferSize = 0;
+
+ m_LastAudioFrameTime = 0;
+ m_AudioStartTimestamp = 0;
+
+ m_pAStream = 0;
+ m_AStreamIndex = -1;
+ }
+ if (m_pFormatContext) {
+ av_close_input_file(m_pFormatContext);
+ m_pFormatContext = 0;
+ }
+
+ if (m_pSwsContext) {
+ sws_freeContext(m_pSwsContext);
+ m_pSwsContext = 0;
+ }
+ m_State = CLOSED;
+}
+
+VideoDecoder::DecoderState FFMpegDecoder::getState() const
+{
+ return m_State;
+}
+
+VideoInfo FFMpegDecoder::getVideoInfo() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ double duration = 0;
+ if (m_pVStream || m_pAStream) {
+ duration = getDuration();
+ }
+ VideoInfo info(duration, m_pFormatContext->bit_rate, m_pVStream != 0,
+ m_pAStream != 0);
+ if (m_pVStream) {
+ info.setVideoData(m_Size, getStreamPF(), getNumFrames(), getNominalFPS(), m_FPS,
+ m_pVStream->codec->codec->name, usesVDPAU());
+ }
+ if (m_pAStream) {
+ AVCodecContext * pACodec = m_pAStream->codec;
+ info.setAudioData(pACodec->codec->name, pACodec->sample_rate,
+ pACodec->channels);
+ }
+ return info;
+}
+
+void FFMpegDecoder::seek(double destTime)
+{
+ AVG_ASSERT(m_State == DECODING);
+ if (m_bFirstPacket && m_pVStream) {
+ AVFrame frame;
+ readFrame(frame);
+ }
+ m_pDemuxer->seek(destTime + getStartTime());
+ if (m_pVStream) {
+ m_LastVideoFrameTime = destTime - 1.0/m_FPS;
+ }
+ if (m_pAStream) {
+ mutex::scoped_lock lock(m_AudioMutex);
+ m_LastAudioFrameTime = destTime;
+ m_SampleBufferStart = m_SampleBufferEnd = 0;
+ m_SampleBufferLeft = SAMPLE_BUFFER_SIZE;
+ m_ResampleBufferStart = m_ResampleBufferEnd = 0;
+ m_AudioPacketSize = 0;
+ }
+ m_bVideoEOF = false;
+ m_bAudioEOF = false;
+}
+
+void FFMpegDecoder::loop()
+{
+ seek(0);
+}
+
+IntPoint FFMpegDecoder::getSize() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_Size;
+}
+
+int FFMpegDecoder::getCurFrame() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return int(m_LastVideoFrameTime*getNominalFPS()+0.5);
+}
+
+int FFMpegDecoder::getNumFramesQueued() const
+{
+ return 0;
+}
+
+double FFMpegDecoder::getCurTime(StreamSelect stream) const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ switch(stream) {
+ case SS_DEFAULT:
+ case SS_VIDEO:
+ AVG_ASSERT(m_pVStream);
+ return m_LastVideoFrameTime;
+ case SS_AUDIO:
+ AVG_ASSERT(m_pAStream);
+ return m_LastAudioFrameTime;
+ default:
+ return -1;
+ }
+}
+
+double FFMpegDecoder::getDuration() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ long long duration;
+ AVRational time_base;
+ if (m_pVStream) {
+ duration = m_pVStream->duration;
+ time_base = m_pVStream->time_base;
+ } else {
+ duration = m_pAStream->duration;
+ time_base = m_pAStream->time_base;
+ }
+ if (duration == AV_NOPTS_VALUE) {
+ return 0;
+ } else {
+ return double(duration)*av_q2d(time_base);
+ }
+}
+
+double FFMpegDecoder::getNominalFPS() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return av_q2d(m_pVStream->r_frame_rate);
+}
+
+double FFMpegDecoder::getFPS() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_FPS;
+}
+
+void FFMpegDecoder::setFPS(double fps)
+{
+ m_bUseStreamFPS = (fps == 0);
+ if (fps == 0) {
+ m_FPS = calcStreamFPS();
+ } else {
+ m_FPS = fps;
+ }
+}
+
+double FFMpegDecoder::getVolume() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_Volume;
+}
+
+void FFMpegDecoder::setVolume(double volume)
+{
+ m_Volume = volume;
+ if (m_State != DECODING) {
+ m_LastVolume = volume;
+ }
+}
+
+void copyPlaneToBmp(BitmapPtr pBmp, unsigned char * pData, int stride)
+{
+ unsigned char * pSrc=pData;
+ unsigned char * pDest= pBmp->getPixels();
+ int destStride = pBmp->getStride();
+ int height = pBmp->getSize().y;
+ int width = pBmp->getSize().x;
+ for (int y = 0; y < height; y++) {
+ memcpy(pDest, pSrc, width);
+ pSrc += stride;
+ pDest += destStride;
+ }
+}
+
+static ProfilingZoneID RenderToBmpProfilingZone("FFMpeg: renderToBmp");
+static ProfilingZoneID CopyImageProfilingZone("FFMpeg: copy image");
+static ProfilingZoneID VDPAUCopyProfilingZone("FFMpeg: VDPAU copy");
+
+FrameAvailableCode FFMpegDecoder::renderToBmps(vector<BitmapPtr>& pBmps,
+ double timeWanted)
+{
+ AVG_ASSERT(m_State == DECODING);
+ ScopeTimer timer(RenderToBmpProfilingZone);
+ AVFrame frame;
+ FrameAvailableCode frameAvailable;
+ if (timeWanted == -1) {
+ readFrame(frame);
+ frameAvailable = FA_NEW_FRAME;
+ } else {
+ frameAvailable = readFrameForTime(frame, timeWanted);
+ }
+ if (!m_bVideoEOF && frameAvailable == FA_NEW_FRAME) {
+ if (pixelFormatIsPlanar(m_PF)) {
+#ifdef AVG_ENABLE_VDPAU
+ if (usesVDPAU()) {
+ ScopeTimer timer(VDPAUCopyProfilingZone);
+ vdpau_render_state* pRenderState = (vdpau_render_state *)frame.data[0];
+ getPlanesFromVDPAU(pRenderState, pBmps[0], pBmps[1], pBmps[2]);
+ } else {
+ ScopeTimer timer(CopyImageProfilingZone);
+ for (unsigned i = 0; i < pBmps.size(); ++i) {
+ copyPlaneToBmp(pBmps[i], frame.data[i], frame.linesize[i]);
+ }
+ }
+#else
+ ScopeTimer timer(CopyImageProfilingZone);
+ for (unsigned i = 0; i < pBmps.size(); ++i) {
+ copyPlaneToBmp(pBmps[i], frame.data[i], frame.linesize[i]);
+ }
+#endif
+ } else {
+ convertFrameToBmp(frame, pBmps[0]);
+ }
+ return FA_NEW_FRAME;
+ }
+ return FA_USE_LAST_FRAME;
+}
+
+
+#ifdef AVG_ENABLE_VDPAU
+FrameAvailableCode FFMpegDecoder::renderToVDPAU(vdpau_render_state** ppRenderState)
+{
+ AVG_ASSERT(m_State == DECODING);
+ ScopeTimer timer(RenderToBmpProfilingZone);
+ AVFrame frame;
+ FrameAvailableCode frameAvailable;
+ readFrame(frame);
+ frameAvailable = FA_NEW_FRAME;
+ if (!m_bVideoEOF && frameAvailable == FA_NEW_FRAME) {
+ if (usesVDPAU()) {
+ ScopeTimer timer(VDPAUCopyProfilingZone);
+ vdpau_render_state *pRenderState = (vdpau_render_state *)frame.data[0];
+ *ppRenderState = pRenderState;
+ }
+ return FA_NEW_FRAME;
+ }
+ return FA_USE_LAST_FRAME;
+}
+#endif
+
+void FFMpegDecoder::throwAwayFrame(double timeWanted)
+{
+ AVG_ASSERT(m_State == DECODING);
+ AVFrame frame;
+ readFrameForTime(frame, timeWanted);
+}
+
+bool FFMpegDecoder::isEOF(StreamSelect stream) const
+{
+ AVG_ASSERT(m_State == DECODING);
+ switch(stream) {
+ case SS_AUDIO:
+ return (!m_pAStream || m_bAudioEOF);
+ case SS_VIDEO:
+ return (!m_pVStream || m_bVideoEOF);
+ case SS_ALL:
+ return isEOF(SS_VIDEO) && isEOF(SS_AUDIO);
+ default:
+ return false;
+ }
+}
+
+int FFMpegDecoder::copyRawAudio(unsigned char* pBuffer, int size)
+{
+ int bytesWritten = min(m_SampleBufferEnd - m_SampleBufferStart, size);
+ memcpy(pBuffer, m_pSampleBuffer + m_SampleBufferStart, bytesWritten);
+
+ m_SampleBufferStart += bytesWritten;
+
+ if (m_SampleBufferStart == m_SampleBufferEnd) {
+ m_SampleBufferStart = 0;
+ m_SampleBufferEnd = 0;
+ m_SampleBufferLeft = SAMPLE_BUFFER_SIZE;
+ }
+
+ return bytesWritten;
+}
+
+int FFMpegDecoder::copyResampledAudio(unsigned char* pBuffer, int size)
+{
+ int bytesWritten = 0;
+
+ // If there is no buffered resampled data, resample some more
+ if (m_ResampleBufferStart >= m_ResampleBufferEnd) {
+ resampleAudio();
+ }
+
+ // If we have some data in the resample buffer, copy it over
+ if (m_ResampleBufferStart < m_ResampleBufferEnd) {
+ bytesWritten = min(m_ResampleBufferEnd - m_ResampleBufferStart, size);
+ memcpy(pBuffer, m_pResampleBuffer + m_ResampleBufferStart, bytesWritten);
+
+ m_ResampleBufferStart += bytesWritten;
+ if (m_ResampleBufferStart >= m_ResampleBufferEnd) {
+ m_ResampleBufferStart = 0;
+ m_ResampleBufferEnd = 0;
+ }
+
+ if (m_SampleBufferStart == m_SampleBufferEnd) {
+ m_SampleBufferStart = 0;
+ m_SampleBufferEnd = 0;
+ m_SampleBufferLeft = SAMPLE_BUFFER_SIZE;
+ }
+ }
+
+ return bytesWritten;
+}
+
+void FFMpegDecoder::resampleAudio()
+{
+ if (!m_pAudioResampleContext) {
+#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(52, 24, 0)
+ m_pAudioResampleContext = av_audio_resample_init(
+ m_AP.m_Channels, m_pAStream->codec->channels,
+ m_AP.m_SampleRate, m_EffectiveSampleRate,
+ SAMPLE_FMT_S16, SAMPLE_FMT_S16,
+ 16, 10, 0, 0.8);
+#else
+ m_pAudioResampleContext = audio_resample_init(
+ m_AP.m_Channels, m_pAStream->codec->channels,
+ m_AP.m_SampleRate, m_EffectiveSampleRate);
+#endif
+ }
+
+ if (!m_pResampleBuffer) {
+ m_ResampleBufferSize = (int)(SAMPLE_BUFFER_SIZE *
+ ((double)m_AP.m_SampleRate / (double)m_EffectiveSampleRate));
+ m_pResampleBuffer = (char*)av_mallocz(m_ResampleBufferSize);
+ }
+
+ int inputSamples =
+ (m_SampleBufferEnd - m_SampleBufferStart) /
+ (2 * m_pAStream->codec->channels);
+
+ int outputSamples = audio_resample(m_pAudioResampleContext,
+ (short*)m_pResampleBuffer,
+ (short*)(m_pSampleBuffer + m_SampleBufferStart),
+ inputSamples);
+
+ // Adjust buffer pointers
+ m_ResampleBufferEnd += outputSamples * 2 * m_AP.m_Channels;
+ m_SampleBufferStart += inputSamples * 2 * m_pAStream->codec->channels;
+}
+
+int FFMpegDecoder::decodeAudio()
+{
+ // Save current size of the audio buffer
+ int lastSampleBufferSize = m_SampleBufferLeft;
+
+ // Decode some data from packet into the audio buffer
+#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 31, 0)
+ AVPacket packet;
+ av_init_packet(&packet);
+ packet.data = m_AudioPacketData;
+ packet.size = m_AudioPacketSize;
+ int packetBytesDecoded = avcodec_decode_audio3(m_pAStream->codec,
+ (short*)(m_pSampleBuffer + m_SampleBufferEnd), &m_SampleBufferLeft,
+ &packet);
+#else
+ int packetBytesDecoded = avcodec_decode_audio2(m_pAStream->codec,
+ (short*)(m_pSampleBuffer + m_SampleBufferEnd), &m_SampleBufferLeft,
+ m_AudioPacketData, m_AudioPacketSize);
+#endif
+
+ // Skip frame on error
+ if (packetBytesDecoded < 0) {
+ return -1;
+ }
+
+ // Did not get any data, try again
+ if (packetBytesDecoded == 0) {
+ return 0;
+ }
+
+ // Adjust audio buffer pointers
+ m_SampleBufferEnd += m_SampleBufferLeft;
+ m_SampleBufferLeft = lastSampleBufferSize - m_SampleBufferLeft;
+
+ // Adjust packet data pointers
+ m_AudioPacketData += packetBytesDecoded;
+ m_AudioPacketSize -= packetBytesDecoded;
+ return packetBytesDecoded;
+}
+
+int FFMpegDecoder::fillAudioBuffer(AudioBufferPtr pBuffer)
+{
+ AVG_ASSERT(m_State == DECODING);
+ mutex::scoped_lock lock(m_AudioMutex);
+
+ unsigned char* pOutputBuffer = (unsigned char*)(pBuffer->getData());
+ int outputAudioBufferSize = pBuffer->getNumBytes();
+
+ AVG_ASSERT (m_pAStream);
+ if (m_bAudioEOF) {
+ return 0;
+ }
+
+ int packetBytesDecoded;
+ int bytesProduced;
+ unsigned char* pCurBufferPos = pOutputBuffer;
+ int bufferLeft = outputAudioBufferSize;
+ bool bFormatMatch = (m_EffectiveSampleRate == m_AP.m_SampleRate &&
+ m_pAStream->codec->channels == m_AP.m_Channels);
+
+ while (true) {
+ while (true) {
+ // Consume any data left in the sample buffers
+ while (m_SampleBufferStart < m_SampleBufferEnd ||
+ m_ResampleBufferStart < m_ResampleBufferEnd)
+ {
+ // If the output format is different from the decoded format,
+ // then convert it, else copy it over
+ if (bFormatMatch) {
+ bytesProduced = copyRawAudio(pCurBufferPos, bufferLeft);
+ } else {
+ bytesProduced = copyResampledAudio(pCurBufferPos, bufferLeft);
+ }
+
+ pCurBufferPos += bytesProduced;
+ bufferLeft -= bytesProduced;
+
+ m_LastAudioFrameTime += (double(bytesProduced) /
+ (2 * m_AP.m_Channels * m_AP.m_SampleRate));
+ if (bufferLeft == 0) {
+ volumize(pBuffer);
+ return pBuffer->getNumFrames();
+ }
+ }
+
+ if (m_AudioPacketSize <= 0)
+ break;
+
+ packetBytesDecoded = decodeAudio();
+
+ // Skip frame on error
+ if (packetBytesDecoded < 0)
+ break;
+
+ // Did not get any data, try again
+ if (packetBytesDecoded == 0)
+ continue;
+ }
+
+ // We have decoded all data in the packet, free it
+ if (m_AudioPacket) {
+ av_free_packet(m_AudioPacket);
+ delete m_AudioPacket;
+ }
+
+ // Get a new packet from the audio stream
+ m_AudioPacket = m_pDemuxer->getPacket(m_AStreamIndex);
+ if (!m_AudioPacket) {
+ m_bAudioEOF = true;
+ volumize(pBuffer);
+ return pBuffer->getNumFrames()-bufferLeft/(pBuffer->getFrameSize());
+ }
+
+ // Initialize packet data pointers
+ m_AudioPacketData = m_AudioPacket->data;
+ m_AudioPacketSize = m_AudioPacket->size;
+ }
+}
+
+PixelFormat FFMpegDecoder::calcPixelFormat(bool bUseYCbCr)
+{
+ AVCodecContext const* pContext = getCodecContext();
+ if (bUseYCbCr) {
+ switch(pContext->pix_fmt) {
+ case PIX_FMT_YUV420P:
+#ifdef AVG_ENABLE_VDPAU
+ case PIX_FMT_VDPAU_H264:
+ case PIX_FMT_VDPAU_MPEG1:
+ case PIX_FMT_VDPAU_MPEG2:
+ case PIX_FMT_VDPAU_WMV3:
+ case PIX_FMT_VDPAU_VC1:
+#endif
+ return YCbCr420p;
+ case PIX_FMT_YUVJ420P:
+ return YCbCrJ420p;
+ case PIX_FMT_YUVA420P:
+ return YCbCrA420p;
+ default:
+ break;
+ }
+ }
+ if (pContext->pix_fmt == PIX_FMT_BGRA || pContext->pix_fmt == PIX_FMT_YUVA420P) {
+ return B8G8R8A8;
+ }
+ return B8G8R8X8;
+}
+
+static ProfilingZoneID ConvertImageLibavgProfilingZone(
+ "FFMpeg: colorspace conv (libavg)");
+static ProfilingZoneID ConvertImageSWSProfilingZone("FFMpeg: colorspace conv (SWS)");
+static ProfilingZoneID SetAlphaProfilingZone("FFMpeg: set alpha channel");
+
+void FFMpegDecoder::convertFrameToBmp(AVFrame& frame, BitmapPtr pBmp)
+{
+ AVPicture destPict;
+ unsigned char * pDestBits = pBmp->getPixels();
+ destPict.data[0] = pDestBits;
+ destPict.linesize[0] = pBmp->getStride();
+ ::PixelFormat destFmt;
+ switch (pBmp->getPixelFormat()) {
+ case R8G8B8X8:
+ case R8G8B8A8:
+ // XXX: Unused and broken.
+ destFmt = PIX_FMT_BGRA;
+ break;
+ case B8G8R8X8:
+ case B8G8R8A8:
+ destFmt = PIX_FMT_BGRA;
+ break;
+ case R8G8B8:
+ destFmt = PIX_FMT_RGB24;
+ break;
+ case B8G8R8:
+ destFmt = PIX_FMT_BGR24;
+ break;
+ case YCbCr422:
+ destFmt = PIX_FMT_YUYV422;
+ break;
+ default:
+ AVG_TRACE(Logger::ERROR, "FFMpegDecoder: Dest format "
+ << pBmp->getPixelFormat() << " not supported.");
+ AVG_ASSERT(false);
+ destFmt = PIX_FMT_BGRA;
+ }
+ AVCodecContext const* pContext = getCodecContext();
+ {
+ if (destFmt == PIX_FMT_BGRA && (pContext->pix_fmt == PIX_FMT_YUV420P ||
+ pContext->pix_fmt == PIX_FMT_YUVJ420P))
+ {
+ ScopeTimer timer(ConvertImageLibavgProfilingZone);
+ BitmapPtr pBmpY(new Bitmap(pBmp->getSize(), I8, frame.data[0],
+ frame.linesize[0], false));
+ BitmapPtr pBmpU(new Bitmap(pBmp->getSize(), I8, frame.data[1],
+ frame.linesize[1], false));
+ BitmapPtr pBmpV(new Bitmap(pBmp->getSize(), I8, frame.data[2],
+ frame.linesize[2], false));
+ pBmp->copyYUVPixels(*pBmpY, *pBmpU, *pBmpV,
+ pContext->pix_fmt == PIX_FMT_YUVJ420P);
+#ifdef AVG_ENABLE_VDPAU
+ } else if (destFmt == PIX_FMT_BGRA && usesVDPAU()) {
+ vdpau_render_state *pRenderState = (vdpau_render_state *)frame.data[0];
+ getBitmapFromVDPAU(pRenderState, pBmp);
+#endif
+ } else {
+ if (!m_pSwsContext) {
+ m_pSwsContext = sws_getContext(pContext->width, pContext->height,
+ pContext->pix_fmt, pContext->width, pContext->height, destFmt,
+ SWS_BICUBIC, 0, 0, 0);
+ AVG_ASSERT(m_pSwsContext);
+ }
+ {
+ ScopeTimer timer(ConvertImageSWSProfilingZone);
+ sws_scale(m_pSwsContext, frame.data, frame.linesize, 0,
+ pContext->height, destPict.data, destPict.linesize);
+ }
+ if (pBmp->getPixelFormat() == B8G8R8X8) {
+ ScopeTimer timer(SetAlphaProfilingZone);
+ // Make sure the alpha channel is white.
+ // TODO: This is slow. Make OpenGL do it.
+ unsigned char * pLine = pBmp->getPixels();
+ IntPoint size = pBmp->getSize();
+ for (int y = 0; y < size.y; ++y) {
+ unsigned char * pPixel = pLine;
+ for (int x = 0; x < size.x; ++x) {
+ pPixel[3] = 0xFF;
+ pPixel += 4;
+ }
+ pLine = pLine + pBmp->getStride();
+ }
+ }
+ }
+ }
+}
+
+PixelFormat FFMpegDecoder::getPixelFormat() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ return m_PF;
+}
+
+void FFMpegDecoder::initVideoSupport()
+{
+ if (!s_bInitialized) {
+ av_register_all();
+ s_bInitialized = true;
+ // Tune libavcodec console spam.
+// av_log_set_level(AV_LOG_DEBUG);
+ av_log_set_level(AV_LOG_QUIET);
+ }
+}
+
+bool FFMpegDecoder::usesVDPAU() const
+{
+#ifdef AVG_ENABLE_VDPAU
+ AVCodecContext const* pContext = getCodecContext();
+ return pContext->codec && (pContext->codec->capabilities & CODEC_CAP_HWACCEL_VDPAU);
+#else
+ return false;
+#endif
+}
+
+int FFMpegDecoder::getNumFrames() const
+{
+ AVG_ASSERT(m_State != CLOSED);
+ // This is broken for some videos, but the code here is correct.
+ // So fix ffmpeg :-).
+ int numFrames = int(m_pVStream->nb_frames);
+ if (numFrames > 0) {
+ return numFrames;
+ } else {
+ return int(getDuration() * calcStreamFPS());
+ }
+}
+
+FrameAvailableCode FFMpegDecoder::readFrameForTime(AVFrame& frame, double timeWanted)
+{
+ AVG_ASSERT(m_State == DECODING);
+// cerr << " readFrameForTime " << timeWanted << ", LastFrameTime= "
+// << m_LastVideoFrameTime << ", diff= " << m_LastVideoFrameTime-timeWanted
+// << endl;
+ AVG_ASSERT(timeWanted != -1);
+ double timePerFrame = 1.0/m_FPS;
+ if (timeWanted-m_LastVideoFrameTime < 0.5*timePerFrame) {
+// cerr << "DISPLAY AGAIN." << endl;
+ // The last frame is still current. Display it again.
+ return FA_USE_LAST_FRAME;
+ } else {
+ bool bInvalidFrame = true;
+ while (bInvalidFrame && !m_bVideoEOF) {
+ double frameTime = readFrame(frame);
+ bInvalidFrame = frameTime-timeWanted < -0.5*timePerFrame;
+#if AVG_ENABLE_VDPAU
+ if (usesVDPAU() && bInvalidFrame && !m_bVideoEOF) {
+ vdpau_render_state *pRenderState = (vdpau_render_state *)frame.data[0];
+ VDPAU::unlockSurface(pRenderState);
+ }
+#endif
+// cerr << " readFrame returned time " << frameTime << ", diff= " <<
+// frameTime-timeWanted << endl;
+ }
+// cerr << "NEW FRAME." << endl;
+ }
+ return FA_NEW_FRAME;
+}
+
+static ProfilingZoneID DecodeProfilingZone("FFMpeg: decode");
+
+double FFMpegDecoder::readFrame(AVFrame& frame)
+{
+ AVG_ASSERT(m_State == DECODING);
+ ScopeTimer timer(DecodeProfilingZone);
+
+ if (m_bEOFPending) {
+ m_bVideoEOF = true;
+ m_bEOFPending = false;
+ return m_LastVideoFrameTime;
+ }
+ AVCodecContext* pContext = getCodecContext();
+ int bGotPicture = 0;
+ AVPacket* pPacket = 0;
+ double frameTime = -1;
+ while (!bGotPicture && !m_bVideoEOF) {
+ pPacket = m_pDemuxer->getPacket(m_VStreamIndex);
+ m_bFirstPacket = false;
+ if (pPacket) {
+#ifdef AVG_ENABLE_VDPAU
+ FrameAge age;
+ m_Opaque.setFrameAge(&age);
+#endif
+#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 31, 0)
+ int len1 = avcodec_decode_video2(pContext, &frame, &bGotPicture, pPacket);
+#else
+ int len1 = avcodec_decode_video(pContext, &frame, &bGotPicture, pPacket->data,
+ pPacket->size);
+#endif
+ if (len1 > 0) {
+ AVG_ASSERT(len1 == pPacket->size);
+ }
+ else {
+ }
+ if (bGotPicture) {
+ frameTime = getFrameTime(pPacket->dts);
+ }
+ av_free_packet(pPacket);
+ delete pPacket;
+ } else {
+ // No more packets -> EOF. Decode the last data we got.
+#if LIBAVCODEC_VERSION_INT > AV_VERSION_INT(52, 31, 0)
+ AVPacket packet;
+ packet.data = 0;
+ packet.size = 0;
+ avcodec_decode_video2(pContext, &frame, &bGotPicture, &packet);
+#else
+ avcodec_decode_video(pContext, &frame, &bGotPicture, 0, 0);
+#endif
+ if (bGotPicture) {
+ m_bEOFPending = true;
+ } else {
+ m_bVideoEOF = true;
+ }
+ // We don't have a timestamp for the last frame, so we'll
+ // calculate it based on the frame before.
+ frameTime = m_LastVideoFrameTime+1.0/m_FPS;
+ m_LastVideoFrameTime = frameTime;
+ }
+ }
+ AVG_ASSERT(frameTime != -1)
+ return frameTime;
+/*
+ cerr << "coded_picture_number: " << frame.coded_picture_number <<
+ ", display_picture_number: " << frame.display_picture_number <<
+ ", pts: " << frame.pts << endl;
+
+ cerr << "key_frame: " << frame.key_frame <<
+ ", pict_type: " << frame.pict_type << endl;
+ AVFrac spts = m_pVStream->pts;
+ cerr << "Stream.pts: " << spts.val + double(spts.num)/spts.den << endl;
+*/
+}
+
+double FFMpegDecoder::getFrameTime(long long dts)
+{
+ if (m_VideoStartTimestamp == -1) {
+ m_VideoStartTimestamp = double(dts)/m_TimeUnitsPerSecond;
+ }
+ double frameTime;
+ if (m_bUseStreamFPS) {
+ frameTime = double(dts)/m_TimeUnitsPerSecond-m_VideoStartTimestamp;
+ } else {
+ if (m_LastVideoFrameTime == -1) {
+ frameTime = 0;
+ } else {
+ frameTime = m_LastVideoFrameTime + 1.0/m_FPS;
+ }
+ }
+ m_LastVideoFrameTime = frameTime;
+ return frameTime;
+}
+
+double FFMpegDecoder::getStartTime()
+{
+ if (m_pVStream) {
+ return m_VideoStartTimestamp;
+ } else {
+ return m_AudioStartTimestamp;
+ }
+}
+
+double FFMpegDecoder::calcStreamFPS() const
+{
+ return (m_pVStream->r_frame_rate.num/m_pVStream->r_frame_rate.den);
+}
+
+string FFMpegDecoder::getStreamPF() const
+{
+ AVCodecContext const* pCodec = getCodecContext();
+ ::PixelFormat pf = pCodec->pix_fmt;
+ const char* psz = av_get_pix_fmt_name(pf);
+ string s;
+ if (psz) {
+ s = psz;
+ }
+ return s;
+}
+
+// TODO: this should be logarithmic...
+void FFMpegDecoder::volumize(AudioBufferPtr pBuffer)
+{
+ double curVol = m_Volume;
+ double volDiff = m_LastVolume - curVol;
+
+ if (curVol == 1.0 && volDiff == 0.0) {
+ return;
+ }
+
+ short * pData = pBuffer->getData();
+ for (int i = 0; i < pBuffer->getNumFrames()*pBuffer->getNumChannels(); i++) {
+ double fadeVol = 0;
+ if (volDiff != 0 && i < VOLUME_FADE_SAMPLES) {
+ fadeVol = volDiff * (VOLUME_FADE_SAMPLES - i) / VOLUME_FADE_SAMPLES;
+ }
+
+ int s = int(pData[i] * (curVol + fadeVol));
+
+ if (s < -32768)
+ s = -32768;
+ if (s > 32767)
+ s = 32767;
+
+ pData[i] = s;
+ }
+ m_LastVolume = curVol;
+}
+
+AVCodecContext const* FFMpegDecoder::getCodecContext() const
+{
+ return m_pVStream->codec;
+}
+
+AVCodecContext* FFMpegDecoder::getCodecContext()
+{
+ return m_pVStream->codec;
+}
+
+#ifdef AVG_ENABLE_VDPAU
+void getPlanesFromVDPAU(vdpau_render_state* pRenderState, BitmapPtr pBmpY,
+ BitmapPtr pBmpU, BitmapPtr pBmpV)
+{
+ VdpStatus status;
+ void *dest[3] = {
+ pBmpY->getPixels(),
+ pBmpV->getPixels(),
+ pBmpU->getPixels()
+ };
+ uint32_t pitches[3] = {
+ pBmpY->getStride(),
+ pBmpV->getStride(),
+ pBmpU->getStride()
+ };
+ status = vdp_video_surface_get_bits_y_cb_cr(pRenderState->surface,
+ VDP_YCBCR_FORMAT_YV12, dest, pitches);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+ VDPAU::unlockSurface(pRenderState);
+}
+
+void getBitmapFromVDPAU(vdpau_render_state* pRenderState, BitmapPtr pBmpDest)
+{
+ IntPoint YSize = pBmpDest->getSize();
+ IntPoint UVSize(YSize.x>>1, YSize.y);
+ BitmapPtr pBmpY(new Bitmap(YSize, I8));
+ BitmapPtr pBmpU(new Bitmap(UVSize, I8));
+ BitmapPtr pBmpV(new Bitmap(UVSize, I8));
+ getPlanesFromVDPAU(pRenderState, pBmpY, pBmpU, pBmpV);
+ pBmpDest->copyYUVPixels(*pBmpY, *pBmpU, *pBmpV, false);
+}
+#endif
+
+}
+
diff --git a/src/video/FFMpegDecoder.h b/src/video/FFMpegDecoder.h
new file mode 100644
index 0000000..4588dd5
--- /dev/null
+++ b/src/video/FFMpegDecoder.h
@@ -0,0 +1,178 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FFMpegDecoder_H_
+#define _FFMpegDecoder_H_
+
+#include "../avgconfigwrapper.h"
+#include "VideoDecoder.h"
+#include "IDemuxer.h"
+
+#include "../audio/AudioParams.h"
+#include "../base/ProfilingZone.h"
+#include "../avgconfigwrapper.h"
+
+#include "WrapFFMpeg.h"
+
+#ifdef AVG_ENABLE_VDPAU
+#include "VDPAU.h"
+#include "AVCCOpaque.h"
+#include "FrameAge.h"
+#include <libavcodec/vdpau.h>
+#endif
+
+#include <boost/thread/mutex.hpp>
+
+namespace avg {
+
+class AudioBuffer;
+
+class AVG_API FFMpegDecoder: public VideoDecoder
+{
+ public:
+ FFMpegDecoder();
+ virtual ~FFMpegDecoder();
+ virtual void open(const std::string& sFilename, bool bThreadedDemuxer,
+ bool bUseHardwareAcceleration);
+ virtual void startDecoding(bool bDeliverYCbCr, const AudioParams* pAP);
+ virtual void close();
+ virtual DecoderState getState() const;
+ virtual VideoInfo getVideoInfo() const;
+
+ virtual double getNominalFPS() const;
+ virtual double getFPS() const;
+ virtual double getVolume() const;
+ virtual PixelFormat getPixelFormat() const;
+
+ // Called from video thread.
+ virtual IntPoint getSize() const;
+ virtual int getCurFrame() const;
+ virtual int getNumFramesQueued() const;
+ virtual double getCurTime(StreamSelect stream = SS_DEFAULT) const;
+ virtual void setFPS(double fps);
+ virtual FrameAvailableCode renderToBmps(std::vector<BitmapPtr>& pBmps,
+ double timeWanted);
+#ifdef AVG_ENABLE_VDPAU
+ virtual FrameAvailableCode renderToVDPAU(vdpau_render_state** ppRenderState);
+#endif
+ virtual void throwAwayFrame(double timeWanted);
+
+ // Called from audio decoder thread
+ virtual void setVolume(double volume);
+ virtual int fillAudioBuffer(AudioBufferPtr pBuffer);
+
+ // Called from video and audio threads
+ virtual void seek(double destTime);
+ virtual void loop();
+ virtual bool isEOF(StreamSelect stream = SS_ALL) const;
+
+ private:
+ void initVideoSupport();
+ bool usesVDPAU() const;
+ int openCodec(int streamIndex, bool bUseHardwareAcceleration);
+ PixelFormat calcPixelFormat(bool bUseYCbCr);
+ virtual double getDuration() const;
+ virtual int getNumFrames() const;
+
+ DecoderState m_State;
+ AVFormatContext * m_pFormatContext;
+ PixelFormat m_PF;
+ std::string m_sFilename;
+ bool m_bThreadedDemuxer;
+
+ // Used from video thread.
+ FrameAvailableCode readFrameForTime(AVFrame& frame, double timeWanted);
+ void convertFrameToBmp(AVFrame& frame, BitmapPtr pBmp);
+ double getFrameTime(long long dts);
+ double calcStreamFPS() const;
+ std::string getStreamPF() const;
+ AVCodecContext const * getCodecContext() const;
+ AVCodecContext * getCodecContext();
+
+ SwsContext * m_pSwsContext;
+ IntPoint m_Size;
+ double m_TimeUnitsPerSecond;
+ bool m_bUseStreamFPS;
+
+ // Used from audio thread.
+ int copyRawAudio(unsigned char* buf, int size);
+ int copyResampledAudio(unsigned char* buf, int size);
+ void resampleAudio();
+ int decodeAudio();
+ void volumize(AudioBufferPtr pBuffer);
+
+ int m_AStreamIndex;
+ AudioParams m_AP;
+ AVPacket * m_AudioPacket;
+ unsigned char * m_AudioPacketData;
+ int m_AudioPacketSize;
+ char * m_pSampleBuffer;
+ int m_SampleBufferStart;
+ int m_SampleBufferEnd;
+ int m_SampleBufferLeft;
+ char * m_pResampleBuffer;
+ int m_ResampleBufferEnd;
+ int m_ResampleBufferStart;
+ int m_ResampleBufferSize;
+ int m_EffectiveSampleRate;
+ ReSampleContext * m_pAudioResampleContext;
+ double m_Volume;
+ double m_LastVolume;
+ double m_AudioStartTimestamp;
+
+ // Used from video and audio threads.
+ double readFrame(AVFrame& frame);
+ double getStartTime();
+
+ IDemuxer * m_pDemuxer;
+ AVStream * m_pVStream;
+ AVStream * m_pAStream;
+#ifdef AVG_ENABLE_VDPAU
+ VDPAU m_VDPAU;
+ AVCCOpaque m_Opaque;
+#endif
+ int m_VStreamIndex;
+ bool m_bEOFPending;
+ bool m_bVideoEOF;
+ bool m_bAudioEOF;
+ boost::mutex m_AudioMutex;
+ double m_LastAudioFrameTime;
+ bool m_bFirstPacket;
+ double m_VideoStartTimestamp;
+ double m_LastVideoFrameTime;
+
+ double m_FPS;
+ double m_StreamTimeOffset;
+
+ static bool s_bInitialized;
+ // Prevents different decoder instances from executing open/close simultaneously
+ static boost::mutex s_OpenMutex;
+};
+
+#ifdef AVG_ENABLE_VDPAU
+void getPlanesFromVDPAU(vdpau_render_state* pRenderState, BitmapPtr pBmpY,
+ BitmapPtr pBmpU, BitmapPtr pBmpV);
+void getBitmapFromVDPAU(vdpau_render_state* pRenderState, BitmapPtr pBmpDest);
+#endif
+
+}
+#endif
+
diff --git a/src/video/FFMpegDemuxer.cpp b/src/video/FFMpegDemuxer.cpp
new file mode 100644
index 0000000..3c325f6
--- /dev/null
+++ b/src/video/FFMpegDemuxer.cpp
@@ -0,0 +1,142 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FFMpegDemuxer.h"
+#include "../base/ScopeTimer.h"
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+#include <cstring>
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+FFMpegDemuxer::FFMpegDemuxer(AVFormatContext * pFormatContext, vector<int> streamIndexes)
+ : m_pFormatContext(pFormatContext)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+ for (unsigned i = 0; i < streamIndexes.size(); ++i) {
+ m_PacketLists[streamIndexes[i]] = PacketList();
+ }
+}
+
+FFMpegDemuxer::~FFMpegDemuxer()
+{
+ clearPacketCache();
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+AVPacket * FFMpegDemuxer::getPacket(int streamIndex)
+{
+ // Make sure enableStream was called on streamIndex.
+ AVG_ASSERT(m_PacketLists.size() > 0);
+ AVG_ASSERT(streamIndex > -1 && streamIndex < 10);
+ if (m_PacketLists.find(streamIndex) == m_PacketLists.end()) {
+ cerr << this << ": getPacket: Stream " << streamIndex << " not found." << endl;
+ dump();
+ AVG_ASSERT(false);
+ }
+ PacketList & CurPacketList = m_PacketLists.find(streamIndex)->second;
+ AVPacket * pPacket;
+ if (!CurPacketList.empty()) {
+ pPacket = CurPacketList.front();
+ CurPacketList.pop_front();
+ } else {
+ do {
+ pPacket = new AVPacket;
+ memset(pPacket, 0, sizeof(AVPacket));
+ int err = av_read_frame(m_pFormatContext, pPacket);
+ // TODO: Check url_ferror here too.
+ if (err < 0) {
+ av_free_packet(pPacket);
+ delete pPacket;
+ pPacket = 0;
+ return 0;
+ }
+ if (pPacket->stream_index != streamIndex) {
+ if (m_PacketLists.find(pPacket->stream_index) != m_PacketLists.end()) {
+ av_dup_packet(pPacket);
+ PacketList& OtherPacketList =
+ m_PacketLists.find(pPacket->stream_index)->second;
+ OtherPacketList.push_back(pPacket);
+ } else {
+ av_free_packet(pPacket);
+ delete pPacket;
+ pPacket = 0;
+ }
+ } else {
+ av_dup_packet(pPacket);
+ }
+ } while (!pPacket || pPacket->stream_index != streamIndex);
+ }
+
+// double timeBase = av_q2d(m_pFormatContext->streams[streamIndex]->time_base);
+// cerr << "FFMpegDemuxer: " << streamIndex << ": " << pPacket->dts*timeBase << endl;
+ return pPacket;
+}
+
+void FFMpegDemuxer::seek(double destTime)
+{
+#if LIBAVFORMAT_BUILD <= 4616
+ av_seek_frame(m_pFormatContext, -1, destTime*1000000);
+#else
+#if LIBAVFORMAT_BUILD < ((49<<16)+(0<<8)+0)
+ av_seek_frame(m_pFormatContext, -1, destTime*1000000, 0);
+#else
+ av_seek_frame(m_pFormatContext, -1, (long long)(destTime*AV_TIME_BASE), AVSEEK_FLAG_BACKWARD);
+#endif
+#endif
+ clearPacketCache();
+ map<int, PacketList>::iterator it;
+ for (it = m_PacketLists.begin(); it != m_PacketLists.end(); ++it) {
+ int CurStreamIndex = it->first;
+ AVStream * pStream = m_pFormatContext->streams[CurStreamIndex];
+ avcodec_flush_buffers(pStream->codec);
+ }
+}
+
+void FFMpegDemuxer::clearPacketCache()
+{
+ map<int, PacketList>::iterator it;
+ for (it = m_PacketLists.begin(); it != m_PacketLists.end(); ++it) {
+ PacketList::iterator it2;
+ PacketList* thePacketList = &(it->second);
+ for (it2 = thePacketList->begin(); it2 != thePacketList->end(); ++it2) {
+ av_free_packet(*it2);
+ delete *it2;
+ }
+ thePacketList->clear();
+ }
+}
+
+void FFMpegDemuxer::dump()
+{
+ map<int, PacketList>::iterator it;
+ cerr << "FFMpegDemuxer " << this << endl;
+ cerr << "packetlists.size(): " << int(m_PacketLists.size()) << endl;
+ for (it = m_PacketLists.begin(); it != m_PacketLists.end(); ++it) {
+ cerr << " " << it->first << ": " << int(it->second.size()) << endl;
+ }
+}
+
+}
diff --git a/src/video/FFMpegDemuxer.h b/src/video/FFMpegDemuxer.h
new file mode 100644
index 0000000..b633fa1
--- /dev/null
+++ b/src/video/FFMpegDemuxer.h
@@ -0,0 +1,59 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _FFMpegDemuxer_H_
+#define _FFMpegDemuxer_H_
+
+#include "../avgconfigwrapper.h"
+#include "IDemuxer.h"
+
+#include "WrapFFMpeg.h"
+
+#include <list>
+#include <vector>
+#include <map>
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+ class AVG_API FFMpegDemuxer: public IDemuxer {
+ public:
+ FFMpegDemuxer(AVFormatContext * pFormatContext,
+ std::vector<int> streamIndexes);
+ virtual ~FFMpegDemuxer();
+
+ AVPacket * getPacket(int streamIndex);
+ void seek(double destTime);
+ void dump();
+
+ private:
+ void clearPacketCache();
+
+ typedef std::list<AVPacket *> PacketList;
+ std::map<int, PacketList> m_PacketLists;
+
+ AVFormatContext * m_pFormatContext;
+ };
+ typedef boost::shared_ptr<FFMpegDemuxer> FFMpegDemuxerPtr;
+}
+
+#endif
diff --git a/src/video/FrameAge.cpp b/src/video/FrameAge.cpp
new file mode 100644
index 0000000..a6dcd1f
--- /dev/null
+++ b/src/video/FrameAge.cpp
@@ -0,0 +1,34 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#include "FrameAge.h"
+
+namespace avg{
+
+FrameAge::FrameAge():
+ m_Age(256*256*256*64),
+ m_IPAge0(256*256*256*64),
+ m_IPAge1(256*256*256*64)
+{
+}
+
+}
+
+
diff --git a/src/video/FrameAge.h b/src/video/FrameAge.h
new file mode 100644
index 0000000..18a529f
--- /dev/null
+++ b/src/video/FrameAge.h
@@ -0,0 +1,37 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#ifndef _FrameAge_H_
+#define _FrameAge_H_
+
+namespace avg{
+
+struct FrameAge
+{
+ FrameAge();
+ int m_Age;
+ int m_IPAge0;
+ int m_IPAge1;
+};
+
+}
+
+#endif
+
diff --git a/src/video/IDemuxer.h b/src/video/IDemuxer.h
new file mode 100644
index 0000000..2df0e03
--- /dev/null
+++ b/src/video/IDemuxer.h
@@ -0,0 +1,46 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _IDemuxer_H_
+#define _IDemuxer_H_
+
+#include "../api.h"
+#include <math.h>
+
+#include "WrapFFMpeg.h"
+
+#include <boost/shared_ptr.hpp>
+
+namespace avg {
+
+ class AVG_API IDemuxer {
+ public:
+ virtual ~IDemuxer() {};
+
+ virtual AVPacket * getPacket(int StreamIndex) = 0;
+ virtual void seek(double DestTime) = 0;
+ virtual void dump() {};
+
+ };
+ typedef boost::shared_ptr<IDemuxer> IDemuxerPtr;
+}
+
+#endif
diff --git a/src/video/Makefile.am b/src/video/Makefile.am
new file mode 100644
index 0000000..9b72552
--- /dev/null
+++ b/src/video/Makefile.am
@@ -0,0 +1,47 @@
+
+INCLUDES = -I.. @PTHREAD_CFLAGS@ @FFMPEG_CFLAGS@
+
+if APPLE
+ X_LIBS =
+else
+ X_LIBS = -lX11
+endif
+
+ALL_H = FFMpegDemuxer.h VideoDemuxerThread.h FFMpegDecoder.h VideoDecoder.h \
+ VideoDecoderThread.h AudioDecoderThread.h VideoMsg.h \
+ PacketVideoMsg.h AsyncVideoDecoder.h VideoDecoderThread.h \
+ IDemuxer.h AsyncDemuxer.h VideoInfo.h WrapFFMpeg.h
+
+if USE_VDPAU_SRC
+ ALL_H += VDPAU.h AVCCOpaque.h FrameAge.h
+endif
+
+TESTS=testvideo
+
+EXTRA_DIST = $(wildcard testfiles/*.mov) $(wildcard testfiles/*.mpg) \
+ $(wildcard testfiles/*.avi) $(wildcard testfiles/*.h264) \
+ $(wildcard testfiles/*.wav) $(wildcard testfiles/*.ogg) \
+ $(wildcard testfiles/*.mp3) $(wildcard testfiles/*.aif) \
+ $(wildcard testfiles/*.flv) $(wildcard baseline/*.png)
+
+noinst_LTLIBRARIES = libvideo.la
+noinst_PROGRAMS=testvideo
+
+libvideo_la_SOURCES = FFMpegDemuxer.cpp VideoDemuxerThread.cpp FFMpegDecoder.cpp \
+ VideoDecoderThread.cpp AudioDecoderThread.cpp VideoMsg.cpp VideoDecoder.cpp \
+ PacketVideoMsg.cpp AsyncVideoDecoder.cpp AsyncDemuxer.cpp VideoInfo.cpp \
+ $(ALL_H)
+
+if USE_VDPAU_SRC
+ libvideo_la_SOURCES += AVCCOpaque.cpp FrameAge.cpp VDPAU.cpp
+endif
+
+libvideo_la_LIBADD = @LIBVIDEO_LDADD@
+
+testvideo_SOURCES = testvideo.cpp $(ALL_H)
+testvideo_LDADD = ./libvideo.la ../audio/libaudio.la ../graphics/libgraphics.la \
+ ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ -lboost_system @PTHREAD_LIBS@ \
+ @LIBFFMPEG@ $(X_LIBS) \
+ @GDK_PIXBUF_LIBS@
+
diff --git a/src/video/Makefile.in b/src/video/Makefile.in
new file mode 100644
index 0000000..cfb48f2
--- /dev/null
+++ b/src/video/Makefile.in
@@ -0,0 +1,756 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+@USE_VDPAU_SRC_TRUE@am__append_1 = VDPAU.h AVCCOpaque.h FrameAge.h
+TESTS = testvideo$(EXEEXT)
+noinst_PROGRAMS = testvideo$(EXEEXT)
+@USE_VDPAU_SRC_TRUE@am__append_2 = AVCCOpaque.cpp FrameAge.cpp VDPAU.cpp
+subdir = src/video
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libvideo_la_DEPENDENCIES =
+am__libvideo_la_SOURCES_DIST = FFMpegDemuxer.cpp \
+ VideoDemuxerThread.cpp FFMpegDecoder.cpp \
+ VideoDecoderThread.cpp AudioDecoderThread.cpp VideoMsg.cpp \
+ VideoDecoder.cpp PacketVideoMsg.cpp AsyncVideoDecoder.cpp \
+ AsyncDemuxer.cpp VideoInfo.cpp FFMpegDemuxer.h \
+ VideoDemuxerThread.h FFMpegDecoder.h VideoDecoder.h \
+ VideoDecoderThread.h AudioDecoderThread.h VideoMsg.h \
+ PacketVideoMsg.h AsyncVideoDecoder.h IDemuxer.h AsyncDemuxer.h \
+ VideoInfo.h WrapFFMpeg.h VDPAU.h AVCCOpaque.h FrameAge.h \
+ AVCCOpaque.cpp FrameAge.cpp VDPAU.cpp
+am__objects_1 =
+am__objects_2 = $(am__objects_1)
+@USE_VDPAU_SRC_TRUE@am__objects_3 = AVCCOpaque.lo FrameAge.lo VDPAU.lo
+am_libvideo_la_OBJECTS = FFMpegDemuxer.lo VideoDemuxerThread.lo \
+ FFMpegDecoder.lo VideoDecoderThread.lo AudioDecoderThread.lo \
+ VideoMsg.lo VideoDecoder.lo PacketVideoMsg.lo \
+ AsyncVideoDecoder.lo AsyncDemuxer.lo VideoInfo.lo \
+ $(am__objects_2) $(am__objects_3)
+libvideo_la_OBJECTS = $(am_libvideo_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+PROGRAMS = $(noinst_PROGRAMS)
+am__testvideo_SOURCES_DIST = testvideo.cpp FFMpegDemuxer.h \
+ VideoDemuxerThread.h FFMpegDecoder.h VideoDecoder.h \
+ VideoDecoderThread.h AudioDecoderThread.h VideoMsg.h \
+ PacketVideoMsg.h AsyncVideoDecoder.h IDemuxer.h AsyncDemuxer.h \
+ VideoInfo.h WrapFFMpeg.h VDPAU.h AVCCOpaque.h FrameAge.h
+am_testvideo_OBJECTS = testvideo.$(OBJEXT) $(am__objects_2)
+testvideo_OBJECTS = $(am_testvideo_OBJECTS)
+am__DEPENDENCIES_1 =
+testvideo_DEPENDENCIES = ./libvideo.la ../audio/libaudio.la \
+ ../graphics/libgraphics.la ../base/libbase.la \
+ $(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(libvideo_la_SOURCES) $(testvideo_SOURCES)
+DIST_SOURCES = $(am__libvideo_la_SOURCES_DIST) \
+ $(am__testvideo_SOURCES_DIST)
+ETAGS = etags
+CTAGS = ctags
+am__tty_colors = \
+red=; grn=; lgn=; blu=; std=
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I.. @PTHREAD_CFLAGS@ @FFMPEG_CFLAGS@
+@APPLE_FALSE@X_LIBS = -lX11
+@APPLE_TRUE@X_LIBS =
+ALL_H = FFMpegDemuxer.h VideoDemuxerThread.h FFMpegDecoder.h \
+ VideoDecoder.h VideoDecoderThread.h AudioDecoderThread.h \
+ VideoMsg.h PacketVideoMsg.h AsyncVideoDecoder.h \
+ VideoDecoderThread.h IDemuxer.h AsyncDemuxer.h VideoInfo.h \
+ WrapFFMpeg.h $(am__append_1)
+EXTRA_DIST = $(wildcard testfiles/*.mov) $(wildcard testfiles/*.mpg) \
+ $(wildcard testfiles/*.avi) $(wildcard testfiles/*.h264) \
+ $(wildcard testfiles/*.wav) $(wildcard testfiles/*.ogg) \
+ $(wildcard testfiles/*.mp3) $(wildcard testfiles/*.aif) \
+ $(wildcard testfiles/*.flv) $(wildcard baseline/*.png)
+
+noinst_LTLIBRARIES = libvideo.la
+libvideo_la_SOURCES = FFMpegDemuxer.cpp VideoDemuxerThread.cpp \
+ FFMpegDecoder.cpp VideoDecoderThread.cpp \
+ AudioDecoderThread.cpp VideoMsg.cpp VideoDecoder.cpp \
+ PacketVideoMsg.cpp AsyncVideoDecoder.cpp AsyncDemuxer.cpp \
+ VideoInfo.cpp $(ALL_H) $(am__append_2)
+libvideo_la_LIBADD = @LIBVIDEO_LDADD@
+testvideo_SOURCES = testvideo.cpp $(ALL_H)
+testvideo_LDADD = ./libvideo.la ../audio/libaudio.la ../graphics/libgraphics.la \
+ ../base/libbase.la \
+ @XML2_LIBS@ -l@BOOST_THREAD_LIB@ @PTHREAD_LIBS@ \
+ @LIBFFMPEG@ $(X_LIBS) \
+ @GDK_PIXBUF_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/video/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/video/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLTLIBRARIES:
+ -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+ @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+libvideo.la: $(libvideo_la_OBJECTS) $(libvideo_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(CXXLINK) $(libvideo_la_OBJECTS) $(libvideo_la_LIBADD) $(LIBS)
+
+clean-noinstPROGRAMS:
+ @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+ echo " rm -f" $$list; \
+ rm -f $$list || exit $$?; \
+ test -n "$(EXEEXT)" || exit 0; \
+ list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+ echo " rm -f" $$list; \
+ rm -f $$list
+testvideo$(EXEEXT): $(testvideo_OBJECTS) $(testvideo_DEPENDENCIES)
+ @rm -f testvideo$(EXEEXT)
+ $(AM_V_CXXLD)$(CXXLINK) $(testvideo_OBJECTS) $(testvideo_LDADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AVCCOpaque.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AsyncDemuxer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AsyncVideoDecoder.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/AudioDecoderThread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FFMpegDecoder.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FFMpegDemuxer.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/FrameAge.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/PacketVideoMsg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VDPAU.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoDecoder.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoDecoderThread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoDemuxerThread.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoInfo.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/VideoMsg.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testvideo.Po@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+check-TESTS: $(TESTS)
+ @failed=0; all=0; xfail=0; xpass=0; skip=0; \
+ srcdir=$(srcdir); export srcdir; \
+ list=' $(TESTS) '; \
+ $(am__tty_colors); \
+ if test -n "$$list"; then \
+ for tst in $$list; do \
+ if test -f ./$$tst; then dir=./; \
+ elif test -f $$tst; then dir=; \
+ else dir="$(srcdir)/"; fi; \
+ if $(TESTS_ENVIRONMENT) $${dir}$$tst; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xpass=`expr $$xpass + 1`; \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=XPASS; \
+ ;; \
+ *) \
+ col=$$grn; res=PASS; \
+ ;; \
+ esac; \
+ elif test $$? -ne 77; then \
+ all=`expr $$all + 1`; \
+ case " $(XFAIL_TESTS) " in \
+ *[\ \ ]$$tst[\ \ ]*) \
+ xfail=`expr $$xfail + 1`; \
+ col=$$lgn; res=XFAIL; \
+ ;; \
+ *) \
+ failed=`expr $$failed + 1`; \
+ col=$$red; res=FAIL; \
+ ;; \
+ esac; \
+ else \
+ skip=`expr $$skip + 1`; \
+ col=$$blu; res=SKIP; \
+ fi; \
+ echo "$${col}$$res$${std}: $$tst"; \
+ done; \
+ if test "$$all" -eq 1; then \
+ tests="test"; \
+ All=""; \
+ else \
+ tests="tests"; \
+ All="All "; \
+ fi; \
+ if test "$$failed" -eq 0; then \
+ if test "$$xfail" -eq 0; then \
+ banner="$$All$$all $$tests passed"; \
+ else \
+ if test "$$xfail" -eq 1; then failures=failure; else failures=failures; fi; \
+ banner="$$All$$all $$tests behaved as expected ($$xfail expected $$failures)"; \
+ fi; \
+ else \
+ if test "$$xpass" -eq 0; then \
+ banner="$$failed of $$all $$tests failed"; \
+ else \
+ if test "$$xpass" -eq 1; then passes=pass; else passes=passes; fi; \
+ banner="$$failed of $$all $$tests did not behave as expected ($$xpass unexpected $$passes)"; \
+ fi; \
+ fi; \
+ dashes="$$banner"; \
+ skipped=""; \
+ if test "$$skip" -ne 0; then \
+ if test "$$skip" -eq 1; then \
+ skipped="($$skip test was not run)"; \
+ else \
+ skipped="($$skip tests were not run)"; \
+ fi; \
+ test `echo "$$skipped" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$skipped"; \
+ fi; \
+ report=""; \
+ if test "$$failed" -ne 0 && test -n "$(PACKAGE_BUGREPORT)"; then \
+ report="Please report to $(PACKAGE_BUGREPORT)"; \
+ test `echo "$$report" | wc -c` -le `echo "$$banner" | wc -c` || \
+ dashes="$$report"; \
+ fi; \
+ dashes=`echo "$$dashes" | sed s/./=/g`; \
+ if test "$$failed" -eq 0; then \
+ echo "$$grn$$dashes"; \
+ else \
+ echo "$$red$$dashes"; \
+ fi; \
+ echo "$$banner"; \
+ test -z "$$skipped" || echo "$$skipped"; \
+ test -z "$$report" || echo "$$report"; \
+ echo "$$dashes$$std"; \
+ test "$$failed" -eq 0; \
+ else :; fi
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+ $(MAKE) $(AM_MAKEFLAGS) check-TESTS
+check: check-am
+all-am: Makefile $(LTLIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-TESTS check-am clean \
+ clean-generic clean-libtool clean-noinstLTLIBRARIES \
+ clean-noinstPROGRAMS ctags distclean distclean-compile \
+ distclean-generic distclean-libtool distclean-tags distdir dvi \
+ dvi-am html html-am info info-am install install-am \
+ install-data install-data-am install-dvi install-dvi-am \
+ install-exec install-exec-am install-html install-html-am \
+ install-info install-info-am install-man install-pdf \
+ install-pdf-am install-ps install-ps-am install-strip \
+ installcheck installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/video/PacketVideoMsg.cpp b/src/video/PacketVideoMsg.cpp
new file mode 100644
index 0000000..e94e98f
--- /dev/null
+++ b/src/video/PacketVideoMsg.cpp
@@ -0,0 +1,57 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "PacketVideoMsg.h"
+
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+PacketVideoMsg::PacketVideoMsg(AVPacket * pPacket, bool bSeekDone)
+{
+ m_pPacket = pPacket;
+ m_bSeekDone = bSeekDone;
+}
+
+PacketVideoMsg::~PacketVideoMsg()
+{
+}
+
+void PacketVideoMsg::freePacket()
+{
+ av_free_packet(m_pPacket);
+ delete m_pPacket;
+}
+
+AVPacket * PacketVideoMsg::getPacket()
+{
+ return m_pPacket;
+}
+
+bool PacketVideoMsg::isSeekDone()
+{
+ return m_bSeekDone;
+}
+
+}
+
diff --git a/src/video/PacketVideoMsg.h b/src/video/PacketVideoMsg.h
new file mode 100644
index 0000000..766ac68
--- /dev/null
+++ b/src/video/PacketVideoMsg.h
@@ -0,0 +1,55 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _PacketVideoMsg_H_
+#define _PacketVideoMsg_H_
+
+#include "../avgconfigwrapper.h"
+#include "../base/Queue.h"
+#include "../graphics/Bitmap.h"
+
+#include "WrapFFMpeg.h"
+
+#include <vector>
+
+namespace avg {
+
+class AVG_API PacketVideoMsg {
+ public:
+ PacketVideoMsg(AVPacket * pPacket, bool bSeekDone);
+ virtual ~PacketVideoMsg();
+
+ void freePacket();
+ AVPacket * getPacket();
+ bool isSeekDone();
+
+ private:
+ AVPacket * m_pPacket;
+ bool m_bSeekDone;
+};
+
+typedef boost::shared_ptr<PacketVideoMsg> PacketVideoMsgPtr;
+typedef Queue<PacketVideoMsg> VideoPacketQueue;
+typedef boost::shared_ptr<VideoPacketQueue> VideoPacketQueuePtr;
+
+}
+#endif
+
diff --git a/src/video/VDPAU.cpp b/src/video/VDPAU.cpp
new file mode 100644
index 0000000..c6d83a0
--- /dev/null
+++ b/src/video/VDPAU.cpp
@@ -0,0 +1,393 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#include "VDPAU.h"
+#include "FrameAge.h"
+#include "AVCCOpaque.h"
+#include "../base/Exception.h"
+#include <iostream>
+
+using namespace std;
+
+namespace avg {
+
+VdpGetProcAddress* vdp_get_proc_address;
+VdpDeviceDestroy* vdp_device_destroy;
+VdpVideoSurfaceCreate* vdp_video_surface_create;
+VdpVideoSurfaceDestroy* vdp_video_surface_destroy;
+VdpDecoderCreate* vdp_decoder_create;
+VdpDecoderDestroy* vdp_decoder_destroy;
+VdpDecoderRender* vdp_decoder_render;
+VdpOutputSurfaceCreate* vdp_output_surface_create;
+VdpOutputSurfaceDestroy* vdp_output_surface_destroy;
+VdpOutputSurfaceGetBitsNative* vdp_output_surface_get_bits_native;
+VdpOutputSurfaceGetParameters* vdp_output_surface_get_parameters;
+VdpVideoSurfaceGetBitsYCbCr* vdp_video_surface_get_bits_y_cb_cr;
+VdpVideoMixerCreate* vdp_video_mixer_create;
+VdpVideoMixerDestroy* vdp_video_mixer_destroy;
+VdpVideoMixerRender* vdp_video_mixer_render;
+VdpPresentationQueueCreate* vdp_presentation_queue_create;
+VdpPresentationQueueDestroy* vdp_presentation_queue_destroy;
+VdpPresentationQueueGetTime* vdp_presentation_queue_get_time;
+VdpPresentationQueueTargetCreateX11* vdp_presentation_queue_target_create_x11;
+VdpPresentationQueueQuerySurfaceStatus* vdp_presentation_queue_query_surface_status;
+VdpPresentationQueueDisplay* vdp_presentation_queue_display;
+VdpPresentationQueueBlockUntilSurfaceIdle*
+ vdp_presentation_queue_block_until_surface_idle;
+VdpVideoSurfaceGetParameters* vdp_video_surface_get_parameters;
+
+
+VdpDevice VDPAU::s_VDPDevice = 0;
+Display* VDPAU::s_pXDisplay = 0;
+bool VDPAU::s_bInitFailed = false;
+
+VDPAU::VDPAU()
+ : m_VDPDecoder(VDP_INVALID_HANDLE),
+ m_VDPMixer(VDP_INVALID_HANDLE),
+ m_PixFmt(PIX_FMT_NONE),
+ m_Size(-1,-1)
+{
+ for (int i = 0; i < N_VIDEO_SURFACES; i++) {
+ m_VideoSurfaces[i].m_Surface = VDP_INVALID_HANDLE;
+ }
+}
+
+VDPAU::~VDPAU()
+{
+ if (m_VDPMixer != VDP_INVALID_HANDLE) {
+ vdp_video_mixer_destroy(m_VDPMixer);
+ }
+ if (m_VDPDecoder != VDP_INVALID_HANDLE) {
+ vdp_decoder_destroy(m_VDPDecoder);
+ }
+ for (int i = 0; i < N_VIDEO_SURFACES; i++) {
+ if (m_VideoSurfaces[i].m_Surface != VDP_INVALID_HANDLE) {
+ vdp_video_surface_destroy(m_VideoSurfaces[i].m_Surface);
+ }
+ }
+}
+
+void VDPAU::safeGetProcAddress(VdpFuncId functionId, void** functionPointer)
+{
+ VdpStatus status;
+ status = vdp_get_proc_address(s_VDPDevice, functionId, functionPointer);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+}
+
+Display* VDPAU::getDisplay()
+{
+ return s_pXDisplay;
+}
+
+bool VDPAU::staticInit()
+{
+ if (s_VDPDevice) {
+ return true;
+ }
+
+ if (s_bInitFailed) {
+ return false;
+ }
+
+ s_pXDisplay = XOpenDisplay(0);
+ if (!s_pXDisplay) {
+ s_bInitFailed = true;
+ return false;
+ }
+
+ VdpStatus status;
+ status = vdp_device_create_x11(s_pXDisplay, DefaultScreen(s_pXDisplay),
+ &s_VDPDevice, &vdp_get_proc_address);
+ if (status != VDP_STATUS_OK) {
+ s_bInitFailed = true;
+ return false;
+ }
+
+ safeGetProcAddress(VDP_FUNC_ID_DEVICE_DESTROY, (void**)&vdp_device_destroy);
+ safeGetProcAddress(VDP_FUNC_ID_OUTPUT_SURFACE_CREATE,
+ (void**)&vdp_output_surface_create);
+ safeGetProcAddress(VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY,
+ (void**)&vdp_output_surface_destroy);
+ safeGetProcAddress(VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE,
+ (void**)&vdp_output_surface_get_bits_native);
+ safeGetProcAddress(VDP_FUNC_ID_VIDEO_SURFACE_CREATE,
+ (void**)&vdp_video_surface_create);
+ safeGetProcAddress(VDP_FUNC_ID_VIDEO_SURFACE_DESTROY,
+ (void**)&vdp_video_surface_destroy);
+ safeGetProcAddress(VDP_FUNC_ID_DECODER_CREATE, (void**)&vdp_decoder_create);
+ safeGetProcAddress(VDP_FUNC_ID_DECODER_DESTROY, (void**)&vdp_decoder_destroy);
+ safeGetProcAddress(VDP_FUNC_ID_DECODER_RENDER, (void**)&vdp_decoder_render);
+ safeGetProcAddress(VDP_FUNC_ID_VIDEO_SURFACE_GET_BITS_Y_CB_CR,
+ (void**)&vdp_video_surface_get_bits_y_cb_cr);
+ safeGetProcAddress(VDP_FUNC_ID_VIDEO_MIXER_CREATE,
+ (void**)&vdp_video_mixer_create);
+ safeGetProcAddress(VDP_FUNC_ID_VIDEO_MIXER_DESTROY,
+ (void**)&vdp_video_mixer_destroy);
+ safeGetProcAddress(VDP_FUNC_ID_VIDEO_MIXER_RENDER,
+ (void**)&vdp_video_mixer_render);
+ safeGetProcAddress(VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE,
+ (void**)&vdp_presentation_queue_create);
+ safeGetProcAddress(VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY,
+ (void**)&vdp_presentation_queue_destroy);
+ safeGetProcAddress(VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11,
+ (void**)&vdp_presentation_queue_target_create_x11);
+ safeGetProcAddress(VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS,
+ (void**)&vdp_presentation_queue_query_surface_status);
+ safeGetProcAddress(VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY,
+ (void**)&vdp_presentation_queue_display);
+ safeGetProcAddress(VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME,
+ (void**)&vdp_presentation_queue_get_time);
+ safeGetProcAddress(VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE,
+ (void**)&vdp_presentation_queue_block_until_surface_idle);
+ safeGetProcAddress(VDP_FUNC_ID_VIDEO_SURFACE_GET_PARAMETERS,
+ (void**)&vdp_video_surface_get_parameters);
+ safeGetProcAddress(VDP_FUNC_ID_OUTPUT_SURFACE_GET_PARAMETERS,
+ (void**)&vdp_output_surface_get_parameters);
+ return true;
+}
+
+void VDPAU::init()
+{
+ if (!staticInit()) {
+ return;
+ }
+ for (int i = 0; i < N_VIDEO_SURFACES; i++) {
+ memset(&m_VideoSurfaces[i].m_RenderState, 0, sizeof(vdpau_render_state));
+ m_VideoSurfaces[i].m_RenderState.surface = VDP_INVALID_HANDLE;
+ m_VideoSurfaces[i].m_Size = IntPoint(-1,-1);
+ }
+}
+
+bool VDPAU::isAvailable()
+{
+ staticInit();
+ return s_VDPDevice;
+}
+
+AVCodec* VDPAU::openCodec(AVCodecContext* pContext)
+{
+ staticInit();
+
+ AVCodec* pCodec = 0;
+ switch (pContext->codec_id) {
+ case CODEC_ID_MPEG1VIDEO:
+ pCodec = avcodec_find_decoder_by_name("mpeg1video_vdpau");
+ pCodec->id = CODEC_ID_MPEG1VIDEO;
+ break;
+ case CODEC_ID_MPEG2VIDEO:
+ pCodec = avcodec_find_decoder_by_name("mpegvideo_vdpau");
+ break;
+ case CODEC_ID_H264:
+ pCodec = avcodec_find_decoder_by_name("h264_vdpau");
+ break;
+ case CODEC_ID_WMV3:
+ pCodec = avcodec_find_decoder_by_name("wmv3_vdpau");
+ break;
+ case CODEC_ID_VC1:
+ pCodec = avcodec_find_decoder_by_name("vc1_vdpau");
+ break;
+ default:
+ pCodec = 0;
+ }
+ if (!pCodec || !s_VDPDevice) {
+ pCodec = avcodec_find_decoder(pContext->codec_id);
+ } else {
+ pContext->get_buffer = VDPAU::getBuffer;
+ pContext->release_buffer = VDPAU::releaseBuffer;
+ pContext->draw_horiz_band = VDPAU::drawHorizBand;
+ pContext->get_format = VDPAU::getFormat;
+ pContext->slice_flags = SLICE_FLAG_CODED_ORDER | SLICE_FLAG_ALLOW_FIELD;
+ }
+ return pCodec;
+}
+
+int VDPAU::getBuffer(AVCodecContext* pContext, AVFrame* pFrame)
+{
+ AVCCOpaque* pOpaque = (AVCCOpaque*)pContext->opaque;
+ FrameAge* pAge = pOpaque->getFrameAge();
+ VDPAU* pVDPAU = pOpaque->getVDPAU();
+ return pVDPAU->getBufferInternal(pContext, pFrame, pAge);
+}
+
+int VDPAU::getFreeSurfaceIndex()
+{
+ for (int i = 0; i < N_VIDEO_SURFACES; i++) {
+ vdpau_render_state* pRenderState = &m_VideoSurfaces[i].m_RenderState;
+ if (!(pRenderState->state & FF_VDPAU_STATE_USED_FOR_REFERENCE)) {
+ return i;
+ }
+ }
+ AVG_ASSERT(false);
+ return -1;
+}
+
+int VDPAU::getBufferInternal(AVCodecContext* pContext, AVFrame* pFrame,
+ FrameAge* pAge)
+{
+ VdpStatus status;
+ int surfaceIndex = getFreeSurfaceIndex();
+
+ VideoSurface* pVideoSurface = &m_VideoSurfaces[surfaceIndex];
+ vdpau_render_state* pRenderState = &pVideoSurface->m_RenderState;
+ pFrame->data[0] = (uint8_t*)pRenderState;
+ pFrame->type = FF_BUFFER_TYPE_USER;
+
+ if (pFrame->reference) { //I-P frame
+ pFrame->age = pAge->m_IPAge0;
+ pAge->m_IPAge0 = pAge->m_IPAge1;
+ pAge->m_IPAge1 = 1;
+ pAge->m_Age++;
+ } else {
+ pFrame->age = pAge->m_Age;
+ pAge->m_IPAge0++;
+ pAge->m_IPAge1++;
+ pAge->m_Age = 1;
+ }
+ pRenderState->state |= FF_VDPAU_STATE_USED_FOR_REFERENCE;
+
+ if (pVideoSurface->m_Size.x != pContext->width ||
+ pVideoSurface->m_Size.y != pContext->height)
+ {
+ // allocate a new surface, freeing the old one, if any
+ if (pVideoSurface->m_Surface != VDP_INVALID_HANDLE) {
+ status = vdp_video_surface_destroy(pVideoSurface->m_Surface);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+ }
+ status = vdp_video_surface_create(s_VDPDevice, VDP_CHROMA_TYPE_420,
+ pContext->width, pContext->height, &pVideoSurface->m_Surface);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+ pVideoSurface->m_Size.x = pContext->width;
+ pVideoSurface->m_Size.y = pContext->height;
+ pVideoSurface->m_RenderState.surface = pVideoSurface->m_Surface;
+ }
+ return 0;
+}
+
+// does not release the render structure, that will be unlocked after getting data
+void VDPAU::releaseBuffer(struct AVCodecContext* pContext, AVFrame* pFrame)
+{
+ pFrame->data[0] = 0;
+}
+
+
+// main rendering routine
+void VDPAU::drawHorizBand(struct AVCodecContext* pContext, const AVFrame* src,
+ int offset[4], int y, int type, int height)
+{
+ AVCCOpaque* pOpaque = (AVCCOpaque*)pContext->opaque;
+ VDPAU* pVDPAU = pOpaque->getVDPAU();
+ pVDPAU->render(pContext, src);
+}
+
+::PixelFormat VDPAU::getFormat(AVCodecContext* pContext, const ::PixelFormat* pFmt)
+{
+ switch (pContext->codec_id) {
+ case CODEC_ID_H264:
+ return PIX_FMT_VDPAU_H264;
+ case CODEC_ID_MPEG1VIDEO:
+ return PIX_FMT_VDPAU_MPEG1;
+ case CODEC_ID_MPEG2VIDEO:
+ return PIX_FMT_VDPAU_MPEG2;
+ case CODEC_ID_WMV3:
+ return PIX_FMT_VDPAU_WMV3;
+ case CODEC_ID_VC1:
+ return PIX_FMT_VDPAU_VC1;
+ default:
+ return pFmt[0];
+ }
+}
+
+void VDPAU::render(AVCodecContext* pContext, const AVFrame* pFrame)
+{
+ vdpau_render_state* pRenderState = (vdpau_render_state*)pFrame->data[0];
+ VdpStatus status;
+ IntPoint size(pContext->width, pContext->height);
+
+ if (pContext->pix_fmt != m_PixFmt || size != m_Size) {
+ VdpDecoderProfile profile = 0;
+ switch (pContext->pix_fmt) {
+ case PIX_FMT_VDPAU_MPEG1:
+ profile = VDP_DECODER_PROFILE_MPEG1;
+ break;
+ case PIX_FMT_VDPAU_MPEG2:
+ profile = VDP_DECODER_PROFILE_MPEG2_MAIN;
+ break;
+ case PIX_FMT_VDPAU_H264:
+ profile = VDP_DECODER_PROFILE_H264_HIGH;
+ break;
+ case PIX_FMT_VDPAU_WMV3:
+ profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
+ break;
+ case PIX_FMT_VDPAU_VC1:
+ profile = VDP_DECODER_PROFILE_VC1_SIMPLE;
+ break;
+ default:
+ AVG_ASSERT(false);
+ }
+ if (m_VDPMixer != VDP_INVALID_HANDLE) {
+ status = vdp_video_mixer_destroy(m_VDPMixer);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+ m_VDPMixer = VDP_INVALID_HANDLE;
+ }
+ if (m_VDPDecoder != VDP_INVALID_HANDLE) {
+ status = vdp_decoder_destroy(m_VDPDecoder);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+ m_VDPDecoder = VDP_INVALID_HANDLE;
+ }
+ status = vdp_decoder_create(s_VDPDevice, profile, size.x, size.y, 16,
+ &m_VDPDecoder);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+
+ m_PixFmt = pContext->pix_fmt;
+ m_Size = size;
+
+ VdpVideoMixerFeature features[] = {
+ VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL,
+ VDP_VIDEO_MIXER_FEATURE_DEINTERLACE_TEMPORAL_SPATIAL,
+ };
+ VdpVideoMixerParameter params[] = {
+ VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_WIDTH,
+ VDP_VIDEO_MIXER_PARAMETER_VIDEO_SURFACE_HEIGHT,
+ VDP_VIDEO_MIXER_PARAMETER_CHROMA_TYPE,
+ VDP_VIDEO_MIXER_PARAMETER_LAYERS
+ };
+ VdpChromaType chroma = VDP_CHROMA_TYPE_420;
+ int numLayers = 0;
+ void const* paramValues [] = { &m_Size.x, &m_Size.y, &chroma, &numLayers };
+
+ status = vdp_video_mixer_create(s_VDPDevice, 2, features, 4, params, paramValues,
+ &m_VDPMixer);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+ }
+
+ status = vdp_decoder_render(m_VDPDecoder, pRenderState->surface,
+ (VdpPictureInfo const*)&(pRenderState->info),
+ pRenderState->bitstream_buffers_used, pRenderState->bitstream_buffers);
+ AVG_ASSERT(status == VDP_STATUS_OK);
+}
+
+void VDPAU::unlockSurface(vdpau_render_state* pRenderState)
+{
+ pRenderState->state &= ~FF_VDPAU_STATE_USED_FOR_REFERENCE;
+}
+
+}
+
+
diff --git a/src/video/VDPAU.h b/src/video/VDPAU.h
new file mode 100644
index 0000000..b2d8a1b
--- /dev/null
+++ b/src/video/VDPAU.h
@@ -0,0 +1,115 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+#ifndef _VDPAU_H_
+#define _VDPAU_H_
+
+
+#include "../avgconfigwrapper.h"
+#include "../graphics/GL/glx.h"
+
+#include "WrapFFMpeg.h"
+#include "../base/Point.h"
+
+#include <vdpau/vdpau.h>
+#include <libavcodec/vdpau.h>
+
+
+namespace avg {
+
+#define N_VIDEO_SURFACES 64
+
+struct FrameAge;
+
+struct VideoSurface
+{
+ struct vdpau_render_state m_RenderState;
+ VdpVideoSurface m_Surface;
+ IntPoint m_Size;
+};
+
+extern VdpVideoSurfaceGetParameters* vdp_video_surface_get_parameters;
+extern VdpVideoSurfaceGetBitsYCbCr* vdp_video_surface_get_bits_y_cb_cr;
+extern VdpOutputSurfaceDestroy* vdp_output_surface_destroy;
+extern VdpGetProcAddress* vdp_get_proc_address;
+extern VdpDeviceDestroy* vdp_device_destroy;
+extern VdpVideoSurfaceCreate* vdp_video_surface_create;
+extern VdpVideoSurfaceDestroy* vdp_video_surface_destroy;
+extern VdpDecoderCreate* vdp_decoder_create;
+extern VdpDecoderDestroy* vdp_decoder_destroy;
+extern VdpDecoderRender* vdp_decoder_render;
+extern VdpOutputSurfaceCreate* vdp_output_surface_create;
+extern VdpOutputSurfaceDestroy* vdp_output_surface_destroy;
+extern VdpOutputSurfaceGetBitsNative* vdp_output_surface_get_bits_native;
+extern VdpOutputSurfaceGetParameters* vdp_output_surface_get_parameters;
+extern VdpVideoSurfaceGetBitsYCbCr* vdp_video_surface_get_bits_y_cb_cr;
+extern VdpVideoMixerCreate* vdp_video_mixer_create;
+extern VdpVideoMixerDestroy* vdp_video_mixer_destroy;
+extern VdpVideoMixerRender* vdp_video_mixer_render;
+extern VdpPresentationQueueCreate* vdp_presentation_queue_create;
+extern VdpPresentationQueueDestroy* vdp_presentation_queue_destroy;
+extern VdpPresentationQueueGetTime* vdp_presentation_queue_get_time;
+extern VdpPresentationQueueTargetCreateX11* vdp_presentation_queue_target_create_x11;
+extern VdpPresentationQueueQuerySurfaceStatus*
+ vdp_presentation_queue_query_surface_status;
+extern VdpPresentationQueueDisplay* vdp_presentation_queue_display;
+extern VdpPresentationQueueBlockUntilSurfaceIdle*
+ vdp_presentation_queue_block_until_surface_idle;
+extern VdpVideoSurfaceGetParameters* vdp_video_surface_get_parameters;
+
+
+class VDPAU
+{
+public:
+ VDPAU();
+ ~VDPAU();
+ AVCodec* openCodec(AVCodecContext* pCodec);
+ void init();
+ Display* getDisplay();
+ static void unlockSurface(vdpau_render_state* pRenderState);
+ static bool isAvailable();
+
+private:
+ static bool staticInit();
+ static int getBuffer(AVCodecContext* pContext, AVFrame* pFrame);
+ int getFreeSurfaceIndex();
+ int getBufferInternal(AVCodecContext* pContext, AVFrame* pFrame, FrameAge* pAge);
+ static void releaseBuffer(struct AVCodecContext* pContext, AVFrame* pFrame);
+ static void drawHorizBand(AVCodecContext* pContext, const AVFrame* pFrame,
+ int offset[4], int y, int type, int height);
+ static ::PixelFormat getFormat(AVCodecContext* pContext, const ::PixelFormat* pFmt);
+ void render(AVCodecContext* pContext, const AVFrame* pFrame);
+ static void safeGetProcAddress(VdpFuncId function_id, void** function_pointer);
+
+ static VdpDevice s_VDPDevice;
+ static Display* s_pXDisplay;
+ static bool s_bInitFailed;
+
+ VdpDecoder m_VDPDecoder;
+ VdpVideoMixer m_VDPMixer;
+ ::PixelFormat m_PixFmt;
+ IntPoint m_Size;
+ VideoSurface m_VideoSurfaces[N_VIDEO_SURFACES];
+
+};
+
+}
+#endif
+
diff --git a/src/video/VideoDecoder.cpp b/src/video/VideoDecoder.cpp
new file mode 100644
index 0000000..e18fa73
--- /dev/null
+++ b/src/video/VideoDecoder.cpp
@@ -0,0 +1,42 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VideoDecoder.h"
+#include "../base/Exception.h"
+
+namespace avg {
+
+FrameAvailableCode VideoDecoder::renderToBmp(BitmapPtr pBmp, double timeWanted)
+{
+ std::vector<BitmapPtr> pBmps;
+ pBmps.push_back(pBmp);
+ return renderToBmps(pBmps, timeWanted);
+}
+
+FrameAvailableCode VideoDecoder::renderToVDPAU(vdpau_render_state** ppRenderState)
+{
+ AVG_ASSERT(false);
+ return FA_NEW_FRAME; // Silence compiler warning.
+}
+
+}
+
+
diff --git a/src/video/VideoDecoder.h b/src/video/VideoDecoder.h
new file mode 100644
index 0000000..60fdea4
--- /dev/null
+++ b/src/video/VideoDecoder.h
@@ -0,0 +1,86 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoDecoder_H_
+#define _VideoDecoder_H_
+
+#include "../api.h"
+
+#include "VideoInfo.h"
+
+#include "../graphics/Bitmap.h"
+#include "../audio/IAudioSource.h"
+
+#include <string>
+
+struct vdpau_render_state;
+
+namespace avg {
+
+enum FrameAvailableCode {
+ FA_NEW_FRAME, FA_USE_LAST_FRAME, FA_STILL_DECODING
+};
+
+enum StreamSelect {
+ SS_AUDIO, SS_VIDEO, SS_DEFAULT, SS_ALL
+};
+
+class AVG_API VideoDecoder
+{
+ public:
+ enum DecoderState {CLOSED, OPENED, DECODING};
+ virtual ~VideoDecoder() {};
+ virtual void open(const std::string& sFilename, bool bSyncDemuxer,
+ bool bUseHardwareAcceleration = true) = 0;
+ virtual void startDecoding(bool bDeliverYCbCr, const AudioParams* pAP) = 0;
+ virtual void close() = 0;
+ virtual DecoderState getState() const = 0;
+ virtual VideoInfo getVideoInfo() const = 0;
+
+ virtual void seek(double destTime) = 0;
+ virtual void loop() = 0;
+ virtual IntPoint getSize() const = 0;
+ virtual int getCurFrame() const = 0;
+ virtual int getNumFramesQueued() const = 0;
+ virtual double getCurTime(StreamSelect stream = SS_DEFAULT) const = 0;
+ virtual double getNominalFPS() const = 0;
+ virtual double getFPS() const = 0;
+ virtual void setFPS(double fps) = 0;
+ virtual double getVolume() const = 0;
+ virtual void setVolume(double volume) = 0;
+ virtual PixelFormat getPixelFormat() const = 0;
+
+ virtual FrameAvailableCode renderToBmp(BitmapPtr pBmp,
+ double timeWanted);
+ virtual FrameAvailableCode renderToBmps(std::vector<BitmapPtr>& pBmps,
+ double timeWanted) = 0;
+ virtual FrameAvailableCode renderToVDPAU(vdpau_render_state** ppRenderState);
+ virtual bool isEOF(StreamSelect stream = SS_ALL) const = 0;
+ virtual void throwAwayFrame(double timeWanted) = 0;
+
+ virtual int fillAudioBuffer(AudioBufferPtr pBuffer) = 0;
+};
+
+typedef boost::shared_ptr<VideoDecoder> VideoDecoderPtr;
+
+}
+#endif
+
diff --git a/src/video/VideoDecoderThread.cpp b/src/video/VideoDecoderThread.cpp
new file mode 100644
index 0000000..59d7d10
--- /dev/null
+++ b/src/video/VideoDecoderThread.cpp
@@ -0,0 +1,163 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VideoDecoderThread.h"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../base/ScopeTimer.h"
+#include "../base/TimeSource.h"
+#include "../avgconfigwrapper.h"
+
+struct vdpau_render_state;
+
+using namespace std;
+
+namespace avg {
+
+VideoDecoderThread::VideoDecoderThread(CQueue& cmdQ, VideoMsgQueue& msgQ,
+ VideoDecoderPtr pDecoder)
+ : WorkerThread<VideoDecoderThread>(string("Video Decoder"), cmdQ,
+ Logger::PROFILE_VIDEO),
+ m_MsgQ(msgQ),
+ m_pDecoder(pDecoder),
+ m_pBmpQ(new BitmapQueue()),
+ m_pHalfBmpQ(new BitmapQueue())
+{
+}
+
+VideoDecoderThread::~VideoDecoderThread()
+{
+}
+
+static ProfilingZoneID DecoderProfilingZone("DecoderThread");
+static ProfilingZoneID PushMsgProfilingZone("DecoderThread: push message");
+
+bool VideoDecoderThread::work()
+{
+ if (m_pDecoder->isEOF(SS_VIDEO)) {
+ if (!m_pDecoder->getVideoInfo().m_bHasAudio) {
+ m_pDecoder->seek(0);
+ } else {
+ // TODO: Replace this with waitForMessage()
+ msleep(10);
+ }
+ } else {
+ ScopeTimer timer(DecoderProfilingZone);
+ vdpau_render_state* pRenderState = 0;
+ FrameAvailableCode frameAvailable;
+ vector<BitmapPtr> pBmps;
+ bool usesVDPAU = m_pDecoder->getVideoInfo().m_bUsesVDPAU;
+ if (usesVDPAU) {
+#ifdef AVG_ENABLE_VDPAU
+ frameAvailable = m_pDecoder->renderToVDPAU(&pRenderState);
+#else
+ frameAvailable = FA_NEW_FRAME; // Never executed - silences compiler warning.
+#endif
+ } else {
+ IntPoint size = m_pDecoder->getSize();
+ IntPoint halfSize(size.x/2, size.y/2);
+ PixelFormat pf = m_pDecoder->getPixelFormat();
+ if (pixelFormatIsPlanar(pf)) {
+ pBmps.push_back(getBmp(m_pBmpQ, size, I8));
+ pBmps.push_back(getBmp(m_pHalfBmpQ, halfSize, I8));
+ pBmps.push_back(getBmp(m_pHalfBmpQ, halfSize, I8));
+ if (pf == YCbCrA420p) {
+ pBmps.push_back(getBmp(m_pBmpQ, size, I8));
+ }
+ } else {
+ pBmps.push_back(getBmp(m_pBmpQ, size, pf));
+ }
+ frameAvailable = m_pDecoder->renderToBmps(pBmps, -1);
+ }
+ if (m_pDecoder->isEOF(SS_VIDEO)) {
+ VideoMsgPtr pMsg(new VideoMsg());
+ pMsg->setEOF();
+ m_MsgQ.push(pMsg);
+ } else {
+ ScopeTimer timer(PushMsgProfilingZone);
+ AVG_ASSERT(frameAvailable == FA_NEW_FRAME);
+ VideoMsgPtr pMsg(new VideoMsg());
+ if (usesVDPAU) {
+ pMsg->setVDPAUFrame(pRenderState, m_pDecoder->getCurTime(SS_VIDEO));
+ } else {
+ pMsg->setFrame(pBmps, m_pDecoder->getCurTime(SS_VIDEO));
+ }
+ m_MsgQ.push(pMsg);
+ msleep(0);
+ }
+ ThreadProfiler::get()->reset();
+ }
+ return true;
+}
+
+void VideoDecoderThread::seek(double destTime)
+{
+ while (!m_MsgQ.empty()) {
+ m_MsgQ.pop(false);
+ }
+
+ double VideoFrameTime = -1;
+ double AudioFrameTime = -1;
+ m_pDecoder->seek(destTime);
+ if (m_pDecoder->getVideoInfo().m_bHasVideo) {
+ VideoFrameTime = m_pDecoder->getCurTime(SS_VIDEO);
+ }
+ if (m_pDecoder->getVideoInfo().m_bHasAudio) {
+ AudioFrameTime = m_pDecoder->getCurTime(SS_AUDIO);
+ }
+
+ VideoMsgPtr pMsg(new VideoMsg());
+ pMsg->setSeekDone(VideoFrameTime, AudioFrameTime);
+ m_MsgQ.push(pMsg);
+}
+
+void VideoDecoderThread::setFPS(double fps)
+{
+ m_pDecoder->setFPS(fps);
+}
+
+void VideoDecoderThread::returnFrame(VideoMsgPtr pMsg)
+{
+ m_pBmpQ->push(pMsg->getFrameBitmap(0));
+ PixelFormat pf = m_pDecoder->getPixelFormat();
+ if (pixelFormatIsPlanar(pf)) {
+ m_pHalfBmpQ->push(pMsg->getFrameBitmap(1));
+ m_pHalfBmpQ->push(pMsg->getFrameBitmap(2));
+ if (pf == YCbCrA420p) {
+ m_pBmpQ->push(pMsg->getFrameBitmap(3));
+ }
+ }
+}
+
+BitmapPtr VideoDecoderThread::getBmp(BitmapQueuePtr pBmpQ, const IntPoint& size,
+ PixelFormat pf)
+{
+ BitmapPtr pBmp = pBmpQ->pop(false);
+ if (pBmp) {
+ AVG_ASSERT (pBmp->getSize() == size && pBmp->getPixelFormat() == pf);
+ return pBmp;
+ } else {
+ return BitmapPtr(new Bitmap(size, pf));
+ }
+}
+
+}
diff --git a/src/video/VideoDecoderThread.h b/src/video/VideoDecoderThread.h
new file mode 100644
index 0000000..2e1f940
--- /dev/null
+++ b/src/video/VideoDecoderThread.h
@@ -0,0 +1,67 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoDecoderThread_H_
+#define _VideoDecoderThread_H_
+
+#include "../api.h"
+#include "VideoDecoder.h"
+#include "VideoMsg.h"
+
+#include "../base/WorkerThread.h"
+#include "../base/Command.h"
+#include "../base/Queue.h"
+
+#include <boost/thread.hpp>
+
+#include <string>
+
+namespace avg {
+
+typedef Queue<Bitmap> BitmapQueue;
+typedef boost::shared_ptr<BitmapQueue> BitmapQueuePtr;
+
+class AVG_API VideoDecoderThread: public WorkerThread<VideoDecoderThread> {
+ public:
+ VideoDecoderThread(CQueue& cmdQ, VideoMsgQueue& msgQ,
+ VideoDecoderPtr pDecoder);
+ virtual ~VideoDecoderThread();
+
+ bool work();
+ void seek(double destTime);
+ void setFPS(double fps);
+ void returnFrame(VideoMsgPtr pMsg);
+
+ private:
+ BitmapPtr getBmp(BitmapQueuePtr pBmpQ, const IntPoint& size,
+ PixelFormat pf);
+ VideoMsgQueue& m_MsgQ;
+ VideoDecoderPtr m_pDecoder;
+
+ BitmapQueuePtr m_pBmpQ;
+ BitmapQueuePtr m_pHalfBmpQ;
+
+// ProfilingZone * m_pPushMsgProfilingZone;
+};
+
+}
+#endif
+
diff --git a/src/video/VideoDemuxerThread.cpp b/src/video/VideoDemuxerThread.cpp
new file mode 100644
index 0000000..2a9e029
--- /dev/null
+++ b/src/video/VideoDemuxerThread.cpp
@@ -0,0 +1,130 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VideoDemuxerThread.h"
+
+#include "../base/Logger.h"
+#include "../base/TimeSource.h"
+
+#include <climits>
+
+using namespace std;
+
+namespace avg {
+
+VideoDemuxerThread::VideoDemuxerThread(CQueue& cmdQ, AVFormatContext * pFormatContext,
+ const map<int, VideoPacketQueuePtr>& packetQs)
+ : WorkerThread<VideoDemuxerThread>("VideoDemuxer", cmdQ),
+ m_PacketQs(packetQs),
+ m_bEOF(false),
+ m_pFormatContext(pFormatContext),
+ m_pDemuxer()
+{
+ map<int, VideoPacketQueuePtr>::iterator it;
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); it++) {
+ int streamIndex = it->first;
+ m_PacketQbEOF[streamIndex] = false;
+ }
+}
+
+VideoDemuxerThread::~VideoDemuxerThread()
+{
+}
+
+bool VideoDemuxerThread::init()
+{
+ map<int, VideoPacketQueuePtr>::iterator it;
+ vector<int> streamIndexes;
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); it++) {
+ streamIndexes.push_back(it->first);
+ }
+ m_pDemuxer = FFMpegDemuxerPtr(new FFMpegDemuxer(m_pFormatContext, streamIndexes));
+ return true;
+}
+
+bool VideoDemuxerThread::work()
+{
+ if (m_PacketQs.empty() || m_bEOF) {
+ waitForCommand();
+ } else {
+ map<int, VideoPacketQueuePtr>::iterator it;
+ int shortestQ = -1;
+ int shortestLength = INT_MAX;
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); it++) {
+ if (it->second->size() < shortestLength &&
+ it->second->size() < it->second->getMaxSize() &&
+ !m_PacketQbEOF[it->first])
+ {
+ shortestLength = it->second->size();
+ shortestQ = it->first;
+ }
+ }
+
+ if (shortestQ < 0) {
+ // All queues are at their max capacity. Take a nap and try again later.
+ msleep(10);
+ return true;
+ }
+
+ AVPacket * pPacket = m_pDemuxer->getPacket(shortestQ);
+ if (pPacket == 0) {
+ onStreamEOF(shortestQ);
+ }
+
+ // On EOF, we send a message which has pPacket=0
+ m_PacketQs[shortestQ]->push(PacketVideoMsgPtr(
+ new PacketVideoMsg(pPacket, false)));
+ msleep(0);
+ }
+ return true;
+}
+
+void VideoDemuxerThread::deinit()
+{
+}
+
+void VideoDemuxerThread::seek(double destTime)
+{
+ map<int, VideoPacketQueuePtr>::iterator it;
+ m_pDemuxer->seek(destTime);
+ for (it = m_PacketQs.begin(); it != m_PacketQs.end(); it++) {
+ VideoPacketQueuePtr pPacketQ = it->second;
+ pPacketQ->push(PacketVideoMsgPtr(new PacketVideoMsg(0, true)));
+ m_PacketQbEOF[it->first] = false;
+ }
+ m_bEOF = false;
+}
+
+void VideoDemuxerThread::onStreamEOF(int streamIndex)
+{
+ m_PacketQbEOF[streamIndex] = true;
+
+ m_bEOF = true;
+ map<int, bool>::iterator it;
+ for (it = m_PacketQbEOF.begin(); it != m_PacketQbEOF.end(); it++) {
+ if (!it->second) {
+ m_bEOF = false;
+ break;
+ }
+ }
+}
+
+}
diff --git a/src/video/VideoDemuxerThread.h b/src/video/VideoDemuxerThread.h
new file mode 100644
index 0000000..5bd669b
--- /dev/null
+++ b/src/video/VideoDemuxerThread.h
@@ -0,0 +1,63 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoDemuxerThread_H_
+#define _VideoDemuxerThread_H_
+
+#include "../api.h"
+#include "FFMpegDemuxer.h"
+#include "PacketVideoMsg.h"
+
+#include "../base/WorkerThread.h"
+#include "../base/Command.h"
+
+#include <boost/thread.hpp>
+
+#include <string>
+#include <vector>
+
+namespace avg {
+
+class AVG_API VideoDemuxerThread: public WorkerThread<VideoDemuxerThread> {
+ public:
+ VideoDemuxerThread(CQueue& cmdQ, AVFormatContext * pFormatContext,
+ const std::map<int, VideoPacketQueuePtr>& m_PacketQs);
+ virtual ~VideoDemuxerThread();
+ bool init();
+ bool work();
+ void deinit();
+
+ void enableStream(VideoPacketQueuePtr pPacketQ, int streamIndex);
+ void seek(double DestTime);
+
+ private:
+ void onStreamEOF(int streamIndex);
+
+ std::map<int, VideoPacketQueuePtr> m_PacketQs;
+ std::map<int, bool> m_PacketQbEOF;
+ bool m_bEOF;
+ AVFormatContext * m_pFormatContext;
+ FFMpegDemuxerPtr m_pDemuxer;
+};
+
+}
+#endif
+
diff --git a/src/video/VideoInfo.cpp b/src/video/VideoInfo.cpp
new file mode 100644
index 0000000..ac48107
--- /dev/null
+++ b/src/video/VideoInfo.cpp
@@ -0,0 +1,64 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VideoInfo.h"
+
+#include "../base/Exception.h"
+
+namespace avg {
+
+using namespace std;
+
+VideoInfo::VideoInfo()
+{
+}
+
+VideoInfo::VideoInfo(double duration, int bitrate, bool bHasVideo, bool bHasAudio)
+ : m_Duration(duration),
+ m_Bitrate(bitrate),
+ m_bHasVideo(bHasVideo),
+ m_bHasAudio(bHasAudio)
+{
+}
+
+void VideoInfo::setVideoData(const IntPoint& size, const string& sPixelFormat,
+ int numFrames, double streamFPS, double FPS, const string& sVCodec,
+ bool bUsesVDPAU)
+{
+ AVG_ASSERT(m_bHasVideo);
+ m_Size = size;
+ m_sPixelFormat = sPixelFormat;
+ m_NumFrames = numFrames;
+ m_StreamFPS = streamFPS;
+ m_FPS = FPS;
+ m_sVCodec = sVCodec;
+ m_bUsesVDPAU = bUsesVDPAU;
+}
+
+void VideoInfo::setAudioData(const string& sACodec, int sampleRate, int numAudioChannels)
+{
+ AVG_ASSERT(m_bHasAudio);
+ m_sACodec = sACodec;
+ m_SampleRate = sampleRate;
+ m_NumAudioChannels = numAudioChannels;
+}
+
+}
diff --git a/src/video/VideoInfo.h b/src/video/VideoInfo.h
new file mode 100644
index 0000000..663dcc7
--- /dev/null
+++ b/src/video/VideoInfo.h
@@ -0,0 +1,63 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoInfo_H_
+#define _VideoInfo_H_
+
+#include "../api.h"
+
+#include "../base/Point.h"
+
+#include <string>
+
+namespace avg {
+
+struct AVG_API VideoInfo
+{
+ VideoInfo();
+ VideoInfo(double duration, int bitrate, bool bHasVideo, bool bHasAudio);
+ void setVideoData(const IntPoint& size, const std::string& sPixelFormat,
+ int numFrames, double streamFPS, double FPS, const std::string& sVCodec,
+ bool bUsesVDPAU);
+
+ void setAudioData(const std::string& sACodec, int sampleRate, int numAudioChannels);
+
+ double m_Duration;
+ int m_Bitrate;
+
+ bool m_bHasVideo;
+ IntPoint m_Size;
+ std::string m_sPixelFormat;
+ int m_NumFrames;
+ double m_StreamFPS;
+ double m_FPS;
+ std::string m_sVCodec;
+ bool m_bUsesVDPAU;
+
+ bool m_bHasAudio;
+ std::string m_sACodec;
+ int m_SampleRate;
+ int m_NumAudioChannels;
+};
+
+}
+#endif
+
diff --git a/src/video/VideoMsg.cpp b/src/video/VideoMsg.cpp
new file mode 100644
index 0000000..585e237
--- /dev/null
+++ b/src/video/VideoMsg.cpp
@@ -0,0 +1,141 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "VideoMsg.h"
+
+#include "../base/ObjectCounter.h"
+#include "../base/Exception.h"
+
+namespace avg {
+
+VideoMsg::VideoMsg()
+ : m_MsgType(NONE)
+{
+ ObjectCounter::get()->incRef(&typeid(*this));
+}
+
+VideoMsg::~VideoMsg()
+{
+ ObjectCounter::get()->decRef(&typeid(*this));
+}
+
+void VideoMsg::setAudio(AudioBufferPtr pAudioBuffer, double audioTime)
+{
+ AVG_ASSERT(m_MsgType == NONE);
+ AVG_ASSERT(pAudioBuffer);
+ m_MsgType = AUDIO;
+ m_pAudioBuffer = pAudioBuffer;
+ m_AudioTime = audioTime;
+}
+
+void VideoMsg::setEOF()
+{
+ AVG_ASSERT(m_MsgType == NONE);
+ m_MsgType = END_OF_FILE;
+}
+
+void VideoMsg::setError(const Exception& ex)
+{
+ AVG_ASSERT(m_MsgType == NONE);
+ m_MsgType = ERROR;
+ m_pEx = new Exception(ex);
+}
+
+void VideoMsg::setFrame(const std::vector<BitmapPtr>& pBmps, double frameTime)
+{
+ AVG_ASSERT(m_MsgType == NONE);
+ AVG_ASSERT(pBmps.size() == 1 || pBmps.size() == 3 || pBmps.size() == 4);
+ m_MsgType = FRAME;
+ m_pBmps = pBmps;
+ m_FrameTime = frameTime;
+}
+
+void VideoMsg::setVDPAUFrame(vdpau_render_state* pRenderState, double frameTime)
+{
+ AVG_ASSERT(m_MsgType == NONE);
+ m_MsgType = VDPAU_FRAME;
+ m_pRenderState = pRenderState;
+ m_FrameTime = frameTime;
+}
+
+void VideoMsg::setSeekDone(double seekVideoFrameTime, double seekAudioFrameTime)
+{
+ AVG_ASSERT(m_MsgType == NONE);
+ m_MsgType = SEEK_DONE;
+ m_SeekVideoFrameTime = seekVideoFrameTime;
+ m_SeekAudioFrameTime = seekAudioFrameTime;
+}
+
+VideoMsg::MsgType VideoMsg::getType()
+{
+ return m_MsgType;
+}
+
+AudioBufferPtr VideoMsg::getAudioBuffer() const
+{
+ AVG_ASSERT(m_MsgType == AUDIO);
+ return m_pAudioBuffer;
+}
+
+double VideoMsg::getAudioTime() const
+{
+ AVG_ASSERT(m_MsgType == AUDIO);
+ return m_AudioTime;
+}
+
+const Exception& VideoMsg::getException() const
+{
+ AVG_ASSERT(m_MsgType == ERROR);
+ return *m_pEx;
+}
+
+BitmapPtr VideoMsg::getFrameBitmap(int i)
+{
+ AVG_ASSERT(m_MsgType == FRAME);
+ return m_pBmps[i];
+}
+
+double VideoMsg::getFrameTime()
+{
+ AVG_ASSERT(m_MsgType == FRAME || m_MsgType == VDPAU_FRAME);
+ return m_FrameTime;
+}
+
+double VideoMsg::getSeekVideoFrameTime()
+{
+ AVG_ASSERT(m_MsgType == SEEK_DONE);
+ return m_SeekVideoFrameTime;
+}
+
+double VideoMsg::getSeekAudioFrameTime()
+{
+ AVG_ASSERT(m_MsgType == SEEK_DONE);
+ return m_SeekAudioFrameTime;
+}
+
+vdpau_render_state* VideoMsg::getRenderState()
+{
+ AVG_ASSERT(m_MsgType == VDPAU_FRAME);
+ return m_pRenderState;
+}
+
+}
+
diff --git a/src/video/VideoMsg.h b/src/video/VideoMsg.h
new file mode 100644
index 0000000..b1dbfbb
--- /dev/null
+++ b/src/video/VideoMsg.h
@@ -0,0 +1,94 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _VideoMsg_H_
+#define _VideoMsg_H_
+
+#include "../api.h"
+#include "../base/Queue.h"
+#include "../graphics/Bitmap.h"
+
+#include "../audio/AudioBuffer.h"
+
+#include <boost/shared_ptr.hpp>
+
+struct vdpau_render_state;
+
+namespace avg {
+
+class AVG_API VideoMsg {
+public:
+ enum MsgType {NONE, AUDIO, END_OF_FILE, ERROR, FRAME, SEEK_DONE, VDPAU_FRAME};
+ VideoMsg();
+ void setAudio(AudioBufferPtr pAudioBuffer, double audioTime);
+ void setEOF();
+ void setError(const Exception& ex);
+ void setFrame(const std::vector<BitmapPtr>& pBmps, double frameTime);
+ void setVDPAUFrame(vdpau_render_state* m_pRenderState, double frameTime);
+ void setSeekDone(double seekVideoFrameTime, double seekAudioFrameTime);
+
+ virtual ~VideoMsg();
+
+ MsgType getType();
+
+ AudioBufferPtr getAudioBuffer() const;
+ double getAudioTime() const;
+
+ const Exception& getException() const;
+
+ BitmapPtr getFrameBitmap(int i);
+ double getFrameTime();
+
+ double getSeekVideoFrameTime();
+ double getSeekAudioFrameTime();
+
+ vdpau_render_state* getRenderState();
+
+private:
+ MsgType m_MsgType;
+
+ // AUDIO
+ AudioBufferPtr m_pAudioBuffer;
+ double m_AudioTime;
+
+ // ERROR
+ Exception* m_pEx;
+
+ // FRAME
+ std::vector<BitmapPtr> m_pBmps;
+ double m_FrameTime;
+
+ // VDPAU_FRAME
+ vdpau_render_state* m_pRenderState;
+
+ // SEEK_DONE
+ double m_SeekVideoFrameTime;
+ double m_SeekAudioFrameTime;
+
+};
+
+typedef boost::shared_ptr<VideoMsg> VideoMsgPtr;
+typedef Queue<VideoMsg> VideoMsgQueue;
+typedef boost::shared_ptr<VideoMsgQueue> VideoMsgQueuePtr;
+
+}
+#endif
+
diff --git a/src/video/WrapFFMpeg.h b/src/video/WrapFFMpeg.h
new file mode 100644
index 0000000..c2176b4
--- /dev/null
+++ b/src/video/WrapFFMpeg.h
@@ -0,0 +1,60 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _WrapFFMpeg_H_
+#define _WrapFFMpeg_H_
+
+#include "../avgconfigwrapper.h"
+
+#ifdef _WIN32
+#define EMULATE_INTTYPES
+#else
+// This is probably GCC-specific.
+#if !defined INT64_C
+#if defined __WORDSIZE && __WORDSIZE == 64
+#define INT64_C(c) c ## L
+#define UINT64_C(c) c ## UL
+#else
+#define INT64_C(c) c ## LL
+#define UINT64_C(c) c ## ULL
+#endif
+#endif
+#endif
+
+extern "C" {
+#include <libavcodec/avcodec.h>
+#include <libavformat/avformat.h>
+#include <libswscale/swscale.h>
+#include <libavutil/avutil.h>
+#if LIBAVCODEC_VERSION_MAJOR > 52
+#include <libavutil/pixdesc.h>
+#include <libavutil/mathematics.h>
+#else
+#define av_get_pix_fmt_name avcodec_get_pix_fmt_name
+#endif
+#if LIBAVFORMAT_VERSION_MAJOR < 53
+#define AVMEDIA_TYPE_VIDEO CODEC_TYPE_VIDEO
+#define AVMEDIA_TYPE_AUDIO CODEC_TYPE_AUDIO
+#endif
+
+}
+
+#endif
diff --git a/src/video/baseline/mjpeg-48x48.avi_1.png b/src/video/baseline/mjpeg-48x48.avi_1.png
new file mode 100644
index 0000000..0a8e5ca
--- /dev/null
+++ b/src/video/baseline/mjpeg-48x48.avi_1.png
Binary files differ
diff --git a/src/video/baseline/mjpeg-48x48.avi_100.png b/src/video/baseline/mjpeg-48x48.avi_100.png
new file mode 100644
index 0000000..343e45b
--- /dev/null
+++ b/src/video/baseline/mjpeg-48x48.avi_100.png
Binary files differ
diff --git a/src/video/baseline/mjpeg-48x48.avi_2.png b/src/video/baseline/mjpeg-48x48.avi_2.png
new file mode 100644
index 0000000..93a551b
--- /dev/null
+++ b/src/video/baseline/mjpeg-48x48.avi_2.png
Binary files differ
diff --git a/src/video/baseline/mjpeg-48x48.avi_201.png b/src/video/baseline/mjpeg-48x48.avi_201.png
new file mode 100644
index 0000000..eb9d4a0
--- /dev/null
+++ b/src/video/baseline/mjpeg-48x48.avi_201.png
Binary files differ
diff --git a/src/video/baseline/mjpeg-48x48.avi_53.png b/src/video/baseline/mjpeg-48x48.avi_53.png
new file mode 100644
index 0000000..22f00c2
--- /dev/null
+++ b/src/video/baseline/mjpeg-48x48.avi_53.png
Binary files differ
diff --git a/src/video/baseline/mjpeg-48x48.avi_end.png b/src/video/baseline/mjpeg-48x48.avi_end.png
new file mode 100644
index 0000000..ed5df07
--- /dev/null
+++ b/src/video/baseline/mjpeg-48x48.avi_end.png
Binary files differ
diff --git a/src/video/baseline/mjpeg-48x48.avi_loop.png b/src/video/baseline/mjpeg-48x48.avi_loop.png
new file mode 100644
index 0000000..f711a88
--- /dev/null
+++ b/src/video/baseline/mjpeg-48x48.avi_loop.png
Binary files differ
diff --git a/src/video/baseline/mpeg1-48x48-sound.avi_end.png b/src/video/baseline/mpeg1-48x48-sound.avi_end.png
new file mode 100644
index 0000000..ad712f0
--- /dev/null
+++ b/src/video/baseline/mpeg1-48x48-sound.avi_end.png
Binary files differ
diff --git a/src/video/baseline/mpeg1-48x48-sound.avi_loop.png b/src/video/baseline/mpeg1-48x48-sound.avi_loop.png
new file mode 100644
index 0000000..db42610
--- /dev/null
+++ b/src/video/baseline/mpeg1-48x48-sound.avi_loop.png
Binary files differ
diff --git a/src/video/baseline/mpeg1-48x48.mpg_1.png b/src/video/baseline/mpeg1-48x48.mpg_1.png
new file mode 100644
index 0000000..73e856b
--- /dev/null
+++ b/src/video/baseline/mpeg1-48x48.mpg_1.png
Binary files differ
diff --git a/src/video/baseline/mpeg1-48x48.mpg_2.png b/src/video/baseline/mpeg1-48x48.mpg_2.png
new file mode 100644
index 0000000..9ff7f5e
--- /dev/null
+++ b/src/video/baseline/mpeg1-48x48.mpg_2.png
Binary files differ
diff --git a/src/video/baseline/mpeg1-48x48.mpg_end.png b/src/video/baseline/mpeg1-48x48.mpg_end.png
new file mode 100644
index 0000000..eb9dab8
--- /dev/null
+++ b/src/video/baseline/mpeg1-48x48.mpg_end.png
Binary files differ
diff --git a/src/video/baseline/mpeg1-48x48.mpg_loop.png b/src/video/baseline/mpeg1-48x48.mpg_loop.png
new file mode 100644
index 0000000..64ceb53
--- /dev/null
+++ b/src/video/baseline/mpeg1-48x48.mpg_loop.png
Binary files differ
diff --git a/src/video/testfiles/22.050Hz_16bit_mono.wav b/src/video/testfiles/22.050Hz_16bit_mono.wav
new file mode 100755
index 0000000..1f86e64
--- /dev/null
+++ b/src/video/testfiles/22.050Hz_16bit_mono.wav
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_16bit_6Chan.ogg b/src/video/testfiles/44.1kHz_16bit_6Chan.ogg
new file mode 100644
index 0000000..7d190d1
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_16bit_6Chan.ogg
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_16bit_mono.wav b/src/video/testfiles/44.1kHz_16bit_mono.wav
new file mode 100755
index 0000000..8676a75
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_16bit_mono.wav
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_16bit_stereo.aif b/src/video/testfiles/44.1kHz_16bit_stereo.aif
new file mode 100755
index 0000000..0c9b5c7
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_16bit_stereo.aif
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_16bit_stereo.wav b/src/video/testfiles/44.1kHz_16bit_stereo.wav
new file mode 100755
index 0000000..af5c2ee
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_16bit_stereo.wav
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_24bit_mono.wav b/src/video/testfiles/44.1kHz_24bit_mono.wav
new file mode 100755
index 0000000..fd2deed
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_24bit_mono.wav
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_24bit_stereo.aif b/src/video/testfiles/44.1kHz_24bit_stereo.aif
new file mode 100755
index 0000000..f569ded
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_24bit_stereo.aif
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_24bit_stereo.wav b/src/video/testfiles/44.1kHz_24bit_stereo.wav
new file mode 100755
index 0000000..36c6aa7
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_24bit_stereo.wav
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_mono.ogg b/src/video/testfiles/44.1kHz_mono.ogg
new file mode 100755
index 0000000..7bcb866
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_mono.ogg
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_stereo.mp3 b/src/video/testfiles/44.1kHz_stereo.mp3
new file mode 100644
index 0000000..cbefc63
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_stereo.mp3
Binary files differ
diff --git a/src/video/testfiles/44.1kHz_stereo.ogg b/src/video/testfiles/44.1kHz_stereo.ogg
new file mode 100644
index 0000000..f5ed4d0
--- /dev/null
+++ b/src/video/testfiles/44.1kHz_stereo.ogg
Binary files differ
diff --git a/src/video/testfiles/48kHz_16bit_mono.wav b/src/video/testfiles/48kHz_16bit_mono.wav
new file mode 100755
index 0000000..0f817c9
--- /dev/null
+++ b/src/video/testfiles/48kHz_16bit_mono.wav
Binary files differ
diff --git a/src/video/testfiles/48kHz_16bit_stereo.aif b/src/video/testfiles/48kHz_16bit_stereo.aif
new file mode 100755
index 0000000..db3a381
--- /dev/null
+++ b/src/video/testfiles/48kHz_16bit_stereo.aif
Binary files differ
diff --git a/src/video/testfiles/48kHz_16bit_stereo.wav b/src/video/testfiles/48kHz_16bit_stereo.wav
new file mode 100755
index 0000000..9fc52f1
--- /dev/null
+++ b/src/video/testfiles/48kHz_16bit_stereo.wav
Binary files differ
diff --git a/src/video/testfiles/48kHz_24bit_mono.wav b/src/video/testfiles/48kHz_24bit_mono.wav
new file mode 100755
index 0000000..296ca11
--- /dev/null
+++ b/src/video/testfiles/48kHz_24bit_mono.wav
Binary files differ
diff --git a/src/video/testfiles/48kHz_24bit_stereo.aif b/src/video/testfiles/48kHz_24bit_stereo.aif
new file mode 100755
index 0000000..3ab7cf1
--- /dev/null
+++ b/src/video/testfiles/48kHz_24bit_stereo.aif
Binary files differ
diff --git a/src/video/testfiles/48kHz_24bit_stereo.wav b/src/video/testfiles/48kHz_24bit_stereo.wav
new file mode 100755
index 0000000..af2c977
--- /dev/null
+++ b/src/video/testfiles/48kHz_24bit_stereo.wav
Binary files differ
diff --git a/src/video/testfiles/48kHz_stereo.mp3 b/src/video/testfiles/48kHz_stereo.mp3
new file mode 100644
index 0000000..0eaa0f5
--- /dev/null
+++ b/src/video/testfiles/48kHz_stereo.mp3
Binary files differ
diff --git a/src/video/testfiles/48kHz_stereo.ogg b/src/video/testfiles/48kHz_stereo.ogg
new file mode 100644
index 0000000..92d7b7b
--- /dev/null
+++ b/src/video/testfiles/48kHz_stereo.ogg
Binary files differ
diff --git a/src/video/testfiles/h264-48x48.h264 b/src/video/testfiles/h264-48x48.h264
new file mode 100644
index 0000000..d650960
--- /dev/null
+++ b/src/video/testfiles/h264-48x48.h264
Binary files differ
diff --git a/src/video/testfiles/mjpeg-48x48.avi b/src/video/testfiles/mjpeg-48x48.avi
new file mode 100644
index 0000000..337df16
--- /dev/null
+++ b/src/video/testfiles/mjpeg-48x48.avi
Binary files differ
diff --git a/src/video/testfiles/mpeg1-48x48-sound.avi b/src/video/testfiles/mpeg1-48x48-sound.avi
new file mode 100644
index 0000000..be415db
--- /dev/null
+++ b/src/video/testfiles/mpeg1-48x48-sound.avi
Binary files differ
diff --git a/src/video/testfiles/mpeg1-48x48.mpg b/src/video/testfiles/mpeg1-48x48.mpg
new file mode 100644
index 0000000..d62180a
--- /dev/null
+++ b/src/video/testfiles/mpeg1-48x48.mpg
Binary files differ
diff --git a/src/video/testfiles/rgba-48x48.mov b/src/video/testfiles/rgba-48x48.mov
new file mode 100644
index 0000000..7e311cc
--- /dev/null
+++ b/src/video/testfiles/rgba-48x48.mov
Binary files differ
diff --git a/src/video/testfiles/vp6a-yuva-48x48.flv b/src/video/testfiles/vp6a-yuva-48x48.flv
new file mode 100644
index 0000000..21866fe
--- /dev/null
+++ b/src/video/testfiles/vp6a-yuva-48x48.flv
Binary files differ
diff --git a/src/video/testvideo.cpp b/src/video/testvideo.cpp
new file mode 100644
index 0000000..a304cb9
--- /dev/null
+++ b/src/video/testvideo.cpp
@@ -0,0 +1,527 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "FFMpegDecoder.h"
+
+#ifdef _WIN32
+#pragma warning(push)
+#pragma warning(disable:4251)
+#endif
+#ifdef _WIN32
+#pragma warning(pop)
+#endif
+
+#include "AsyncVideoDecoder.h"
+
+#include "../graphics/Filterfliprgba.h"
+#include "../graphics/Filterfliprgb.h"
+#include "../graphics/GraphicsTest.h"
+
+#include "../base/StringHelper.h"
+#include "../base/TimeSource.h"
+#include "../base/TestSuite.h"
+#include "../base/Exception.h"
+#include "../base/ThreadProfiler.h"
+#include "../base/Directory.h"
+#include "../base/DirEntry.h"
+
+#include <string>
+#include <sstream>
+#include <cmath>
+
+using namespace avg;
+using namespace std;
+
+
+class DecoderTest: public GraphicsTest {
+ public:
+ DecoderTest(const string& sClassName, bool bThreadedDecoder,
+ bool bThreadedDemuxer, bool bUseHardwareAcceleration)
+ : GraphicsTest(sClassName+getDecoderName(bThreadedDecoder,
+ bThreadedDemuxer), 2),
+ m_bThreadedDecoder(bThreadedDecoder),
+ m_bThreadedDemuxer(bThreadedDemuxer),
+ m_bUseHardwareAcceleration(bUseHardwareAcceleration)
+ {}
+
+ protected:
+ bool isDemuxerThreaded()
+ {
+ return m_bThreadedDemuxer;
+ }
+
+ bool useHardwareAcceleration()
+ {
+ return m_bUseHardwareAcceleration;
+ }
+
+ VideoDecoderPtr createDecoder()
+ {
+ VideoDecoderPtr pDecoder;
+ pDecoder = VideoDecoderPtr(new FFMpegDecoder());
+ if (m_bThreadedDecoder) {
+ pDecoder = VideoDecoderPtr(new AsyncVideoDecoder(pDecoder, 8));
+ }
+ return pDecoder;
+ }
+
+ AudioBufferPtr createAudioBuffer(int numFrames)
+ {
+ return AudioBufferPtr(new AudioBuffer(numFrames, *getAudioParams()));
+ }
+
+ const AudioParams* getAudioParams()
+ {
+ static AudioParams AP(44100, 2, 256);
+ return &AP;
+ }
+
+ virtual void testEqual(Bitmap& resultBmp, const std::string& sFName,
+ avg::PixelFormat pf = NO_PIXELFORMAT, double maxAverage=1.0,
+ double maxStdDev=1.0)
+ {
+ GraphicsTest::testEqual(resultBmp, sFName, pf, maxAverage, maxStdDev);
+ }
+
+ void testEqual(Bitmap& resultBmp, Bitmap& BaselineBmp,
+ const std::string& sFName, double maxAverage=1.0, double maxStdDev=1.0)
+ {
+ GraphicsTest::testEqual(resultBmp, BaselineBmp, sFName,
+ maxAverage, maxStdDev);
+ }
+
+ private:
+ string getDecoderName(bool bThreadedDecoder, bool bThreadedDemuxer)
+ {
+ string sName = "(";
+ if (bThreadedDecoder) {
+ sName += "Threaded decoder, ";
+ } else {
+ sName += "Sync decoder, ";
+ }
+ if (bThreadedDemuxer) {
+ return sName+string("Threaded demuxer)");
+ } else {
+ return sName+string("Sync demuxer)");
+ }
+ }
+
+ bool m_bThreadedDecoder;
+ bool m_bThreadedDemuxer;
+ bool m_bUseHardwareAcceleration;
+};
+
+class VideoDecoderTest: public DecoderTest {
+ public:
+ VideoDecoderTest(bool bThreadedDecoder, bool bThreadedDemuxer,
+ bool bUseHardwareAcceleration)
+ : DecoderTest("VideoDecoderTest", bThreadedDecoder, bThreadedDemuxer,
+ bUseHardwareAcceleration)
+ {}
+
+ void runTests()
+ {
+ basicFileTest("mpeg1-48x48.mpg", 30);
+ basicFileTest("mjpeg-48x48.avi", 202);
+ testSeeks("mjpeg-48x48.avi");
+ }
+
+ private:
+ void basicFileTest(const string& sFilename, int expectedNumFrames)
+ {
+ try {
+ cerr << " Testing " << sFilename << endl;
+
+ VideoDecoderPtr pDecoder = createDecoder();
+ pDecoder->open(getSrcDirName()+"testfiles/"+sFilename,
+ isDemuxerThreaded(), useHardwareAcceleration());
+ IntPoint frameSize = pDecoder->getSize();
+ TEST(frameSize == IntPoint(48, 48));
+ TEST(pDecoder->getVideoInfo().m_bHasVideo);
+ TEST(pDecoder->getNominalFPS() != 0);
+ pDecoder->startDecoding(false, getAudioParams());
+ TEST(pDecoder->getPixelFormat() == B8G8R8X8);
+ BitmapPtr pBmp(new Bitmap(frameSize, B8G8R8X8));
+
+ // Test first two frames.
+ pDecoder->renderToBmp(pBmp, -1);
+ testEqual(*pBmp, sFilename+"_1", B8G8R8X8);
+ pDecoder->renderToBmp(pBmp, -1);
+ testEqual(*pBmp, sFilename+"_2", B8G8R8X8);
+ pDecoder->close();
+
+ readWholeFile(sFilename, 1, expectedNumFrames);
+ readWholeFile(sFilename, 0.5, expectedNumFrames);
+ readWholeFile(sFilename, 2, expectedNumFrames/2);
+ } catch (Exception & ex) {
+ cerr << string(m_IndentLevel+6, ' ') << ex.getStr() << endl;
+ throw;
+ }
+ }
+
+ void testSeeks(const string& sFilename)
+ {
+ cerr << " Testing " << sFilename << " (seek)" << endl;
+
+ VideoDecoderPtr pDecoder = createDecoder();
+ pDecoder->open(getSrcDirName()+"testfiles/"+sFilename, isDemuxerThreaded(),
+ useHardwareAcceleration());
+ pDecoder->startDecoding(false, getAudioParams());
+
+ // Seek forward
+ testSeek(100, sFilename, pDecoder);
+ // Seek backward
+ testSeek(53, sFilename, pDecoder);
+ // Seek to last frame
+ testSeek(201, sFilename, pDecoder);
+
+ pDecoder->close();
+ }
+
+ void testSeek(int frameNum, const string& sFilename, VideoDecoderPtr pDecoder)
+ {
+ IntPoint frameSize = pDecoder->getSize();
+
+ BitmapPtr pBmp(new Bitmap(frameSize, B8G8R8X8));
+ pDecoder->seek(double(frameNum)/pDecoder->getNominalFPS());
+ pDecoder->renderToBmp(pBmp, -1);
+ testEqual(*pBmp, sFilename+"_"+toString(frameNum), B8G8R8X8);
+
+ }
+
+ void readWholeFile(const string& sFilename, double speedFactor,
+ int expectedNumFrames)
+ {
+ // Read whole file, test last image.
+ VideoDecoderPtr pDecoder = createDecoder();
+ pDecoder->open(getSrcDirName()+"testfiles/"+sFilename, isDemuxerThreaded(),
+ useHardwareAcceleration());
+ IntPoint frameSize = pDecoder->getSize();
+ double timePerFrame = (1.0/pDecoder->getFPS())*speedFactor;
+ pDecoder->startDecoding(false, getAudioParams());
+ BitmapPtr pBmp(new Bitmap(frameSize, B8G8R8X8));
+ int numFrames = 0;
+ double curTime = 0;
+
+ while (!pDecoder->isEOF()) {
+ FrameAvailableCode frameAvailable = pDecoder->renderToBmp(pBmp, curTime);
+ if (frameAvailable == FA_NEW_FRAME) {
+/*
+ stringstream ss;
+ ss << "resultimages/" << sFilename << numFrames << ".png";
+ pBmp->save(ss.str());
+*/
+ numFrames++;
+ } else {
+ msleep(0);
+ }
+ if (frameAvailable == FA_NEW_FRAME || frameAvailable == FA_USE_LAST_FRAME)
+ {
+ curTime += timePerFrame;
+ }
+ }
+// cerr << "numFrames: " << numFrames <<
+// ", expectedNumFrames: " << expectedNumFrames << endl;
+ TEST(numFrames == expectedNumFrames);
+ if (speedFactor == 1) {
+ testEqual(*pBmp, sFilename+"_end", B8G8R8X8);
+ }
+
+ // Test loop.
+ pDecoder->loop();
+ pDecoder->renderToBmp(pBmp, -1);
+ testEqual(*pBmp, sFilename+"_loop", B8G8R8X8);
+
+ pDecoder->close();
+ }
+
+};
+
+class AudioDecoderTest: public DecoderTest {
+ public:
+ AudioDecoderTest(bool bThreadedDecoder, bool bThreadedDemuxer)
+ : DecoderTest("AudioDecoderTest", bThreadedDecoder, bThreadedDemuxer, true)
+ {}
+
+ void runTests()
+ {
+ testOneFile("22.050Hz_16bit_mono.wav");
+
+ testOneFile("44.1kHz_16bit_mono.wav");
+ testOneFile("44.1kHz_16bit_stereo.wav");
+ testOneFile("44.1kHz_24bit_mono.wav");
+ testOneFile("44.1kHz_24bit_stereo.wav");
+
+ testOneFile("48kHz_16bit_mono.wav");
+ testOneFile("48kHz_16bit_stereo.wav");
+ testOneFile("48kHz_24bit_mono.wav");
+ testOneFile("48kHz_24bit_stereo.wav");
+
+ testOneFile("44.1kHz_16bit_stereo.aif");
+ testOneFile("44.1kHz_stereo.mp3");
+ }
+
+ private:
+ void testOneFile(const string& sFilename)
+ {
+ try {
+ cerr << " Testing " << sFilename << endl;
+
+ {
+ cerr << " Reading complete file." << endl;
+ VideoDecoderPtr pDecoder = createDecoder();
+ pDecoder->open(getSrcDirName()+"testfiles/"+sFilename,
+ isDemuxerThreaded(), useHardwareAcceleration());
+ TEST(pDecoder->getVideoInfo().m_bHasAudio);
+ pDecoder->setVolume(0.5);
+ TEST(pDecoder->getVolume() == 0.5);
+ pDecoder->startDecoding(false, getAudioParams());
+ int totalFramesDecoded = 0;
+ bool bCheckTimestamps = (sFilename.find(".ogg") == string::npos &&
+ sFilename.find(".mp3") == string::npos);
+ readAudioToEOF(pDecoder, totalFramesDecoded, bCheckTimestamps);
+
+ // Check if we've decoded the whole file.
+ int framesInDuration = int(pDecoder->getVideoInfo().m_Duration*44100);
+// cerr << "framesInDuration: " << framesInDuration << endl;
+ TEST(abs(totalFramesDecoded-framesInDuration) < 65);
+ }
+ {
+ cerr << " Seek test." << endl;
+ VideoDecoderPtr pDecoder = createDecoder();
+ pDecoder->open(getSrcDirName()+"testfiles/"+sFilename,
+ isDemuxerThreaded(), useHardwareAcceleration());
+ double duration = pDecoder->getVideoInfo().m_Duration;
+ pDecoder->startDecoding(false, getAudioParams());
+ pDecoder->seek(duration/2);
+ AudioBufferPtr pAudioBuffer = createAudioBuffer(4);
+ pDecoder->fillAudioBuffer(pAudioBuffer);
+ // 60 ms accuracy for seeks.
+ TEST(abs(duration/2-pDecoder->getCurTime(SS_AUDIO)) < 0.06);
+ int totalFramesDecoded = 4;
+
+ readAudioToEOF(pDecoder, totalFramesDecoded, false);
+ if (sFilename.find(".mp3") == string::npos) {
+ // Check if we've decoded half the file.
+ // TODO: Find out why there are problems with this
+ // for mp3 files.
+ int framesInDuration =
+ int(pDecoder->getVideoInfo().m_Duration*44100);
+// cerr << "framesDecoded: " << totalFramesDecoded << endl;
+// cerr << "framesInDuration: " << framesInDuration << endl;
+ TEST(abs(totalFramesDecoded-framesInDuration/2) < 65);
+ }
+
+ }
+
+ } catch (Exception & ex) {
+ cerr << string(m_IndentLevel+6, ' ') << ex.getStr() << endl;
+ throw;
+ }
+ }
+
+ void readAudioToEOF(VideoDecoderPtr pDecoder, int& totalFramesDecoded,
+ bool bCheckTimestamps)
+ {
+ int numWrongTimestamps = 0;
+ while (!pDecoder->isEOF()) {
+ AudioBufferPtr pBuffer = createAudioBuffer(256);
+ int framesDecoded = 0;
+ while (framesDecoded == 0 && !pDecoder->isEOF()) {
+ framesDecoded = pDecoder->fillAudioBuffer(pBuffer);
+// cerr << "framesDecoded: " << framesDecoded << endl;
+ msleep(0);
+ }
+ totalFramesDecoded += framesDecoded;
+ double curTime = double(totalFramesDecoded)/44100;
+ if (abs(curTime-pDecoder->getCurTime(SS_AUDIO)) > 0.02) {
+ numWrongTimestamps++;
+ }
+// cerr << curTime << "->" << pDecoder->getCurTime(SS_AUDIO) << endl;
+ }
+ if (bCheckTimestamps) {
+ if (numWrongTimestamps>0) {
+ TEST_FAILED(numWrongTimestamps << " wrong timestamps.");
+ }
+ }
+ }
+};
+
+class AVDecoderTest: public DecoderTest {
+ public:
+ AVDecoderTest(bool bThreadedDecoder, bool bThreadedDemuxer,
+ bool bUseHardwareAcceleration)
+ : DecoderTest("AVDecoderTest", bThreadedDecoder, bThreadedDemuxer,
+ bUseHardwareAcceleration)
+ {}
+
+ void runTests()
+ {
+ basicFileTest("mpeg1-48x48-sound.avi", 30);
+ }
+
+ private:
+ void basicFileTest(const string& sFilename, int expectedNumFrames)
+ {
+ VideoDecoderPtr pDecoder = createDecoder();
+ pDecoder->open(getSrcDirName()+"testfiles/"+sFilename, isDemuxerThreaded(),
+ useHardwareAcceleration());
+ TEST(pDecoder->getVideoInfo().m_bHasVideo);
+ TEST(pDecoder->getNominalFPS() != 0);
+ pDecoder->startDecoding(false, getAudioParams());
+ if (isDemuxerThreaded()) {
+ TEST(pDecoder->getVideoInfo().m_bHasAudio);
+ }
+ IntPoint frameSize = pDecoder->getSize();
+ BitmapPtr pBmp(new Bitmap(frameSize, B8G8R8X8));
+ int numFrames = 0;
+ int totalFramesDecoded = 0;
+ double curTime = 0;
+
+ while (!pDecoder->isEOF()) {
+ FrameAvailableCode frameAvailable;
+ do {
+ frameAvailable = pDecoder->renderToBmp(pBmp, curTime);
+ msleep(0);
+ } while (frameAvailable == FA_STILL_DECODING);
+ if (frameAvailable == FA_NEW_FRAME) {
+// stringstream ss;
+// ss << "testfiles/result/" << sFilename << numFrames << ".png";
+// pBmp->save(ss.str());
+ numFrames++;
+ }
+ if (isDemuxerThreaded()) {
+ AudioBufferPtr pBuffer = createAudioBuffer(256);
+ int framesDecoded = 0;
+ while (framesDecoded == 0 && !pDecoder->isEOF(SS_AUDIO)) {
+ framesDecoded = pDecoder->fillAudioBuffer(pBuffer);
+ msleep(0);
+ }
+ totalFramesDecoded += framesDecoded;
+// cerr << "framesDecoded: " << framesDecoded << endl;
+ }
+ curTime += 1.0/pDecoder->getFPS();
+ }
+ TEST(pDecoder->isEOF(SS_VIDEO));
+// cerr << "numFrames: " << numFrames << endl;
+ TEST(numFrames == expectedNumFrames);
+ testEqual(*pBmp, sFilename+"_end", B8G8R8X8);
+
+ if (isDemuxerThreaded()) {
+ // Check if audio length was ok.
+ // TODO: Currently, getDuration() is the duration of the video stream.
+ // This causes the test to fail.
+ //int framesInDuration = int(pDecoder->getDuration()*44100);
+ //cerr << "framesDecoded: " << totalFramesDecoded << ", framesInDuration: " << framesInDuration << endl;
+ //TEST (abs(totalFramesDecoded-framesInDuration) < 45);
+ }
+
+ // Test loop.
+ pDecoder->seek(0);
+ pDecoder->renderToBmp(pBmp, -1);
+ testEqual(*pBmp, sFilename+"_loop", B8G8R8X8);
+
+ pDecoder->close();
+ }
+};
+
+
+class VideoTestSuite: public TestSuite {
+public:
+ VideoTestSuite()
+ : TestSuite("VideoTestSuite")
+ {
+ addAudioTests();
+ addVideoTests(false);
+#ifdef AVG_ENABLE_VDPAU
+ if (VDPAU::isAvailable()) {
+ addVideoTests(true);
+ }
+#endif
+ }
+private:
+
+ void addAudioTests()
+ {
+ addTest(TestPtr(new AudioDecoderTest(false, true)));
+ addTest(TestPtr(new AudioDecoderTest(true, true)));
+ }
+
+ void addVideoTests(bool bUseHardwareAcceleration)
+ {
+ addTest(TestPtr(new VideoDecoderTest(false, false, bUseHardwareAcceleration)));
+ addTest(TestPtr(new VideoDecoderTest(false, true, bUseHardwareAcceleration)));
+ addTest(TestPtr(new VideoDecoderTest(true, true, bUseHardwareAcceleration)));
+
+ addTest(TestPtr(new AVDecoderTest(false, false, bUseHardwareAcceleration)));
+ addTest(TestPtr(new AVDecoderTest(false, true, bUseHardwareAcceleration)));
+ addTest(TestPtr(new AVDecoderTest(true, true, bUseHardwareAcceleration)));
+ }
+};
+
+
+void deleteOldResultImages()
+{
+ string sDirName("resultimages");
+ Directory dir(sDirName);
+ int err = dir.open(true);
+ if (err) {
+ cerr << "Creating directory " << sDirName << " failed." << strerror(err) << endl;
+ } else {
+ cerr << "Deleting files in " << sDirName << endl;
+ DirEntryPtr pEntry = dir.getNextEntry();
+ while (pEntry) {
+ if (pEntry->getName()[0] != '.') {
+ pEntry->remove();
+ }
+ pEntry = dir.getNextEntry();
+ }
+ }
+}
+
+int main(int nargs, char** args)
+{
+ ThreadProfilerPtr pProfiler = ThreadProfiler::get();
+ pProfiler->setName("main");
+
+ deleteOldResultImages();
+
+ VideoTestSuite suite;
+ bool bOk;
+
+ suite.runTests();
+ bOk = suite.isOk();
+ if (bOk) {
+ return 0;
+ } else {
+ return 1;
+ }
+/*
+ while(true) {
+ suite.runTests();
+ bOk = suite.isOk();
+ if (!bOk) {
+ return 1;
+ }
+ }
+*/
+}
+
diff --git a/src/wrapper/Makefile.am b/src/wrapper/Makefile.am
new file mode 100644
index 0000000..fdb3f17
--- /dev/null
+++ b/src/wrapper/Makefile.am
@@ -0,0 +1,39 @@
+
+INCLUDES = -I. -I../player \
+ @XML2_CFLAGS@ @PTHREAD_CFLAGS@ @PANGOFT2_CFLAGS@ @PYTHON_INCLUDES@ \
+ @DC1394_2_CFLAGS@ @LIBRSVG_CFLAGS@ @FONTCONFIG_CFLAGS@
+
+ALL_H = WrapHelper.h raw_constructor.hpp
+
+if APPLE
+ XGL_LIBS =
+ APPLE_LDFLAGS=-read_only_relocs suppress -F/System/Library/PrivateFrameworks -framework MultitouchSupport
+else
+ XGL_LIBS = -lXxf86vm
+ APPLE_LDFLAGS=
+endif
+
+ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
+
+pkgpyexec_LTLIBRARIES = avg.la
+avg_la_SOURCES = WrapHelper.cpp avg_wrap.cpp node_wrap.cpp raster_wrap.cpp \
+ event_wrap.cpp fx_wrap.cpp \
+ device_wrap.cpp bitmap_wrap.cpp anim_wrap.cpp $(ALL_H)
+avg_la_LDFLAGS = $(APPLE_LDFLAGS) -module -XCClinker
+avg_la_LIBADD = ../conradrelais/libconradrelais.la \
+ ../player/libplayer.la \
+ ../audio/libaudio.la \
+ ../video/libvideo.la \
+ ../graphics/libgraphics.la \
+ ../base/libbase.la \
+ ../imaging/libimaging.la \
+ ../parport/libparport.la \
+ ../anim/libanim.la \
+ ../lmfit/liblmfit.la \
+ ../oscpack/liboscpack.la \
+ @PANGOFT2_LIBS@ @LIBRSVG_LIBS@ $(BOOST_PYTHON_LIBS)\
+ -l@BOOST_THREAD_LIB@ -lboost_system @XML2_LIBS@ \
+ @DC1394_2_LIBS@ @GLU_LIBS@ $(XI2_1_LIBS) $(XI2_2_LIBS) \
+ $(ALL_GL_LIBS) @LIBFFMPEG@ @PTHREAD_LIBS@ \
+ @GDK_PIXBUF_LIBS@ @FONTCONFIG_LIBS@
+
diff --git a/src/wrapper/Makefile.in b/src/wrapper/Makefile.in
new file mode 100644
index 0000000..a5acc9a
--- /dev/null
+++ b/src/wrapper/Makefile.in
@@ -0,0 +1,675 @@
+# Makefile.in generated by automake 1.11.1 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/wrapper
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/m4/ac_cxx_namespaces.m4 \
+ $(top_srcdir)/m4/ac_path_generic.m4 \
+ $(top_srcdir)/m4/ax_boost_thread.m4 \
+ $(top_srcdir)/m4/ax_check_gl.m4 $(top_srcdir)/m4/libtool.m4 \
+ $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
+ $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
+ $(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/python_dev.m4 \
+ $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+ $(ACLOCAL_M4)
+mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
+CONFIG_HEADER = $(top_builddir)/src/avgconfig.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+ *) f=$$p;; \
+ esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+ for p in $$list; do echo "$$p $$p"; done | \
+ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+ if (++n[$$2] == $(am__install_max)) \
+ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+ END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(pkgpyexecdir)"
+LTLIBRARIES = $(pkgpyexec_LTLIBRARIES)
+am__DEPENDENCIES_1 =
+am__DEPENDENCIES_2 = $(am__DEPENDENCIES_1)
+avg_la_DEPENDENCIES = ../conradrelais/libconradrelais.la \
+ ../player/libplayer.la ../audio/libaudio.la \
+ ../video/libvideo.la ../graphics/libgraphics.la \
+ ../base/libbase.la ../imaging/libimaging.la \
+ ../parport/libparport.la ../anim/libanim.la \
+ ../lmfit/liblmfit.la ../oscpack/liboscpack.la \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2)
+am__objects_1 =
+am_avg_la_OBJECTS = WrapHelper.lo avg_wrap.lo node_wrap.lo \
+ raster_wrap.lo event_wrap.lo fx_wrap.lo device_wrap.lo \
+ bitmap_wrap.lo anim_wrap.lo $(am__objects_1)
+avg_la_OBJECTS = $(am_avg_la_OBJECTS)
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+avg_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(avg_la_LDFLAGS) $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)/src
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
+ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
+LTCXXCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CXX) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CXXFLAGS) $(CXXFLAGS)
+AM_V_CXX = $(am__v_CXX_$(V))
+am__v_CXX_ = $(am__v_CXX_$(AM_DEFAULT_VERBOSITY))
+am__v_CXX_0 = @echo " CXX " $@;
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+CXXLD = $(CXX)
+CXXLINK = $(LIBTOOL) $(AM_V_lt) --tag=CXX $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CXXLD) $(AM_CXXFLAGS) \
+ $(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CXXLD = $(am__v_CXXLD_$(V))
+am__v_CXXLD_ = $(am__v_CXXLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CXXLD_0 = @echo " CXXLD " $@;
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \
+ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+ $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo " CC " $@;
+CCLD = $(CC)
+LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
+ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+ $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo " CCLD " $@;
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo " GEN " $@;
+SOURCES = $(avg_la_SOURCES)
+DIST_SOURCES = $(avg_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BOOST_PYTHON_LIBS = @BOOST_PYTHON_LIBS@
+BOOST_THREAD_LIB = @BOOST_THREAD_LIB@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DC1394_2_CFLAGS = @DC1394_2_CFLAGS@
+DC1394_2_LIBS = @DC1394_2_LIBS@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DSYMUTIL = @DSYMUTIL@
+DUMPBIN = @DUMPBIN@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+FFMPEG_CFLAGS = @FFMPEG_CFLAGS@
+FFMPEG_LIBS = @FFMPEG_LIBS@
+FGREP = @FGREP@
+FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@
+FONTCONFIG_LIBS = @FONTCONFIG_LIBS@
+FREETYPE_CFLAGS = @FREETYPE_CFLAGS@
+FREETYPE_CONFIG = @FREETYPE_CONFIG@
+FREETYPE_LIBS = @FREETYPE_LIBS@
+GDK_PIXBUF_CFLAGS = @GDK_PIXBUF_CFLAGS@
+GDK_PIXBUF_LIBS = @GDK_PIXBUF_LIBS@
+GLU_CFLAGS = @GLU_CFLAGS@
+GLU_LIBS = @GLU_LIBS@
+GL_CFLAGS = @GL_CFLAGS@
+GL_LIBS = @GL_LIBS@
+GREP = @GREP@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LD = @LD@
+LDFLAGS = @LDFLAGS@
+LIBFFMPEG = @LIBFFMPEG@
+LIBOBJS = @LIBOBJS@
+LIBRSVG_CFLAGS = @LIBRSVG_CFLAGS@
+LIBRSVG_LIBS = @LIBRSVG_LIBS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LIBVIDEO_LDADD = @LIBVIDEO_LDADD@
+LIPO = @LIPO@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+MTDEV_CFLAGS = @MTDEV_CFLAGS@
+MTDEV_LIBS = @MTDEV_LIBS@
+NM = @NM@
+NMEDIT = @NMEDIT@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJCLDFLAGS = @OBJCLDFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OTOOL = @OTOOL@
+OTOOL64 = @OTOOL64@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PANGOFT2_CFLAGS = @PANGOFT2_CFLAGS@
+PANGOFT2_LIBS = @PANGOFT2_LIBS@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PREFIX = @PREFIX@
+PTHREAD_CC = @PTHREAD_CC@
+PTHREAD_CFLAGS = @PTHREAD_CFLAGS@
+PTHREAD_LIBS = @PTHREAD_LIBS@
+PYTHON = @PYTHON@
+PYTHON_EXEC_PREFIX = @PYTHON_EXEC_PREFIX@
+PYTHON_INCLUDES = @PYTHON_INCLUDES@
+PYTHON_LIBS = @PYTHON_LIBS@
+PYTHON_PLATFORM = @PYTHON_PLATFORM@
+PYTHON_PREFIX = @PYTHON_PREFIX@
+PYTHON_VERSION = @PYTHON_VERSION@
+RANLIB = @RANLIB@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_CONFIG = @SDL_CONFIG@
+SDL_LIBS = @SDL_LIBS@
+SED = @SED@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+XI2_1_CFLAGS = @XI2_1_CFLAGS@
+XI2_1_LIBS = @XI2_1_LIBS@
+XI2_2_CFLAGS = @XI2_2_CFLAGS@
+XI2_2_LIBS = @XI2_2_LIBS@
+XMKMF = @XMKMF@
+XML2_CFLAGS = @XML2_CFLAGS@
+XML2_CONFIG = @XML2_CONFIG@
+XML2_LIBS = @XML2_LIBS@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DUMPBIN = @ac_ct_DUMPBIN@
+acx_pthread_config = @acx_pthread_config@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+lt_ECHO = @lt_ECHO@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+pkgpyexecdir = @pkgpyexecdir@
+pkgpythondir = @pkgpythondir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+pyexecdir = @pyexecdir@
+pythondir = @pythondir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+INCLUDES = -I. -I../player \
+ @XML2_CFLAGS@ @PTHREAD_CFLAGS@ @PANGOFT2_CFLAGS@ @PYTHON_INCLUDES@ \
+ @DC1394_2_CFLAGS@ @LIBRSVG_CFLAGS@ @FONTCONFIG_CFLAGS@
+
+ALL_H = WrapHelper.h raw_constructor.hpp
+@APPLE_FALSE@XGL_LIBS = -lXxf86vm
+@APPLE_TRUE@XGL_LIBS =
+@APPLE_FALSE@APPLE_LDFLAGS =
+@APPLE_TRUE@APPLE_LDFLAGS = -read_only_relocs suppress -F/System/Library/PrivateFrameworks -framework MultitouchSupport
+ALL_GL_LIBS = @GL_LIBS@ @SDL_LIBS@ $(XGL_LIBS)
+pkgpyexec_LTLIBRARIES = avg.la
+avg_la_SOURCES = WrapHelper.cpp avg_wrap.cpp node_wrap.cpp raster_wrap.cpp \
+ event_wrap.cpp fx_wrap.cpp \
+ device_wrap.cpp bitmap_wrap.cpp anim_wrap.cpp $(ALL_H)
+
+avg_la_LDFLAGS = $(APPLE_LDFLAGS) -module -XCClinker
+avg_la_LIBADD = ../conradrelais/libconradrelais.la \
+ ../player/libplayer.la \
+ ../audio/libaudio.la \
+ ../video/libvideo.la \
+ ../graphics/libgraphics.la \
+ ../base/libbase.la \
+ ../imaging/libimaging.la \
+ ../parport/libparport.la \
+ ../anim/libanim.la \
+ ../lmfit/liblmfit.la \
+ ../oscpack/liboscpack.la \
+ @PANGOFT2_LIBS@ @LIBRSVG_LIBS@ $(BOOST_PYTHON_LIBS)\
+ -l@BOOST_THREAD_LIB@ @XML2_LIBS@ \
+ @DC1394_2_LIBS@ @GLU_LIBS@ $(XI2_1_LIBS) $(XI2_2_LIBS) \
+ $(ALL_GL_LIBS) @LIBFFMPEG@ @PTHREAD_LIBS@ \
+ @GDK_PIXBUF_LIBS@ @FONTCONFIG_LIBS@
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .cpp .lo .o .obj
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps)
+ @for dep in $?; do \
+ case '$(am__configure_deps)' in \
+ *$$dep*) \
+ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+ && { if test -f $@; then exit 0; else break; fi; }; \
+ exit 1;; \
+ esac; \
+ done; \
+ echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign src/wrapper/Makefile'; \
+ $(am__cd) $(top_srcdir) && \
+ $(AUTOMAKE) --foreign src/wrapper/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+ @case '$?' in \
+ *config.status*) \
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+ *) \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure: $(am__configure_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4): $(am__aclocal_m4_deps)
+ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-pkgpyexecLTLIBRARIES: $(pkgpyexec_LTLIBRARIES)
+ @$(NORMAL_INSTALL)
+ test -z "$(pkgpyexecdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgpyexecdir)"
+ @list='$(pkgpyexec_LTLIBRARIES)'; test -n "$(pkgpyexecdir)" || list=; \
+ list2=; for p in $$list; do \
+ if test -f $$p; then \
+ list2="$$list2 $$p"; \
+ else :; fi; \
+ done; \
+ test -z "$$list2" || { \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(pkgpyexecdir)'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(pkgpyexecdir)"; \
+ }
+
+uninstall-pkgpyexecLTLIBRARIES:
+ @$(NORMAL_UNINSTALL)
+ @list='$(pkgpyexec_LTLIBRARIES)'; test -n "$(pkgpyexecdir)" || list=; \
+ for p in $$list; do \
+ $(am__strip_dir) \
+ echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(pkgpyexecdir)/$$f'"; \
+ $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(pkgpyexecdir)/$$f"; \
+ done
+
+clean-pkgpyexecLTLIBRARIES:
+ -test -z "$(pkgpyexec_LTLIBRARIES)" || rm -f $(pkgpyexec_LTLIBRARIES)
+ @list='$(pkgpyexec_LTLIBRARIES)'; for p in $$list; do \
+ dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+ test "$$dir" != "$$p" || dir=.; \
+ echo "rm -f \"$${dir}/so_locations\""; \
+ rm -f "$${dir}/so_locations"; \
+ done
+avg.la: $(avg_la_OBJECTS) $(avg_la_DEPENDENCIES)
+ $(AM_V_CXXLD)$(avg_la_LINK) -rpath $(pkgpyexecdir) $(avg_la_OBJECTS) $(avg_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+ -rm -f *.$(OBJEXT)
+
+distclean-compile:
+ -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/WrapHelper.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/anim_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/avg_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitmap_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/device_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/event_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fx_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/node_wrap.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/raster_wrap.Plo@am__quote@
+
+.cpp.o:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ $<
+
+.cpp.obj:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+.cpp.lo:
+@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(LTCXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo
+@am__fastdepCXX_FALSE@ $(AM_V_CXX) @AM_BACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(LTCXXCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+ -rm -f *.lo
+
+clean-libtool:
+ -rm -rf .libs _libs
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ mkid -fID $$unique
+tags: TAGS
+
+TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ set x; \
+ here=`pwd`; \
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ shift; \
+ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+ test -n "$$unique" || unique=$$empty_fix; \
+ if test $$# -gt 0; then \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ "$$@" $$unique; \
+ else \
+ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+ $$unique; \
+ fi; \
+ fi
+ctags: CTAGS
+CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
+ $(TAGS_FILES) $(LISP)
+ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+ unique=`for i in $$list; do \
+ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+ done | \
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \
+ END { if (nonempty) { for (i in files) print i; }; }'`; \
+ test -z "$(CTAGS_ARGS)$$unique" \
+ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+ $$unique
+
+GTAGS:
+ here=`$(am__cd) $(top_builddir) && pwd` \
+ && $(am__cd) $(top_srcdir) \
+ && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+ -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+ @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+ list='$(DISTFILES)'; \
+ dist_files=`for file in $$list; do echo $$file; done | \
+ sed -e "s|^$$srcdirstrip/||;t" \
+ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+ case $$dist_files in \
+ */*) $(MKDIR_P) `echo "$$dist_files" | \
+ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+ sort -u` ;; \
+ esac; \
+ for file in $$dist_files; do \
+ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+ if test -d $$d/$$file; then \
+ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+ if test -d "$(distdir)/$$file"; then \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+ fi; \
+ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+ else \
+ test -f "$(distdir)/$$file" \
+ || cp -p $$d/$$file "$(distdir)/$$file" \
+ || exit 1; \
+ fi; \
+ done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+ for dir in "$(DESTDIR)$(pkgpyexecdir)"; do \
+ test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+ done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+ @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+ `test -z '$(STRIP)' || \
+ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+ -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+ -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+ @echo "This command is intended for maintainers to use"
+ @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-pkgpyexecLTLIBRARIES \
+ mostlyclean-am
+
+distclean: distclean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+ distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-pkgpyexecLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+ -rm -rf ./$(DEPDIR)
+ -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+ mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-pkgpyexecLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+ clean-libtool clean-pkgpyexecLTLIBRARIES ctags distclean \
+ distclean-compile distclean-generic distclean-libtool \
+ distclean-tags distdir dvi dvi-am html html-am info info-am \
+ install install-am install-data install-data-am install-dvi \
+ install-dvi-am install-exec install-exec-am install-html \
+ install-html-am install-info install-info-am install-man \
+ install-pdf install-pdf-am install-pkgpyexecLTLIBRARIES \
+ install-ps install-ps-am install-strip installcheck \
+ installcheck-am installdirs maintainer-clean \
+ maintainer-clean-generic mostlyclean mostlyclean-compile \
+ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+ tags uninstall uninstall-am uninstall-pkgpyexecLTLIBRARIES
+
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff --git a/src/wrapper/WrapHelper.cpp b/src/wrapper/WrapHelper.cpp
new file mode 100644
index 0000000..093cd70
--- /dev/null
+++ b/src/wrapper/WrapHelper.cpp
@@ -0,0 +1,345 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WrapHelper.h"
+
+#include "../base/Exception.h"
+
+#include <boost/version.hpp>
+
+using namespace avg;
+using namespace std;
+using namespace boost::python;
+
+namespace DPointHelper
+{
+ int len(const DPoint&)
+ {
+ return 2;
+ }
+
+ double getX(const DPoint& pt)
+ {
+ return pt.x;
+ }
+
+ double getY(const DPoint& pt)
+ {
+ return pt.y;
+ }
+
+ void setX(DPoint& pt, double val)
+ {
+ pt.x = val;
+ }
+
+ void setY(DPoint& pt, double val)
+ {
+ pt.y = val;
+ }
+
+ void checkItemRange(int i) {
+ if (i != 0 && i != 1) {
+ throw std::out_of_range("Index out of range for Point2D. Must be 0 or 1.");
+ }
+ }
+
+ double getItem(const DPoint& pt, int i)
+ {
+ checkItemRange(i);
+ if (i==0) {
+ return pt.x;
+ } else {
+ return pt.y;
+ }
+ }
+
+ void setItem(DPoint& pt, int i, double val)
+ {
+ checkItemRange(i);
+ if (i==0) {
+ pt.x = val;
+ } else {
+ pt.y = val;
+ }
+ }
+
+ string str(const DPoint& pt)
+ {
+ stringstream st;
+ st << "(" << pt.x << "," << pt.y << ")";
+ return st.str();
+ }
+
+ string repr(const DPoint& pt)
+ {
+ stringstream st;
+ st << "avg.Point2D(" << pt.x << "," << pt.y << ")";
+ return st.str();
+ }
+
+ long getHash(const DPoint& pt)
+ {
+ // Wild guess at what could constitute a good hash function.
+ // Will generate very bad hashes if most values are in a range < 0.1,
+ // but this is meant for pixel values anyway, right? ;-).
+ return long(pt.x*42+pt.y*23);
+ }
+}
+
+// The ConstDPoint stuff is there so that DPoint attributes behave sensibly. That is,
+// node.pos.x = 30 causes an error instead of failing silently.
+ConstDPoint::ConstDPoint()
+{
+}
+
+ConstDPoint::ConstDPoint(const DPoint& other)
+{
+ x = other.x;
+ y = other.y;
+}
+
+ConstDPoint::operator DPoint() const
+{
+ return DPoint(x,y);
+}
+
+void checkEmptyArgs(const boost::python::tuple &args, int numArgs)
+{
+ if (boost::python::len(args) != numArgs) {
+ throw avg::Exception(AVG_ERR_INVALID_ARGS,
+ "Nodes must be constructed using named parameters. Positional parameters are not supported.");
+ }
+}
+
+template<class NUM>
+struct Point_to_python_tuple
+{
+ static PyObject* convert (avg::Point<NUM> pt)
+ {
+ return boost::python::incref(boost::python::make_tuple(pt.x, pt.y).ptr());
+ }
+};
+
+struct Exception_to_python_exception
+{
+ static PyObject* convert (avg::Exception ex)
+ {
+ PyObject *arglist = boost::python::incref(Py_BuildValue("(s)", ex.getStr().c_str()));
+
+ return boost::python::incref(
+ PyObject_CallObject(PyExc_RuntimeError, arglist));
+ }
+};
+
+template<class NUM>
+struct Triple_to_python_tuple
+{
+ static PyObject* convert (avg::Triple<NUM> t)
+ {
+ return boost::python::incref(boost::python::make_tuple(t.x,t.y,t.z).ptr());
+ }
+};
+
+template<class POINT, class ATTR>
+struct point_from_python
+{
+ point_from_python()
+ {
+ boost::python::converter::registry::push_back(
+ &convertible, &construct, boost::python::type_id<POINT>());
+ }
+
+ static void* convertible(PyObject* obj_ptr)
+ {
+ // Using PySequence_Check here causes infinite recursion.
+ if (!PyTuple_Check(obj_ptr) && !PyList_Check(obj_ptr)) {
+ return 0;
+ }
+ if (PySequence_Size(obj_ptr) != 2) {
+ return 0;
+ }
+ return obj_ptr;
+ }
+
+ static void construct(PyObject* obj_ptr,
+ boost::python::converter::rvalue_from_python_stage1_data* data)
+ {
+ POINT pt;
+ PyObject * pEntry = PySequence_GetItem(obj_ptr, 0);
+ pt.x = (ATTR)PyFloat_AsDouble(pEntry);
+ Py_DECREF(pEntry);
+ pEntry = PySequence_GetItem(obj_ptr, 1);
+ pt.y = (ATTR)PyFloat_AsDouble(pEntry);
+ Py_DECREF(pEntry);
+ void* storage = (
+ (boost::python::converter::rvalue_from_python_storage<POINT>*)data)
+ ->storage.bytes;
+ new (storage) POINT(pt);
+ data->convertible = storage;
+ }
+};
+
+template<class NUM>
+struct triple_from_python
+{
+ triple_from_python()
+ {
+ boost::python::converter::registry::push_back(
+ &convertible, &construct, boost::python::type_id<Triple<NUM> >());
+ }
+
+ static void* convertible(PyObject* obj_ptr)
+ {
+ if (!PySequence_Check(obj_ptr)) {
+ return 0;
+ }
+ if (PySequence_Size(obj_ptr) != 3) {
+ return 0;
+ }
+ return obj_ptr;
+ }
+
+ static void construct(PyObject* obj_ptr,
+ boost::python::converter::rvalue_from_python_stage1_data* data)
+ {
+ avg::Triple<NUM> t;
+ PyObject * pEntry = PySequence_GetItem(obj_ptr, 0);
+ t.x = (NUM)PyFloat_AsDouble(pEntry);
+ Py_DECREF(pEntry);
+ pEntry = PySequence_GetItem(obj_ptr, 1);
+ t.y = (NUM)PyFloat_AsDouble(pEntry);
+ Py_DECREF(pEntry);
+ pEntry = PySequence_GetItem(obj_ptr, 2);
+ t.z = (NUM)PyFloat_AsDouble(pEntry);
+ Py_DECREF(pEntry);
+ void* storage = (
+ (boost::python::converter::rvalue_from_python_storage<Triple<NUM> >*)
+ data)->storage.bytes;
+ new (storage) Triple<NUM>(t);
+ data->convertible = storage;
+ }
+};
+
+void exception_translator(Exception const & e)
+{
+ PyErr_SetString(PyExc_RuntimeError, e.getStr().c_str());
+}
+
+struct UTF8String_to_unicode
+{
+ static PyObject *convert(const UTF8String & s)
+ {
+ const char * pStr = s.c_str();
+ return PyUnicode_DecodeUTF8(pStr, strlen(pStr), "ignore");
+ }
+};
+
+struct UTF8String_from_unicode
+{
+ UTF8String_from_unicode()
+ {
+ boost::python::converter::registry::push_back(
+ &convertible,
+ &construct,
+ boost::python::type_id<UTF8String>());
+ }
+
+ static void* convertible(PyObject* obj_ptr)
+ {
+ if (!PyUnicode_Check(obj_ptr)) return 0;
+ return obj_ptr;
+ }
+
+ static void construct(PyObject* obj_ptr,
+ boost::python::converter::rvalue_from_python_stage1_data* data)
+ {
+ UTF8String s;
+ PyObject * pPyUTF8 = PyUnicode_AsUTF8String(obj_ptr);
+ char * psz = PyString_AsString(pPyUTF8);
+ void* storage = (
+ (boost::python::converter::rvalue_from_python_storage<UTF8String>*)data)
+ ->storage.bytes;
+ new (storage) UTF8String(psz);
+ data->convertible = storage;
+ }
+};
+
+struct UTF8String_from_string
+{
+ UTF8String_from_string()
+ {
+ boost::python::converter::registry::push_back(
+ &convertible,
+ &construct,
+ boost::python::type_id<UTF8String>());
+ }
+
+ static void* convertible(PyObject* obj_ptr)
+ {
+ if (!PyString_Check(obj_ptr)) return 0;
+ return obj_ptr;
+ }
+
+ static void construct(PyObject* obj_ptr,
+ boost::python::converter::rvalue_from_python_stage1_data* data)
+ {
+ UTF8String s;
+ char * psz = PyString_AsString(obj_ptr);
+ void* storage = (
+ (boost::python::converter::rvalue_from_python_storage<UTF8String>*)data)
+ ->storage.bytes;
+ new (storage) UTF8String(psz);
+ data->convertible = storage;
+ }
+};
+
+void export_base()
+{
+#if (BOOST_VERSION / 100000) > 1 || ((BOOST_VERSION / 100) % 1000) >= 33
+ register_exception_translator<Exception>(exception_translator);
+#endif
+ to_python_converter<Exception, Exception_to_python_exception>();
+ to_python_converter<IntPoint, Point_to_python_tuple<int> >();
+ to_python_converter<DTriple, Triple_to_python_tuple<double> >();
+ point_from_python<DPoint, double>();
+ point_from_python<ConstDPoint, double>();
+ point_from_python<IntPoint, int>();
+
+ triple_from_python<double>();
+ triple_from_python<int>();
+
+ to_python_converter<vector<DPoint>, to_list<vector<DPoint> > >();
+ to_python_converter<vector<string>, to_list<vector<string> > >();
+
+ from_python_sequence<vector<DPoint>, variable_capacity_policy>();
+ from_python_sequence<vector<IntPoint>, variable_capacity_policy>();
+ from_python_sequence<vector<string>, variable_capacity_policy>();
+
+ from_python_sequence<vector<IntTriple>, variable_capacity_policy>();
+ from_python_sequence<vector<DTriple>, variable_capacity_policy>();
+ from_python_sequence<vector<double>, variable_capacity_policy>();
+
+ to_python_converter<UTF8String, UTF8String_to_unicode>();
+ UTF8String_from_unicode();
+ UTF8String_from_string();
+}
+
diff --git a/src/wrapper/WrapHelper.h b/src/wrapper/WrapHelper.h
new file mode 100644
index 0000000..5ca9457
--- /dev/null
+++ b/src/wrapper/WrapHelper.h
@@ -0,0 +1,320 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#ifndef _WrapHelper_H_
+#define _WrapHelper_H_
+
+#include "../api.h"
+#include "../base/Point.h"
+#include "../base/Triple.h"
+#include "../base/Exception.h"
+
+#include "../player/BoostPython.h"
+#include "../player/Player.h"
+
+#include <string>
+
+template <typename ContainerType>
+struct to_tuple
+{
+ static PyObject* convert(ContainerType const& a)
+ {
+ boost::python::list result;
+ typedef typename ContainerType::const_iterator const_iter;
+ for(const_iter p=a.begin();p!=a.end();p++) {
+ result.append(boost::python::object(*p));
+ }
+ return boost::python::incref(boost::python::tuple(result).ptr());
+ }
+
+ static const PyTypeObject* get_pytype() { return &PyTuple_Type; }
+};
+
+template <typename ContainerType>
+struct to_list
+{
+ static PyObject* convert(ContainerType const& a)
+ {
+ boost::python::list result;
+ typedef typename ContainerType::const_iterator const_iter;
+ for(const_iter p=a.begin();p!=a.end();p++) {
+ result.append(boost::python::object(*p));
+ }
+ return boost::python::incref(result.ptr());
+ }
+
+ static const PyTypeObject* get_pytype() { return &PyList_Type; }
+};
+
+struct default_policy
+{
+ static bool check_convertibility_per_element() { return false; }
+
+ template <typename ContainerType>
+ static bool check_size(boost::type<ContainerType>, std::size_t /*sz*/)
+ {
+ return true;
+ }
+
+ template <typename ContainerType>
+ static void assert_size(boost::type<ContainerType>, std::size_t /*sz*/) {}
+
+ template <typename ContainerType>
+ static void reserve(ContainerType& a, std::size_t sz) {}
+};
+
+struct fixed_size_policy
+{
+ static bool check_convertibility_per_element() { return true; }
+
+ template <typename ContainerType>
+ static bool check_size(boost::type<ContainerType>, std::size_t sz)
+ {
+ return ContainerType::size() == sz;
+ }
+
+ template <typename ContainerType>
+ static void assert_size(boost::type<ContainerType>, std::size_t sz)
+ {
+ if (!check_size(boost::type<ContainerType>(), sz)) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Insufficient elements for fixed-size array.");
+ boost::python::throw_error_already_set();
+ }
+ }
+
+ template <typename ContainerType>
+ static void reserve(ContainerType& /*a*/, std::size_t sz)
+ {
+ if (sz > ContainerType::size()) {
+ PyErr_SetString(PyExc_RuntimeError,
+ "Too many elements for fixed-size array.");
+ boost::python::throw_error_already_set();
+ }
+ }
+
+ template <typename ContainerType, typename ValueType>
+ static void set_value(ContainerType& a, std::size_t i, ValueType const& v)
+ {
+ reserve(a, i+1);
+ a[i] = v;
+ }
+};
+
+struct variable_capacity_policy : default_policy
+{
+ template <typename ContainerType>
+ static void reserve(ContainerType& a, std::size_t sz)
+ {
+ a.reserve(sz);
+ }
+
+ template <typename ContainerType, typename ValueType>
+ static void set_value(
+ ContainerType& a,
+ std::size_t
+#if !defined(NDEBUG)
+ i
+#endif
+ ,
+ ValueType const& v)
+ {
+ assert(a.size() == i);
+ a.push_back(v);
+ }
+};
+
+struct fixed_capacity_policy : variable_capacity_policy
+{
+ template <typename ContainerType>
+ static bool check_size(boost::type<ContainerType>, std::size_t sz)
+ {
+ return ContainerType::max_size() >= sz;
+ }
+};
+
+struct linked_list_policy : default_policy
+{
+ template <typename ContainerType, typename ValueType>
+ static void
+ set_value(ContainerType& a, std::size_t /*i*/, ValueType const& v)
+ {
+ a.push_back(v);
+ }
+};
+
+struct set_policy : default_policy
+{
+ template <typename ContainerType, typename ValueType>
+ static void
+ set_value(ContainerType& a, std::size_t /*i*/, ValueType const& v)
+ {
+ a.insert(v);
+ }
+};
+
+template <typename ContainerType, typename ConversionPolicy>
+struct from_python_sequence
+{
+ typedef typename ContainerType::value_type container_element_type;
+
+ from_python_sequence()
+ {
+ boost::python::converter::registry::push_back(
+ &convertible,
+ &construct,
+ boost::python::type_id<ContainerType>());
+ }
+
+ static void* convertible(PyObject* obj_ptr)
+ {
+ if (!( PyList_Check(obj_ptr)
+ || PyTuple_Check(obj_ptr)
+ || PyIter_Check(obj_ptr)
+ || PyRange_Check(obj_ptr)
+ || ( !PyString_Check(obj_ptr)
+ && !PyUnicode_Check(obj_ptr)
+ && ( obj_ptr->ob_type == 0
+ || obj_ptr->ob_type->ob_type == 0
+ || obj_ptr->ob_type->ob_type->tp_name == 0
+ || std::strcmp(
+ obj_ptr->ob_type->ob_type->tp_name,
+ "Boost.Python.class") != 0)
+ && PyObject_HasAttrString(obj_ptr, "__len__")
+ && PyObject_HasAttrString(obj_ptr, "__getitem__")))) return 0;
+ boost::python::handle<> obj_iter(
+ boost::python::allow_null(PyObject_GetIter(obj_ptr)));
+ if (!obj_iter.get()) { // must be convertible to an iterator
+ PyErr_Clear();
+ return 0;
+ }
+ if (ConversionPolicy::check_convertibility_per_element()) {
+ int obj_size = int(PyObject_Length(obj_ptr));
+ if (obj_size < 0) { // must be a measurable sequence
+ PyErr_Clear();
+ return 0;
+ }
+ if (!ConversionPolicy::check_size(
+ boost::type<ContainerType>(), obj_size)) return 0;
+ bool is_range = PyRange_Check(obj_ptr);
+ std::size_t i=0;
+ if (!all_elements_convertible(obj_iter, is_range, i)) return 0;
+ if (!is_range) assert(i == (std::size_t)obj_size);
+ }
+ return obj_ptr;
+ }
+
+ // This loop factored out by Achim Domma to avoid Visual C++
+ // Internal Compiler Error.
+ static bool
+ all_elements_convertible(
+ boost::python::handle<>& obj_iter,
+ bool is_range,
+ std::size_t& i)
+ {
+ for(;;i++) {
+ boost::python::handle<> py_elem_hdl(
+ boost::python::allow_null(PyIter_Next(obj_iter.get())));
+ if (PyErr_Occurred()) {
+ PyErr_Clear();
+ return false;
+ }
+ if (!py_elem_hdl.get()) break; // end of iteration
+ boost::python::object py_elem_obj(py_elem_hdl);
+ boost::python::extract<container_element_type>
+ elem_proxy(py_elem_obj);
+ if (!elem_proxy.check()) return false;
+ if (is_range) break; // in a range all elements are of the same type
+ }
+ return true;
+ }
+
+ static void construct(
+ PyObject* obj_ptr,
+ boost::python::converter::rvalue_from_python_stage1_data* data)
+ {
+ boost::python::handle<> obj_iter(PyObject_GetIter(obj_ptr));
+ void* storage = (
+ (boost::python::converter::rvalue_from_python_storage<ContainerType>*)
+ data)->storage.bytes;
+ new (storage) ContainerType();
+ data->convertible = storage;
+ ContainerType& result = *((ContainerType*)storage);
+ std::size_t i=0;
+ for(;;i++) {
+ boost::python::handle<> py_elem_hdl(
+ boost::python::allow_null(PyIter_Next(obj_iter.get())));
+ if (PyErr_Occurred()) boost::python::throw_error_already_set();
+ if (!py_elem_hdl.get()) break; // end of iteration
+ boost::python::object py_elem_obj(py_elem_hdl);
+ boost::python::extract<container_element_type> elem_proxy(py_elem_obj);
+ ConversionPolicy::set_value(result, i, elem_proxy());
+ }
+ ConversionPolicy::assert_size(boost::type<ContainerType>(), i);
+ }
+};
+
+template<class T>
+double deprecatedGet(T& node)
+{
+ throw avg::Exception(AVG_ERR_DEPRECATED, "Attribute has been removed from libavg.");
+}
+
+template<class T>
+void deprecatedSet(T& node, double d)
+{
+ throw avg::Exception(AVG_ERR_DEPRECATED, "Attribute has been removed from libavg.");
+}
+
+namespace DPointHelper
+{
+ int len(const avg::DPoint&);
+ double getX(const avg::DPoint& pt);
+ double getY(const avg::DPoint& pt);
+ void setX(avg::DPoint& pt, double val);
+ void setY(avg::DPoint& pt, double val);
+ void checkItemRange(int i);
+ double getItem(const avg::DPoint& pt, int i);
+ void setItem(avg::DPoint& pt, int i, double val);
+ std::string str(const avg::DPoint& pt);
+ std::string repr(const avg::DPoint& pt);
+ long getHash(const avg::DPoint& pt);
+}
+
+class ConstDPoint: public avg::DPoint
+{
+public:
+ ConstDPoint();
+ ConstDPoint(const avg::DPoint& other);
+ operator avg::DPoint() const;
+};
+
+AVG_API void checkEmptyArgs(const boost::python::tuple &args, int numArgs=0);
+
+template<const char * pszType>
+avg::NodePtr createNode(const boost::python::tuple &args,
+ const boost::python::dict &attrs)
+{
+ checkEmptyArgs(args);
+ return avg::Player::get()->createNode(pszType, attrs);
+}
+
+#endif
diff --git a/src/wrapper/anim_wrap.cpp b/src/wrapper/anim_wrap.cpp
new file mode 100644
index 0000000..7e22f07
--- /dev/null
+++ b/src/wrapper/anim_wrap.cpp
@@ -0,0 +1,112 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WrapHelper.h"
+
+#include "../anim/SimpleAnim.h"
+#include "../anim/LinearAnim.h"
+#include "../anim/EaseInOutAnim.h"
+#include "../anim/ContinuousAnim.h"
+#include "../anim/WaitAnim.h"
+#include "../anim/ParallelAnim.h"
+#include "../anim/StateAnim.h"
+
+#include "../player/BoostPython.h"
+
+using namespace boost::python;
+using namespace std;
+using namespace avg;
+
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(start_overloads, start, 0, 1);
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(setState_overloads, StateAnim::setState, 1, 2);
+BOOST_PYTHON_FUNCTION_OVERLOADS(fadeIn_overloads, fadeIn, 2, 4);
+BOOST_PYTHON_FUNCTION_OVERLOADS(fadeOut_overloads, fadeOut, 2, 3);
+
+void export_anim()
+{
+ from_python_sequence<vector<AnimPtr>, variable_capacity_policy>();
+ from_python_sequence<vector<AnimState>, variable_capacity_policy>();
+
+ def("getNumRunningAnims", AttrAnim::getNumRunningAnims);
+
+ class_<Anim, boost::shared_ptr<Anim>, boost::noncopyable>("Anim", no_init)
+ .def("setStartCallback", &Anim::setStartCallback)
+ .def("setStopCallback", &Anim::setStopCallback)
+ .def("abort", &Anim::abort)
+ .def("isRunning", &Anim::isRunning)
+ ;
+
+ class_<AttrAnim, boost::shared_ptr<AttrAnim>, bases<Anim>, boost::noncopyable>
+ ("AttrAnim", no_init)
+ .def("start", &AttrAnim::start, start_overloads(args("bKeepAttr")))
+ ;
+
+ class_<SimpleAnim, boost::shared_ptr<SimpleAnim>, bases<AttrAnim>,
+ boost::noncopyable>("SimpleAnim", no_init)
+ ;
+
+ class_<LinearAnim, boost::shared_ptr<LinearAnim>, bases<SimpleAnim>,
+ boost::noncopyable>
+ ("LinearAnim", init<const object&, const string&, long long, const object&,
+ const object&, optional<bool, const object&, const object&> >())
+ ;
+
+ class_<EaseInOutAnim, boost::shared_ptr<EaseInOutAnim>, bases<SimpleAnim>,
+ boost::noncopyable>
+ ("EaseInOutAnim", init<const object&, const string&, long long, const object&,
+ const object&, long long, long long,
+ optional<bool, const object&, const object&> >())
+ ;
+
+ class_<ContinuousAnim, boost::shared_ptr<ContinuousAnim>, bases<AttrAnim>,
+ boost::noncopyable>(
+ "ContinuousAnim", init<const object&, const string&,
+ const object&, const object&,
+ optional<bool, const object&, const object&> >())
+ ;
+
+ class_<WaitAnim, boost::shared_ptr<WaitAnim>, bases<Anim>, boost::noncopyable>(
+ "WaitAnim", init<optional<long long, const object&, const object&> >())
+ .def("start", &WaitAnim::start, start_overloads(args("bKeepAttr")))
+ ;
+
+ class_<ParallelAnim, boost::shared_ptr<ParallelAnim>, bases<Anim>,
+ boost::noncopyable>("ParallelAnim", init<const vector<AnimPtr>&,
+ optional<const object&, const object&, long long> >())
+ .def("start", &ParallelAnim::start, start_overloads(args("bKeepAttr")))
+ ;
+
+ class_<AnimState, boost::noncopyable>("AnimState",
+ init<const string&, AnimPtr, optional<const string&> >())
+ ;
+
+ class_<StateAnim, boost::shared_ptr<StateAnim>, bases<Anim>,
+ boost::noncopyable>("StateAnim", init<const vector<AnimState>&>())
+ .def("setState", &StateAnim::setState, setState_overloads(args("bKeepAttr")))
+ .def("getState", make_function(&StateAnim::getState,
+ return_value_policy<copy_const_reference>()))
+ .def("setDebug", &StateAnim::setDebug)
+ ;
+
+ def("fadeIn", fadeIn, fadeIn_overloads(args("max", "stopCallback")));
+
+ def("fadeOut", fadeOut, fadeOut_overloads(args("stopCallback")));
+}
diff --git a/src/wrapper/avg_wrap.cpp b/src/wrapper/avg_wrap.cpp
new file mode 100644
index 0000000..cecd675
--- /dev/null
+++ b/src/wrapper/avg_wrap.cpp
@@ -0,0 +1,260 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+void export_base();
+void export_node();
+void export_event();
+#ifndef WIN32
+void export_devices();
+#endif
+void export_anim();
+
+#include "WrapHelper.h"
+
+#include "../base/Logger.h"
+#include "../base/OSHelper.h"
+#include "../base/GeomHelper.h"
+#include "../player/Player.h"
+#include "../player/AVGNode.h"
+#include "../player/DivNode.h"
+#include "../player/TrackerInputDevice.h"
+#include "../player/TouchEvent.h"
+#include "../player/MouseEvent.h"
+#include "../player/TestHelper.h"
+#include "../player/Canvas.h"
+#include "../player/OffscreenCanvas.h"
+#include "../player/VideoWriter.h"
+#include "../player/SVG.h"
+
+#include <boost/version.hpp>
+#include <boost/shared_ptr.hpp>
+#include <boost/python/raw_function.hpp>
+
+using namespace boost::python;
+using namespace avg;
+using namespace std;
+
+
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(TestHelper_fakeTouchEvent_overloads,
+ fakeTouchEvent, 4, 5)
+
+OffscreenCanvasPtr createCanvas(const boost::python::tuple &args,
+ const boost::python::dict& params)
+{
+ checkEmptyArgs(args, 1);
+ return extract<Player&>(args[0])().createCanvas(params);
+}
+
+CanvasPtr createMainCanvas(const boost::python::tuple &args,
+ const boost::python::dict& params)
+{
+ checkEmptyArgs(args, 1);
+ return extract<Player&>(args[0])().createMainCanvas(params);
+}
+
+
+BOOST_PYTHON_MODULE(avg)
+{
+ docstring_options doc_options(true, false);
+
+ export_base();
+
+ register_ptr_to_python<DivNodePtr>();
+ register_ptr_to_python<CanvasNodePtr>();
+ register_ptr_to_python<AVGNodePtr>();
+ register_ptr_to_python<EventPtr>();
+ register_ptr_to_python<MouseEventPtr>();
+ register_ptr_to_python<TouchEventPtr>();
+
+ def("getMemoryUsage", getMemoryUsage);
+
+ def("pointInPolygon", pointInPolygon);
+
+ class_<Logger>("Logger", no_init)
+ .def("get", &Logger::get,
+ return_value_policy<reference_existing_object>())
+ .staticmethod("get")
+ .def("setCategories", &Logger::setCategories)
+ .def("pushCategories", &Logger::pushCategories)
+ .def("popCategories", &Logger::popCategories)
+ .def("trace", &Logger::trace)
+ .def_readonly("NONE", &Logger::NONE)
+ .def_readonly("BLTS", &Logger::BLTS)
+ .def_readonly("PROFILE", &Logger::PROFILE)
+ .def_readonly("PROFILE_LATEFRAMES", &Logger::PROFILE_LATEFRAMES)
+ .def_readonly("PROFILE_VIDEO", &Logger::PROFILE_VIDEO)
+ .def_readonly("EVENTS", &Logger::EVENTS)
+ .def_readonly("EVENTS2", &Logger::EVENTS2)
+ .def_readonly("CONFIG", &Logger::CONFIG)
+ .def_readonly("WARNING", &Logger::WARNING)
+ .def_readonly("ERROR", &Logger::ERROR)
+ .def_readonly("MEMORY", &Logger::MEMORY)
+ .def_readonly("APP", &Logger::APP)
+ .def_readonly("PLUGIN", &Logger::PLUGIN)
+ .def_readonly("PLAYER", &Logger::PLAYER)
+ ;
+
+#ifndef WIN32
+ export_devices();
+#endif
+ export_event();
+ export_node();
+ export_anim();
+
+ class_<TestHelper>("TestHelper", no_init)
+ .def("fakeMouseEvent", &TestHelper::fakeMouseEvent)
+ .def("fakeTouchEvent", &TestHelper::fakeTouchEvent,
+ TestHelper_fakeTouchEvent_overloads())
+ .def("fakeKeyEvent", &TestHelper::fakeKeyEvent)
+ .def("dumpObjects", &TestHelper::dumpObjects)
+ ;
+
+ class_<Player>("Player")
+ .def("get", &Player::get,
+ return_value_policy<reference_existing_object>())
+ .staticmethod("get")
+ .def("setResolution", &Player::setResolution)
+ .def("isFullscreen", &Player::isFullscreen)
+ .def("setWindowFrame", &Player::setWindowFrame)
+ .def("setWindowPos", &Player::setWindowPos)
+ .def("setOGLOptions", &Player::setOGLOptions)
+ .def("setMultiSampleSamples", &Player::setMultiSampleSamples)
+ .def("getScreenResolution", &Player::getScreenResolution)
+ .def("getPixelsPerMM", &Player::getPixelsPerMM)
+ .def("getPhysicalScreenDimensions", &Player::getPhysicalScreenDimensions)
+ .def("assumePixelsPerMM", &Player::assumePixelsPerMM)
+ .def("loadFile", &Player::loadFile)
+ .def("loadString", &Player::loadString)
+ .def("loadCanvasFile", &Player::loadCanvasFile)
+ .def("loadCanvasString", &Player::loadCanvasString)
+ .def("createMainCanvas", raw_function(createMainCanvas))
+ .def("createCanvas", raw_function(createCanvas))
+ .def("deleteCanvas", &Player::deleteCanvas)
+ .def("getMainCanvas", &Player::getMainCanvas)
+ .def("getCanvas", &Player::getCanvas)
+ .def("play", &Player::play)
+ .def("stop", &Player::stop)
+ .def("isPlaying", &Player::isPlaying)
+ .def("setFramerate", &Player::setFramerate)
+ .def("setVBlankFramerate", &Player::setVBlankFramerate)
+ .def("getEffectiveFramerate", &Player::getEffectiveFramerate)
+ .def("getTestHelper", &Player::getTestHelper,
+ return_value_policy<reference_existing_object>())
+ .def("setFakeFPS", &Player::setFakeFPS)
+ .def("getFrameTime", &Player::getFrameTime)
+ .def("getFrameDuration", &Player::getFrameDuration)
+ .def("createNode", &Player::createNodeFromXmlString)
+ .def("createNode", &Player::createNode)
+ .def("addTracker", &Player::addTracker,
+ return_value_policy<reference_existing_object>())
+ .def("enableMultitouch", &Player::enableMultitouch)
+ .def("isMultitouchAvailable", &Player::isMultitouchAvailable)
+ .def("getTracker", &Player::getTracker,
+ return_value_policy<reference_existing_object>())
+ .def("setInterval", &Player::setInterval)
+ .def("setTimeout", &Player::setTimeout)
+ .def("setOnFrameHandler", &Player::setOnFrameHandler)
+ .def("clearInterval", &Player::clearInterval)
+ .def("addInputDevice", &Player::addInputDevice)
+ .def("getMouseState", &Player::getMouseState)
+ .def("getKeyModifierState", &Player::getKeyModifierState)
+ .def("screenshot", &Player::screenshot)
+ .def("stopOnEscape", &Player::setStopOnEscape)
+ .def("showCursor", &Player::showCursor)
+ .def("setCursor", &Player::setCursor)
+ .def("getElementByID", &Player::getElementByID)
+ .def("getRootNode", &Player::getRootNode)
+ .def("getFramerate", &Player::getFramerate)
+ .def("getVideoRefreshRate", &Player::getVideoRefreshRate)
+ .def("isUsingShaders", &Player::isUsingShaders)
+ .def("setGamma", &Player::setGamma)
+ .def("setMousePos", &Player::setMousePos)
+ .def("loadPlugin", &Player::loadPlugin)
+ .def("setEventHook", &Player::setEventHook)
+ .def("getEventHook", &Player::getEventHook)
+ .add_property("pluginPath", &Player::getPluginPath, &Player::setPluginPath)
+ .add_property("volume", &Player::getVolume, &Player::setVolume)
+ ;
+
+ class_<Canvas, boost::shared_ptr<Canvas>, boost::noncopyable>("Canvas", no_init)
+ .def(self == self)
+ .def(self != self)
+ .def("__hash__", &Canvas::getHash)
+ .def("getRootNode", &Canvas::getRootNode)
+ .def("getElementByID", &Canvas::getElementByID)
+ .def("screenshot", &Canvas::screenshot)
+ ;
+
+ class_<OffscreenCanvas, boost::shared_ptr<OffscreenCanvas>, bases<Canvas>,
+ boost::noncopyable>("OffscreenCanvas", no_init)
+ .def("getID", &OffscreenCanvas::getID)
+ .def("render", &OffscreenCanvas::manualRender)
+ .def("registerCameraNode", &OffscreenCanvas::registerCameraNode)
+ .def("unregisterCameraNode", &OffscreenCanvas::unregisterCameraNode)
+ .add_property("handleevents", &OffscreenCanvas::getHandleEvents)
+ .add_property("multisamplesamples", &OffscreenCanvas::getMultiSampleSamples)
+ .add_property("mipmap", &OffscreenCanvas::getMipmap)
+ .add_property("autorender", &OffscreenCanvas::getAutoRender,
+ &OffscreenCanvas::setAutoRender)
+ .def("getNumDependentCanvases", &OffscreenCanvas::getNumDependentCanvases)
+ .def("isSupported", &OffscreenCanvas::isSupported)
+ .staticmethod("isSupported")
+ .def("isMultisampleSupported", &OffscreenCanvas::isMultisampleSupported)
+ .staticmethod("isMultisampleSupported")
+ ;
+
+ class_<VideoWriter, boost::shared_ptr<VideoWriter>, boost::noncopyable>
+ ("VideoWriter", no_init)
+ .def(init<CanvasPtr, const std::string&, int, int, int, bool>())
+ .def(init<CanvasPtr, const std::string&, int, int, int>())
+ .def(init<CanvasPtr, const std::string&, int>())
+ .def("stop", &VideoWriter::stop)
+ .def("pause", &VideoWriter::pause)
+ .def("play", &VideoWriter::play)
+ .add_property("filename", &VideoWriter::getFileName)
+ .add_property("framerate", &VideoWriter::getFramerate)
+ .add_property("qmin", &VideoWriter::getQMin)
+ .add_property("qmax", &VideoWriter::getQMax)
+ ;
+
+ BitmapPtr (SVG::*renderElement1)(const UTF8String&) = &SVG::renderElement;
+ BitmapPtr (SVG::*renderElement2)(const UTF8String&, const DPoint&) =
+ &SVG::renderElement;
+ BitmapPtr (SVG::*renderElement3)(const UTF8String&, double) =
+ &SVG::renderElement;
+ NodePtr (SVG::*createImageNode1)(const UTF8String&, const dict&) =
+ &SVG::createImageNode;
+ NodePtr (SVG::*createImageNode2)(const UTF8String&, const dict&, const DPoint&) =
+ &SVG::createImageNode;
+ NodePtr (SVG::*createImageNode3)(const UTF8String&, const dict&, double) =
+ &SVG::createImageNode;
+
+ class_<SVG, boost::noncopyable>("SVG", init<const UTF8String&, bool>())
+ .def("renderElement", renderElement1)
+ .def("renderElement", renderElement2)
+ .def("renderElement", renderElement3)
+ .def("createImageNode", createImageNode1)
+ .def("createImageNode", createImageNode2)
+ .def("createImageNode", createImageNode3)
+ .def("getElementSize", &SVG::getElementSize)
+ ;
+
+}
diff --git a/src/wrapper/bitmap_wrap.cpp b/src/wrapper/bitmap_wrap.cpp
new file mode 100644
index 0000000..e9631e6
--- /dev/null
+++ b/src/wrapper/bitmap_wrap.cpp
@@ -0,0 +1,162 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WrapHelper.h"
+
+#include "../player/BoostPython.h"
+
+#include "../graphics/Bitmap.h"
+#include "../graphics/BitmapManager.h"
+
+#include "../base/Point.h"
+
+#include <vector>
+#include <sstream>
+
+using namespace boost::python;
+using namespace std;
+using namespace avg;
+
+template<class POINT>
+class_<POINT> export_point(const string& sName)
+{
+ return class_<POINT>(sName.c_str(), no_init)
+ .def("__len__", &DPointHelper::len)
+ .def("__getitem__", &DPointHelper::getItem)
+ .def("__str__", &DPointHelper::str)
+ .def("__repr__", &DPointHelper::repr)
+ .def("__hash__", &DPointHelper::getHash)
+ .def("getNormalized", &DPoint::safeGetNormalized)
+ .def("getNorm", &DPoint::getNorm)
+ .def("getRotated", &DPoint::getRotated)
+ .def("getRotated", &DPoint::getRotatedPivot)
+ .def("isNaN", &DPoint::isNaN)
+ .def("isInf", &DPoint::isInf)
+ .def(self == self)
+ .def(self != self)
+ .def(-self)
+ .def(self + self)
+ .def(self - self)
+ .def(float() * self)
+ .def(self * float())
+ .def(self / float())
+ .def("getAngle", &DPoint::getAngle)
+ .def("fromPolar", &DPoint::fromPolar)
+ .staticmethod("fromPolar")
+ .def("angle", &vecAngle)
+ .staticmethod("angle")
+ ;
+}
+
+struct Pixel32_to_python_tuple
+{
+ static PyObject* convert (avg::Pixel32 px)
+ {
+ return boost::python::incref(boost::python::make_tuple(
+ px.getR(), px.getG(), px.getB(), px.getA()).ptr());
+ }
+};
+
+ConstDPoint Bitmap_getSize(Bitmap* This)
+{
+ return (DPoint)(This->getSize());
+}
+
+DPoint* createPoint()
+{
+ return new DPoint(0,0);
+}
+
+void export_bitmap()
+{
+ export_point<DPoint>("Point2D")
+ .def("__init__", make_constructor(createPoint))
+ .def(init<double, double>())
+ .def(init<const DPoint&>())
+ .def("__setitem__", &DPointHelper::setItem)
+ .add_property("x", &DPointHelper::getX, &DPointHelper::setX,"")
+ .add_property("y", &DPointHelper::getY, &DPointHelper::setY,"")
+ ;
+ export_point<ConstDPoint>("ConstPoint2D")
+ .add_property("x", &DPointHelper::getX, "")
+ .add_property("y", &DPointHelper::getY, "")
+ ;
+
+ implicitly_convertible<ConstDPoint, DPoint>();
+ implicitly_convertible<DPoint, ConstDPoint>();
+
+ enum_<PixelFormat>("pixelformat")
+ .value("B5G6R5", B5G6R5)
+ .value("B8G8R8", B8G8R8)
+ .value("B8G8R8A8", B8G8R8A8)
+ .value("B8G8R8X8", B8G8R8X8)
+ .value("A8B8G8R8", A8B8G8R8)
+ .value("X8B8G8R8", X8B8G8R8)
+ .value("R5G6B5", R5G6B5)
+ .value("R8G8B8", R8G8B8)
+ .value("R8G8B8A8", R8G8B8A8)
+ .value("R8G8B8X8", R8G8B8X8)
+ .value("A8R8G8B8", A8R8G8B8)
+ .value("X8R8G8B8", X8R8G8B8)
+ .value("I8", I8)
+ .value("I16", I16)
+ .value("A8", A8)
+ .value("YCbCr411", YCbCr411)
+ .value("YCbCr422", YCbCr422)
+ .value("YUYV422", YUYV422)
+ .value("YCbCr420p", YCbCr420p)
+ .value("YCbCrA420p", YCbCrA420p)
+ .value("BAYER8", BAYER8)
+ .value("BAYER8_RGGB", BAYER8_RGGB)
+ .value("BAYER8_GBRG", BAYER8_GBRG)
+ .value("BAYER8_GRBG", BAYER8_GRBG)
+ .value("BAYER8_BGGR", BAYER8_BGGR)
+ .value("R32G32B32A32F", R32G32B32A32F)
+ .value("I32F", I32F)
+ .export_values();
+
+ to_python_converter<Pixel32, Pixel32_to_python_tuple>();
+
+ class_<Bitmap, boost::shared_ptr<Bitmap> >("Bitmap", no_init)
+ .def(init<DPoint, PixelFormat, UTF8String>())
+ .def(init<Bitmap>())
+ .def(init<UTF8String>())
+ .def("save", &Bitmap::save)
+ .def("getSize", &Bitmap_getSize)
+ .def("getFormat", &Bitmap::getPixelFormat)
+ .def("getPixels", &Bitmap::getPixelsAsString)
+ .def("setPixels", &Bitmap::setPixelsFromString)
+ .def("getPixel", &Bitmap::getPythonPixel)
+ .def("subtract", &Bitmap::subtract)
+ .def("getAvg", &Bitmap::getAvg)
+ .def("getChannelAvg", &Bitmap::getChannelAvg)
+ .def("getStdDev", &Bitmap::getStdDev)
+ .def("getName", &Bitmap::getName,
+ return_value_policy<copy_const_reference>())
+ ;
+
+ class_<BitmapManager>("BitmapManager", no_init)
+ .def("get", &BitmapManager::get,
+ return_value_policy<reference_existing_object>())
+ .staticmethod("get")
+ .def("loadBitmap", &BitmapManager::loadBitmap)
+ ;
+}
diff --git a/src/wrapper/device_wrap.cpp b/src/wrapper/device_wrap.cpp
new file mode 100644
index 0000000..02d964b
--- /dev/null
+++ b/src/wrapper/device_wrap.cpp
@@ -0,0 +1,93 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WrapHelper.h"
+
+#include "../avgconfigwrapper.h"
+#include "../parport/ParPort.h"
+#include "../conradrelais/ConradRelais.h"
+#ifdef AVG_ENABLE_PARPORT
+#include <linux/parport.h>
+#endif
+
+using namespace boost::python;
+using namespace avg;
+
+enum ControlLines {
+ CONTROL_STROBE = PARPORT_CONTROL_STROBE,
+ CONTROL_AUTOFD = PARPORT_CONTROL_AUTOFD,
+ CONTROL_INIT = PARPORT_CONTROL_INIT,
+ CONTROL_SELECT = PARPORT_CONTROL_SELECT
+};
+
+enum StatusLines {
+ STATUS_ERROR = PARPORT_STATUS_ERROR,
+ STATUS_SELECT = PARPORT_STATUS_SELECT,
+ STATUS_PAPEROUT = PARPORT_STATUS_PAPEROUT,
+ STATUS_ACK = PARPORT_STATUS_ACK,
+ STATUS_BUSY = PARPORT_STATUS_BUSY
+};
+
+void export_devices()
+{
+ enum_<ControlLines>("controllines")
+ .value("CONTROL_STROBE", CONTROL_STROBE)
+ .value("CONTROL_AUTOFD", CONTROL_AUTOFD)
+ .value("CONTROL_INIT", CONTROL_INIT)
+ .value("CONTROL_SELECT", CONTROL_SELECT)
+ .export_values();
+
+ enum_<StatusLines>("statuslines")
+ .value("STATUS_ERROR", STATUS_ERROR)
+ .value("STATUS_SELECT", STATUS_SELECT)
+ .value("STATUS_PAPEROUT", STATUS_PAPEROUT)
+ .value("STATUS_ACK", STATUS_ACK)
+ .value("STATUS_BUSY", STATUS_BUSY)
+ .export_values();
+
+ enum_<ParPortData>("DataBits")
+ .value("PARPORTDATA0", BIT0)
+ .value("PARPORTDATA1", BIT1)
+ .value("PARPORTDATA2", BIT2)
+ .value("PARPORTDATA3", BIT3)
+ .value("PARPORTDATA4", BIT4)
+ .value("PARPORTDATA5", BIT5)
+ .value("PARPORTDATA6", BIT6)
+ .value("PARPORTDATA7", BIT7)
+ .export_values();
+
+ class_<ParPort>("ParPort")
+ .def("init", &ParPort::init)
+ .def("setControlLine", &ParPort::setControlLine)
+ .def("getStatusLine", &ParPort::getStatusLine)
+ .def("setDataLines", &ParPort::setDataLines)
+ .def("clearDataLines", &ParPort::clearDataLines)
+ .def("setAllDataLines", &ParPort::setDataLines)
+ .def("isAvailable", &ParPort::isAvailable)
+ ;
+
+ class_<ConradRelais>("ConradRelais", init<Player*, int>())
+ .def("getNumCards", &ConradRelais::getNumCards)
+ .def("set", &ConradRelais::set)
+ .def("get", &ConradRelais::get)
+ ;
+}
+
diff --git a/src/wrapper/event_wrap.cpp b/src/wrapper/event_wrap.cpp
new file mode 100644
index 0000000..8fea62c
--- /dev/null
+++ b/src/wrapper/event_wrap.cpp
@@ -0,0 +1,250 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WrapHelper.h"
+
+#include "../player/KeyEvent.h"
+#include "../player/MouseEvent.h"
+#include "../player/TouchEvent.h"
+#include "../player/Contact.h"
+#include "../player/TrackerInputDevice.h"
+
+#include <boost/shared_ptr.hpp>
+#include <string>
+
+using namespace boost::python;
+using namespace avg;
+using namespace std;
+
+
+class IInputDeviceWrapper : public IInputDevice, public wrapper<IInputDevice>
+{
+ public:
+ IInputDeviceWrapper(const std::string& name,
+ const DivNodePtr& pEventReceiverNode=DivNodePtr())
+ : IInputDevice(name, pEventReceiverNode)
+ {
+ }
+
+ IInputDeviceWrapper(const IInputDevice& inputDevice)
+ : IInputDevice(inputDevice)
+ {
+ }
+
+ virtual void start()
+ {
+ override startMethod = this->get_override("start");
+ if (startMethod) {
+ startMethod();
+ }
+ IInputDevice::start();
+ }
+
+ void default_start()
+ {
+ return this->IInputDevice::start();
+ }
+
+ virtual std::vector<EventPtr> pollEvents()
+ {
+ return this->get_override("pollEvents")();
+ }
+
+};
+
+void export_event()
+{
+ boost::python::to_python_converter<vector<TouchEventPtr>,
+ to_tuple<vector<TouchEventPtr> > >();
+ boost::python::to_python_converter<vector<CursorEventPtr>,
+ to_tuple<vector<CursorEventPtr> > >();
+
+ boost::python::to_python_converter<ContourSeq, to_list<ContourSeq> >();
+
+ from_python_sequence<ContourSeq, variable_capacity_policy>();
+ from_python_sequence<vector<EventPtr>, variable_capacity_policy>();
+
+ enum_<Event::Type>("Type")
+ .value("KEYUP", Event::KEYUP)
+ .value("KEYDOWN", Event::KEYDOWN)
+ .value("CURSORMOTION", Event::CURSORMOTION)
+ .value("CURSORUP", Event::CURSORUP)
+ .value("CURSORDOWN", Event::CURSORDOWN)
+ .value("CURSOROVER", Event::CURSOROVER)
+ .value("CURSOROUT", Event::CURSOROUT)
+ .value("CUSTOMEVENT", Event::CUSTOMEVENT)
+ .value("RESIZE", Event::RESIZE)
+ .value("QUIT", Event::QUIT)
+ .export_values()
+ ;
+
+ enum_<CursorEvent::Source>("Source")
+ .value("MOUSE", CursorEvent::MOUSE)
+ .value("TOUCH", CursorEvent::TOUCH)
+ .value("TRACK", CursorEvent::TRACK)
+ .value("CUSTOM", Event::CUSTOM)
+ .value("NONE", Event::NONE)
+ .export_values()
+ ;
+
+ enum_<int>("KeyModifier")
+ .value("KEYMOD_NONE", key::KEYMOD_NONE)
+ .value("KEYMOD_LSHIFT", key::KEYMOD_LSHIFT)
+ .value("KEYMOD_RSHIFT", key::KEYMOD_RSHIFT)
+ .value("KEYMOD_LCTRL", key::KEYMOD_LCTRL)
+ .value("KEYMOD_RCTRL", key::KEYMOD_RCTRL)
+ .value("KEYMOD_LALT", key::KEYMOD_LALT)
+ .value("KEYMOD_RALT", key::KEYMOD_RALT)
+ .value("KEYMOD_LMETA", key::KEYMOD_LMETA)
+ .value("KEYMOD_RMETA", key::KEYMOD_RMETA)
+ .value("KEYMOD_NUM", key::KEYMOD_NUM)
+ .value("KEYMOD_CAPS", key::KEYMOD_CAPS)
+ .value("KEYMOD_MODE", key::KEYMOD_MODE)
+ .value("KEYMOD_RESERVED", key::KEYMOD_RESERVED)
+ .value("KEYMOD_CTRL", key::KEYMOD_CTRL)
+ .value("KEYMOD_SHIFT", key::KEYMOD_SHIFT)
+ .value("KEYMOD_ALT", key::KEYMOD_ALT)
+ .value("KEYMOD_META", key::KEYMOD_META)
+ .export_values()
+ ;
+
+ class_<Event, boost::noncopyable>("Event", init<Event::Type, Event::Source,
+ optional<int> >())
+ .add_property("type", &Event::getType)
+ .add_property("source", &Event::getSource)
+ .add_property("when", &Event::getWhen)
+ .add_property("inputdevice", &Event::getInputDevice)
+ .add_property("inputdevicename",
+ make_function(&Event::getInputDeviceName,
+ return_value_policy<copy_const_reference>()))
+ ;
+
+ class_<CursorEvent, boost::shared_ptr<CursorEvent>, bases<Event> >("CursorEvent",
+ no_init)
+ .add_property("source", &CursorEvent::getSource)
+ .add_property("pos", &CursorEvent::getPos)
+ .add_property("x", &CursorEvent::getXPosition)
+ .add_property("y", &CursorEvent::getYPosition)
+ .add_property("cursorid", &CursorEvent::getCursorID, &CursorEvent::setCursorID)
+ .add_property("node", &CursorEvent::getNode)
+ .add_property("speed", make_function(&CursorEvent::getSpeed,
+ return_value_policy<copy_const_reference>()))
+ .add_property("contact", &CursorEvent::getContact)
+ ;
+
+ class_<KeyEvent, bases<Event> >("KeyEvent", no_init)
+ .add_property("scancode", &KeyEvent::getScanCode)
+ .add_property("keycode", &KeyEvent::getKeyCode)
+ .add_property("keystring", make_function(&KeyEvent::getKeyString,
+ return_value_policy<copy_const_reference>()))
+ .add_property("unicode", &KeyEvent::getUnicode)
+ .add_property("modifiers", &KeyEvent::getModifiers)
+ ;
+
+ class_<MouseEvent, bases<CursorEvent> >("MouseEvent",
+ init<Event::Type, bool, bool, bool, const IntPoint&, int,
+ optional<const DPoint&, int> >())
+ .add_property("leftbuttonstate", &MouseEvent::getLeftButtonState)
+ .add_property("middlebuttonstate", &MouseEvent::getMiddleButtonState)
+ .add_property("rightbuttonstate", &MouseEvent::getRightButtonState)
+ .add_property("button", &MouseEvent::getButton)
+ ;
+
+ class_<TouchEvent, bases<CursorEvent> >("TouchEvent", init<int, Event::Type,
+ const IntPoint&, Event::Source, optional<const DPoint&> >())
+ .add_property("area", &TouchEvent::getArea)
+ .add_property("orientation", &TouchEvent::getOrientation)
+ .add_property("eccentricity", &TouchEvent::getEccentricity)
+ .add_property("center", make_function(&TouchEvent::getCenter,
+ return_value_policy<copy_const_reference>()))
+ .add_property("majoraxis", make_function(&TouchEvent::getMajorAxis,
+ return_value_policy<copy_const_reference>()))
+ .add_property("minoraxis", make_function(&TouchEvent::getMinorAxis,
+ return_value_policy<copy_const_reference>()))
+ .add_property("handorientation", &TouchEvent::getHandOrientation)
+ .def("getRelatedEvents", &TouchEvent::getRelatedEvents)
+ .def("getContour", &TouchEvent::getContour)
+ ;
+
+ class_<Contact, boost::shared_ptr<Contact> >("Contact", no_init)
+ .add_property("id", &Contact::getID)
+ .add_property("age", &Contact::getAge)
+ .add_property("distancefromstart", &Contact::getDistanceFromStart)
+ .add_property("motionangle", &Contact::getMotionAngle)
+ .add_property("motionvec", &Contact::getMotionVec)
+ .add_property("distancetravelled", &Contact::getDistanceTravelled)
+ .add_property("events", &Contact::getEvents)
+ .def("connectListener", &Contact::connectListener)
+ .def("disconnectListener", &Contact::disconnectListener)
+ .def("__hash__", &Contact::getHash)
+ .def(self == self)
+ .def(self != self)
+ ;
+
+ enum_<TrackerImageID>("TrackerImageID")
+ .value("IMG_CAMERA", TRACKER_IMG_CAMERA)
+ .value("IMG_DISTORTED", TRACKER_IMG_DISTORTED)
+ .value("IMG_NOHISTORY", TRACKER_IMG_NOHISTORY)
+ .value("IMG_HISTOGRAM", TRACKER_IMG_HISTOGRAM)
+ .value("IMG_FINGERS", TRACKER_IMG_FINGERS)
+ .value("IMG_HIGHPASS", TRACKER_IMG_HIGHPASS)
+ .export_values()
+ ;
+
+ class_<IInputDevicePtr>("IInputDevice")
+ ;
+
+ class_< IInputDeviceWrapper,
+ boost::shared_ptr<IInputDeviceWrapper>,
+ boost::noncopyable
+ >("InputDevice", init<const std::string&, optional<const DivNodePtr&> >())
+ .def("start", &IInputDevice::start, &IInputDeviceWrapper::default_start)
+ .def("pollEvents", pure_virtual(&IInputDevice::pollEvents))
+ .add_property("name",
+ make_function(&IInputDevice::getName,
+ return_value_policy<copy_const_reference>()))
+ .add_property("eventreceivernode",
+ make_function(&IInputDevice::getEventReceiverNode,
+ return_value_policy<copy_const_reference>()))
+ ;
+
+ class_<TrackerInputDevice, boost::noncopyable>("Tracker", no_init)
+ .def("getImage", &TrackerInputDevice::getImage,
+ return_value_policy<manage_new_object>())
+ .def("getDisplayROIPos", &TrackerInputDevice::getDisplayROIPos)
+ .def("getDisplayROISize", &TrackerInputDevice::getDisplayROISize)
+ .def("saveConfig", &TrackerInputDevice::saveConfig)
+ .def("resetHistory", &TrackerInputDevice::resetHistory)
+ .def("setDebugImages", &TrackerInputDevice::setDebugImages)
+ .def("startCalibration", &TrackerInputDevice::startCalibration,
+ return_value_policy<reference_existing_object>())
+ .def("endCalibration", &TrackerInputDevice::endCalibration)
+ .def("abortCalibration", &TrackerInputDevice::abortCalibration)
+ .def("setParam", &TrackerInputDevice::setParam)
+ .def("getParam", &TrackerInputDevice::getParam)
+ ;
+
+ class_<TrackerCalibrator, boost::noncopyable>("TrackerCalibrator", no_init)
+ .def("nextPoint", &TrackerCalibrator::nextPoint)
+ .def("getDisplayPoint", &TrackerCalibrator::getDisplayPoint)
+ .def("setCamPoint", &TrackerCalibrator::setCamPoint)
+ ;
+}
diff --git a/src/wrapper/fx_wrap.cpp b/src/wrapper/fx_wrap.cpp
new file mode 100644
index 0000000..4e2e77b
--- /dev/null
+++ b/src/wrapper/fx_wrap.cpp
@@ -0,0 +1,101 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WrapHelper.h"
+#include "raw_constructor.hpp"
+
+#include "../player/BlurFXNode.h"
+#include "../player/ChromaKeyFXNode.h"
+#include "../player/FXNode.h"
+#include "../player/HueSatFXNode.h"
+#include "../player/InvertFXNode.h"
+#include "../player/NullFXNode.h"
+#include "../player/ShadowFXNode.h"
+
+#include <boost/shared_ptr.hpp>
+
+using namespace boost::python;
+using namespace avg;
+
+void export_fx()
+{
+
+ class_<FXNode, boost::shared_ptr<FXNode>, boost::noncopyable>("FXNode", no_init)
+ ;
+
+ class_<BlurFXNode, bases<FXNode>, boost::shared_ptr<BlurFXNode>,
+ boost::noncopyable>("BlurFXNode")
+ .def("setParam", &BlurFXNode::setParam)
+ .add_property("radius", &BlurFXNode::getRadius,
+ &BlurFXNode::setRadius)
+ ;
+
+ class_<ChromaKeyFXNode, bases<FXNode>, boost::shared_ptr<ChromaKeyFXNode>,
+ boost::noncopyable>("ChromaKeyFXNode")
+ .add_property("color",
+ make_function(&ChromaKeyFXNode::getColor,
+ return_value_policy<copy_const_reference>()),
+ &ChromaKeyFXNode::setColor)
+ .add_property("htolerance", &ChromaKeyFXNode::getHTolerance,
+ &ChromaKeyFXNode::setHTolerance)
+ .add_property("stolerance", &ChromaKeyFXNode::getSTolerance,
+ &ChromaKeyFXNode::setSTolerance)
+ .add_property("ltolerance", &ChromaKeyFXNode::getLTolerance,
+ &ChromaKeyFXNode::setLTolerance)
+ .add_property("softness", &ChromaKeyFXNode::getSoftness,
+ &ChromaKeyFXNode::setSoftness)
+ .add_property("erosion", &ChromaKeyFXNode::getErosion,
+ &ChromaKeyFXNode::setErosion)
+ .add_property("spillthreshold", &ChromaKeyFXNode::getSpillThreshold,
+ &ChromaKeyFXNode::setSpillThreshold)
+ ;
+
+ class_<HueSatFXNode, bases<FXNode>, boost::shared_ptr<HueSatFXNode>,
+ boost::noncopyable > ("HueSatFXNode", init< optional<float, float, float,
+ bool> >())
+ .add_property("hue", &HueSatFXNode::getHue,
+ &HueSatFXNode::setHue)
+ .add_property("saturation", &HueSatFXNode::getSaturation,
+ &HueSatFXNode::setSaturation)
+ .add_property("lightness", &HueSatFXNode::getLightnessOffset,
+ &HueSatFXNode::setLightnessOffset)
+ .add_property("colorize", &HueSatFXNode::isColorizing,
+ &HueSatFXNode::setColorizing)
+ .def("__repr__", &HueSatFXNode::toString)
+ ;
+
+ class_<InvertFXNode, bases<FXNode>, boost::shared_ptr<InvertFXNode>, boost::noncopyable>(
+ "InvertFXNode")
+ ;
+
+ class_<NullFXNode, bases<FXNode>, boost::shared_ptr<NullFXNode>, boost::noncopyable>(
+ "NullFXNode")
+ ;
+
+ class_<ShadowFXNode, bases<FXNode>, boost::shared_ptr<ShadowFXNode>,
+ boost::noncopyable>("ShadowFXNode")
+ .def("setParams", &ShadowFXNode::setParams)
+ .add_property("offset", &ShadowFXNode::getOffset, &ShadowFXNode::setOffset)
+ .add_property("radius", &ShadowFXNode::getRadius, &ShadowFXNode::setRadius)
+ .add_property("opacity", &ShadowFXNode::getOpacity, &ShadowFXNode::setOpacity)
+ .add_property("color", &ShadowFXNode::getColor, &ShadowFXNode::setColor)
+ ;
+}
diff --git a/src/wrapper/node_wrap.cpp b/src/wrapper/node_wrap.cpp
new file mode 100644
index 0000000..171e8fc
--- /dev/null
+++ b/src/wrapper/node_wrap.cpp
@@ -0,0 +1,340 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+void export_bitmap();
+void export_fx();
+void export_raster();
+void export_event();
+#ifndef WIN32
+void export_devices();
+#endif
+
+#include "WrapHelper.h"
+#include "raw_constructor.hpp"
+
+#include "../base/Logger.h"
+#include "../base/Exception.h"
+#include "../player/Player.h"
+#include "../player/AVGNode.h"
+#include "../player/CanvasNode.h"
+#include "../player/DivNode.h"
+#include "../player/PanoImageNode.h"
+#include "../player/SoundNode.h"
+#include "../player/LineNode.h"
+#include "../player/RectNode.h"
+#include "../player/CurveNode.h"
+#include "../player/PolyLineNode.h"
+#include "../player/PolygonNode.h"
+#include "../player/CircleNode.h"
+#include "../player/MeshNode.h"
+
+#include <boost/version.hpp>
+#include <boost/shared_ptr.hpp>
+
+using namespace boost::python;
+using namespace avg;
+
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(unlink_overloads, Node::unlink, 0, 1);
+BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(disconnectEventHandler_overloads,
+ Node::disconnectEventHandler, 1, 2);
+
+// These function templates essentially call functions such as AreaNode::getPos()
+// and return a version of the result that don't allow setting of the individual
+// elements of the DPoint returned.
+// Without this stuff, python code like node.pos.x=30 would fail silently. With it,
+// it at least throws an exception.
+template<class CLASS, const DPoint& (CLASS::*FUNC)() const>
+ConstDPoint constPointGetterRef(const CLASS& node)
+{
+ return (node.*FUNC)();
+}
+
+template<class CLASS, DPoint (CLASS::*FUNC)() const>
+ConstDPoint constPointGetter(const CLASS& node)
+{
+ return (node.*FUNC)();
+}
+
+ConstDPoint AreaNode_getMediaSize(AreaNode* This)
+{
+ return (DPoint)(This->getMediaSize());
+}
+
+char divNodeName[] = "div";
+char avgNodeName[] = "avg";
+char soundNodeName[] = "sound";
+char panoImageNodeName[] = "panoimage";
+char lineNodeName[] = "line";
+char rectNodeName[] = "rect";
+char curveNodeName[] = "curve";
+char polylineNodeName[] = "polyline";
+char polygonNodeName[] = "polygon";
+char circleNodeName[] = "circle";
+char meshNodeName[] = "mesh";
+
+void export_node()
+{
+
+ class_<Node, boost::shared_ptr<Node>, boost::noncopyable>("Node", no_init)
+ .def(self == self)
+ .def(self != self)
+ .def("__hash__", &Node::getHash)
+ .add_property("id", make_function(&Node::getID,
+ return_value_policy<copy_const_reference>()), &Node::setID)
+ .def("getParent", &Node::getParent)
+ .def("unlink", &Node::unlink, unlink_overloads(args("bKill")))
+ .def("setEventCapture", &Node::setMouseEventCapture)
+ .def("setEventCapture", &Node::setEventCapture)
+ .def("releaseEventCapture", &Node::releaseMouseEventCapture)
+ .def("releaseEventCapture", &Node::releaseEventCapture)
+ .def("setEventHandler", &Node::setEventHandler)
+ .def("connectEventHandler", &Node::connectEventHandler)
+ .def("disconnectEventHandler", &Node::disconnectEventHandler,
+ disconnectEventHandler_overloads(args("pFunc")))
+ .def("getAbsPos", &Node::getAbsPos)
+ .def("getRelPos", &Node::getRelPos)
+ .def("getElementByPos", &Node::getElementByPos)
+ .add_property("active", &Node::getActive, &Node::setActive)
+ .add_property("sensitive", &Node::getSensitive, &Node::setSensitive)
+ .add_property("opacity", &Node::getOpacity, &Node::setOpacity)
+ ;
+
+ class_<AreaNode, boost::shared_ptr<AreaNode>, bases<Node>, boost::noncopyable>(
+ "AreaNode",
+ no_init)
+ .def("getMediaSize", &AreaNode_getMediaSize)
+ .add_property("x", &AreaNode::getX, &AreaNode::setX)
+ .add_property("y", &AreaNode::getY, &AreaNode::setY)
+ .add_property("pos", &constPointGetterRef<AreaNode, &AreaNode::getPos>,
+ &AreaNode::setPos)
+ .add_property("width", &AreaNode::getWidth, &AreaNode::setWidth)
+ .add_property("height", &AreaNode::getHeight, &AreaNode::setHeight)
+ .add_property("angle", &AreaNode::getAngle, &AreaNode::setAngle)
+ .add_property("size", &constPointGetter<AreaNode, &AreaNode::getSize>,
+ &AreaNode::setSize)
+ .add_property("pivot", &constPointGetter<AreaNode, &AreaNode::getPivot>,
+ &AreaNode::setPivot)
+ .add_property("pivotx", &deprecatedGet<AreaNode>, &deprecatedSet<AreaNode>)
+ .add_property("pivoty", &deprecatedGet<AreaNode>, &deprecatedSet<AreaNode>)
+ ;
+ export_bitmap();
+ export_fx();
+ export_raster();
+
+ class_<DivNode, bases<AreaNode>, boost::noncopyable>("DivNode", no_init)
+ .def("__init__", raw_constructor(createNode<divNodeName>))
+ .add_property("crop", &DivNode::getCrop, &DivNode::setCrop)
+ .add_property("elementoutlinecolor",
+ make_function(&DivNode::getElementOutlineColor,
+ return_value_policy<copy_const_reference>()),
+ make_function(&DivNode::setElementOutlineColor,
+ return_value_policy<copy_const_reference>()))
+ .def("getNumChildren", &DivNode::getNumChildren)
+ .def("getChild", make_function(&DivNode::getChild,
+ return_value_policy<copy_const_reference>()))
+ .def("appendChild", &DivNode::appendChild)
+ .def("insertChildBefore", &DivNode::insertChildBefore)
+ .def("insertChildAfter", &DivNode::insertChildAfter)
+ .def("insertChild", &DivNode::insertChild)
+ .def("removeChild", (void (DivNode::*)(NodePtr))(&DivNode::removeChild))
+ .def("removeChild", (void (DivNode::*)(unsigned))(&DivNode::removeChild))
+ .def("reorderChild", (void (DivNode::*)(unsigned, unsigned))
+ (&DivNode::reorderChild))
+ .def("reorderChild", (void (DivNode::*)(NodePtr, unsigned))
+ (&DivNode::reorderChild))
+ .def("indexOf", &DivNode::indexOf)
+ .def("getEffectiveMediaDir", &DivNode::getEffectiveMediaDir)
+ .add_property("mediadir", make_function(&DivNode::getMediaDir,
+ return_value_policy<copy_const_reference>()), &DivNode::setMediaDir)
+ ;
+
+ class_<CanvasNode, bases<DivNode> >("CanvasNode",
+ no_init)
+ ;
+
+ class_<AVGNode, bases<CanvasNode> >("AVGNode", no_init)
+ ;
+
+ class_<SoundNode, bases<AreaNode> >("SoundNode", no_init)
+ .def("__init__", raw_constructor(createNode<soundNodeName>))
+ .def("play", &SoundNode::play)
+ .def("stop", &SoundNode::stop)
+ .def("pause", &SoundNode::pause)
+ .def("setEOFCallback", &SoundNode::setEOFCallback)
+ .def("getAudioCodec", &SoundNode::getAudioCodec)
+ .def("getAudioSampleRate", &SoundNode::getAudioSampleRate)
+ .def("getNumAudioChannels", &SoundNode::getNumAudioChannels)
+ .def("seekToTime", &SoundNode::seekToTime)
+ .def("getCurTime", &SoundNode::getCurTime)
+ .add_property("href", make_function(&SoundNode::getHRef,
+ return_value_policy<copy_const_reference>()), &SoundNode::setHRef)
+ .add_property("loop", &SoundNode::getLoop)
+ .add_property("duration", &SoundNode::getDuration)
+ .add_property("volume", &SoundNode::getVolume, &SoundNode::setVolume)
+ ;
+
+ class_<PanoImageNode, bases<AreaNode> >("PanoImageNode", no_init)
+ .def("__init__", raw_constructor(createNode<panoImageNodeName>))
+ .def("getScreenPosFromPanoPos", &PanoImageNode::getScreenPosFromPanoPos)
+ .def("getScreenPosFromAngle", &PanoImageNode::getScreenPosFromAngle)
+ .add_property("href", make_function(&PanoImageNode::getHRef,
+ return_value_policy<copy_const_reference>()), &PanoImageNode::setHRef)
+ .add_property("sensorwidth", &PanoImageNode::getSensorWidth,
+ &PanoImageNode::setSensorWidth)
+ .add_property("sensorheight", &PanoImageNode::getSensorHeight,
+ &PanoImageNode::setSensorHeight)
+ .add_property("focallength", &PanoImageNode::getFocalLength,
+ &PanoImageNode::setFocalLength)
+ .add_property("rotation", &PanoImageNode::getRotation,
+ &PanoImageNode::setRotation)
+ .add_property("maxrotation", &PanoImageNode::getMaxRotation)
+ ;
+
+ class_<VectorNode, bases<Node>, boost::noncopyable>("VectorNode",
+ no_init)
+ .add_property("strokewidth", &VectorNode::getStrokeWidth,
+ &VectorNode::setStrokeWidth)
+ .add_property("color", make_function(&VectorNode::getColor,
+ return_value_policy<copy_const_reference>()), &VectorNode::setColor)
+ .add_property("texhref", make_function(&VectorNode::getTexHRef,
+ return_value_policy<copy_const_reference>()), &VectorNode::setTexHRef)
+ .add_property("blendmode",
+ make_function(&VectorNode::getBlendModeStr,
+ return_value_policy<copy_const_reference>()),
+ &VectorNode::setBlendModeStr)
+ .def("setBitmap", &VectorNode::setBitmap)
+ ;
+
+ class_<FilledVectorNode, bases<VectorNode>, boost::noncopyable>("FilledVectorNode",
+ no_init)
+ .add_property("filltexhref", make_function(&FilledVectorNode::getFillTexHRef,
+ return_value_policy<copy_const_reference>()),
+ &FilledVectorNode::setFillTexHRef)
+ .add_property("fillcolor", make_function(&FilledVectorNode::getFillColor,
+ return_value_policy<copy_const_reference>()),
+ &FilledVectorNode::setFillColor)
+ .add_property("fillopacity", &FilledVectorNode::getFillOpacity,
+ &FilledVectorNode::setFillOpacity)
+ .add_property("filltexcoord1", make_function(&FilledVectorNode::getFillTexCoord1,
+ return_value_policy<copy_const_reference>()),
+ &FilledVectorNode::setFillTexCoord1)
+ .add_property("filltexcoord2", make_function(&FilledVectorNode::getFillTexCoord2,
+ return_value_policy<copy_const_reference>()),
+ &FilledVectorNode::setFillTexCoord2)
+ .def("setFillBitmap", &FilledVectorNode::setFillBitmap)
+ ;
+
+ class_<LineNode, bases<VectorNode>, boost::noncopyable>("LineNode",
+ no_init)
+ .def("__init__", raw_constructor(createNode<lineNodeName>))
+ .add_property("pos1", &constPointGetterRef<LineNode, &LineNode::getPos1>,
+ &LineNode::setPos1)
+ .add_property("pos2", &constPointGetterRef<LineNode, &LineNode::getPos2>,
+ &LineNode::setPos2)
+ .add_property("x1", &deprecatedGet<LineNode>, &deprecatedSet<LineNode>)
+ .add_property("y1", &deprecatedGet<LineNode>, &deprecatedSet<LineNode>)
+ .add_property("x2", &deprecatedGet<LineNode>, &deprecatedSet<LineNode>)
+ .add_property("y2", &deprecatedGet<LineNode>, &deprecatedSet<LineNode>)
+ .add_property("texcoord1", &LineNode::getTexCoord1, &LineNode::setTexCoord1)
+ .add_property("texcoord2", &LineNode::getTexCoord2, &LineNode::setTexCoord2)
+ ;
+
+ class_<RectNode, bases<FilledVectorNode>, boost::noncopyable>("RectNode",
+ no_init)
+ .def("__init__", raw_constructor(createNode<rectNodeName>))
+ .add_property("pos", &constPointGetterRef<RectNode, &RectNode::getPos>,
+ &RectNode::setPos)
+ .add_property("size", &constPointGetter<RectNode, &RectNode::getSize>,
+ &RectNode::setSize)
+ .add_property("x", &deprecatedGet<RectNode>, &deprecatedSet<RectNode>)
+ .add_property("y", &deprecatedGet<RectNode>, &deprecatedSet<RectNode>)
+ .add_property("width", &deprecatedGet<RectNode>, &deprecatedSet<RectNode>)
+ .add_property("height", &deprecatedGet<RectNode>, &deprecatedSet<RectNode>)
+ .add_property("texcoords", make_function(&RectNode::getTexCoords,
+ return_value_policy<copy_const_reference>()), &RectNode::setTexCoords)
+ .add_property("angle", &RectNode::getAngle, &RectNode::setAngle)
+ ;
+
+ class_<CurveNode, bases<VectorNode>, boost::noncopyable>("CurveNode",
+ no_init)
+ .def("__init__", raw_constructor(createNode<curveNodeName>))
+ .add_property("pos1", &constPointGetterRef<CurveNode, &CurveNode::getPos1>,
+ &CurveNode::setPos1)
+ .add_property("pos2", &constPointGetterRef<CurveNode, &CurveNode::getPos2>,
+ &CurveNode::setPos2)
+ .add_property("pos3", &constPointGetterRef<CurveNode, &CurveNode::getPos3>,
+ &CurveNode::setPos3)
+ .add_property("pos4", &constPointGetterRef<CurveNode, &CurveNode::getPos4>,
+ &CurveNode::setPos4)
+ .add_property("x1", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("y1", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("x2", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("y2", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("x3", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("y3", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("x4", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("y4", &deprecatedGet<CurveNode>, &deprecatedSet<CurveNode>)
+ .add_property("texcoord1", &CurveNode::getTexCoord1, &CurveNode::setTexCoord1)
+ .add_property("texcoord2", &CurveNode::getTexCoord2, &CurveNode::setTexCoord2)
+ ;
+
+ class_<PolyLineNode, bases<VectorNode>, boost::noncopyable>("PolyLineNode", no_init)
+ .def("__init__", raw_constructor(createNode<polylineNodeName>))
+ .add_property("pos", make_function(&PolyLineNode::getPos,
+ return_value_policy<copy_const_reference>()), &PolyLineNode::setPos)
+ .add_property("texcoords", make_function(&PolyLineNode::getTexCoords,
+ return_value_policy<copy_const_reference>()), &PolyLineNode::setTexCoords)
+ .add_property("linejoin", &PolyLineNode::getLineJoin, &PolyLineNode::setLineJoin)
+ ;
+
+ class_<PolygonNode, bases<FilledVectorNode>, boost::noncopyable>("PolygonNode",
+ no_init)
+ .def("__init__", raw_constructor(createNode<polygonNodeName>))
+ .add_property("pos", make_function(&PolygonNode::getPos,
+ return_value_policy<copy_const_reference>()), &PolygonNode::setPos)
+ .add_property("texcoords", make_function(&PolygonNode::getTexCoords,
+ return_value_policy<copy_const_reference>()), &PolygonNode::setTexCoords)
+ .add_property("linejoin", &PolygonNode::getLineJoin, &PolygonNode::setLineJoin)
+ ;
+
+ class_<CircleNode, bases<FilledVectorNode>, boost::noncopyable>("CircleNode",
+ no_init)
+ .def("__init__", raw_constructor(createNode<circleNodeName>))
+ .add_property("pos", &constPointGetterRef<CircleNode, &CircleNode::getPos>,
+ &CircleNode::setPos)
+ .add_property("x", &deprecatedGet<CircleNode>, &deprecatedSet<CircleNode>)
+ .add_property("y", &deprecatedGet<CircleNode>, &deprecatedSet<CircleNode>)
+ .add_property("r", &CircleNode::getR, &CircleNode::setR)
+ .add_property("texcoord1", &CircleNode::getTexCoord1, &CircleNode::setTexCoord1)
+ .add_property("texcoord2", &CircleNode::getTexCoord2, &CircleNode::setTexCoord2)
+ ;
+
+ class_<MeshNode, bases<VectorNode>, boost::noncopyable>("MeshNode", no_init)
+ .def("__init__", raw_constructor(createNode<meshNodeName>))
+ .add_property("vertexcoords", make_function(&MeshNode::getVertexCoords,
+ return_value_policy<copy_const_reference>()), &MeshNode::setVertexCoords)
+ .add_property("texcoords", make_function(&MeshNode::getTexCoords,
+ return_value_policy<copy_const_reference>()), &MeshNode::setTexCoords)
+ .add_property("triangles", make_function(&MeshNode::getTriangles,
+ return_value_policy<copy_const_reference>()), &MeshNode::setTriangles)
+ ;
+
+}
diff --git a/src/wrapper/raster_wrap.cpp b/src/wrapper/raster_wrap.cpp
new file mode 100644
index 0000000..182064f
--- /dev/null
+++ b/src/wrapper/raster_wrap.cpp
@@ -0,0 +1,208 @@
+//
+// libavg - Media Playback Engine.
+// Copyright (C) 2003-2011 Ulrich von Zadow
+//
+// This library 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 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Current versions can be found at www.libavg.de
+//
+
+#include "WrapHelper.h"
+#include "raw_constructor.hpp"
+
+#include "../player/CameraNode.h"
+#include "../player/ImageNode.h"
+#include "../player/VideoNode.h"
+#include "../player/WordsNode.h"
+
+using namespace boost::python;
+using namespace avg;
+using namespace std;
+
+char imageNodeName[] = "image";
+char cameraNodeName[] = "camera";
+char videoNodeName[] = "video";
+char wordsNodeName[] = "words";
+
+void export_raster()
+{
+ to_python_converter<VertexGrid, to_list<VertexGrid> >();
+ from_python_sequence<VertexGrid, variable_capacity_policy>();
+
+ class_<RasterNode, bases<AreaNode>, boost::noncopyable>("RasterNode", no_init)
+ .def("getOrigVertexCoords", &RasterNode::getOrigVertexCoords)
+ .def("getWarpedVertexCoords", &RasterNode::getWarpedVertexCoords)
+ .def("setWarpedVertexCoords", &RasterNode::setWarpedVertexCoords)
+ .def("setEffect", &RasterNode::setEffect)
+ .add_property("maxtilewidth", &RasterNode::getMaxTileWidth)
+ .add_property("maxtileheight", &RasterNode::getMaxTileHeight)
+ .add_property("blendmode",
+ make_function(&RasterNode::getBlendModeStr,
+ return_value_policy<copy_const_reference>()),
+ &RasterNode::setBlendModeStr)
+ .add_property("maskhref",
+ make_function(&RasterNode::getMaskHRef,
+ return_value_policy<copy_const_reference>()),
+ &RasterNode::setMaskHRef)
+ .add_property("maskpos",
+ make_function(&RasterNode::getMaskPos,
+ return_value_policy<copy_const_reference>()),
+ &RasterNode::setMaskPos)
+ .add_property("masksize",
+ make_function(&RasterNode::getMaskSize,
+ return_value_policy<copy_const_reference>()),
+ &RasterNode::setMaskSize)
+ .add_property("mipmap", &RasterNode::getMipmap)
+ .add_property("gamma", &RasterNode::getGamma, &RasterNode::setGamma)
+ .add_property("intensity", &RasterNode::getIntensity, &RasterNode::setIntensity)
+ .add_property("contrast", &RasterNode::getContrast, &RasterNode::setContrast)
+ ;
+
+ class_<ImageNode, bases<RasterNode> >("ImageNode", no_init)
+ .def("__init__", raw_constructor(createNode<imageNodeName>))
+ .def("getBitmap", &ImageNode::getBitmap)
+ .def("setBitmap", &ImageNode::setBitmap)
+ .add_property("href",
+ make_function(&ImageNode::getHRef,
+ return_value_policy<copy_const_reference>()),
+ &ImageNode::setHRef)
+ .add_property("compression",
+ &ImageNode::getCompression)
+ ;
+
+ class_<CameraNode, bases<RasterNode> >("CameraNode", no_init)
+ .def("__init__", raw_constructor(createNode<cameraNodeName>))
+ .add_property("device", make_function(&CameraNode::getDevice,
+ return_value_policy<copy_const_reference>()))
+ .add_property("driver", make_function(&CameraNode::getDriverName,
+ return_value_policy<copy_const_reference>()))
+ .add_property("framerate", &CameraNode::getFrameRate)
+ .add_property("framenum", &CameraNode::getFrameNum)
+ .add_property("brightness", &CameraNode::getBrightness,
+ &CameraNode::setBrightness)
+ .add_property("sharpness", &CameraNode::getSharpness, &CameraNode::setSharpness)
+ .add_property("saturation", &CameraNode::getSaturation,
+ &CameraNode::setSaturation)
+ .add_property("camgamma", &CameraNode::getCamGamma, &CameraNode::setCamGamma)
+ .add_property("shutter", &CameraNode::getShutter, &CameraNode::setShutter)
+ .add_property("gain", &CameraNode::getGain, &CameraNode::setGain)
+ .add_property("strobeduration", &CameraNode::getStrobeDuration,
+ &CameraNode::setStrobeDuration)
+ .def("play", &CameraNode::play)
+ .def("stop", &CameraNode::stop)
+ .def("getBitmap", &CameraNode::getBitmap)
+ .def("getWhitebalanceU", &CameraNode::getWhitebalanceU)
+ .def("getWhitebalanceV", &CameraNode::getWhitebalanceV)
+ .def("setWhitebalance", &CameraNode::setWhitebalance)
+ .def("doOneShotWhitebalance", &CameraNode::doOneShotWhitebalance)
+ .def("isAvailable", &CameraNode::isAvailable)
+ .def("dumpCameras", make_function(&CameraNode::dumpCameras))
+ .staticmethod("dumpCameras")
+ .def("resetFirewireBus", &CameraNode::resetFirewireBus)
+ .staticmethod("resetFirewireBus")
+ ;
+
+ enum_<VideoNode::VideoAccelType>("VideoAccelType")
+ .value("NO_ACCELERATION", VideoNode::NONE)
+ .value("VDPAU", VideoNode::VDPAU)
+ .export_values()
+ ;
+
+ class_<VideoNode, bases<RasterNode> >("VideoNode", no_init)
+ .def("__init__", raw_constructor(createNode<videoNodeName>))
+ .def("play", &VideoNode::play)
+ .def("stop", &VideoNode::stop)
+ .def("pause", &VideoNode::pause)
+ .def("getNumFrames", &VideoNode::getNumFrames)
+ .def("getNumFramesQueued", &VideoNode::getNumFramesQueued)
+ .def("getCurFrame", &VideoNode::getCurFrame)
+ .def("seekToFrame", &VideoNode::seekToFrame)
+ .def("getStreamPixelFormat", &VideoNode::getStreamPixelFormat)
+ .def("getDuration", &VideoNode::getDuration)
+ .def("getBitrate", &VideoNode::getBitrate)
+ .def("getVideoCodec", &VideoNode::getVideoCodec)
+ .def("getAudioCodec", &VideoNode::getAudioCodec)
+ .def("getAudioSampleRate", &VideoNode::getAudioSampleRate)
+ .def("getNumAudioChannels", &VideoNode::getNumAudioChannels)
+ .def("getCurTime", &VideoNode::getCurTime)
+ .def("seekToTime", &VideoNode::seekToTime)
+ .def("hasAudio", &VideoNode::hasAudio)
+ .def("hasAlpha", &VideoNode::hasAlpha)
+ .def("setEOFCallback", &VideoNode::setEOFCallback)
+ .def("getVideoAccelConfig", &VideoNode::getVideoAccelConfig)
+ .staticmethod("getVideoAccelConfig")
+ .add_property("fps", &VideoNode::getFPS)
+ .add_property("queuelength", &VideoNode::getQueueLength)
+ .add_property("href",
+ make_function(&VideoNode::getHRef,
+ return_value_policy<copy_const_reference>()),
+ &VideoNode::setHRef)
+ .add_property("loop", &VideoNode::getLoop)
+ .add_property("volume", &VideoNode::getVolume, &VideoNode::setVolume)
+ .add_property("threaded", &VideoNode::isThreaded)
+ .add_property("accelerated", &VideoNode::isAccelerated)
+ ;
+
+ class_<WordsNode, bases<RasterNode> >("WordsNode", no_init)
+ .def("__init__", raw_constructor(createNode<wordsNodeName>))
+ .add_property("font",
+ make_function(&WordsNode::getFont,
+ return_value_policy<copy_const_reference>()),
+ make_function(&WordsNode::setFont,
+ return_value_policy<copy_const_reference>()))
+ .add_property("variant",
+ make_function(&WordsNode::getFontVariant,
+ return_value_policy<copy_const_reference>()),
+ make_function(&WordsNode::setFontVariant,
+ return_value_policy<copy_const_reference>()))
+ .add_property("text",
+ make_function(&WordsNode::getText,
+ return_value_policy<copy_const_reference>()),
+ make_function(&WordsNode::setText,
+ return_value_policy<copy_const_reference>()))
+ .add_property("color",
+ make_function(&WordsNode::getColor,
+ return_value_policy<copy_const_reference>()),
+ make_function(&WordsNode::setColor,
+ return_value_policy<copy_const_reference>()))
+ .add_property("fontsize", &WordsNode::getFontSize, &WordsNode::setFontSize)
+ .add_property("parawidth", &deprecatedGet<WordsNode>, &deprecatedSet<WordsNode>)
+ .add_property("indent", &WordsNode::getIndent, &WordsNode::setIndent)
+ .add_property("linespacing", &WordsNode::getLineSpacing,
+ &WordsNode::setLineSpacing)
+ .add_property("alignment", &WordsNode::getAlignment, &WordsNode::setAlignment)
+ .add_property("wrapmode", &WordsNode::getWrapMode, &WordsNode::setWrapMode)
+ .add_property("justify", &WordsNode::getJustify, &WordsNode::setJustify)
+ .add_property("rawtextmode", &WordsNode::getRawTextMode,
+ &WordsNode::setRawTextMode)
+ .add_property("letterspacing", &WordsNode::getLetterSpacing,
+ &WordsNode::setLetterSpacing)
+ .add_property("hint", &WordsNode::getHint, &WordsNode::setHint)
+ .def("getGlyphPos", &WordsNode::getGlyphPos)
+ .def("getGlyphSize", &WordsNode::getGlyphSize)
+ .def("getNumLines", &WordsNode::getNumLines)
+ .def("getCharIndexFromPos", &WordsNode::getCharIndexFromPos)
+ .def("getTextAsDisplayed", &WordsNode::getTextAsDisplayed)
+ .def("getLineExtents", &WordsNode::getLineExtents)
+ .def("getFontFamilies", make_function(&WordsNode::getFontFamilies,
+ return_value_policy<copy_const_reference>()))
+ .staticmethod("getFontFamilies")
+ .def("getFontVariants", make_function(&WordsNode::getFontVariants,
+ return_value_policy<copy_const_reference>()))
+ .staticmethod("getFontVariants")
+ .def("addFontDir", &WordsNode::addFontDir)
+ .staticmethod("addFontDir")
+ ;
+}
diff --git a/src/wrapper/raw_constructor.hpp b/src/wrapper/raw_constructor.hpp
new file mode 100644
index 0000000..8f6b3a4
--- /dev/null
+++ b/src/wrapper/raw_constructor.hpp
@@ -0,0 +1,61 @@
+// Original code by Hans Meine <meine <at> kogs1.informatik.uni-hamburg.de>:
+// Subject: Re: Raw constructor (i.e. combination of make_constructor and raw_function)
+// Newsgroups: gmane.comp.python.c++
+// Date: 2005-11-17 18:43:48 GMT
+// No copyright statement found. Presumed to be in the public domain.
+
+#ifndef RAW_CONSTRUCTOR_HPP
+#define RAW_CONSTRUCTOR_HPP
+
+#include <boost/python.hpp>
+#include <boost/python/raw_function.hpp>
+#include <boost/python/make_constructor.hpp>
+#include "boost/python/detail/api_placeholder.hpp" // python::len
+
+namespace boost { namespace python {
+
+namespace detail {
+
+ template <class F>
+ struct raw_constructor_dispatcher
+ {
+ raw_constructor_dispatcher(F f)
+ : f(make_constructor(f)) {}
+
+ PyObject* operator()(PyObject* args, PyObject* keywords)
+ {
+ borrowed_reference_t* ra = borrowed_reference(args);
+ object a(ra);
+ return incref(
+ object(
+ f(
+ object(a[0])
+ , object(a.slice(1, len(a)))
+ , keywords ? dict(borrowed_reference(keywords)) : dict()
+ )
+ ).ptr()
+ );
+ }
+
+ private:
+ object f;
+ };
+
+} // namespace detail
+
+template <class F>
+object raw_constructor(F f, int min_args = 0)
+{
+ return detail::make_raw_function(
+ objects::py_function(
+ detail::raw_constructor_dispatcher<F>(f)
+ , mpl::vector2<void, object>()
+ , min_args+1
+ , (std::numeric_limits<unsigned>::max)()
+ )
+ );
+}
+
+}} // namespace boost::python
+
+#endif // RAW_CONSTRUCTOR_HPP