Fixed line endings

This commit is contained in:
ExMix 2013-05-02 11:39:16 +03:00 committed by Alex Zolotarev
parent 72dd2a7b55
commit 4d01357109
42 changed files with 8636 additions and 8636 deletions

View file

@ -1,400 +1,400 @@
# Microsoft Developer Studio Project File - Name="freetype" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=freetype - Win32 Debug Singlethreaded
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "freetype.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "freetype.mak" CFG="freetype - Win32 Debug Singlethreaded"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "freetype - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Debug Multithreaded" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Release Multithreaded" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Release Singlethreaded" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Debug Singlethreaded" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "freetype - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\..\objs\release"
# PROP Intermediate_Dir "..\..\..\objs\release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /MD /Za /W4 /GX /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /c
# SUBTRACT CPP /nologo /Z<none> /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\..\objs\debug"
# PROP Intermediate_Dir "..\..\..\objs\debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /MDd /Za /W4 /GX /Z7 /Od /I "..\..\..\include" /D "_DEBUG" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /GZ /c
# SUBTRACT CPP /nologo /X /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411_D.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Debug Multithreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "freetype___Win32_Debug_Multithreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Debug_Multithreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\..\objs\debug_mt"
# PROP Intermediate_Dir "..\..\..\objs\debug_mt"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Za /W3 /Gm /GX /ZI /Od /I "..\freetype\include\\" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT_FLAT_COMPILE" /YX /FD /GZ /c
# SUBTRACT BASE CPP /X
# ADD CPP /MTd /Za /W4 /GX /Z7 /Od /I "..\..\..\include" /D "_DEBUG" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /GZ /c
# SUBTRACT CPP /nologo /X /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"lib\freetype2411_D.lib"
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411MT_D.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Release Multithreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "freetype___Win32_Release_Multithreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Release_Multithreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\..\objs\release_mt"
# PROP Intermediate_Dir "..\..\..\objs\release_mt"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Za /W3 /GX /O2 /I "..\freetype\include\\" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT_FLAT_COMPILE" /YX /FD /c
# ADD CPP /MT /Za /W4 /GX /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /c
# SUBTRACT CPP /nologo /Z<none> /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"lib\freetype2411.lib"
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411MT.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Release Singlethreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "freetype___Win32_Release_Singlethreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Release_Singlethreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\..\objs\release_st"
# PROP Intermediate_Dir "..\..\..\objs\release_st"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /Za /W4 /GX /Zi /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /Za /W4 /GX /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /c
# SUBTRACT CPP /nologo /Z<none> /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"..\..\..\objs\freetype2411.lib"
# ADD LIB32 /out:"..\..\..\objs\freetype2411ST.lib"
# SUBTRACT LIB32 /nologo
!ELSEIF "$(CFG)" == "freetype - Win32 Debug Singlethreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "freetype___Win32_Debug_Singlethreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Debug_Singlethreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\..\objs\debug_st"
# PROP Intermediate_Dir "..\..\..\objs\debug_st"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /Za /W4 /Gm /GX /Zi /Od /I "..\..\..\include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /FD /GZ /c
# SUBTRACT BASE CPP /X /YX
# ADD CPP /Za /W4 /GX /Z7 /Od /I "..\..\..\include" /D "_DEBUG" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /GZ /c
# SUBTRACT CPP /nologo /X /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"..\..\..\objs\freetype2411_D.lib"
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411ST_D.lib"
!ENDIF
# Begin Target
# Name "freetype - Win32 Release"
# Name "freetype - Win32 Debug"
# Name "freetype - Win32 Debug Multithreaded"
# Name "freetype - Win32 Release Multithreaded"
# Name "freetype - Win32 Release Singlethreaded"
# Name "freetype - Win32 Debug Singlethreaded"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\src\autofit\autofit.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\bdf\bdf.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\cff\cff.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbase.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbbox.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbdf.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbitmap.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftfstype.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftgasp.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\cache\ftcache.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\ftdebug.c
# ADD CPP /Ze
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftglyph.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftgxval.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\gzip\ftgzip.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftinit.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\lzw\ftlzw.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftmm.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftotval.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftpfr.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftstroke.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftsynth.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftsystem.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\fttype1.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftwinfnt.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftxf86.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\pcf\pcf.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\pfr\pfr.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\psaux\psaux.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\pshinter\pshinter.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\psnames\psmodule.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\raster\raster.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\sfnt\sfnt.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\smooth\smooth.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\truetype\truetype.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\type1\type1.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\cid\type1cid.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\type42\type42.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\winfonts\winfnt.c
# SUBTRACT CPP /Fr
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\include\ft2build.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftconfig.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftheader.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftmodule.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftoption.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftstdlib.h
# End Source File
# End Group
# End Target
# End Project
# Microsoft Developer Studio Project File - Name="freetype" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Static Library" 0x0104
CFG=freetype - Win32 Debug Singlethreaded
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "freetype.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "freetype.mak" CFG="freetype - Win32 Debug Singlethreaded"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "freetype - Win32 Release" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Debug" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Debug Multithreaded" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Release Multithreaded" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Release Singlethreaded" (based on "Win32 (x86) Static Library")
!MESSAGE "freetype - Win32 Debug Singlethreaded" (based on "Win32 (x86) Static Library")
!MESSAGE
# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
RSC=rc.exe
!IF "$(CFG)" == "freetype - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\..\objs\release"
# PROP Intermediate_Dir "..\..\..\objs\release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
# ADD CPP /MD /Za /W4 /GX /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /c
# SUBTRACT CPP /nologo /Z<none> /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\..\objs\debug"
# PROP Intermediate_Dir "..\..\..\objs\debug"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
# ADD CPP /MDd /Za /W4 /GX /Z7 /Od /I "..\..\..\include" /D "_DEBUG" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /GZ /c
# SUBTRACT CPP /nologo /X /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411_D.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Debug Multithreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "freetype___Win32_Debug_Multithreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Debug_Multithreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\..\objs\debug_mt"
# PROP Intermediate_Dir "..\..\..\objs\debug_mt"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Za /W3 /Gm /GX /ZI /Od /I "..\freetype\include\\" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT_FLAT_COMPILE" /YX /FD /GZ /c
# SUBTRACT BASE CPP /X
# ADD CPP /MTd /Za /W4 /GX /Z7 /Od /I "..\..\..\include" /D "_DEBUG" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /GZ /c
# SUBTRACT CPP /nologo /X /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"lib\freetype2411_D.lib"
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411MT_D.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Release Multithreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "freetype___Win32_Release_Multithreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Release_Multithreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\..\objs\release_mt"
# PROP Intermediate_Dir "..\..\..\objs\release_mt"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /Za /W3 /GX /O2 /I "..\freetype\include\\" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT_FLAT_COMPILE" /YX /FD /c
# ADD CPP /MT /Za /W4 /GX /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /c
# SUBTRACT CPP /nologo /Z<none> /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"lib\freetype2411.lib"
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411MT.lib"
!ELSEIF "$(CFG)" == "freetype - Win32 Release Singlethreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "freetype___Win32_Release_Singlethreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Release_Singlethreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "..\..\..\objs\release_st"
# PROP Intermediate_Dir "..\..\..\objs\release_st"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MD /Za /W4 /GX /Zi /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /FD /c
# SUBTRACT BASE CPP /YX
# ADD CPP /Za /W4 /GX /O2 /I "..\..\..\include" /D "NDEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /c
# SUBTRACT CPP /nologo /Z<none> /YX
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"..\..\..\objs\freetype2411.lib"
# ADD LIB32 /out:"..\..\..\objs\freetype2411ST.lib"
# SUBTRACT LIB32 /nologo
!ELSEIF "$(CFG)" == "freetype - Win32 Debug Singlethreaded"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "freetype___Win32_Debug_Singlethreaded"
# PROP BASE Intermediate_Dir "freetype___Win32_Debug_Singlethreaded"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "..\..\..\objs\debug_st"
# PROP Intermediate_Dir "..\..\..\objs\debug_st"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MDd /Za /W4 /Gm /GX /Zi /Od /I "..\..\..\include" /D "_DEBUG" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /FD /GZ /c
# SUBTRACT BASE CPP /X /YX
# ADD CPP /Za /W4 /GX /Z7 /Od /I "..\..\..\include" /D "_DEBUG" /D "FT_DEBUG_LEVEL_ERROR" /D "FT_DEBUG_LEVEL_TRACE" /D "WIN32" /D "_MBCS" /D "_LIB" /D "FT2_BUILD_LIBRARY" /FD /GZ /c
# SUBTRACT CPP /nologo /X /YX
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LIB32=link.exe -lib
# ADD BASE LIB32 /nologo /out:"..\..\..\objs\freetype2411_D.lib"
# ADD LIB32 /nologo /out:"..\..\..\objs\freetype2411ST_D.lib"
!ENDIF
# Begin Target
# Name "freetype - Win32 Release"
# Name "freetype - Win32 Debug"
# Name "freetype - Win32 Debug Multithreaded"
# Name "freetype - Win32 Release Multithreaded"
# Name "freetype - Win32 Release Singlethreaded"
# Name "freetype - Win32 Debug Singlethreaded"
# Begin Group "Source Files"
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File
SOURCE=..\..\..\src\autofit\autofit.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\bdf\bdf.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\cff\cff.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbase.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbbox.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbdf.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftbitmap.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftfstype.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftgasp.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\cache\ftcache.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\ftdebug.c
# ADD CPP /Ze
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftglyph.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftgxval.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\gzip\ftgzip.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftinit.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\lzw\ftlzw.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftmm.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftotval.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftpfr.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftstroke.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftsynth.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftsystem.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\fttype1.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftwinfnt.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\base\ftxf86.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\pcf\pcf.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\pfr\pfr.c
# End Source File
# Begin Source File
SOURCE=..\..\..\src\psaux\psaux.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\pshinter\pshinter.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\psnames\psmodule.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\raster\raster.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\sfnt\sfnt.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\smooth\smooth.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\truetype\truetype.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\type1\type1.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\cid\type1cid.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\type42\type42.c
# SUBTRACT CPP /Fr
# End Source File
# Begin Source File
SOURCE=..\..\..\src\winfonts\winfnt.c
# SUBTRACT CPP /Fr
# End Source File
# End Group
# Begin Group "Header Files"
# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File
SOURCE=..\..\..\include\ft2build.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftconfig.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftheader.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftmodule.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftoption.h
# End Source File
# Begin Source File
SOURCE=..\..\..\include\freetype\config\ftstdlib.h
# End Source File
# End Group
# End Target
# End Project

View file

@ -1,29 +1,29 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "freetype"=.\freetype.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "freetype"=.\freetype.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

File diff suppressed because it is too large Load diff

View file

@ -1,34 +1,34 @@
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "utf8/checked.h"
#include "utf8/unchecked.h"
#endif // header guard
// Copyright 2006 Nemanja Trifunovic
/*
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#ifndef UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#define UTF8_FOR_CPP_2675DCD0_9480_4c0c_B92A_CC14C027B731
#include "utf8/checked.h"
#include "utf8/unchecked.h"
#endif // header guard

View file

@ -1,33 +1,33 @@
<?xml version="1.0" encoding="utf-8" ?>
<project name="DotZLib" default="build" basedir="./DotZLib">
<description>A .Net wrapper library around ZLib1.dll</description>
<property name="nunit.location" value="c:/program files/NUnit V2.1/bin" />
<property name="build.root" value="bin" />
<property name="debug" value="true" />
<property name="nunit" value="true" />
<property name="build.folder" value="${build.root}/debug/" if="${debug}" />
<property name="build.folder" value="${build.root}/release/" unless="${debug}" />
<target name="clean" description="Remove all generated files">
<delete dir="${build.root}" failonerror="false" />
</target>
<target name="build" description="compiles the source code">
<mkdir dir="${build.folder}" />
<csc target="library" output="${build.folder}DotZLib.dll" debug="${debug}">
<references basedir="${nunit.location}">
<includes if="${nunit}" name="nunit.framework.dll" />
</references>
<sources>
<includes name="*.cs" />
<excludes name="UnitTests.cs" unless="${nunit}" />
</sources>
<arg value="/d:nunit" if="${nunit}" />
</csc>
</target>
<?xml version="1.0" encoding="utf-8" ?>
<project name="DotZLib" default="build" basedir="./DotZLib">
<description>A .Net wrapper library around ZLib1.dll</description>
<property name="nunit.location" value="c:/program files/NUnit V2.1/bin" />
<property name="build.root" value="bin" />
<property name="debug" value="true" />
<property name="nunit" value="true" />
<property name="build.folder" value="${build.root}/debug/" if="${debug}" />
<property name="build.folder" value="${build.root}/release/" unless="${debug}" />
<target name="clean" description="Remove all generated files">
<delete dir="${build.root}" failonerror="false" />
</target>
<target name="build" description="compiles the source code">
<mkdir dir="${build.folder}" />
<csc target="library" output="${build.folder}DotZLib.dll" debug="${debug}">
<references basedir="${nunit.location}">
<includes if="${nunit}" name="nunit.framework.dll" />
</references>
<sources>
<includes name="*.cs" />
<excludes name="UnitTests.cs" unless="${nunit}" />
</sources>
<arg value="/d:nunit" if="${nunit}" />
</csc>
</target>
</project>

View file

@ -1,58 +1,58 @@
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("DotZLib")]
[assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Henrik Ravn")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("DotZLib")]
[assembly: AssemblyDescription(".Net bindings for ZLib compression dll 1.2.x")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Henrik Ravn")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("(c) 2004 by Henrik Ravn")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]

View file

@ -1,202 +1,202 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region ChecksumGeneratorBase
/// <summary>
/// Implements the common functionality needed for all <see cref="ChecksumGenerator"/>s
/// </summary>
/// <example></example>
public abstract class ChecksumGeneratorBase : ChecksumGenerator
{
/// <summary>
/// The value of the current checksum
/// </summary>
protected uint _current;
/// <summary>
/// Initializes a new instance of the checksum generator base - the current checksum is
/// set to zero
/// </summary>
public ChecksumGeneratorBase()
{
_current = 0;
}
/// <summary>
/// Initializes a new instance of the checksum generator basewith a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public ChecksumGeneratorBase(uint initialValue)
{
_current = initialValue;
}
/// <summary>
/// Resets the current checksum to zero
/// </summary>
public void Reset() { _current = 0; }
/// <summary>
/// Gets the current checksum value
/// </summary>
public uint Value { get { return _current; } }
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
/// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one.
/// This is therefore the only method a derived class has to implement</remarks>
public abstract void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with an array of bytes.
/// </summary>
/// <param name="data">The data to update the checksum with</param>
public void Update(byte[] data)
{
Update(data, 0, data.Length);
}
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
public void Update(string data)
{
Update(Encoding.UTF8.GetBytes(data));
}
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
public void Update(string data, Encoding encoding)
{
Update(encoding.GetBytes(data));
}
}
#endregion
#region CRC32
/// <summary>
/// Implements a CRC32 checksum generator
/// </summary>
public sealed class CRC32Checksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint crc32(uint crc, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator
/// </summary>
public CRC32Checksum() : base() {}
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public CRC32Checksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
#region Adler
/// <summary>
/// Implements a checksum generator that computes the Adler checksum on data
/// </summary>
public sealed class AdlerChecksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint adler32(uint adler, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the Adler checksum generator
/// </summary>
public AdlerChecksum() : base() {}
/// <summary>
/// Initializes a new instance of the Adler checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public AdlerChecksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region ChecksumGeneratorBase
/// <summary>
/// Implements the common functionality needed for all <see cref="ChecksumGenerator"/>s
/// </summary>
/// <example></example>
public abstract class ChecksumGeneratorBase : ChecksumGenerator
{
/// <summary>
/// The value of the current checksum
/// </summary>
protected uint _current;
/// <summary>
/// Initializes a new instance of the checksum generator base - the current checksum is
/// set to zero
/// </summary>
public ChecksumGeneratorBase()
{
_current = 0;
}
/// <summary>
/// Initializes a new instance of the checksum generator basewith a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public ChecksumGeneratorBase(uint initialValue)
{
_current = initialValue;
}
/// <summary>
/// Resets the current checksum to zero
/// </summary>
public void Reset() { _current = 0; }
/// <summary>
/// Gets the current checksum value
/// </summary>
public uint Value { get { return _current; } }
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
/// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one.
/// This is therefore the only method a derived class has to implement</remarks>
public abstract void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with an array of bytes.
/// </summary>
/// <param name="data">The data to update the checksum with</param>
public void Update(byte[] data)
{
Update(data, 0, data.Length);
}
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
public void Update(string data)
{
Update(Encoding.UTF8.GetBytes(data));
}
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
public void Update(string data, Encoding encoding)
{
Update(encoding.GetBytes(data));
}
}
#endregion
#region CRC32
/// <summary>
/// Implements a CRC32 checksum generator
/// </summary>
public sealed class CRC32Checksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint crc32(uint crc, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator
/// </summary>
public CRC32Checksum() : base() {}
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public CRC32Checksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
#region Adler
/// <summary>
/// Implements a checksum generator that computes the Adler checksum on data
/// </summary>
public sealed class AdlerChecksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint adler32(uint adler, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the Adler checksum generator
/// </summary>
public AdlerChecksum() : base() {}
/// <summary>
/// Initializes a new instance of the Adler checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public AdlerChecksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
}

View file

@ -1,83 +1,83 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
namespace DotZLib
{
/// <summary>
/// This class implements a circular buffer
/// </summary>
internal class CircularBuffer
{
#region Private data
private int _capacity;
private int _head;
private int _tail;
private int _size;
private byte[] _buffer;
#endregion
public CircularBuffer(int capacity)
{
Debug.Assert( capacity > 0 );
_buffer = new byte[capacity];
_capacity = capacity;
_head = 0;
_tail = 0;
_size = 0;
}
public int Size { get { return _size; } }
public int Put(byte[] source, int offset, int count)
{
Debug.Assert( count > 0 );
int trueCount = Math.Min(count, _capacity - Size);
for (int i = 0; i < trueCount; ++i)
_buffer[(_tail+i) % _capacity] = source[offset+i];
_tail += trueCount;
_tail %= _capacity;
_size += trueCount;
return trueCount;
}
public bool Put(byte b)
{
if (Size == _capacity) // no room
return false;
_buffer[_tail++] = b;
_tail %= _capacity;
++_size;
return true;
}
public int Get(byte[] destination, int offset, int count)
{
int trueCount = Math.Min(count,Size);
for (int i = 0; i < trueCount; ++i)
destination[offset + i] = _buffer[(_head+i) % _capacity];
_head += trueCount;
_head %= _capacity;
_size -= trueCount;
return trueCount;
}
public int Get()
{
if (Size == 0)
return -1;
int result = (int)_buffer[_head++ % _capacity];
--_size;
return result;
}
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
namespace DotZLib
{
/// <summary>
/// This class implements a circular buffer
/// </summary>
internal class CircularBuffer
{
#region Private data
private int _capacity;
private int _head;
private int _tail;
private int _size;
private byte[] _buffer;
#endregion
public CircularBuffer(int capacity)
{
Debug.Assert( capacity > 0 );
_buffer = new byte[capacity];
_capacity = capacity;
_head = 0;
_tail = 0;
_size = 0;
}
public int Size { get { return _size; } }
public int Put(byte[] source, int offset, int count)
{
Debug.Assert( count > 0 );
int trueCount = Math.Min(count, _capacity - Size);
for (int i = 0; i < trueCount; ++i)
_buffer[(_tail+i) % _capacity] = source[offset+i];
_tail += trueCount;
_tail %= _capacity;
_size += trueCount;
return trueCount;
}
public bool Put(byte b)
{
if (Size == _capacity) // no room
return false;
_buffer[_tail++] = b;
_tail %= _capacity;
++_size;
return true;
}
public int Get(byte[] destination, int offset, int count)
{
int trueCount = Math.Min(count,Size);
for (int i = 0; i < trueCount; ++i)
destination[offset + i] = _buffer[(_head+i) % _capacity];
_head += trueCount;
_head %= _capacity;
_size -= trueCount;
return trueCount;
}
public int Get()
{
if (Size == 0)
return -1;
int result = (int)_buffer[_head++ % _capacity];
--_size;
return result;
}
}
}

View file

@ -1,198 +1,198 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements the common functionality needed for all <see cref="Codec"/>s
/// </summary>
public abstract class CodecBase : Codec, IDisposable
{
#region Data members
/// <summary>
/// Instance of the internal zlib buffer structure that is
/// passed to all functions in the zlib dll
/// </summary>
internal ZStream _ztream = new ZStream();
/// <summary>
/// True if the object instance has been disposed, false otherwise
/// </summary>
protected bool _isDisposed = false;
/// <summary>
/// The size of the internal buffers
/// </summary>
protected const int kBufferSize = 16384;
private byte[] _outBuffer = new byte[kBufferSize];
private byte[] _inBuffer = new byte[kBufferSize];
private GCHandle _hInput;
private GCHandle _hOutput;
private uint _checksum = 0;
#endregion
/// <summary>
/// Initializes a new instance of the <c>CodeBase</c> class.
/// </summary>
public CodecBase()
{
try
{
_hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned);
_hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned);
}
catch (Exception)
{
CleanUp(false);
throw;
}
}
#region Codec Members
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
public event DataAvailableHandler DataAvailable;
/// <summary>
/// Fires the <see cref="DataAvailable"/> event
/// </summary>
protected void OnDataAvailable()
{
if (_ztream.total_out > 0)
{
if (DataAvailable != null)
DataAvailable( _outBuffer, 0, (int)_ztream.total_out);
resetOutput();
}
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public void Add(byte[] data)
{
Add(data,0,data.Length);
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
public uint Checksum { get { return _checksum; } }
#endregion
#region Destructor & IDisposable stuff
/// <summary>
/// Destroys this instance
/// </summary>
~CodecBase()
{
CleanUp(false);
}
/// <summary>
/// Releases any unmanaged resources and calls the <see cref="CleanUp()"/> method of the derived class
/// </summary>
public void Dispose()
{
CleanUp(true);
}
/// <summary>
/// Performs any codec specific cleanup
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
protected abstract void CleanUp();
// performs the release of the handles and calls the dereived CleanUp()
private void CleanUp(bool isDisposing)
{
if (!_isDisposed)
{
CleanUp();
if (_hInput.IsAllocated)
_hInput.Free();
if (_hOutput.IsAllocated)
_hOutput.Free();
_isDisposed = true;
}
}
#endregion
#region Helper methods
/// <summary>
/// Copies a number of bytes to the internal codec buffer - ready for proccesing
/// </summary>
/// <param name="data">The byte array that contains the data to copy</param>
/// <param name="startIndex">The index of the first byte to copy</param>
/// <param name="count">The number of bytes to copy from <c>data</c></param>
protected void copyInput(byte[] data, int startIndex, int count)
{
Array.Copy(data, startIndex, _inBuffer,0, count);
_ztream.next_in = _hInput.AddrOfPinnedObject();
_ztream.total_in = 0;
_ztream.avail_in = (uint)count;
}
/// <summary>
/// Resets the internal output buffers to a known state - ready for processing
/// </summary>
protected void resetOutput()
{
_ztream.total_out = 0;
_ztream.avail_out = kBufferSize;
_ztream.next_out = _hOutput.AddrOfPinnedObject();
}
/// <summary>
/// Updates the running checksum property
/// </summary>
/// <param name="newSum">The new checksum value</param>
protected void setChecksum(uint newSum)
{
_checksum = newSum;
}
#endregion
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements the common functionality needed for all <see cref="Codec"/>s
/// </summary>
public abstract class CodecBase : Codec, IDisposable
{
#region Data members
/// <summary>
/// Instance of the internal zlib buffer structure that is
/// passed to all functions in the zlib dll
/// </summary>
internal ZStream _ztream = new ZStream();
/// <summary>
/// True if the object instance has been disposed, false otherwise
/// </summary>
protected bool _isDisposed = false;
/// <summary>
/// The size of the internal buffers
/// </summary>
protected const int kBufferSize = 16384;
private byte[] _outBuffer = new byte[kBufferSize];
private byte[] _inBuffer = new byte[kBufferSize];
private GCHandle _hInput;
private GCHandle _hOutput;
private uint _checksum = 0;
#endregion
/// <summary>
/// Initializes a new instance of the <c>CodeBase</c> class.
/// </summary>
public CodecBase()
{
try
{
_hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned);
_hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned);
}
catch (Exception)
{
CleanUp(false);
throw;
}
}
#region Codec Members
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
public event DataAvailableHandler DataAvailable;
/// <summary>
/// Fires the <see cref="DataAvailable"/> event
/// </summary>
protected void OnDataAvailable()
{
if (_ztream.total_out > 0)
{
if (DataAvailable != null)
DataAvailable( _outBuffer, 0, (int)_ztream.total_out);
resetOutput();
}
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public void Add(byte[] data)
{
Add(data,0,data.Length);
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
public uint Checksum { get { return _checksum; } }
#endregion
#region Destructor & IDisposable stuff
/// <summary>
/// Destroys this instance
/// </summary>
~CodecBase()
{
CleanUp(false);
}
/// <summary>
/// Releases any unmanaged resources and calls the <see cref="CleanUp()"/> method of the derived class
/// </summary>
public void Dispose()
{
CleanUp(true);
}
/// <summary>
/// Performs any codec specific cleanup
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
protected abstract void CleanUp();
// performs the release of the handles and calls the dereived CleanUp()
private void CleanUp(bool isDisposing)
{
if (!_isDisposed)
{
CleanUp();
if (_hInput.IsAllocated)
_hInput.Free();
if (_hOutput.IsAllocated)
_hOutput.Free();
_isDisposed = true;
}
}
#endregion
#region Helper methods
/// <summary>
/// Copies a number of bytes to the internal codec buffer - ready for proccesing
/// </summary>
/// <param name="data">The byte array that contains the data to copy</param>
/// <param name="startIndex">The index of the first byte to copy</param>
/// <param name="count">The number of bytes to copy from <c>data</c></param>
protected void copyInput(byte[] data, int startIndex, int count)
{
Array.Copy(data, startIndex, _inBuffer,0, count);
_ztream.next_in = _hInput.AddrOfPinnedObject();
_ztream.total_in = 0;
_ztream.avail_in = (uint)count;
}
/// <summary>
/// Resets the internal output buffers to a known state - ready for processing
/// </summary>
protected void resetOutput()
{
_ztream.total_out = 0;
_ztream.avail_out = kBufferSize;
_ztream.next_out = _hOutput.AddrOfPinnedObject();
}
/// <summary>
/// Updates the running checksum property
/// </summary>
/// <param name="newSum">The new checksum value</param>
protected void setChecksum(uint newSum)
{
_checksum = newSum;
}
#endregion
}
}

View file

@ -1,106 +1,106 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data compressor, using the deflate algorithm in the ZLib dll
/// </summary>
public sealed class Deflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Deflater</c>
/// </summary>
/// <param name="level">The compression level to use for this <c>Deflater</c></param>
public Deflater(CompressLevel level) : base()
{
int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize deflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
while (err >= 0 && _ztream.avail_in > 0)
{
err = deflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = deflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = deflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
deflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib deflate stream
/// </summary>
protected override void CleanUp() { deflateEnd(ref _ztream); }
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data compressor, using the deflate algorithm in the ZLib dll
/// </summary>
public sealed class Deflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Deflater</c>
/// </summary>
/// <param name="level">The compression level to use for this <c>Deflater</c></param>
public Deflater(CompressLevel level) : base()
{
int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize deflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
while (err >= 0 && _ztream.avail_in > 0)
{
err = deflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = deflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = deflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
deflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib deflate stream
/// </summary>
protected override void CleanUp() { deflateEnd(ref _ztream); }
}
}

View file

@ -1,288 +1,288 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region Internal types
/// <summary>
/// Defines constants for the various flush types used with zlib
/// </summary>
internal enum FlushTypes
{
None, Partial, Sync, Full, Finish, Block
}
#region ZStream structure
// internal mapping of the zlib zstream structure for marshalling
[StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)]
internal struct ZStream
{
public IntPtr next_in;
public uint avail_in;
public uint total_in;
public IntPtr next_out;
public uint avail_out;
public uint total_out;
[MarshalAs(UnmanagedType.LPStr)]
string msg;
uint state;
uint zalloc;
uint zfree;
uint opaque;
int data_type;
public uint adler;
uint reserved;
}
#endregion
#endregion
#region Public enums
/// <summary>
/// Defines constants for the available compression levels in zlib
/// </summary>
public enum CompressLevel : int
{
/// <summary>
/// The default compression level with a reasonable compromise between compression and speed
/// </summary>
Default = -1,
/// <summary>
/// No compression at all. The data are passed straight through.
/// </summary>
None = 0,
/// <summary>
/// The maximum compression rate available.
/// </summary>
Best = 9,
/// <summary>
/// The fastest available compression level.
/// </summary>
Fastest = 1
}
#endregion
#region Exception classes
/// <summary>
/// The exception that is thrown when an error occurs on the zlib dll
/// </summary>
public class ZLibException : ApplicationException
{
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error message and error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
/// <param name="msg">A message that (hopefully) describes the error</param>
public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode))
{
}
}
#endregion
#region Interfaces
/// <summary>
/// Declares methods and properties that enables a running checksum to be calculated
/// </summary>
public interface ChecksumGenerator
{
/// <summary>
/// Gets the current value of the checksum
/// </summary>
uint Value { get; }
/// <summary>
/// Clears the current checksum to 0
/// </summary>
void Reset();
/// <summary>
/// Updates the current checksum with an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
void Update(byte[] data);
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="ArgumentNullException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
void Update(string data);
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
void Update(string data, Encoding encoding);
}
/// <summary>
/// Represents the method that will be called from a codec when new data
/// are available.
/// </summary>
/// <paramref name="data">The byte array containing the processed data</paramref>
/// <paramref name="startIndex">The index of the first processed byte in <c>data</c></paramref>
/// <paramref name="count">The number of processed bytes available</paramref>
/// <remarks>On return from this method, the data may be overwritten, so grab it while you can.
/// You cannot assume that startIndex will be zero.
/// </remarks>
public delegate void DataAvailableHandler(byte[] data, int startIndex, int count);
/// <summary>
/// Declares methods and events for implementing compressors/decompressors
/// </summary>
public interface Codec
{
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
event DataAvailableHandler DataAvailable;
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data);
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
uint Checksum { get; }
}
#endregion
#region Classes
/// <summary>
/// Encapsulates general information about the ZLib library
/// </summary>
public class Info
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint zlibCompileFlags();
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern string zlibVersion();
#endregion
#region Private stuff
private uint _flags;
// helper function that unpacks a bitsize mask
private static int bitSize(uint bits)
{
switch (bits)
{
case 0: return 16;
case 1: return 32;
case 2: return 64;
}
return -1;
}
#endregion
/// <summary>
/// Constructs an instance of the <c>Info</c> class.
/// </summary>
public Info()
{
_flags = zlibCompileFlags();
}
/// <summary>
/// True if the library is compiled with debug info
/// </summary>
public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } }
/// <summary>
/// True if the library is compiled with assembly optimizations
/// </summary>
public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } }
/// <summary>
/// Gets the size of the unsigned int that was compiled into Zlib
/// </summary>
public int SizeOfUInt { get { return bitSize(_flags & 3); } }
/// <summary>
/// Gets the size of the unsigned long that was compiled into Zlib
/// </summary>
public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } }
/// <summary>
/// Gets the size of the pointers that were compiled into Zlib
/// </summary>
public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } }
/// <summary>
/// Gets the size of the z_off_t type that was compiled into Zlib
/// </summary>
public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } }
/// <summary>
/// Gets the version of ZLib as a string, e.g. "1.2.1"
/// </summary>
public static string Version { get { return zlibVersion(); } }
}
#endregion
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region Internal types
/// <summary>
/// Defines constants for the various flush types used with zlib
/// </summary>
internal enum FlushTypes
{
None, Partial, Sync, Full, Finish, Block
}
#region ZStream structure
// internal mapping of the zlib zstream structure for marshalling
[StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)]
internal struct ZStream
{
public IntPtr next_in;
public uint avail_in;
public uint total_in;
public IntPtr next_out;
public uint avail_out;
public uint total_out;
[MarshalAs(UnmanagedType.LPStr)]
string msg;
uint state;
uint zalloc;
uint zfree;
uint opaque;
int data_type;
public uint adler;
uint reserved;
}
#endregion
#endregion
#region Public enums
/// <summary>
/// Defines constants for the available compression levels in zlib
/// </summary>
public enum CompressLevel : int
{
/// <summary>
/// The default compression level with a reasonable compromise between compression and speed
/// </summary>
Default = -1,
/// <summary>
/// No compression at all. The data are passed straight through.
/// </summary>
None = 0,
/// <summary>
/// The maximum compression rate available.
/// </summary>
Best = 9,
/// <summary>
/// The fastest available compression level.
/// </summary>
Fastest = 1
}
#endregion
#region Exception classes
/// <summary>
/// The exception that is thrown when an error occurs on the zlib dll
/// </summary>
public class ZLibException : ApplicationException
{
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error message and error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
/// <param name="msg">A message that (hopefully) describes the error</param>
public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode))
{
}
}
#endregion
#region Interfaces
/// <summary>
/// Declares methods and properties that enables a running checksum to be calculated
/// </summary>
public interface ChecksumGenerator
{
/// <summary>
/// Gets the current value of the checksum
/// </summary>
uint Value { get; }
/// <summary>
/// Clears the current checksum to 0
/// </summary>
void Reset();
/// <summary>
/// Updates the current checksum with an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
void Update(byte[] data);
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="ArgumentNullException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
void Update(string data);
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
void Update(string data, Encoding encoding);
}
/// <summary>
/// Represents the method that will be called from a codec when new data
/// are available.
/// </summary>
/// <paramref name="data">The byte array containing the processed data</paramref>
/// <paramref name="startIndex">The index of the first processed byte in <c>data</c></paramref>
/// <paramref name="count">The number of processed bytes available</paramref>
/// <remarks>On return from this method, the data may be overwritten, so grab it while you can.
/// You cannot assume that startIndex will be zero.
/// </remarks>
public delegate void DataAvailableHandler(byte[] data, int startIndex, int count);
/// <summary>
/// Declares methods and events for implementing compressors/decompressors
/// </summary>
public interface Codec
{
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
event DataAvailableHandler DataAvailable;
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data);
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
uint Checksum { get; }
}
#endregion
#region Classes
/// <summary>
/// Encapsulates general information about the ZLib library
/// </summary>
public class Info
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint zlibCompileFlags();
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern string zlibVersion();
#endregion
#region Private stuff
private uint _flags;
// helper function that unpacks a bitsize mask
private static int bitSize(uint bits)
{
switch (bits)
{
case 0: return 16;
case 1: return 32;
case 2: return 64;
}
return -1;
}
#endregion
/// <summary>
/// Constructs an instance of the <c>Info</c> class.
/// </summary>
public Info()
{
_flags = zlibCompileFlags();
}
/// <summary>
/// True if the library is compiled with debug info
/// </summary>
public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } }
/// <summary>
/// True if the library is compiled with assembly optimizations
/// </summary>
public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } }
/// <summary>
/// Gets the size of the unsigned int that was compiled into Zlib
/// </summary>
public int SizeOfUInt { get { return bitSize(_flags & 3); } }
/// <summary>
/// Gets the size of the unsigned long that was compiled into Zlib
/// </summary>
public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } }
/// <summary>
/// Gets the size of the pointers that were compiled into Zlib
/// </summary>
public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } }
/// <summary>
/// Gets the size of the z_off_t type that was compiled into Zlib
/// </summary>
public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } }
/// <summary>
/// Gets the version of ZLib as a string, e.g. "1.2.1"
/// </summary>
public static string Version { get { return zlibVersion(); } }
}
#endregion
}

View file

@ -1,105 +1,105 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data decompressor, using the inflate algorithm in the ZLib dll
/// </summary>
public class Inflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int inflateInit_(ref ZStream sz, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Inflater</c>
/// </summary>
public Inflater() : base()
{
int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize inflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
err = inflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = inflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = inflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
inflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib inflate stream
/// </summary>
protected override void CleanUp() { inflateEnd(ref _ztream); }
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data decompressor, using the inflate algorithm in the ZLib dll
/// </summary>
public class Inflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int inflateInit_(ref ZStream sz, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Inflater</c>
/// </summary>
public Inflater() : base()
{
int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize inflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
err = inflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = inflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = inflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
inflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib inflate stream
/// </summary>
protected override void CleanUp() { inflateEnd(ref _ztream); }
}
}

View file

@ -1,274 +1,274 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Collections;
using System.IO;
// uncomment the define below to include unit tests
//#define nunit
#if nunit
using NUnit.Framework;
// Unit tests for the DotZLib class library
// ----------------------------------------
//
// Use this with NUnit 2 from http://www.nunit.org
//
namespace DotZLibTests
{
using DotZLib;
// helper methods
internal class Utils
{
public static bool byteArrEqual( byte[] lhs, byte[] rhs )
{
if (lhs.Length != rhs.Length)
return false;
for (int i = lhs.Length-1; i >= 0; --i)
if (lhs[i] != rhs[i])
return false;
return true;
}
}
[TestFixture]
public class CircBufferTests
{
#region Circular buffer tests
[Test]
public void SinglePutGet()
{
CircularBuffer buf = new CircularBuffer(10);
Assert.AreEqual( 0, buf.Size );
Assert.AreEqual( -1, buf.Get() );
Assert.IsTrue(buf.Put( 1 ));
Assert.AreEqual( 1, buf.Size );
Assert.AreEqual( 1, buf.Get() );
Assert.AreEqual( 0, buf.Size );
Assert.AreEqual( -1, buf.Get() );
}
[Test]
public void BlockPutGet()
{
CircularBuffer buf = new CircularBuffer(10);
byte[] arr = {1,2,3,4,5,6,7,8,9,10};
Assert.AreEqual( 10, buf.Put(arr,0,10) );
Assert.AreEqual( 10, buf.Size );
Assert.IsFalse( buf.Put(11) );
Assert.AreEqual( 1, buf.Get() );
Assert.IsTrue( buf.Put(11) );
byte[] arr2 = (byte[])arr.Clone();
Assert.AreEqual( 9, buf.Get(arr2,1,9) );
Assert.IsTrue( Utils.byteArrEqual(arr,arr2) );
}
#endregion
}
[TestFixture]
public class ChecksumTests
{
#region CRC32 Tests
[Test]
public void CRC32_Null()
{
CRC32Checksum crc32 = new CRC32Checksum();
Assert.AreEqual( 0, crc32.Value );
crc32 = new CRC32Checksum(1);
Assert.AreEqual( 1, crc32.Value );
crc32 = new CRC32Checksum(556);
Assert.AreEqual( 556, crc32.Value );
}
[Test]
public void CRC32_Data()
{
CRC32Checksum crc32 = new CRC32Checksum();
byte[] data = { 1,2,3,4,5,6,7 };
crc32.Update(data);
Assert.AreEqual( 0x70e46888, crc32.Value );
crc32 = new CRC32Checksum();
crc32.Update("penguin");
Assert.AreEqual( 0x0e5c1a120, crc32.Value );
crc32 = new CRC32Checksum(1);
crc32.Update("penguin");
Assert.AreEqual(0x43b6aa94, crc32.Value);
}
#endregion
#region Adler tests
[Test]
public void Adler_Null()
{
AdlerChecksum adler = new AdlerChecksum();
Assert.AreEqual(0, adler.Value);
adler = new AdlerChecksum(1);
Assert.AreEqual( 1, adler.Value );
adler = new AdlerChecksum(556);
Assert.AreEqual( 556, adler.Value );
}
[Test]
public void Adler_Data()
{
AdlerChecksum adler = new AdlerChecksum(1);
byte[] data = { 1,2,3,4,5,6,7 };
adler.Update(data);
Assert.AreEqual( 0x5b001d, adler.Value );
adler = new AdlerChecksum();
adler.Update("penguin");
Assert.AreEqual(0x0bcf02f6, adler.Value );
adler = new AdlerChecksum(1);
adler.Update("penguin");
Assert.AreEqual(0x0bd602f7, adler.Value);
}
#endregion
}
[TestFixture]
public class InfoTests
{
#region Info tests
[Test]
public void Info_Version()
{
Info info = new Info();
Assert.AreEqual("1.2.5", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer);
Assert.AreEqual(32, info.SizeOfOffset);
}
#endregion
}
[TestFixture]
public class DeflateInflateTests
{
#region Deflate tests
[Test]
public void Deflate_Init()
{
using (Deflater def = new Deflater(CompressLevel.Default))
{
}
}
private ArrayList compressedData = new ArrayList();
private uint adler1;
private ArrayList uncompressedData = new ArrayList();
private uint adler2;
public void CDataAvail(byte[] data, int startIndex, int count)
{
for (int i = 0; i < count; ++i)
compressedData.Add(data[i+startIndex]);
}
[Test]
public void Deflate_Compress()
{
compressedData.Clear();
byte[] testData = new byte[35000];
for (int i = 0; i < testData.Length; ++i)
testData[i] = 5;
using (Deflater def = new Deflater((CompressLevel)5))
{
def.DataAvailable += new DataAvailableHandler(CDataAvail);
def.Add(testData);
def.Finish();
adler1 = def.Checksum;
}
}
#endregion
#region Inflate tests
[Test]
public void Inflate_Init()
{
using (Inflater inf = new Inflater())
{
}
}
private void DDataAvail(byte[] data, int startIndex, int count)
{
for (int i = 0; i < count; ++i)
uncompressedData.Add(data[i+startIndex]);
}
[Test]
public void Inflate_Expand()
{
uncompressedData.Clear();
using (Inflater inf = new Inflater())
{
inf.DataAvailable += new DataAvailableHandler(DDataAvail);
inf.Add((byte[])compressedData.ToArray(typeof(byte)));
inf.Finish();
adler2 = inf.Checksum;
}
Assert.AreEqual( adler1, adler2 );
}
#endregion
}
[TestFixture]
public class GZipStreamTests
{
#region GZipStream test
[Test]
public void GZipStream_WriteRead()
{
using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best))
{
BinaryWriter writer = new BinaryWriter(gzOut);
writer.Write("hi there");
writer.Write(Math.PI);
writer.Write(42);
}
using (GZipStream gzIn = new GZipStream("gzstream.gz"))
{
BinaryReader reader = new BinaryReader(gzIn);
string s = reader.ReadString();
Assert.AreEqual("hi there",s);
double d = reader.ReadDouble();
Assert.AreEqual(Math.PI, d);
int i = reader.ReadInt32();
Assert.AreEqual(42,i);
}
}
#endregion
}
}
#endif
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Collections;
using System.IO;
// uncomment the define below to include unit tests
//#define nunit
#if nunit
using NUnit.Framework;
// Unit tests for the DotZLib class library
// ----------------------------------------
//
// Use this with NUnit 2 from http://www.nunit.org
//
namespace DotZLibTests
{
using DotZLib;
// helper methods
internal class Utils
{
public static bool byteArrEqual( byte[] lhs, byte[] rhs )
{
if (lhs.Length != rhs.Length)
return false;
for (int i = lhs.Length-1; i >= 0; --i)
if (lhs[i] != rhs[i])
return false;
return true;
}
}
[TestFixture]
public class CircBufferTests
{
#region Circular buffer tests
[Test]
public void SinglePutGet()
{
CircularBuffer buf = new CircularBuffer(10);
Assert.AreEqual( 0, buf.Size );
Assert.AreEqual( -1, buf.Get() );
Assert.IsTrue(buf.Put( 1 ));
Assert.AreEqual( 1, buf.Size );
Assert.AreEqual( 1, buf.Get() );
Assert.AreEqual( 0, buf.Size );
Assert.AreEqual( -1, buf.Get() );
}
[Test]
public void BlockPutGet()
{
CircularBuffer buf = new CircularBuffer(10);
byte[] arr = {1,2,3,4,5,6,7,8,9,10};
Assert.AreEqual( 10, buf.Put(arr,0,10) );
Assert.AreEqual( 10, buf.Size );
Assert.IsFalse( buf.Put(11) );
Assert.AreEqual( 1, buf.Get() );
Assert.IsTrue( buf.Put(11) );
byte[] arr2 = (byte[])arr.Clone();
Assert.AreEqual( 9, buf.Get(arr2,1,9) );
Assert.IsTrue( Utils.byteArrEqual(arr,arr2) );
}
#endregion
}
[TestFixture]
public class ChecksumTests
{
#region CRC32 Tests
[Test]
public void CRC32_Null()
{
CRC32Checksum crc32 = new CRC32Checksum();
Assert.AreEqual( 0, crc32.Value );
crc32 = new CRC32Checksum(1);
Assert.AreEqual( 1, crc32.Value );
crc32 = new CRC32Checksum(556);
Assert.AreEqual( 556, crc32.Value );
}
[Test]
public void CRC32_Data()
{
CRC32Checksum crc32 = new CRC32Checksum();
byte[] data = { 1,2,3,4,5,6,7 };
crc32.Update(data);
Assert.AreEqual( 0x70e46888, crc32.Value );
crc32 = new CRC32Checksum();
crc32.Update("penguin");
Assert.AreEqual( 0x0e5c1a120, crc32.Value );
crc32 = new CRC32Checksum(1);
crc32.Update("penguin");
Assert.AreEqual(0x43b6aa94, crc32.Value);
}
#endregion
#region Adler tests
[Test]
public void Adler_Null()
{
AdlerChecksum adler = new AdlerChecksum();
Assert.AreEqual(0, adler.Value);
adler = new AdlerChecksum(1);
Assert.AreEqual( 1, adler.Value );
adler = new AdlerChecksum(556);
Assert.AreEqual( 556, adler.Value );
}
[Test]
public void Adler_Data()
{
AdlerChecksum adler = new AdlerChecksum(1);
byte[] data = { 1,2,3,4,5,6,7 };
adler.Update(data);
Assert.AreEqual( 0x5b001d, adler.Value );
adler = new AdlerChecksum();
adler.Update("penguin");
Assert.AreEqual(0x0bcf02f6, adler.Value );
adler = new AdlerChecksum(1);
adler.Update("penguin");
Assert.AreEqual(0x0bd602f7, adler.Value);
}
#endregion
}
[TestFixture]
public class InfoTests
{
#region Info tests
[Test]
public void Info_Version()
{
Info info = new Info();
Assert.AreEqual("1.2.5", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer);
Assert.AreEqual(32, info.SizeOfOffset);
}
#endregion
}
[TestFixture]
public class DeflateInflateTests
{
#region Deflate tests
[Test]
public void Deflate_Init()
{
using (Deflater def = new Deflater(CompressLevel.Default))
{
}
}
private ArrayList compressedData = new ArrayList();
private uint adler1;
private ArrayList uncompressedData = new ArrayList();
private uint adler2;
public void CDataAvail(byte[] data, int startIndex, int count)
{
for (int i = 0; i < count; ++i)
compressedData.Add(data[i+startIndex]);
}
[Test]
public void Deflate_Compress()
{
compressedData.Clear();
byte[] testData = new byte[35000];
for (int i = 0; i < testData.Length; ++i)
testData[i] = 5;
using (Deflater def = new Deflater((CompressLevel)5))
{
def.DataAvailable += new DataAvailableHandler(CDataAvail);
def.Add(testData);
def.Finish();
adler1 = def.Checksum;
}
}
#endregion
#region Inflate tests
[Test]
public void Inflate_Init()
{
using (Inflater inf = new Inflater())
{
}
}
private void DDataAvail(byte[] data, int startIndex, int count)
{
for (int i = 0; i < count; ++i)
uncompressedData.Add(data[i+startIndex]);
}
[Test]
public void Inflate_Expand()
{
uncompressedData.Clear();
using (Inflater inf = new Inflater())
{
inf.DataAvailable += new DataAvailableHandler(DDataAvail);
inf.Add((byte[])compressedData.ToArray(typeof(byte)));
inf.Finish();
adler2 = inf.Checksum;
}
Assert.AreEqual( adler1, adler2 );
}
#endregion
}
[TestFixture]
public class GZipStreamTests
{
#region GZipStream test
[Test]
public void GZipStream_WriteRead()
{
using (GZipStream gzOut = new GZipStream("gzstream.gz", CompressLevel.Best))
{
BinaryWriter writer = new BinaryWriter(gzOut);
writer.Write("hi there");
writer.Write(Math.PI);
writer.Write(42);
}
using (GZipStream gzIn = new GZipStream("gzstream.gz"))
{
BinaryReader reader = new BinaryReader(gzIn);
string s = reader.ReadString();
Assert.AreEqual("hi there",s);
double d = reader.ReadDouble();
Assert.AreEqual(Math.PI, d);
int i = reader.ReadInt32();
Assert.AreEqual(42,i);
}
}
#endregion
}
}
#endif

View file

@ -1,23 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
Boost Software License - Version 1.0 - August 17th, 2003
Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:
The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.
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, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

File diff suppressed because it is too large Load diff

View file

@ -1,396 +1,396 @@
; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding
; version for AMD64 on Windows using Microsoft C compiler
;
; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
; inffasx64.asm is called by inffas8664.c, which contain more info.
; to compile this file, I use option
; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm
; with Microsoft Macro Assembler (x64) for AMD64
;
; This file compile with Microsoft Macro Assembler (x64) for AMD64
;
; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK
;
; (you can get Windows WDK with ml64 for AMD64 from
; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price)
;
.code
inffas8664fnc PROC
; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and
; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp
;
; All registers must be preserved across the call, except for
; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch.
mov [rsp-8],rsi
mov [rsp-16],rdi
mov [rsp-24],r12
mov [rsp-32],r13
mov [rsp-40],r14
mov [rsp-48],r15
mov [rsp-56],rbx
mov rax,rcx
mov [rax+8], rbp ; /* save regs rbp and rsp */
mov [rax], rsp
mov rsp, rax ; /* make rsp point to &ar */
mov rsi, [rsp+16] ; /* rsi = in */
mov rdi, [rsp+32] ; /* rdi = out */
mov r9, [rsp+24] ; /* r9 = last */
mov r10, [rsp+48] ; /* r10 = end */
mov rbp, [rsp+64] ; /* rbp = lcode */
mov r11, [rsp+72] ; /* r11 = dcode */
mov rdx, [rsp+80] ; /* rdx = hold */
mov ebx, [rsp+88] ; /* ebx = bits */
mov r12d, [rsp+100] ; /* r12d = lmask */
mov r13d, [rsp+104] ; /* r13d = dmask */
; /* r14d = len */
; /* r15d = dist */
cld
cmp r10, rdi
je L_one_time ; /* if only one decode left */
cmp r9, rsi
jne L_do_loop
L_one_time:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code_one_time
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
jmp L_get_length_code_one_time
ALIGN 4
L_while_test:
cmp r10, rdi
jbe L_break_loop
cmp r9, rsi
jbe L_break_loop
L_do_loop:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_length_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
mov r8, r12 ; /* r8 = lmask */
shr eax, 16 ; /* output this.val char */
stosb
L_get_length_code_one_time:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
L_dolen:
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
shr eax, 16 ; /* output this.val char */
stosb
jmp L_while_test
ALIGN 4
L_test_for_length_base:
mov r14d, eax ; /* len = this */
shr r14d, 16 ; /* len = this.val */
mov cl, al
test al, 16
jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */
and cl, 15 ; /* op &= 15 */
jz L_decode_distance ; /* if (!op) */
L_add_bits_to_len:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r14d, eax ; /* len += hold & mask[op] */
L_decode_distance:
mov r8, r13 ; /* r8 = dmask */
cmp bl, 32
ja L_get_distance_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_distance_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */
L_dodist:
mov r15d, eax ; /* dist = this */
shr r15d, 16 ; /* dist = this.val */
mov cl, ah
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
mov cl, al ; /* cl = this.op */
test al, 16 ; /* if ((op & 16) == 0) */
jz L_test_for_second_level_dist
and cl, 15 ; /* op &= 15 */
jz L_check_dist_one
L_add_bits_to_dist:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax ; /* (1 << op) - 1 */
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r15d, eax ; /* dist += hold & ((1 << op) - 1) */
L_check_window:
mov r8, rsi ; /* save in so from can use it's reg */
mov rax, rdi
sub rax, [rsp+40] ; /* nbytes = out - beg */
cmp eax, r15d
jb L_clip_window ; /* if (dist > nbytes) 4.2% */
mov ecx, r14d ; /* ecx = len */
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
sar ecx, 1
jnc L_copy_two ; /* if len % 2 == 0 */
rep movsw
mov al, [rsi]
mov [rdi], al
inc rdi
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
L_copy_two:
rep movsw
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
ALIGN 4
L_check_dist_one:
cmp r15d, 1 ; /* if dist 1, is a memset */
jne L_check_window
cmp [rsp+40], rdi ; /* if out == beg, outside window */
je L_check_window
mov ecx, r14d ; /* ecx = len */
mov al, [rdi-1]
mov ah, al
sar ecx, 1
jnc L_set_two
mov [rdi], al
inc rdi
L_set_two:
rep stosw
jmp L_while_test
ALIGN 4
L_test_for_second_level_length:
test al, 64
jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r14d ; /* eax += len */
mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/
jmp L_dolen
ALIGN 4
L_test_for_second_level_dist:
test al, 64
jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r15d ; /* eax += dist */
mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/
jmp L_dodist
ALIGN 4
L_clip_window:
mov ecx, eax ; /* ecx = nbytes */
mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */
neg ecx ; /* nbytes = -nbytes */
cmp eax, r15d
jb L_invalid_distance_too_far ; /* if (dist > wsize) */
add ecx, r15d ; /* nbytes = dist - nbytes */
cmp dword ptr [rsp+96], 0
jne L_wrap_around_window ; /* if (write != 0) */
mov rsi, [rsp+56] ; /* from = window */
sub eax, ecx ; /* eax -= nbytes */
add rsi, rax ; /* from += wsize - nbytes */
mov eax, r14d ; /* eax = len */
cmp r14d, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* eax -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = &out[ -dist ] */
jmp L_do_copy
ALIGN 4
L_wrap_around_window:
mov eax, [rsp+96] ; /* eax = write */
cmp ecx, eax
jbe L_contiguous_in_window ; /* if (write >= nbytes) */
mov esi, [rsp+92] ; /* from = wsize */
add rsi, [rsp+56] ; /* from += window */
add rsi, rax ; /* from += write */
sub rsi, rcx ; /* from -= nbytes */
sub ecx, eax ; /* nbytes -= write */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, [rsp+56] ; /* from = window */
mov ecx, [rsp+96] ; /* nbytes = write */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy
ALIGN 4
L_contiguous_in_window:
mov rsi, [rsp+56] ; /* rsi = window */
add rsi, rax
sub rsi, rcx ; /* from += write - nbytes */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy ; /* if (nbytes >= len) */
ALIGN 4
L_do_copy:
mov ecx, eax ; /* ecx = len */
rep movsb
mov rsi, r8 ; /* move in back to %esi, toss from */
jmp L_while_test
L_test_for_end_of_block:
test al, 32
jz L_invalid_literal_length_code
mov dword ptr [rsp+116], 1
jmp L_break_loop_with_status
L_invalid_literal_length_code:
mov dword ptr [rsp+116], 2
jmp L_break_loop_with_status
L_invalid_distance_code:
mov dword ptr [rsp+116], 3
jmp L_break_loop_with_status
L_invalid_distance_too_far:
mov dword ptr [rsp+116], 4
jmp L_break_loop_with_status
L_break_loop:
mov dword ptr [rsp+116], 0
L_break_loop_with_status:
; /* put in, out, bits, and hold back into ar and pop esp */
mov [rsp+16], rsi ; /* in */
mov [rsp+32], rdi ; /* out */
mov [rsp+88], ebx ; /* bits */
mov [rsp+80], rdx ; /* hold */
mov rax, [rsp] ; /* restore rbp and rsp */
mov rbp, [rsp+8]
mov rsp, rax
mov rsi,[rsp-8]
mov rdi,[rsp-16]
mov r12,[rsp-24]
mov r13,[rsp-32]
mov r14,[rsp-40]
mov r15,[rsp-48]
mov rbx,[rsp-56]
ret 0
; :
; : "m" (ar)
; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi",
; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
; );
inffas8664fnc ENDP
;_TEXT ENDS
END
; inffasx64.asm is a hand tuned assembler version of inffast.c - fast decoding
; version for AMD64 on Windows using Microsoft C compiler
;
; inffasx64.asm is automatically convert from AMD64 portion of inffas86.c
; inffasx64.asm is called by inffas8664.c, which contain more info.
; to compile this file, I use option
; ml64.exe /Flinffasx64 /c /Zi inffasx64.asm
; with Microsoft Macro Assembler (x64) for AMD64
;
; This file compile with Microsoft Macro Assembler (x64) for AMD64
;
; ml64.exe is given with Visual Studio 2005/2008/2010 and Windows WDK
;
; (you can get Windows WDK with ml64 for AMD64 from
; http://www.microsoft.com/whdc/Devtools/wdk/default.mspx for low price)
;
.code
inffas8664fnc PROC
; see http://weblogs.asp.net/oldnewthing/archive/2004/01/14/58579.aspx and
; http://msdn.microsoft.com/library/en-us/kmarch/hh/kmarch/64bitAMD_8e951dd2-ee77-4728-8702-55ce4b5dd24a.xml.asp
;
; All registers must be preserved across the call, except for
; rax, rcx, rdx, r8, r-9, r10, and r11, which are scratch.
mov [rsp-8],rsi
mov [rsp-16],rdi
mov [rsp-24],r12
mov [rsp-32],r13
mov [rsp-40],r14
mov [rsp-48],r15
mov [rsp-56],rbx
mov rax,rcx
mov [rax+8], rbp ; /* save regs rbp and rsp */
mov [rax], rsp
mov rsp, rax ; /* make rsp point to &ar */
mov rsi, [rsp+16] ; /* rsi = in */
mov rdi, [rsp+32] ; /* rdi = out */
mov r9, [rsp+24] ; /* r9 = last */
mov r10, [rsp+48] ; /* r10 = end */
mov rbp, [rsp+64] ; /* rbp = lcode */
mov r11, [rsp+72] ; /* r11 = dcode */
mov rdx, [rsp+80] ; /* rdx = hold */
mov ebx, [rsp+88] ; /* ebx = bits */
mov r12d, [rsp+100] ; /* r12d = lmask */
mov r13d, [rsp+104] ; /* r13d = dmask */
; /* r14d = len */
; /* r15d = dist */
cld
cmp r10, rdi
je L_one_time ; /* if only one decode left */
cmp r9, rsi
jne L_do_loop
L_one_time:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code_one_time
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
jmp L_get_length_code_one_time
ALIGN 4
L_while_test:
cmp r10, rdi
jbe L_break_loop
cmp r9, rsi
jbe L_break_loop
L_do_loop:
mov r8, r12 ; /* r8 = lmask */
cmp bl, 32
ja L_get_length_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_length_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
mov r8, r12 ; /* r8 = lmask */
shr eax, 16 ; /* output this.val char */
stosb
L_get_length_code_one_time:
and r8, rdx ; /* r8 &= hold */
mov eax, [rbp+r8*4] ; /* eax = lcode[hold & lmask] */
L_dolen:
mov cl, ah ; /* cl = this.bits */
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
test al, al
jnz L_test_for_length_base ; /* if (op != 0) 45.7% */
shr eax, 16 ; /* output this.val char */
stosb
jmp L_while_test
ALIGN 4
L_test_for_length_base:
mov r14d, eax ; /* len = this */
shr r14d, 16 ; /* len = this.val */
mov cl, al
test al, 16
jz L_test_for_second_level_length ; /* if ((op & 16) == 0) 8% */
and cl, 15 ; /* op &= 15 */
jz L_decode_distance ; /* if (!op) */
L_add_bits_to_len:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r14d, eax ; /* len += hold & mask[op] */
L_decode_distance:
mov r8, r13 ; /* r8 = dmask */
cmp bl, 32
ja L_get_distance_code ; /* if (32 < bits) */
lodsd ; /* eax = *(uint *)in++ */
mov cl, bl ; /* cl = bits, needs it for shifting */
add bl, 32 ; /* bits += 32 */
shl rax, cl
or rdx, rax ; /* hold |= *((uint *)in)++ << bits */
L_get_distance_code:
and r8, rdx ; /* r8 &= hold */
mov eax, [r11+r8*4] ; /* eax = dcode[hold & dmask] */
L_dodist:
mov r15d, eax ; /* dist = this */
shr r15d, 16 ; /* dist = this.val */
mov cl, ah
sub bl, ah ; /* bits -= this.bits */
shr rdx, cl ; /* hold >>= this.bits */
mov cl, al ; /* cl = this.op */
test al, 16 ; /* if ((op & 16) == 0) */
jz L_test_for_second_level_dist
and cl, 15 ; /* op &= 15 */
jz L_check_dist_one
L_add_bits_to_dist:
sub bl, cl
xor eax, eax
inc eax
shl eax, cl
dec eax ; /* (1 << op) - 1 */
and eax, edx ; /* eax &= hold */
shr rdx, cl
add r15d, eax ; /* dist += hold & ((1 << op) - 1) */
L_check_window:
mov r8, rsi ; /* save in so from can use it's reg */
mov rax, rdi
sub rax, [rsp+40] ; /* nbytes = out - beg */
cmp eax, r15d
jb L_clip_window ; /* if (dist > nbytes) 4.2% */
mov ecx, r14d ; /* ecx = len */
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
sar ecx, 1
jnc L_copy_two ; /* if len % 2 == 0 */
rep movsw
mov al, [rsi]
mov [rdi], al
inc rdi
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
L_copy_two:
rep movsw
mov rsi, r8 ; /* move in back to %rsi, toss from */
jmp L_while_test
ALIGN 4
L_check_dist_one:
cmp r15d, 1 ; /* if dist 1, is a memset */
jne L_check_window
cmp [rsp+40], rdi ; /* if out == beg, outside window */
je L_check_window
mov ecx, r14d ; /* ecx = len */
mov al, [rdi-1]
mov ah, al
sar ecx, 1
jnc L_set_two
mov [rdi], al
inc rdi
L_set_two:
rep stosw
jmp L_while_test
ALIGN 4
L_test_for_second_level_length:
test al, 64
jnz L_test_for_end_of_block ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r14d ; /* eax += len */
mov eax, [rbp+rax*4] ; /* eax = lcode[val+(hold&mask[op])]*/
jmp L_dolen
ALIGN 4
L_test_for_second_level_dist:
test al, 64
jnz L_invalid_distance_code ; /* if ((op & 64) != 0) */
xor eax, eax
inc eax
shl eax, cl
dec eax
and eax, edx ; /* eax &= hold */
add eax, r15d ; /* eax += dist */
mov eax, [r11+rax*4] ; /* eax = dcode[val+(hold&mask[op])]*/
jmp L_dodist
ALIGN 4
L_clip_window:
mov ecx, eax ; /* ecx = nbytes */
mov eax, [rsp+92] ; /* eax = wsize, prepare for dist cmp */
neg ecx ; /* nbytes = -nbytes */
cmp eax, r15d
jb L_invalid_distance_too_far ; /* if (dist > wsize) */
add ecx, r15d ; /* nbytes = dist - nbytes */
cmp dword ptr [rsp+96], 0
jne L_wrap_around_window ; /* if (write != 0) */
mov rsi, [rsp+56] ; /* from = window */
sub eax, ecx ; /* eax -= nbytes */
add rsi, rax ; /* from += wsize - nbytes */
mov eax, r14d ; /* eax = len */
cmp r14d, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* eax -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = &out[ -dist ] */
jmp L_do_copy
ALIGN 4
L_wrap_around_window:
mov eax, [rsp+96] ; /* eax = write */
cmp ecx, eax
jbe L_contiguous_in_window ; /* if (write >= nbytes) */
mov esi, [rsp+92] ; /* from = wsize */
add rsi, [rsp+56] ; /* from += window */
add rsi, rax ; /* from += write */
sub rsi, rcx ; /* from -= nbytes */
sub ecx, eax ; /* nbytes -= write */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, [rsp+56] ; /* from = window */
mov ecx, [rsp+96] ; /* nbytes = write */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy
ALIGN 4
L_contiguous_in_window:
mov rsi, [rsp+56] ; /* rsi = window */
add rsi, rax
sub rsi, rcx ; /* from += write - nbytes */
mov eax, r14d ; /* eax = len */
cmp eax, ecx
jbe L_do_copy ; /* if (nbytes >= len) */
sub eax, ecx ; /* len -= nbytes */
rep movsb
mov rsi, rdi
sub rsi, r15 ; /* from = out - dist */
jmp L_do_copy ; /* if (nbytes >= len) */
ALIGN 4
L_do_copy:
mov ecx, eax ; /* ecx = len */
rep movsb
mov rsi, r8 ; /* move in back to %esi, toss from */
jmp L_while_test
L_test_for_end_of_block:
test al, 32
jz L_invalid_literal_length_code
mov dword ptr [rsp+116], 1
jmp L_break_loop_with_status
L_invalid_literal_length_code:
mov dword ptr [rsp+116], 2
jmp L_break_loop_with_status
L_invalid_distance_code:
mov dword ptr [rsp+116], 3
jmp L_break_loop_with_status
L_invalid_distance_too_far:
mov dword ptr [rsp+116], 4
jmp L_break_loop_with_status
L_break_loop:
mov dword ptr [rsp+116], 0
L_break_loop_with_status:
; /* put in, out, bits, and hold back into ar and pop esp */
mov [rsp+16], rsi ; /* in */
mov [rsp+32], rdi ; /* out */
mov [rsp+88], ebx ; /* bits */
mov [rsp+80], rdx ; /* hold */
mov rax, [rsp] ; /* restore rbp and rsp */
mov rbp, [rsp+8]
mov rsp, rax
mov rsi,[rsp-8]
mov rdi,[rsp-16]
mov r12,[rsp-24]
mov r13,[rsp-32]
mov r14,[rsp-40]
mov r15,[rsp-48]
mov rbx,[rsp-56]
ret 0
; :
; : "m" (ar)
; : "memory", "%rax", "%rbx", "%rcx", "%rdx", "%rsi", "%rdi",
; "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
; );
inffas8664fnc ENDP
;_TEXT ENDS
END

View file

@ -1,31 +1,31 @@
Summary
-------
This directory contains ASM implementations of the functions
longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t),
for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits.
gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits
assembly optimized version from Jean-loup Gailly original longest_match function
inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing
original function from Mark Adler
Use instructions
----------------
Assemble the .asm files using MASM and put the object files into the zlib source
directory. You can also get object files here:
http://www.winimage.com/zLibDll/zlib124_masm_obj.zip
define ASMV and ASMINF in your project. Include inffas8664.c in your source tree,
and inffasx64.obj and gvmat64.obj as object to link.
Build instructions
------------------
run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe)
ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK
You can get Windows 2003 server DDK with ml64 and cl for AMD64 from
http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price)
Summary
-------
This directory contains ASM implementations of the functions
longest_match() and inflate_fast(), for 64 bits x86 (both AMD64 and Intel EM64t),
for use with Microsoft Macro Assembler (x64) for AMD64 and Microsoft C++ 64 bits.
gvmat64.asm is written by Gilles Vollant (2005), by using Brian Raiter 686/32 bits
assembly optimized version from Jean-loup Gailly original longest_match function
inffasx64.asm and inffas8664.c were written by Chris Anderson, by optimizing
original function from Mark Adler
Use instructions
----------------
Assemble the .asm files using MASM and put the object files into the zlib source
directory. You can also get object files here:
http://www.winimage.com/zLibDll/zlib124_masm_obj.zip
define ASMV and ASMINF in your project. Include inffas8664.c in your source tree,
and inffasx64.obj and gvmat64.obj as object to link.
Build instructions
------------------
run bld_64.bat with Microsoft Macro Assembler (x64) for AMD64 (ml64.exe)
ml64.exe is given with Visual Studio 2005, Windows 2003 server DDK
You can get Windows 2003 server DDK with ml64 and cl for AMD64 from
http://www.microsoft.com/whdc/devtools/ddk/default.mspx for low price)

View file

@ -1,2 +1,2 @@
ml /coff /Zi /c /Flmatch686.lst match686.asm
ml /coff /Zi /c /Flinffas32.lst inffas32.asm
ml /coff /Zi /c /Flmatch686.lst match686.asm
ml /coff /Zi /c /Flinffas32.lst inffas32.asm

File diff suppressed because it is too large Load diff

View file

@ -1,478 +1,478 @@
; match686.asm -- Asm portion of the optimized longest_match for 32 bits x86
; Copyright (C) 1995-1996 Jean-loup Gailly, Brian Raiter and Gilles Vollant.
; File written by Gilles Vollant, by converting match686.S from Brian Raiter
; for MASM. This is as assembly version of longest_match
; from Jean-loup Gailly in deflate.c
;
; http://www.zlib.net
; http://www.winimage.com/zLibDll
; http://www.muppetlabs.com/~breadbox/software/assembly.html
;
; For Visual C++ 4.x and higher and ML 6.x and higher
; ml.exe is distributed in
; http://www.microsoft.com/downloads/details.aspx?FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64
;
; this file contain two implementation of longest_match
;
; this longest_match was written by Brian raiter (1998), optimized for Pentium Pro
; (and the faster known version of match_init on modern Core 2 Duo and AMD Phenom)
;
; for using an assembly version of longest_match, you need define ASMV in project
;
; compile the asm file running
; ml /coff /Zi /c /Flmatch686.lst match686.asm
; and do not include match686.obj in your project
;
; note: contrib of zLib 1.2.3 and earlier contained both a deprecated version for
; Pentium (prior Pentium Pro) and this version for Pentium Pro and modern processor
; with autoselect (with cpu detection code)
; if you want support the old pentium optimization, you can still use these version
;
; this file is not optimized for old pentium, but it compatible with all x86 32 bits
; processor (starting 80386)
;
;
; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2
;uInt longest_match(s, cur_match)
; deflate_state *s;
; IPos cur_match; /* current match */
NbStack equ 76
cur_match equ dword ptr[esp+NbStack-0]
str_s equ dword ptr[esp+NbStack-4]
; 5 dword on top (ret,ebp,esi,edi,ebx)
adrret equ dword ptr[esp+NbStack-8]
pushebp equ dword ptr[esp+NbStack-12]
pushedi equ dword ptr[esp+NbStack-16]
pushesi equ dword ptr[esp+NbStack-20]
pushebx equ dword ptr[esp+NbStack-24]
chain_length equ dword ptr [esp+NbStack-28]
limit equ dword ptr [esp+NbStack-32]
best_len equ dword ptr [esp+NbStack-36]
window equ dword ptr [esp+NbStack-40]
prev equ dword ptr [esp+NbStack-44]
scan_start equ word ptr [esp+NbStack-48]
wmask equ dword ptr [esp+NbStack-52]
match_start_ptr equ dword ptr [esp+NbStack-56]
nice_match equ dword ptr [esp+NbStack-60]
scan equ dword ptr [esp+NbStack-64]
windowlen equ dword ptr [esp+NbStack-68]
match_start equ dword ptr [esp+NbStack-72]
strend equ dword ptr [esp+NbStack-76]
NbStackAdd equ (NbStack-24)
.386p
name gvmatch
.MODEL FLAT
; all the +zlib1222add offsets are due to the addition of fields
; in zlib in the deflate_state structure since the asm code was first written
; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
zlib1222add equ 8
; Note : these value are good with a 8 bytes boundary pack structure
dep_chain_length equ 74h+zlib1222add
dep_window equ 30h+zlib1222add
dep_strstart equ 64h+zlib1222add
dep_prev_length equ 70h+zlib1222add
dep_nice_match equ 88h+zlib1222add
dep_w_size equ 24h+zlib1222add
dep_prev equ 38h+zlib1222add
dep_w_mask equ 2ch+zlib1222add
dep_good_match equ 84h+zlib1222add
dep_match_start equ 68h+zlib1222add
dep_lookahead equ 6ch+zlib1222add
_TEXT segment
IFDEF NOUNDERLINE
public longest_match
public match_init
ELSE
public _longest_match
public _match_init
ENDIF
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1)
MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h)
;;; stack frame offsets
chainlenwmask equ esp + 0 ; high word: current chain len
; low word: s->wmask
window equ esp + 4 ; local copy of s->window
windowbestlen equ esp + 8 ; s->window + bestlen
scanstart equ esp + 16 ; first two bytes of string
scanend equ esp + 12 ; last two bytes of string
scanalign equ esp + 20 ; dword-misalignment of string
nicematch equ esp + 24 ; a good enough match size
bestlen equ esp + 28 ; size of best match so far
scan equ esp + 32 ; ptr to string wanting match
LocalVarsSize equ 36
; saved ebx byte esp + 36
; saved edi byte esp + 40
; saved esi byte esp + 44
; saved ebp byte esp + 48
; return address byte esp + 52
deflatestate equ esp + 56 ; the function arguments
curmatch equ esp + 60
;;; Offsets for fields in the deflate_state structure. These numbers
;;; are calculated from the definition of deflate_state, with the
;;; assumption that the compiler will dword-align the fields. (Thus,
;;; changing the definition of deflate_state could easily cause this
;;; program to crash horribly, without so much as a warning at
;;; compile time. Sigh.)
dsWSize equ 36+zlib1222add
dsWMask equ 44+zlib1222add
dsWindow equ 48+zlib1222add
dsPrev equ 56+zlib1222add
dsMatchLen equ 88+zlib1222add
dsPrevMatch equ 92+zlib1222add
dsStrStart equ 100+zlib1222add
dsMatchStart equ 104+zlib1222add
dsLookahead equ 108+zlib1222add
dsPrevLen equ 112+zlib1222add
dsMaxChainLen equ 116+zlib1222add
dsGoodMatch equ 132+zlib1222add
dsNiceMatch equ 136+zlib1222add
;;; match686.asm -- Pentium-Pro-optimized version of longest_match()
;;; Written for zlib 1.1.2
;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html
;;;
;;
;; This software is provided 'as-is', without any express or implied
;; warranty. In no event will the authors be held liable for any damages
;; arising from the use of this software.
;;
;; Permission is granted to anyone to use this software for any purpose,
;; including commercial applications, and to alter it and redistribute it
;; freely, subject to the following restrictions:
;;
;; 1. The origin of this software must not be misrepresented; you must not
;; claim that you wrote the original software. If you use this software
;; in a product, an acknowledgment in the product documentation would be
;; appreciated but is not required.
;; 2. Altered source versions must be plainly marked as such, and must not be
;; misrepresented as being the original software
;; 3. This notice may not be removed or altered from any source distribution.
;;
;GLOBAL _longest_match, _match_init
;SECTION .text
;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch)
;_longest_match:
IFDEF NOUNDERLINE
longest_match proc near
ELSE
_longest_match proc near
ENDIF
;;; Save registers that the compiler may be using, and adjust esp to
;;; make room for our stack frame.
push ebp
push edi
push esi
push ebx
sub esp, LocalVarsSize
;;; Retrieve the function arguments. ecx will hold cur_match
;;; throughout the entire function. edx will hold the pointer to the
;;; deflate_state structure during the function's setup (before
;;; entering the main loop.
mov edx, [deflatestate]
mov ecx, [curmatch]
;;; uInt wmask = s->w_mask;
;;; unsigned chain_length = s->max_chain_length;
;;; if (s->prev_length >= s->good_match) {
;;; chain_length >>= 2;
;;; }
mov eax, [edx + dsPrevLen]
mov ebx, [edx + dsGoodMatch]
cmp eax, ebx
mov eax, [edx + dsWMask]
mov ebx, [edx + dsMaxChainLen]
jl LastMatchGood
shr ebx, 2
LastMatchGood:
;;; chainlen is decremented once beforehand so that the function can
;;; use the sign flag instead of the zero flag for the exit test.
;;; It is then shifted into the high word, to make room for the wmask
;;; value, which it will always accompany.
dec ebx
shl ebx, 16
or ebx, eax
mov [chainlenwmask], ebx
;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
mov eax, [edx + dsNiceMatch]
mov ebx, [edx + dsLookahead]
cmp ebx, eax
jl LookaheadLess
mov ebx, eax
LookaheadLess: mov [nicematch], ebx
;;; register Bytef *scan = s->window + s->strstart;
mov esi, [edx + dsWindow]
mov [window], esi
mov ebp, [edx + dsStrStart]
lea edi, [esi + ebp]
mov [scan], edi
;;; Determine how many bytes the scan ptr is off from being
;;; dword-aligned.
mov eax, edi
neg eax
and eax, 3
mov [scanalign], eax
;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
mov eax, [edx + dsWSize]
sub eax, MIN_LOOKAHEAD
sub ebp, eax
jg LimitPositive
xor ebp, ebp
LimitPositive:
;;; int best_len = s->prev_length;
mov eax, [edx + dsPrevLen]
mov [bestlen], eax
;;; Store the sum of s->window + best_len in esi locally, and in esi.
add esi, eax
mov [windowbestlen], esi
;;; register ush scan_start = *(ushf*)scan;
;;; register ush scan_end = *(ushf*)(scan+best_len-1);
;;; Posf *prev = s->prev;
movzx ebx, word ptr [edi]
mov [scanstart], ebx
movzx ebx, word ptr [edi + eax - 1]
mov [scanend], ebx
mov edi, [edx + dsPrev]
;;; Jump into the main loop.
mov edx, [chainlenwmask]
jmp short LoopEntry
align 4
;;; do {
;;; match = s->window + cur_match;
;;; if (*(ushf*)(match+best_len-1) != scan_end ||
;;; *(ushf*)match != scan_start) continue;
;;; [...]
;;; } while ((cur_match = prev[cur_match & wmask]) > limit
;;; && --chain_length != 0);
;;;
;;; Here is the inner loop of the function. The function will spend the
;;; majority of its time in this loop, and majority of that time will
;;; be spent in the first ten instructions.
;;;
;;; Within this loop:
;;; ebx = scanend
;;; ecx = curmatch
;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
;;; esi = windowbestlen - i.e., (window + bestlen)
;;; edi = prev
;;; ebp = limit
LookupLoop:
and ecx, edx
movzx ecx, word ptr [edi + ecx*2]
cmp ecx, ebp
jbe LeaveNow
sub edx, 00010000h
js LeaveNow
LoopEntry: movzx eax, word ptr [esi + ecx - 1]
cmp eax, ebx
jnz LookupLoop
mov eax, [window]
movzx eax, word ptr [eax + ecx]
cmp eax, [scanstart]
jnz LookupLoop
;;; Store the current value of chainlen.
mov [chainlenwmask], edx
;;; Point edi to the string under scrutiny, and esi to the string we
;;; are hoping to match it up with. In actuality, esi and edi are
;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
;;; initialized to -(MAX_MATCH_8 - scanalign).
mov esi, [window]
mov edi, [scan]
add esi, ecx
mov eax, [scanalign]
mov edx, 0fffffef8h; -(MAX_MATCH_8)
lea edi, [edi + eax + 0108h] ;MAX_MATCH_8]
lea esi, [esi + eax + 0108h] ;MAX_MATCH_8]
;;; Test the strings for equality, 8 bytes at a time. At the end,
;;; adjust edx so that it is offset to the exact byte that mismatched.
;;;
;;; We already know at this point that the first three bytes of the
;;; strings match each other, and they can be safely passed over before
;;; starting the compare loop. So what this code does is skip over 0-3
;;; bytes, as much as necessary in order to dword-align the edi
;;; pointer. (esi will still be misaligned three times out of four.)
;;;
;;; It should be confessed that this loop usually does not represent
;;; much of the total running time. Replacing it with a more
;;; straightforward "rep cmpsb" would not drastically degrade
;;; performance.
LoopCmps:
mov eax, [esi + edx]
xor eax, [edi + edx]
jnz LeaveLoopCmps
mov eax, [esi + edx + 4]
xor eax, [edi + edx + 4]
jnz LeaveLoopCmps4
add edx, 8
jnz LoopCmps
jmp short LenMaximum
LeaveLoopCmps4: add edx, 4
LeaveLoopCmps: test eax, 0000FFFFh
jnz LenLower
add edx, 2
shr eax, 16
LenLower: sub al, 1
adc edx, 0
;;; Calculate the length of the match. If it is longer than MAX_MATCH,
;;; then automatically accept it as the best possible match and leave.
lea eax, [edi + edx]
mov edi, [scan]
sub eax, edi
cmp eax, MAX_MATCH
jge LenMaximum
;;; If the length of the match is not longer than the best match we
;;; have so far, then forget it and return to the lookup loop.
mov edx, [deflatestate]
mov ebx, [bestlen]
cmp eax, ebx
jg LongerMatch
mov esi, [windowbestlen]
mov edi, [edx + dsPrev]
mov ebx, [scanend]
mov edx, [chainlenwmask]
jmp LookupLoop
;;; s->match_start = cur_match;
;;; best_len = len;
;;; if (len >= nice_match) break;
;;; scan_end = *(ushf*)(scan+best_len-1);
LongerMatch: mov ebx, [nicematch]
mov [bestlen], eax
mov [edx + dsMatchStart], ecx
cmp eax, ebx
jge LeaveNow
mov esi, [window]
add esi, eax
mov [windowbestlen], esi
movzx ebx, word ptr [edi + eax - 1]
mov edi, [edx + dsPrev]
mov [scanend], ebx
mov edx, [chainlenwmask]
jmp LookupLoop
;;; Accept the current string, with the maximum possible length.
LenMaximum: mov edx, [deflatestate]
mov dword ptr [bestlen], MAX_MATCH
mov [edx + dsMatchStart], ecx
;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
;;; return s->lookahead;
LeaveNow:
mov edx, [deflatestate]
mov ebx, [bestlen]
mov eax, [edx + dsLookahead]
cmp ebx, eax
jg LookaheadRet
mov eax, ebx
LookaheadRet:
;;; Restore the stack and return from whence we came.
add esp, LocalVarsSize
pop ebx
pop esi
pop edi
pop ebp
ret
; please don't remove this string !
; Your can freely use match686 in any free or commercial app if you don't remove the string in the binary!
db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah
IFDEF NOUNDERLINE
longest_match endp
ELSE
_longest_match endp
ENDIF
IFDEF NOUNDERLINE
match_init proc near
ret
match_init endp
ELSE
_match_init proc near
ret
_match_init endp
ENDIF
_TEXT ends
end
; match686.asm -- Asm portion of the optimized longest_match for 32 bits x86
; Copyright (C) 1995-1996 Jean-loup Gailly, Brian Raiter and Gilles Vollant.
; File written by Gilles Vollant, by converting match686.S from Brian Raiter
; for MASM. This is as assembly version of longest_match
; from Jean-loup Gailly in deflate.c
;
; http://www.zlib.net
; http://www.winimage.com/zLibDll
; http://www.muppetlabs.com/~breadbox/software/assembly.html
;
; For Visual C++ 4.x and higher and ML 6.x and higher
; ml.exe is distributed in
; http://www.microsoft.com/downloads/details.aspx?FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64
;
; this file contain two implementation of longest_match
;
; this longest_match was written by Brian raiter (1998), optimized for Pentium Pro
; (and the faster known version of match_init on modern Core 2 Duo and AMD Phenom)
;
; for using an assembly version of longest_match, you need define ASMV in project
;
; compile the asm file running
; ml /coff /Zi /c /Flmatch686.lst match686.asm
; and do not include match686.obj in your project
;
; note: contrib of zLib 1.2.3 and earlier contained both a deprecated version for
; Pentium (prior Pentium Pro) and this version for Pentium Pro and modern processor
; with autoselect (with cpu detection code)
; if you want support the old pentium optimization, you can still use these version
;
; this file is not optimized for old pentium, but it compatible with all x86 32 bits
; processor (starting 80386)
;
;
; see below : zlib1222add must be adjuster if you use a zlib version < 1.2.2.2
;uInt longest_match(s, cur_match)
; deflate_state *s;
; IPos cur_match; /* current match */
NbStack equ 76
cur_match equ dword ptr[esp+NbStack-0]
str_s equ dword ptr[esp+NbStack-4]
; 5 dword on top (ret,ebp,esi,edi,ebx)
adrret equ dword ptr[esp+NbStack-8]
pushebp equ dword ptr[esp+NbStack-12]
pushedi equ dword ptr[esp+NbStack-16]
pushesi equ dword ptr[esp+NbStack-20]
pushebx equ dword ptr[esp+NbStack-24]
chain_length equ dword ptr [esp+NbStack-28]
limit equ dword ptr [esp+NbStack-32]
best_len equ dword ptr [esp+NbStack-36]
window equ dword ptr [esp+NbStack-40]
prev equ dword ptr [esp+NbStack-44]
scan_start equ word ptr [esp+NbStack-48]
wmask equ dword ptr [esp+NbStack-52]
match_start_ptr equ dword ptr [esp+NbStack-56]
nice_match equ dword ptr [esp+NbStack-60]
scan equ dword ptr [esp+NbStack-64]
windowlen equ dword ptr [esp+NbStack-68]
match_start equ dword ptr [esp+NbStack-72]
strend equ dword ptr [esp+NbStack-76]
NbStackAdd equ (NbStack-24)
.386p
name gvmatch
.MODEL FLAT
; all the +zlib1222add offsets are due to the addition of fields
; in zlib in the deflate_state structure since the asm code was first written
; (if you compile with zlib 1.0.4 or older, use "zlib1222add equ (-4)").
; (if you compile with zlib between 1.0.5 and 1.2.2.1, use "zlib1222add equ 0").
; if you compile with zlib 1.2.2.2 or later , use "zlib1222add equ 8").
zlib1222add equ 8
; Note : these value are good with a 8 bytes boundary pack structure
dep_chain_length equ 74h+zlib1222add
dep_window equ 30h+zlib1222add
dep_strstart equ 64h+zlib1222add
dep_prev_length equ 70h+zlib1222add
dep_nice_match equ 88h+zlib1222add
dep_w_size equ 24h+zlib1222add
dep_prev equ 38h+zlib1222add
dep_w_mask equ 2ch+zlib1222add
dep_good_match equ 84h+zlib1222add
dep_match_start equ 68h+zlib1222add
dep_lookahead equ 6ch+zlib1222add
_TEXT segment
IFDEF NOUNDERLINE
public longest_match
public match_init
ELSE
public _longest_match
public _match_init
ENDIF
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH+MIN_MATCH+1)
MAX_MATCH equ 258
MIN_MATCH equ 3
MIN_LOOKAHEAD equ (MAX_MATCH + MIN_MATCH + 1)
MAX_MATCH_8_ equ ((MAX_MATCH + 7) AND 0FFF0h)
;;; stack frame offsets
chainlenwmask equ esp + 0 ; high word: current chain len
; low word: s->wmask
window equ esp + 4 ; local copy of s->window
windowbestlen equ esp + 8 ; s->window + bestlen
scanstart equ esp + 16 ; first two bytes of string
scanend equ esp + 12 ; last two bytes of string
scanalign equ esp + 20 ; dword-misalignment of string
nicematch equ esp + 24 ; a good enough match size
bestlen equ esp + 28 ; size of best match so far
scan equ esp + 32 ; ptr to string wanting match
LocalVarsSize equ 36
; saved ebx byte esp + 36
; saved edi byte esp + 40
; saved esi byte esp + 44
; saved ebp byte esp + 48
; return address byte esp + 52
deflatestate equ esp + 56 ; the function arguments
curmatch equ esp + 60
;;; Offsets for fields in the deflate_state structure. These numbers
;;; are calculated from the definition of deflate_state, with the
;;; assumption that the compiler will dword-align the fields. (Thus,
;;; changing the definition of deflate_state could easily cause this
;;; program to crash horribly, without so much as a warning at
;;; compile time. Sigh.)
dsWSize equ 36+zlib1222add
dsWMask equ 44+zlib1222add
dsWindow equ 48+zlib1222add
dsPrev equ 56+zlib1222add
dsMatchLen equ 88+zlib1222add
dsPrevMatch equ 92+zlib1222add
dsStrStart equ 100+zlib1222add
dsMatchStart equ 104+zlib1222add
dsLookahead equ 108+zlib1222add
dsPrevLen equ 112+zlib1222add
dsMaxChainLen equ 116+zlib1222add
dsGoodMatch equ 132+zlib1222add
dsNiceMatch equ 136+zlib1222add
;;; match686.asm -- Pentium-Pro-optimized version of longest_match()
;;; Written for zlib 1.1.2
;;; Copyright (C) 1998 Brian Raiter <breadbox@muppetlabs.com>
;;; You can look at http://www.muppetlabs.com/~breadbox/software/assembly.html
;;;
;;
;; This software is provided 'as-is', without any express or implied
;; warranty. In no event will the authors be held liable for any damages
;; arising from the use of this software.
;;
;; Permission is granted to anyone to use this software for any purpose,
;; including commercial applications, and to alter it and redistribute it
;; freely, subject to the following restrictions:
;;
;; 1. The origin of this software must not be misrepresented; you must not
;; claim that you wrote the original software. If you use this software
;; in a product, an acknowledgment in the product documentation would be
;; appreciated but is not required.
;; 2. Altered source versions must be plainly marked as such, and must not be
;; misrepresented as being the original software
;; 3. This notice may not be removed or altered from any source distribution.
;;
;GLOBAL _longest_match, _match_init
;SECTION .text
;;; uInt longest_match(deflate_state *deflatestate, IPos curmatch)
;_longest_match:
IFDEF NOUNDERLINE
longest_match proc near
ELSE
_longest_match proc near
ENDIF
;;; Save registers that the compiler may be using, and adjust esp to
;;; make room for our stack frame.
push ebp
push edi
push esi
push ebx
sub esp, LocalVarsSize
;;; Retrieve the function arguments. ecx will hold cur_match
;;; throughout the entire function. edx will hold the pointer to the
;;; deflate_state structure during the function's setup (before
;;; entering the main loop.
mov edx, [deflatestate]
mov ecx, [curmatch]
;;; uInt wmask = s->w_mask;
;;; unsigned chain_length = s->max_chain_length;
;;; if (s->prev_length >= s->good_match) {
;;; chain_length >>= 2;
;;; }
mov eax, [edx + dsPrevLen]
mov ebx, [edx + dsGoodMatch]
cmp eax, ebx
mov eax, [edx + dsWMask]
mov ebx, [edx + dsMaxChainLen]
jl LastMatchGood
shr ebx, 2
LastMatchGood:
;;; chainlen is decremented once beforehand so that the function can
;;; use the sign flag instead of the zero flag for the exit test.
;;; It is then shifted into the high word, to make room for the wmask
;;; value, which it will always accompany.
dec ebx
shl ebx, 16
or ebx, eax
mov [chainlenwmask], ebx
;;; if ((uInt)nice_match > s->lookahead) nice_match = s->lookahead;
mov eax, [edx + dsNiceMatch]
mov ebx, [edx + dsLookahead]
cmp ebx, eax
jl LookaheadLess
mov ebx, eax
LookaheadLess: mov [nicematch], ebx
;;; register Bytef *scan = s->window + s->strstart;
mov esi, [edx + dsWindow]
mov [window], esi
mov ebp, [edx + dsStrStart]
lea edi, [esi + ebp]
mov [scan], edi
;;; Determine how many bytes the scan ptr is off from being
;;; dword-aligned.
mov eax, edi
neg eax
and eax, 3
mov [scanalign], eax
;;; IPos limit = s->strstart > (IPos)MAX_DIST(s) ?
;;; s->strstart - (IPos)MAX_DIST(s) : NIL;
mov eax, [edx + dsWSize]
sub eax, MIN_LOOKAHEAD
sub ebp, eax
jg LimitPositive
xor ebp, ebp
LimitPositive:
;;; int best_len = s->prev_length;
mov eax, [edx + dsPrevLen]
mov [bestlen], eax
;;; Store the sum of s->window + best_len in esi locally, and in esi.
add esi, eax
mov [windowbestlen], esi
;;; register ush scan_start = *(ushf*)scan;
;;; register ush scan_end = *(ushf*)(scan+best_len-1);
;;; Posf *prev = s->prev;
movzx ebx, word ptr [edi]
mov [scanstart], ebx
movzx ebx, word ptr [edi + eax - 1]
mov [scanend], ebx
mov edi, [edx + dsPrev]
;;; Jump into the main loop.
mov edx, [chainlenwmask]
jmp short LoopEntry
align 4
;;; do {
;;; match = s->window + cur_match;
;;; if (*(ushf*)(match+best_len-1) != scan_end ||
;;; *(ushf*)match != scan_start) continue;
;;; [...]
;;; } while ((cur_match = prev[cur_match & wmask]) > limit
;;; && --chain_length != 0);
;;;
;;; Here is the inner loop of the function. The function will spend the
;;; majority of its time in this loop, and majority of that time will
;;; be spent in the first ten instructions.
;;;
;;; Within this loop:
;;; ebx = scanend
;;; ecx = curmatch
;;; edx = chainlenwmask - i.e., ((chainlen << 16) | wmask)
;;; esi = windowbestlen - i.e., (window + bestlen)
;;; edi = prev
;;; ebp = limit
LookupLoop:
and ecx, edx
movzx ecx, word ptr [edi + ecx*2]
cmp ecx, ebp
jbe LeaveNow
sub edx, 00010000h
js LeaveNow
LoopEntry: movzx eax, word ptr [esi + ecx - 1]
cmp eax, ebx
jnz LookupLoop
mov eax, [window]
movzx eax, word ptr [eax + ecx]
cmp eax, [scanstart]
jnz LookupLoop
;;; Store the current value of chainlen.
mov [chainlenwmask], edx
;;; Point edi to the string under scrutiny, and esi to the string we
;;; are hoping to match it up with. In actuality, esi and edi are
;;; both pointed (MAX_MATCH_8 - scanalign) bytes ahead, and edx is
;;; initialized to -(MAX_MATCH_8 - scanalign).
mov esi, [window]
mov edi, [scan]
add esi, ecx
mov eax, [scanalign]
mov edx, 0fffffef8h; -(MAX_MATCH_8)
lea edi, [edi + eax + 0108h] ;MAX_MATCH_8]
lea esi, [esi + eax + 0108h] ;MAX_MATCH_8]
;;; Test the strings for equality, 8 bytes at a time. At the end,
;;; adjust edx so that it is offset to the exact byte that mismatched.
;;;
;;; We already know at this point that the first three bytes of the
;;; strings match each other, and they can be safely passed over before
;;; starting the compare loop. So what this code does is skip over 0-3
;;; bytes, as much as necessary in order to dword-align the edi
;;; pointer. (esi will still be misaligned three times out of four.)
;;;
;;; It should be confessed that this loop usually does not represent
;;; much of the total running time. Replacing it with a more
;;; straightforward "rep cmpsb" would not drastically degrade
;;; performance.
LoopCmps:
mov eax, [esi + edx]
xor eax, [edi + edx]
jnz LeaveLoopCmps
mov eax, [esi + edx + 4]
xor eax, [edi + edx + 4]
jnz LeaveLoopCmps4
add edx, 8
jnz LoopCmps
jmp short LenMaximum
LeaveLoopCmps4: add edx, 4
LeaveLoopCmps: test eax, 0000FFFFh
jnz LenLower
add edx, 2
shr eax, 16
LenLower: sub al, 1
adc edx, 0
;;; Calculate the length of the match. If it is longer than MAX_MATCH,
;;; then automatically accept it as the best possible match and leave.
lea eax, [edi + edx]
mov edi, [scan]
sub eax, edi
cmp eax, MAX_MATCH
jge LenMaximum
;;; If the length of the match is not longer than the best match we
;;; have so far, then forget it and return to the lookup loop.
mov edx, [deflatestate]
mov ebx, [bestlen]
cmp eax, ebx
jg LongerMatch
mov esi, [windowbestlen]
mov edi, [edx + dsPrev]
mov ebx, [scanend]
mov edx, [chainlenwmask]
jmp LookupLoop
;;; s->match_start = cur_match;
;;; best_len = len;
;;; if (len >= nice_match) break;
;;; scan_end = *(ushf*)(scan+best_len-1);
LongerMatch: mov ebx, [nicematch]
mov [bestlen], eax
mov [edx + dsMatchStart], ecx
cmp eax, ebx
jge LeaveNow
mov esi, [window]
add esi, eax
mov [windowbestlen], esi
movzx ebx, word ptr [edi + eax - 1]
mov edi, [edx + dsPrev]
mov [scanend], ebx
mov edx, [chainlenwmask]
jmp LookupLoop
;;; Accept the current string, with the maximum possible length.
LenMaximum: mov edx, [deflatestate]
mov dword ptr [bestlen], MAX_MATCH
mov [edx + dsMatchStart], ecx
;;; if ((uInt)best_len <= s->lookahead) return (uInt)best_len;
;;; return s->lookahead;
LeaveNow:
mov edx, [deflatestate]
mov ebx, [bestlen]
mov eax, [edx + dsLookahead]
cmp ebx, eax
jg LookaheadRet
mov eax, ebx
LookaheadRet:
;;; Restore the stack and return from whence we came.
add esp, LocalVarsSize
pop ebx
pop esi
pop edi
pop ebp
ret
; please don't remove this string !
; Your can freely use match686 in any free or commercial app if you don't remove the string in the binary!
db 0dh,0ah,"asm686 with masm, optimised assembly code from Brian Raiter, written 1998",0dh,0ah
IFDEF NOUNDERLINE
longest_match endp
ELSE
_longest_match endp
ENDIF
IFDEF NOUNDERLINE
match_init proc near
ret
match_init endp
ELSE
_match_init proc near
ret
_match_init endp
ENDIF
_TEXT ends
end

View file

@ -1,27 +1,27 @@
Summary
-------
This directory contains ASM implementations of the functions
longest_match() and inflate_fast().
Use instructions
----------------
Assemble using MASM, and copy the object files into the zlib source
directory, then run the appropriate makefile, as suggested below. You can
donwload MASM from here:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64
You can also get objects files here:
http://www.winimage.com/zLibDll/zlib124_masm_obj.zip
Build instructions
------------------
* With Microsoft C and MASM:
nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj"
* With Borland C and TASM:
make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" OBJPA="+match686c.obj+match686.obj+inffas32.obj"
Summary
-------
This directory contains ASM implementations of the functions
longest_match() and inflate_fast().
Use instructions
----------------
Assemble using MASM, and copy the object files into the zlib source
directory, then run the appropriate makefile, as suggested below. You can
donwload MASM from here:
http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=7a1c9da0-0510-44a2-b042-7ef370530c64
You can also get objects files here:
http://www.winimage.com/zLibDll/zlib124_masm_obj.zip
Build instructions
------------------
* With Microsoft C and MASM:
nmake -f win32/Makefile.msc LOC="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj"
* With Borland C and TASM:
make -f win32/Makefile.bor LOCAL_ZLIB="-DASMV -DASMINF" OBJA="match686.obj inffas32.obj" OBJPA="+match686c.obj+match686.obj+inffas32.obj"

View file

@ -1,10 +1,10 @@
To build testzLib with Visual Studio 2005:
copy to a directory file from :
- root of zLib tree
- contrib/testzlib
- contrib/masmx86
- contrib/masmx64
- contrib/vstudio/vc7
To build testzLib with Visual Studio 2005:
copy to a directory file from :
- root of zLib tree
- contrib/testzlib
- contrib/masmx86
- contrib/masmx64
- contrib/vstudio/vc7
and open testzlib8.sln

View file

@ -1,130 +1,130 @@
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.24
EXPORTS
adler32 @1
compress @2
crc32 @3
deflate @4
deflateCopy @5
deflateEnd @6
deflateInit2_ @7
deflateInit_ @8
deflateParams @9
deflateReset @10
deflateSetDictionary @11
gzclose @12
gzdopen @13
gzerror @14
gzflush @15
gzopen @16
gzread @17
gzwrite @18
inflate @19
inflateEnd @20
inflateInit2_ @21
inflateInit_ @22
inflateReset @23
inflateSetDictionary @24
inflateSync @25
uncompress @26
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
gzeof @34
gzsetparams @35
zError @36
inflateSyncPoint @37
get_crc_table @38
compress2 @39
gzputs @40
gzgets @41
inflateCopy @42
inflateBackInit_ @43
inflateBack @44
inflateBackEnd @45
compressBound @46
deflateBound @47
gzclearerr @48
gzungetc @49
zlibCompileFlags @50
deflatePrime @51
unzOpen @61
unzClose @62
unzGetGlobalInfo @63
unzGetCurrentFileInfo @64
unzGoToFirstFile @65
unzGoToNextFile @66
unzOpenCurrentFile @67
unzReadCurrentFile @68
unzOpenCurrentFile3 @69
unztell @70
unzeof @71
unzCloseCurrentFile @72
unzGetGlobalComment @73
unzStringFileNameCompare @74
unzLocateFile @75
unzGetLocalExtrafield @76
unzOpen2 @77
unzOpenCurrentFile2 @78
unzOpenCurrentFilePassword @79
zipOpen @80
zipOpenNewFileInZip @81
zipWriteInFileInZip @82
zipCloseFileInZip @83
zipClose @84
zipOpenNewFileInZip2 @86
zipCloseFileInZipRaw @87
zipOpen2 @88
zipOpenNewFileInZip3 @89
unzGetFilePos @100
unzGoToFilePos @101
fill_win32_filefunc @110
; zlibwapi v1.2.4 added:
fill_win32_filefunc64 @111
fill_win32_filefunc64A @112
fill_win32_filefunc64W @113
unzOpen64 @120
unzOpen2_64 @121
unzGetGlobalInfo64 @122
unzGetCurrentFileInfo64 @124
unzGetCurrentFileZStreamPos64 @125
unztell64 @126
unzGetFilePos64 @127
unzGoToFilePos64 @128
zipOpen64 @130
zipOpen2_64 @131
zipOpenNewFileInZip64 @132
zipOpenNewFileInZip2_64 @133
zipOpenNewFileInZip3_64 @134
zipOpenNewFileInZip4_64 @135
zipCloseFileInZipRaw64 @136
; zlib1 v1.2.4 added:
adler32_combine @140
crc32_combine @142
deflateSetHeader @144
deflateTune @145
gzbuffer @146
gzclose_r @147
gzclose_w @148
gzdirect @149
gzoffset @150
inflateGetHeader @156
inflateMark @157
inflatePrime @158
inflateReset2 @159
inflateUndermine @160
LIBRARY
; zlib data compression and ZIP file I/O library
VERSION 1.24
EXPORTS
adler32 @1
compress @2
crc32 @3
deflate @4
deflateCopy @5
deflateEnd @6
deflateInit2_ @7
deflateInit_ @8
deflateParams @9
deflateReset @10
deflateSetDictionary @11
gzclose @12
gzdopen @13
gzerror @14
gzflush @15
gzopen @16
gzread @17
gzwrite @18
inflate @19
inflateEnd @20
inflateInit2_ @21
inflateInit_ @22
inflateReset @23
inflateSetDictionary @24
inflateSync @25
uncompress @26
zlibVersion @27
gzprintf @28
gzputc @29
gzgetc @30
gzseek @31
gzrewind @32
gztell @33
gzeof @34
gzsetparams @35
zError @36
inflateSyncPoint @37
get_crc_table @38
compress2 @39
gzputs @40
gzgets @41
inflateCopy @42
inflateBackInit_ @43
inflateBack @44
inflateBackEnd @45
compressBound @46
deflateBound @47
gzclearerr @48
gzungetc @49
zlibCompileFlags @50
deflatePrime @51
unzOpen @61
unzClose @62
unzGetGlobalInfo @63
unzGetCurrentFileInfo @64
unzGoToFirstFile @65
unzGoToNextFile @66
unzOpenCurrentFile @67
unzReadCurrentFile @68
unzOpenCurrentFile3 @69
unztell @70
unzeof @71
unzCloseCurrentFile @72
unzGetGlobalComment @73
unzStringFileNameCompare @74
unzLocateFile @75
unzGetLocalExtrafield @76
unzOpen2 @77
unzOpenCurrentFile2 @78
unzOpenCurrentFilePassword @79
zipOpen @80
zipOpenNewFileInZip @81
zipWriteInFileInZip @82
zipCloseFileInZip @83
zipClose @84
zipOpenNewFileInZip2 @86
zipCloseFileInZipRaw @87
zipOpen2 @88
zipOpenNewFileInZip3 @89
unzGetFilePos @100
unzGoToFilePos @101
fill_win32_filefunc @110
; zlibwapi v1.2.4 added:
fill_win32_filefunc64 @111
fill_win32_filefunc64A @112
fill_win32_filefunc64W @113
unzOpen64 @120
unzOpen2_64 @121
unzGetGlobalInfo64 @122
unzGetCurrentFileInfo64 @124
unzGetCurrentFileZStreamPos64 @125
unztell64 @126
unzGetFilePos64 @127
unzGoToFilePos64 @128
zipOpen64 @130
zipOpen2_64 @131
zipOpenNewFileInZip64 @132
zipOpenNewFileInZip2_64 @133
zipOpenNewFileInZip3_64 @134
zipOpenNewFileInZip4_64 @135
zipCloseFileInZipRaw64 @136
; zlib1 v1.2.4 added:
adler32_combine @140
crc32_combine @142
deflateSetHeader @144
deflateTune @145
gzbuffer @146
gzclose_r @147
gzclose_w @148
gzdirect @149
gzoffset @150
inflateGetHeader @156
inflateMark @157
inflatePrime @158
inflateReset2 @159
inflateUndermine @160

View file

@ -1,73 +1,73 @@
Microsoft Developer Studio Project Files, Format Version 6.00 for zlib.
Copyright (C) 2000-2004 Simon-Pierre Cadieux.
Copyright (C) 2004 Cosmin Truta.
For conditions of distribution and use, see copyright notice in zlib.h.
This project builds the zlib binaries as follows:
* Win32_DLL_Release\zlib1.dll DLL build
* Win32_DLL_Debug\zlib1d.dll DLL build (debug version)
* Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code
* Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code (debug version)
* Win32_LIB_Release\zlib.lib static build
* Win32_LIB_Debug\zlibd.lib static build (debug version)
* Win32_LIB_ASM_Release\zlib.lib static build using ASM code
* Win32_LIB_ASM_Debug\zlibd.lib static build using ASM code (debug version)
For more information regarding the DLL builds, please see the DLL FAQ
in ..\..\win32\DLL_FAQ.txt.
To build and test:
1) On the main menu, select "File | Open Workspace".
Open "zlib.dsw".
2) Select "Build | Set Active Configuration".
Choose the configuration you wish to build.
3) Select "Build | Clean".
4) Select "Build | Build ... (F7)". Ignore warning messages about
not being able to find certain include files (e.g. alloc.h).
5) If you built one of the sample programs (example or minigzip),
select "Build | Execute ... (Ctrl+F5)".
To use:
1) Select "Project | Settings (Alt+F7)".
Make note of the configuration names used in your project.
Usually, these names are "Win32 Release" and "Win32 Debug".
2) In the Workspace window, select the "FileView" tab.
Right-click on the root item "Workspace '...'".
Select "Insert Project into Workspace".
Switch on the checkbox "Dependency of:", and select the name
of your project. Open "zlib.dsp".
3) Select "Build | Configurations".
For each configuration of your project:
3.1) Choose the zlib configuration you wish to use.
3.2) Click on "Add".
3.3) Set the new zlib configuration name to the name used by
the configuration from the current iteration.
4) Select "Build | Set Active Configuration".
Choose the configuration you wish to build.
5) Select "Build | Build ... (F7)".
6) If you built an executable program, select
"Build | Execute ... (Ctrl+F5)".
Note:
To build the ASM-enabled code, you need Microsoft Assembler
(ML.EXE). You can get it by downloading and installing the
latest Processor Pack for Visual C++ 6.0.
Microsoft Developer Studio Project Files, Format Version 6.00 for zlib.
Copyright (C) 2000-2004 Simon-Pierre Cadieux.
Copyright (C) 2004 Cosmin Truta.
For conditions of distribution and use, see copyright notice in zlib.h.
This project builds the zlib binaries as follows:
* Win32_DLL_Release\zlib1.dll DLL build
* Win32_DLL_Debug\zlib1d.dll DLL build (debug version)
* Win32_DLL_ASM_Release\zlib1.dll DLL build using ASM code
* Win32_DLL_ASM_Debug\zlib1d.dll DLL build using ASM code (debug version)
* Win32_LIB_Release\zlib.lib static build
* Win32_LIB_Debug\zlibd.lib static build (debug version)
* Win32_LIB_ASM_Release\zlib.lib static build using ASM code
* Win32_LIB_ASM_Debug\zlibd.lib static build using ASM code (debug version)
For more information regarding the DLL builds, please see the DLL FAQ
in ..\..\win32\DLL_FAQ.txt.
To build and test:
1) On the main menu, select "File | Open Workspace".
Open "zlib.dsw".
2) Select "Build | Set Active Configuration".
Choose the configuration you wish to build.
3) Select "Build | Clean".
4) Select "Build | Build ... (F7)". Ignore warning messages about
not being able to find certain include files (e.g. alloc.h).
5) If you built one of the sample programs (example or minigzip),
select "Build | Execute ... (Ctrl+F5)".
To use:
1) Select "Project | Settings (Alt+F7)".
Make note of the configuration names used in your project.
Usually, these names are "Win32 Release" and "Win32 Debug".
2) In the Workspace window, select the "FileView" tab.
Right-click on the root item "Workspace '...'".
Select "Insert Project into Workspace".
Switch on the checkbox "Dependency of:", and select the name
of your project. Open "zlib.dsp".
3) Select "Build | Configurations".
For each configuration of your project:
3.1) Choose the zlib configuration you wish to use.
3.2) Click on "Add".
3.3) Set the new zlib configuration name to the name used by
the configuration from the current iteration.
4) Select "Build | Set Active Configuration".
Choose the configuration you wish to build.
5) Select "Build | Build ... (F7)".
6) If you built an executable program, select
"Build | Execute ... (Ctrl+F5)".
Note:
To build the ASM-enabled code, you need Microsoft Assembler
(ML.EXE). You can get it by downloading and installing the
latest Processor Pack for Visual C++ 6.0.

File diff suppressed because it is too large Load diff

View file

@ -1,59 +1,59 @@
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "example"=.\example.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlib
End Project Dependency
}}}
###############################################################################
Project: "minigzip"=.\minigzip.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlib
End Project Dependency
}}}
###############################################################################
Project: "zlib"=.\zlib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################
Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "example"=.\example.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlib
End Project Dependency
}}}
###############################################################################
Project: "minigzip"=.\minigzip.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name zlib
End Project Dependency
}}}
###############################################################################
Project: "zlib"=.\zlib.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View file

@ -1 +1 @@
#include <jni.h>
#include <jni.h>

View file

@ -1,77 +1,77 @@
//----------------------------------------------------------------------------------
// File: libs\jni\nv_debug.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#ifndef __INCLUDED_NV_DEBUG_H
#define __INCLUDED_NV_DEBUG_H
#define CT_ASSERT(tag,cond) \
enum { COMPILE_TIME_ASSERT__ ## tag = 1/(cond) }
#define dimof( x ) ( sizeof(x) / sizeof(x[0]) )
#include <android/log.h>
#define DBG_DETAILED 0
#if 0
// the detailed prefix can be customised by setting DBG_DETAILED_PREFIX. See
// below as a reference.
// NOTE: fmt is the desired format string and must be in the prefix.
//#ifndef DBG_DETAILED_PREFIX
// #define DBG_DETAILED_PREFIX "%s, %s, line %d: " fmt, __FILE__, __FUNCTION__, __LINE__,
//#endif
//#define DEBUG_D_(fmt, args...)
//#define DEBUG_D(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, MODULE, (DBG_DETAILED_PREFIX) ## args)
#else
#ifdef STRINGIFY
#pragma push_macro("STRINGIFY")
#undef STRINGIFY
#define STRINGIFYPUSHED_____
#endif
#define STRINGIFY(x) #x
// debug macro, includes file name function name and line number
#define TO(x) typeof(x)
#define DEBUG_D_(file, line, fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, MODULE, file ", %s, line(" STRINGIFY(line) "): " fmt, __FUNCTION__, ## args)
#define DEBUG_D(fmt, args...) DEBUG_D_( __FILE__ , __LINE__ , fmt, ## args)
#ifdef STRINGIFYPUSHED_____
#undef STRINGIFYPUSHED_____
#pragma pop_macro("STRINGIFY")
#endif
#endif
// basic debug macro
#define NVDEBUG_(fmt, args...) (__android_log_print(ANDROID_LOG_DEBUG, MODULE, fmt, ## args))
// Debug macro that can be switched to spew a file name,
// function and line number using DEBUG_DETAILED
#if DBG_DETAILED == 1
#define NVDEBUG(fmt, args...) NVDEBUG_D(fmt, ## args)
#else
#define NVDEBUG(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, MODULE, fmt, ## args)
#endif
#endif
//----------------------------------------------------------------------------------
// File: libs\jni\nv_debug.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#ifndef __INCLUDED_NV_DEBUG_H
#define __INCLUDED_NV_DEBUG_H
#define CT_ASSERT(tag,cond) \
enum { COMPILE_TIME_ASSERT__ ## tag = 1/(cond) }
#define dimof( x ) ( sizeof(x) / sizeof(x[0]) )
#include <android/log.h>
#define DBG_DETAILED 0
#if 0
// the detailed prefix can be customised by setting DBG_DETAILED_PREFIX. See
// below as a reference.
// NOTE: fmt is the desired format string and must be in the prefix.
//#ifndef DBG_DETAILED_PREFIX
// #define DBG_DETAILED_PREFIX "%s, %s, line %d: " fmt, __FILE__, __FUNCTION__, __LINE__,
//#endif
//#define DEBUG_D_(fmt, args...)
//#define DEBUG_D(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, MODULE, (DBG_DETAILED_PREFIX) ## args)
#else
#ifdef STRINGIFY
#pragma push_macro("STRINGIFY")
#undef STRINGIFY
#define STRINGIFYPUSHED_____
#endif
#define STRINGIFY(x) #x
// debug macro, includes file name function name and line number
#define TO(x) typeof(x)
#define DEBUG_D_(file, line, fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, MODULE, file ", %s, line(" STRINGIFY(line) "): " fmt, __FUNCTION__, ## args)
#define DEBUG_D(fmt, args...) DEBUG_D_( __FILE__ , __LINE__ , fmt, ## args)
#ifdef STRINGIFYPUSHED_____
#undef STRINGIFYPUSHED_____
#pragma pop_macro("STRINGIFY")
#endif
#endif
// basic debug macro
#define NVDEBUG_(fmt, args...) (__android_log_print(ANDROID_LOG_DEBUG, MODULE, fmt, ## args))
// Debug macro that can be switched to spew a file name,
// function and line number using DEBUG_DETAILED
#if DBG_DETAILED == 1
#define NVDEBUG(fmt, args...) NVDEBUG_D(fmt, ## args)
#else
#define NVDEBUG(fmt, args...) __android_log_print(ANDROID_LOG_DEBUG, MODULE, fmt, ## args)
#endif
#endif

File diff suppressed because it is too large Load diff

View file

@ -1,277 +1,277 @@
//----------------------------------------------------------------------------------
// File: libs\jni\nv_event\nv_event_queue.cpp
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#define MODULE "NVEventQueue"
#define DBG_DETAILED 1
#include "../nv_debug/nv_debug.hpp"
#include "nv_event_queue.hpp"
#include <assert.h>
#include <stdlib.h>
#include <jni.h>
#include <pthread.h>
#include <android/log.h>
#define NVNextWrapped(index) (((index) + 1) & QUEUE_MASK)
#define NVPrevWrapped(index) (((index) - 1) & QUEUE_MASK)
/* you must be inside a m_accessLock lock to invoke this! */
static void unlockAll(NVEventSync* sem)
{
sem->m_block = false;
pthread_cond_broadcast(&(sem->m_cond));
}
/* you must be inside mutex lock to invoke this! */
static int32_t wait(NVEventSync* sem, pthread_mutex_t* mutex, int waitMS)
{
// TBD - spec is dodgy; do we definitely release the mutex even if
// wait fails?
if(sem->m_block)
{
if( waitMS < 0 )
return pthread_cond_wait(&sem->m_cond, mutex);
else
return pthread_cond_timeout_np(&sem->m_cond, mutex, (unsigned)waitMS);
}
else
{
// must release this, as failure assumes no lock
pthread_mutex_unlock(mutex);
return 1; // do not return 0 - we do not own the lock!
}
}
static void signal(NVEventSync* sem)
{
pthread_cond_signal(&sem->m_cond);
}
static void broadcast(NVEventSync* sem)
{
pthread_cond_broadcast(&sem->m_cond);
}
static void syncInit( NVEventSync* sync )
{
pthread_cond_init(&(sync->m_cond), NULL);
sync->m_block = true;
}
static void syncDestroy( NVEventSync* sync )
{
pthread_cond_destroy( &sync->m_cond );
}
/* you must be inside a m_accessLock lock to invoke this! */
bool NVEventQueue::insert(const NVEvent* ev)
{
// Is the queue full?
int32_t nextNext = NVNextWrapped(m_nextInsertIndex);
if (nextNext == m_headIndex)
{
// TBD - what to do when we cannot insert (full queue)
return false;
}
NVEvent* evDest = m_events + m_nextInsertIndex;
memcpy(evDest, ev, sizeof(NVEvent));
m_nextInsertIndex = nextNext;
return true;
}
void NVEventQueue::Init()
{
m_nextInsertIndex = 0;
m_headIndex = 0;
pthread_mutex_init(&(m_accessLock), NULL);
syncInit(&m_consumerSync);
syncInit(&m_blockerSync);
m_blocker = NULL;
m_blockerState = NO_BLOCKER;
m_blockerReturnVal = false;
}
void NVEventQueue::Shutdown()
{
pthread_mutex_destroy(&(m_accessLock));
// free everyone...
unlockAll(&m_consumerSync);
unlockAll(&m_blockerSync);
syncDestroy(&(m_consumerSync));
syncDestroy(&(m_blockerSync));
}
void NVEventQueue::Flush()
{
// TBD: Lock the mutex????
m_headIndex = m_nextInsertIndex;
}
void NVEventQueue::UnblockConsumer()
{
unlockAll(&(m_consumerSync));
}
void NVEventQueue::UnblockProducer()
{
unlockAll(&(m_blockerSync));
}
void NVEventQueue::Insert(const NVEvent* ev)
{
pthread_mutex_lock(&(m_accessLock));
// insert the event and unblock a waiter
insert(ev);
signal(&m_consumerSync);
pthread_mutex_unlock(&(m_accessLock));
}
bool NVEventQueue::InsertBlocking(const NVEvent* ev)
{
// TBD - how to handle the destruction of these mutexes
pthread_mutex_lock(&(m_accessLock));
while (m_blocker)
{
if (wait(&(m_blockerSync), &(m_accessLock), NV_EVENT_WAIT_FOREVER))
return false;
}
assert(!m_blocker);
assert(m_blockerState == NO_BLOCKER);
// we have the mutex _and_ the blocking event is NULL
// So now we can push a new one
m_blocker = ev;
m_blockerState = PENDING_BLOCKER;
// Release the consumer, as we just posted a new event
signal(&(m_consumerSync));
// Loop on the condition variable until we find out that
// there is a return value waiting for us. Since only we
// will null the blocker pointer, we will not let anyone
// else start to post a blocking event
while (m_blockerState != RETURNED_BLOCKER)
{
if (wait(&(m_blockerSync), &(m_accessLock), NV_EVENT_WAIT_FOREVER))
return false;
}
bool handled = m_blockerReturnVal;
m_blocker = NULL;
m_blockerState = NO_BLOCKER;
NVDEBUG("producer unblocking from consumer handling blocking event (%s)", handled ? "true" : "false");
// We've handled the event, so the producer can release the
// next thread to potentially post a blocking event
signal(&(m_blockerSync));
pthread_mutex_unlock(&(m_accessLock));
return handled;
}
const NVEvent* NVEventQueue::RemoveOldest(int waitMSecs)
{
pthread_mutex_lock(&(m_accessLock));
// Hmm - the last event we got from RemoveOldest was a
// blocker, and DoneWithEvent not called.
// Default to "false" as a return value
if (m_blockerState == PROCESSING_BLOCKER)
{
m_blockerReturnVal = false;
m_blockerState = RETURNED_BLOCKER;
broadcast(&(m_blockerSync));
}
// Blocker is waiting - return it
// And push the blocker pipeline forward
if(m_blockerState == PENDING_BLOCKER)
{
m_blockerState = PROCESSING_BLOCKER;
const NVEvent* ev = m_blocker;
pthread_mutex_unlock(&(m_accessLock));
return ev;
}
else if (m_nextInsertIndex == m_headIndex)
{
// We're empty - so what do we do?
if (waitMSecs == 0)
{
goto no_event;
}
else
{
// wait for the specified time
wait(&(m_consumerSync), &(m_accessLock), (unsigned)waitMSecs);
}
// check again after exiting cond waits, either we had a timeout
if(m_blockerState == PENDING_BLOCKER)
{
m_blockerState = PROCESSING_BLOCKER;
const NVEvent* ev = m_blocker;
pthread_mutex_unlock(&(m_accessLock));
return ev;
}
else if (m_nextInsertIndex == m_headIndex)
{
goto no_event;
}
}
{
// One way or another, we have an event...
const NVEvent* ev = m_events + m_headIndex;
m_headIndex = NVNextWrapped(m_headIndex);
pthread_mutex_unlock(&(m_accessLock));
return ev;
}
no_event:
pthread_mutex_unlock(&(m_accessLock));
return NULL;
}
void NVEventQueue::DoneWithEvent(bool ret)
{
// We only care about blockers for now.
// All other events just NOP
pthread_mutex_lock(&(m_accessLock));
if (m_blockerState == PROCESSING_BLOCKER)
{
m_blockerReturnVal = ret;
m_blockerState = RETURNED_BLOCKER;
broadcast(&(m_blockerSync));
}
pthread_mutex_unlock(&(m_accessLock));
}
//----------------------------------------------------------------------------------
// File: libs\jni\nv_event\nv_event_queue.cpp
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#define MODULE "NVEventQueue"
#define DBG_DETAILED 1
#include "../nv_debug/nv_debug.hpp"
#include "nv_event_queue.hpp"
#include <assert.h>
#include <stdlib.h>
#include <jni.h>
#include <pthread.h>
#include <android/log.h>
#define NVNextWrapped(index) (((index) + 1) & QUEUE_MASK)
#define NVPrevWrapped(index) (((index) - 1) & QUEUE_MASK)
/* you must be inside a m_accessLock lock to invoke this! */
static void unlockAll(NVEventSync* sem)
{
sem->m_block = false;
pthread_cond_broadcast(&(sem->m_cond));
}
/* you must be inside mutex lock to invoke this! */
static int32_t wait(NVEventSync* sem, pthread_mutex_t* mutex, int waitMS)
{
// TBD - spec is dodgy; do we definitely release the mutex even if
// wait fails?
if(sem->m_block)
{
if( waitMS < 0 )
return pthread_cond_wait(&sem->m_cond, mutex);
else
return pthread_cond_timeout_np(&sem->m_cond, mutex, (unsigned)waitMS);
}
else
{
// must release this, as failure assumes no lock
pthread_mutex_unlock(mutex);
return 1; // do not return 0 - we do not own the lock!
}
}
static void signal(NVEventSync* sem)
{
pthread_cond_signal(&sem->m_cond);
}
static void broadcast(NVEventSync* sem)
{
pthread_cond_broadcast(&sem->m_cond);
}
static void syncInit( NVEventSync* sync )
{
pthread_cond_init(&(sync->m_cond), NULL);
sync->m_block = true;
}
static void syncDestroy( NVEventSync* sync )
{
pthread_cond_destroy( &sync->m_cond );
}
/* you must be inside a m_accessLock lock to invoke this! */
bool NVEventQueue::insert(const NVEvent* ev)
{
// Is the queue full?
int32_t nextNext = NVNextWrapped(m_nextInsertIndex);
if (nextNext == m_headIndex)
{
// TBD - what to do when we cannot insert (full queue)
return false;
}
NVEvent* evDest = m_events + m_nextInsertIndex;
memcpy(evDest, ev, sizeof(NVEvent));
m_nextInsertIndex = nextNext;
return true;
}
void NVEventQueue::Init()
{
m_nextInsertIndex = 0;
m_headIndex = 0;
pthread_mutex_init(&(m_accessLock), NULL);
syncInit(&m_consumerSync);
syncInit(&m_blockerSync);
m_blocker = NULL;
m_blockerState = NO_BLOCKER;
m_blockerReturnVal = false;
}
void NVEventQueue::Shutdown()
{
pthread_mutex_destroy(&(m_accessLock));
// free everyone...
unlockAll(&m_consumerSync);
unlockAll(&m_blockerSync);
syncDestroy(&(m_consumerSync));
syncDestroy(&(m_blockerSync));
}
void NVEventQueue::Flush()
{
// TBD: Lock the mutex????
m_headIndex = m_nextInsertIndex;
}
void NVEventQueue::UnblockConsumer()
{
unlockAll(&(m_consumerSync));
}
void NVEventQueue::UnblockProducer()
{
unlockAll(&(m_blockerSync));
}
void NVEventQueue::Insert(const NVEvent* ev)
{
pthread_mutex_lock(&(m_accessLock));
// insert the event and unblock a waiter
insert(ev);
signal(&m_consumerSync);
pthread_mutex_unlock(&(m_accessLock));
}
bool NVEventQueue::InsertBlocking(const NVEvent* ev)
{
// TBD - how to handle the destruction of these mutexes
pthread_mutex_lock(&(m_accessLock));
while (m_blocker)
{
if (wait(&(m_blockerSync), &(m_accessLock), NV_EVENT_WAIT_FOREVER))
return false;
}
assert(!m_blocker);
assert(m_blockerState == NO_BLOCKER);
// we have the mutex _and_ the blocking event is NULL
// So now we can push a new one
m_blocker = ev;
m_blockerState = PENDING_BLOCKER;
// Release the consumer, as we just posted a new event
signal(&(m_consumerSync));
// Loop on the condition variable until we find out that
// there is a return value waiting for us. Since only we
// will null the blocker pointer, we will not let anyone
// else start to post a blocking event
while (m_blockerState != RETURNED_BLOCKER)
{
if (wait(&(m_blockerSync), &(m_accessLock), NV_EVENT_WAIT_FOREVER))
return false;
}
bool handled = m_blockerReturnVal;
m_blocker = NULL;
m_blockerState = NO_BLOCKER;
NVDEBUG("producer unblocking from consumer handling blocking event (%s)", handled ? "true" : "false");
// We've handled the event, so the producer can release the
// next thread to potentially post a blocking event
signal(&(m_blockerSync));
pthread_mutex_unlock(&(m_accessLock));
return handled;
}
const NVEvent* NVEventQueue::RemoveOldest(int waitMSecs)
{
pthread_mutex_lock(&(m_accessLock));
// Hmm - the last event we got from RemoveOldest was a
// blocker, and DoneWithEvent not called.
// Default to "false" as a return value
if (m_blockerState == PROCESSING_BLOCKER)
{
m_blockerReturnVal = false;
m_blockerState = RETURNED_BLOCKER;
broadcast(&(m_blockerSync));
}
// Blocker is waiting - return it
// And push the blocker pipeline forward
if(m_blockerState == PENDING_BLOCKER)
{
m_blockerState = PROCESSING_BLOCKER;
const NVEvent* ev = m_blocker;
pthread_mutex_unlock(&(m_accessLock));
return ev;
}
else if (m_nextInsertIndex == m_headIndex)
{
// We're empty - so what do we do?
if (waitMSecs == 0)
{
goto no_event;
}
else
{
// wait for the specified time
wait(&(m_consumerSync), &(m_accessLock), (unsigned)waitMSecs);
}
// check again after exiting cond waits, either we had a timeout
if(m_blockerState == PENDING_BLOCKER)
{
m_blockerState = PROCESSING_BLOCKER;
const NVEvent* ev = m_blocker;
pthread_mutex_unlock(&(m_accessLock));
return ev;
}
else if (m_nextInsertIndex == m_headIndex)
{
goto no_event;
}
}
{
// One way or another, we have an event...
const NVEvent* ev = m_events + m_headIndex;
m_headIndex = NVNextWrapped(m_headIndex);
pthread_mutex_unlock(&(m_accessLock));
return ev;
}
no_event:
pthread_mutex_unlock(&(m_accessLock));
return NULL;
}
void NVEventQueue::DoneWithEvent(bool ret)
{
// We only care about blockers for now.
// All other events just NOP
pthread_mutex_lock(&(m_accessLock));
if (m_blockerState == PROCESSING_BLOCKER)
{
m_blockerReturnVal = ret;
m_blockerState = RETURNED_BLOCKER;
broadcast(&(m_blockerSync));
}
pthread_mutex_unlock(&(m_accessLock));
}

View file

@ -1,147 +1,147 @@
//----------------------------------------------------------------------------------
// File: libs\jni\nv_event\nv_keycode_mapping.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
class NVKeyCodeMapping
{
public:
NVKeyCodeMapping()
{
memset(m_keyMapping, 0, sizeof(NVKeyCode) * NV_MAX_KEYCODE);
}
void Init(JNIEnv* env, jobject thiz);
bool MapKey(int key, NVKeyCode& code);
protected:
void AddKeyMapping(JNIEnv* env, jobject thiz, jclass KeyCode_class, const char* name, NVKeyCode value);
NVKeyCode m_keyMapping[NV_MAX_KEYCODE];
};
/* Init the mapping array, set up the event queue */
void NVKeyCodeMapping::AddKeyMapping(JNIEnv* env, jobject thiz, jclass KeyCode_class, const char* name, NVKeyCode value)
{
// Add a new mapping...
jfieldID id = env->GetStaticFieldID(KeyCode_class, name, "I");
int keyID = env->GetStaticIntField(KeyCode_class, id);
if (keyID < NV_MAX_KEYCODE)
{
/* TODO TBD Should check for collision */
m_keyMapping[keyID] = value;
}
}
#define AddKeymappingMacro(name, value) \
AddKeyMapping(env, thiz, KeyCode_class, name, value)
void NVKeyCodeMapping::Init(JNIEnv* env, jobject thiz)
{
jclass KeyCode_class = env->FindClass("android/view/KeyEvent");
AddKeymappingMacro("KEYCODE_BACK",NV_KEYCODE_BACK);
AddKeymappingMacro("KEYCODE_TAB",NV_KEYCODE_TAB);
AddKeymappingMacro("KEYCODE_ENTER",NV_KEYCODE_ENTER);
AddKeymappingMacro("KEYCODE_SPACE",NV_KEYCODE_SPACE);
AddKeymappingMacro("KEYCODE_ENDCALL",NV_KEYCODE_ENDCALL);
AddKeymappingMacro("KEYCODE_HOME",NV_KEYCODE_HOME);
AddKeymappingMacro("KEYCODE_DPAD_LEFT",NV_KEYCODE_DPAD_LEFT);
AddKeymappingMacro("KEYCODE_DPAD_UP",NV_KEYCODE_DPAD_UP);
AddKeymappingMacro("KEYCODE_DPAD_RIGHT",NV_KEYCODE_DPAD_RIGHT);
AddKeymappingMacro("KEYCODE_DPAD_DOWN",NV_KEYCODE_DPAD_DOWN);
AddKeymappingMacro("KEYCODE_DEL",NV_KEYCODE_DEL);
AddKeymappingMacro("KEYCODE_0",NV_KEYCODE_0);
AddKeymappingMacro("KEYCODE_1",NV_KEYCODE_1);
AddKeymappingMacro("KEYCODE_2",NV_KEYCODE_2);
AddKeymappingMacro("KEYCODE_3",NV_KEYCODE_3);
AddKeymappingMacro("KEYCODE_4",NV_KEYCODE_4);
AddKeymappingMacro("KEYCODE_5",NV_KEYCODE_5);
AddKeymappingMacro("KEYCODE_6",NV_KEYCODE_6);
AddKeymappingMacro("KEYCODE_7",NV_KEYCODE_7);
AddKeymappingMacro("KEYCODE_8",NV_KEYCODE_8);
AddKeymappingMacro("KEYCODE_9",NV_KEYCODE_9);
AddKeymappingMacro("KEYCODE_A",NV_KEYCODE_A);
AddKeymappingMacro("KEYCODE_B",NV_KEYCODE_B);
AddKeymappingMacro("KEYCODE_C",NV_KEYCODE_C);
AddKeymappingMacro("KEYCODE_D",NV_KEYCODE_D);
AddKeymappingMacro("KEYCODE_E",NV_KEYCODE_E);
AddKeymappingMacro("KEYCODE_F",NV_KEYCODE_F);
AddKeymappingMacro("KEYCODE_G",NV_KEYCODE_G);
AddKeymappingMacro("KEYCODE_H",NV_KEYCODE_H);
AddKeymappingMacro("KEYCODE_I",NV_KEYCODE_I);
AddKeymappingMacro("KEYCODE_J",NV_KEYCODE_J);
AddKeymappingMacro("KEYCODE_K",NV_KEYCODE_K);
AddKeymappingMacro("KEYCODE_L",NV_KEYCODE_L);
AddKeymappingMacro("KEYCODE_M",NV_KEYCODE_M);
AddKeymappingMacro("KEYCODE_N",NV_KEYCODE_N);
AddKeymappingMacro("KEYCODE_O",NV_KEYCODE_O);
AddKeymappingMacro("KEYCODE_P",NV_KEYCODE_P);
AddKeymappingMacro("KEYCODE_Q",NV_KEYCODE_Q);
AddKeymappingMacro("KEYCODE_R",NV_KEYCODE_R);
AddKeymappingMacro("KEYCODE_S",NV_KEYCODE_S);
AddKeymappingMacro("KEYCODE_T",NV_KEYCODE_T);
AddKeymappingMacro("KEYCODE_U",NV_KEYCODE_U);
AddKeymappingMacro("KEYCODE_V",NV_KEYCODE_V);
AddKeymappingMacro("KEYCODE_W",NV_KEYCODE_W);
AddKeymappingMacro("KEYCODE_X",NV_KEYCODE_X);
AddKeymappingMacro("KEYCODE_Y",NV_KEYCODE_Y);
AddKeymappingMacro("KEYCODE_Z",NV_KEYCODE_Z);
AddKeymappingMacro("KEYCODE_STAR",NV_KEYCODE_STAR);
AddKeymappingMacro("KEYCODE_PLUS",NV_KEYCODE_PLUS);
AddKeymappingMacro("KEYCODE_MINUS",NV_KEYCODE_MINUS);
AddKeymappingMacro("KEYCODE_NUM",NV_KEYCODE_NUM);
AddKeymappingMacro("KEYCODE_ALT_LEFT",NV_KEYCODE_ALT_LEFT);
AddKeymappingMacro("KEYCODE_ALT_RIGHT",NV_KEYCODE_ALT_RIGHT);
AddKeymappingMacro("KEYCODE_SHIFT_LEFT",NV_KEYCODE_SHIFT_LEFT);
AddKeymappingMacro("KEYCODE_SHIFT_RIGHT",NV_KEYCODE_SHIFT_RIGHT);
AddKeymappingMacro("KEYCODE_APOSTROPHE",NV_KEYCODE_APOSTROPHE);
AddKeymappingMacro("KEYCODE_SEMICOLON",NV_KEYCODE_SEMICOLON);
AddKeymappingMacro("KEYCODE_EQUALS",NV_KEYCODE_EQUALS);
AddKeymappingMacro("KEYCODE_COMMA",NV_KEYCODE_COMMA);
AddKeymappingMacro("KEYCODE_PERIOD",NV_KEYCODE_PERIOD);
AddKeymappingMacro("KEYCODE_SLASH",NV_KEYCODE_SLASH);
AddKeymappingMacro("KEYCODE_GRAVE",NV_KEYCODE_GRAVE);
AddKeymappingMacro("KEYCODE_LEFT_BRACKET",NV_KEYCODE_LEFT_BRACKET);
AddKeymappingMacro("KEYCODE_BACKSLASH",NV_KEYCODE_BACKSLASH);
AddKeymappingMacro("KEYCODE_RIGHT_BRACKET",NV_KEYCODE_RIGHT_BRACKET);
}
bool NVKeyCodeMapping::MapKey(int key, NVKeyCode& code)
{
if (key < NV_MAX_KEYCODE)
{
code = m_keyMapping[key];
return true;
}
else
return false;
}
//----------------------------------------------------------------------------------
// File: libs\jni\nv_event\nv_keycode_mapping.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
class NVKeyCodeMapping
{
public:
NVKeyCodeMapping()
{
memset(m_keyMapping, 0, sizeof(NVKeyCode) * NV_MAX_KEYCODE);
}
void Init(JNIEnv* env, jobject thiz);
bool MapKey(int key, NVKeyCode& code);
protected:
void AddKeyMapping(JNIEnv* env, jobject thiz, jclass KeyCode_class, const char* name, NVKeyCode value);
NVKeyCode m_keyMapping[NV_MAX_KEYCODE];
};
/* Init the mapping array, set up the event queue */
void NVKeyCodeMapping::AddKeyMapping(JNIEnv* env, jobject thiz, jclass KeyCode_class, const char* name, NVKeyCode value)
{
// Add a new mapping...
jfieldID id = env->GetStaticFieldID(KeyCode_class, name, "I");
int keyID = env->GetStaticIntField(KeyCode_class, id);
if (keyID < NV_MAX_KEYCODE)
{
/* TODO TBD Should check for collision */
m_keyMapping[keyID] = value;
}
}
#define AddKeymappingMacro(name, value) \
AddKeyMapping(env, thiz, KeyCode_class, name, value)
void NVKeyCodeMapping::Init(JNIEnv* env, jobject thiz)
{
jclass KeyCode_class = env->FindClass("android/view/KeyEvent");
AddKeymappingMacro("KEYCODE_BACK",NV_KEYCODE_BACK);
AddKeymappingMacro("KEYCODE_TAB",NV_KEYCODE_TAB);
AddKeymappingMacro("KEYCODE_ENTER",NV_KEYCODE_ENTER);
AddKeymappingMacro("KEYCODE_SPACE",NV_KEYCODE_SPACE);
AddKeymappingMacro("KEYCODE_ENDCALL",NV_KEYCODE_ENDCALL);
AddKeymappingMacro("KEYCODE_HOME",NV_KEYCODE_HOME);
AddKeymappingMacro("KEYCODE_DPAD_LEFT",NV_KEYCODE_DPAD_LEFT);
AddKeymappingMacro("KEYCODE_DPAD_UP",NV_KEYCODE_DPAD_UP);
AddKeymappingMacro("KEYCODE_DPAD_RIGHT",NV_KEYCODE_DPAD_RIGHT);
AddKeymappingMacro("KEYCODE_DPAD_DOWN",NV_KEYCODE_DPAD_DOWN);
AddKeymappingMacro("KEYCODE_DEL",NV_KEYCODE_DEL);
AddKeymappingMacro("KEYCODE_0",NV_KEYCODE_0);
AddKeymappingMacro("KEYCODE_1",NV_KEYCODE_1);
AddKeymappingMacro("KEYCODE_2",NV_KEYCODE_2);
AddKeymappingMacro("KEYCODE_3",NV_KEYCODE_3);
AddKeymappingMacro("KEYCODE_4",NV_KEYCODE_4);
AddKeymappingMacro("KEYCODE_5",NV_KEYCODE_5);
AddKeymappingMacro("KEYCODE_6",NV_KEYCODE_6);
AddKeymappingMacro("KEYCODE_7",NV_KEYCODE_7);
AddKeymappingMacro("KEYCODE_8",NV_KEYCODE_8);
AddKeymappingMacro("KEYCODE_9",NV_KEYCODE_9);
AddKeymappingMacro("KEYCODE_A",NV_KEYCODE_A);
AddKeymappingMacro("KEYCODE_B",NV_KEYCODE_B);
AddKeymappingMacro("KEYCODE_C",NV_KEYCODE_C);
AddKeymappingMacro("KEYCODE_D",NV_KEYCODE_D);
AddKeymappingMacro("KEYCODE_E",NV_KEYCODE_E);
AddKeymappingMacro("KEYCODE_F",NV_KEYCODE_F);
AddKeymappingMacro("KEYCODE_G",NV_KEYCODE_G);
AddKeymappingMacro("KEYCODE_H",NV_KEYCODE_H);
AddKeymappingMacro("KEYCODE_I",NV_KEYCODE_I);
AddKeymappingMacro("KEYCODE_J",NV_KEYCODE_J);
AddKeymappingMacro("KEYCODE_K",NV_KEYCODE_K);
AddKeymappingMacro("KEYCODE_L",NV_KEYCODE_L);
AddKeymappingMacro("KEYCODE_M",NV_KEYCODE_M);
AddKeymappingMacro("KEYCODE_N",NV_KEYCODE_N);
AddKeymappingMacro("KEYCODE_O",NV_KEYCODE_O);
AddKeymappingMacro("KEYCODE_P",NV_KEYCODE_P);
AddKeymappingMacro("KEYCODE_Q",NV_KEYCODE_Q);
AddKeymappingMacro("KEYCODE_R",NV_KEYCODE_R);
AddKeymappingMacro("KEYCODE_S",NV_KEYCODE_S);
AddKeymappingMacro("KEYCODE_T",NV_KEYCODE_T);
AddKeymappingMacro("KEYCODE_U",NV_KEYCODE_U);
AddKeymappingMacro("KEYCODE_V",NV_KEYCODE_V);
AddKeymappingMacro("KEYCODE_W",NV_KEYCODE_W);
AddKeymappingMacro("KEYCODE_X",NV_KEYCODE_X);
AddKeymappingMacro("KEYCODE_Y",NV_KEYCODE_Y);
AddKeymappingMacro("KEYCODE_Z",NV_KEYCODE_Z);
AddKeymappingMacro("KEYCODE_STAR",NV_KEYCODE_STAR);
AddKeymappingMacro("KEYCODE_PLUS",NV_KEYCODE_PLUS);
AddKeymappingMacro("KEYCODE_MINUS",NV_KEYCODE_MINUS);
AddKeymappingMacro("KEYCODE_NUM",NV_KEYCODE_NUM);
AddKeymappingMacro("KEYCODE_ALT_LEFT",NV_KEYCODE_ALT_LEFT);
AddKeymappingMacro("KEYCODE_ALT_RIGHT",NV_KEYCODE_ALT_RIGHT);
AddKeymappingMacro("KEYCODE_SHIFT_LEFT",NV_KEYCODE_SHIFT_LEFT);
AddKeymappingMacro("KEYCODE_SHIFT_RIGHT",NV_KEYCODE_SHIFT_RIGHT);
AddKeymappingMacro("KEYCODE_APOSTROPHE",NV_KEYCODE_APOSTROPHE);
AddKeymappingMacro("KEYCODE_SEMICOLON",NV_KEYCODE_SEMICOLON);
AddKeymappingMacro("KEYCODE_EQUALS",NV_KEYCODE_EQUALS);
AddKeymappingMacro("KEYCODE_COMMA",NV_KEYCODE_COMMA);
AddKeymappingMacro("KEYCODE_PERIOD",NV_KEYCODE_PERIOD);
AddKeymappingMacro("KEYCODE_SLASH",NV_KEYCODE_SLASH);
AddKeymappingMacro("KEYCODE_GRAVE",NV_KEYCODE_GRAVE);
AddKeymappingMacro("KEYCODE_LEFT_BRACKET",NV_KEYCODE_LEFT_BRACKET);
AddKeymappingMacro("KEYCODE_BACKSLASH",NV_KEYCODE_BACKSLASH);
AddKeymappingMacro("KEYCODE_RIGHT_BRACKET",NV_KEYCODE_RIGHT_BRACKET);
}
bool NVKeyCodeMapping::MapKey(int key, NVKeyCode& code)
{
if (key < NV_MAX_KEYCODE)
{
code = m_keyMapping[key];
return true;
}
else
return false;
}

View file

@ -1,82 +1,82 @@
//----------------------------------------------------------------------------------
// File: libs\jni\nv_event\scoped_profiler.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#ifndef SCOPED_PROFILER_H
#define SCOPED_PROFILER_H
#define PERF_STMTS 0
#if PERF_STMTS == 1
#include "../nv_time/nv_time.hpp"
#include "stdio.h"
#include "stdlib.h"
static char s_bigString[4096];
static int s_bigStringSize;
static char s_tmpBuf[1024];
class ScopedProfiler
{
public:
ScopedProfiler(const char* text)
{
_text = text;
_startTime = nvGetSystemTime();
__last = this;
}
~ScopedProfiler()
{
stop();
}
inline void stop()
{
if(_text)
{
int size = snprintf(s_tmpBuf, dimof(s_tmpBuf)-1, "%d ms spent in %s" , (int)(nvGetSystemTime() - _startTime), _text);
strcat(s_bigString + s_bigStringSize, s_tmpBuf);
s_bigStringSize += size;
_text = 0;
}
static void stopLast()
{
if(__last)
__last->stop();
__last = 0;
}
const char* _text;
long _startTime;
static ScopedProfiler* __last;
};
ScopedProfiler* ScopedProfiler::__last = 0;
#define STRINGIFIER(s) #s
#define CONCAT_(a,b) a ## b
#define CONCAT(a,b) CONCAT_(a,b)
#define PERFBLURB(s) static const char CONCAT(___str,__LINE__)[] = s "\n"; ScopedProfiler CONCAT(SCOPED_PROFILER,__LINE__)(CONCAT(___str,__LINE__));
#define RESET_PROFILING() { DEBUG_D("%s", s_bigString); s_bigString[0] = 0; s_bigStringSize = 0; }
#else
#define PERFBLURB(s)
#define RESET_PROFILING()
#endif
#endif // SCOPED_PROFILER_H
//----------------------------------------------------------------------------------
// File: libs\jni\nv_event\scoped_profiler.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#ifndef SCOPED_PROFILER_H
#define SCOPED_PROFILER_H
#define PERF_STMTS 0
#if PERF_STMTS == 1
#include "../nv_time/nv_time.hpp"
#include "stdio.h"
#include "stdlib.h"
static char s_bigString[4096];
static int s_bigStringSize;
static char s_tmpBuf[1024];
class ScopedProfiler
{
public:
ScopedProfiler(const char* text)
{
_text = text;
_startTime = nvGetSystemTime();
__last = this;
}
~ScopedProfiler()
{
stop();
}
inline void stop()
{
if(_text)
{
int size = snprintf(s_tmpBuf, dimof(s_tmpBuf)-1, "%d ms spent in %s" , (int)(nvGetSystemTime() - _startTime), _text);
strcat(s_bigString + s_bigStringSize, s_tmpBuf);
s_bigStringSize += size;
_text = 0;
}
static void stopLast()
{
if(__last)
__last->stop();
__last = 0;
}
const char* _text;
long _startTime;
static ScopedProfiler* __last;
};
ScopedProfiler* ScopedProfiler::__last = 0;
#define STRINGIFIER(s) #s
#define CONCAT_(a,b) a ## b
#define CONCAT(a,b) CONCAT_(a,b)
#define PERFBLURB(s) static const char CONCAT(___str,__LINE__)[] = s "\n"; ScopedProfiler CONCAT(SCOPED_PROFILER,__LINE__)(CONCAT(___str,__LINE__));
#define RESET_PROFILING() { DEBUG_D("%s", s_bigString); s_bigString[0] = 0; s_bigStringSize = 0; }
#else
#define PERFBLURB(s)
#define RESET_PROFILING()
#endif
#endif // SCOPED_PROFILER_H

View file

@ -1,167 +1,167 @@
//----------------------------------------------------------------------------------
// File: libs\jni\nv_thread\nv_thread.c
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA<49> Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#include <jni.h>
#include "nv_thread.hpp"
#include <android/log.h>
#include <pthread.h>
static JavaVM* s_vm = NULL;
static pthread_key_t s_jniEnvKey = 0;
#define MODULE "NVThread"
#include "../nv_debug/nv_debug.hpp"
#include "../com/mapswithme/core/jni_helper.hpp"
void NVThreadInit(JavaVM* vm)
{
s_vm = vm;
}
JNIEnv* NVThreadGetCurrentJNIEnv()
{
return jni::GetEnv();
// JNIEnv* env = NULL;
// if (s_jniEnvKey)
// {
// env = (JNIEnv*)pthread_getspecific(s_jniEnvKey);
// }
// else
// {
// pthread_key_create(&s_jniEnvKey, NULL);
// }
//
// if (!env)
// {
// // do we have a VM cached?
// if (!s_vm)
// {
// __android_log_print(ANDROID_LOG_DEBUG, MODULE, "Error - could not find JVM!");
// return NULL;
// }
//
// // Hmm - no env for this thread cached yet
// int error = s_vm->AttachCurrentThread(&env, NULL);
// __android_log_print(ANDROID_LOG_DEBUG, MODULE, "AttachCurrentThread: %d, 0x%p", error, env);
// if (error || !env)
// {
// __android_log_print(ANDROID_LOG_DEBUG, MODULE, "Error - could not attach thread to JVM!");
// return NULL;
// }
//
// pthread_setspecific(s_jniEnvKey, env);
// }
//
// return env;
}
typedef struct NVThreadInitStruct
{
void* m_arg;
void *(*m_startRoutine)(void *);
} NVThreadInitStruct;
// Implementations are in PThreadImpl.cpp
// They're used automatically if thread is created with base/thread.hpp
// @TODO: refactor and remove
void AndroidThreadAttachToJVM();
void AndroidThreadDetachFromJVM();
static void* NVThreadSpawnProc(void* arg)
{
NVThreadInitStruct* init = (NVThreadInitStruct*)arg;
void *(*start_routine)(void *) = init->m_startRoutine;
void* data = init->m_arg;
void* ret;
free(arg);
AndroidThreadAttachToJVM();
ret = start_routine(data);
AndroidThreadDetachFromJVM();
return ret;
}
int NVThreadSpawnJNIThread(pthread_t *thread, pthread_attr_t const * attr,
void *(*start_routine)(void *), void * arg)
{
if (!start_routine)
return -1;
NVThreadInitStruct * initData = new NVThreadInitStruct;
initData->m_startRoutine = start_routine;
initData->m_arg = arg;
int err = pthread_create(thread, attr, NVThreadSpawnProc, initData);
// If the thread was not started, then we need to delete the init data ourselves
if (err)
free(initData);
return err;
}
// on linuces, signals can interrupt sleep functions, so you might need to
// retry to get the full sleep going. I'm not entirely sure this is necessary
// *here* clients could retry themselves when the exposed function returns
// nonzero
inline int __sleep(const struct timespec *req, struct timespec *rem)
{
int ret = 1;
int i;
static const int sleepTries = 2;
struct timespec req_tmp={0}, rem_tmp={0};
rem_tmp = *req;
for(i = 0; i < sleepTries; ++i)
{
req_tmp = rem_tmp;
int ret = nanosleep(&req_tmp, &rem_tmp);
if(ret == 0)
{
ret = 0;
break;
}
}
if(rem)
*rem = rem_tmp;
return ret;
}
int NVThreadSleep(unsigned long millisec)
{
struct timespec req={0},rem={0};
time_t sec =(int)(millisec/1000);
millisec = millisec-(sec*1000);
req.tv_sec = sec;
req.tv_nsec = millisec*1000000L;
return __sleep(&req,&rem);
}
//----------------------------------------------------------------------------------
// File: libs\jni\nv_thread\nv_thread.c
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA<49> Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#include <jni.h>
#include "nv_thread.hpp"
#include <android/log.h>
#include <pthread.h>
static JavaVM* s_vm = NULL;
static pthread_key_t s_jniEnvKey = 0;
#define MODULE "NVThread"
#include "../nv_debug/nv_debug.hpp"
#include "../com/mapswithme/core/jni_helper.hpp"
void NVThreadInit(JavaVM* vm)
{
s_vm = vm;
}
JNIEnv* NVThreadGetCurrentJNIEnv()
{
return jni::GetEnv();
// JNIEnv* env = NULL;
// if (s_jniEnvKey)
// {
// env = (JNIEnv*)pthread_getspecific(s_jniEnvKey);
// }
// else
// {
// pthread_key_create(&s_jniEnvKey, NULL);
// }
//
// if (!env)
// {
// // do we have a VM cached?
// if (!s_vm)
// {
// __android_log_print(ANDROID_LOG_DEBUG, MODULE, "Error - could not find JVM!");
// return NULL;
// }
//
// // Hmm - no env for this thread cached yet
// int error = s_vm->AttachCurrentThread(&env, NULL);
// __android_log_print(ANDROID_LOG_DEBUG, MODULE, "AttachCurrentThread: %d, 0x%p", error, env);
// if (error || !env)
// {
// __android_log_print(ANDROID_LOG_DEBUG, MODULE, "Error - could not attach thread to JVM!");
// return NULL;
// }
//
// pthread_setspecific(s_jniEnvKey, env);
// }
//
// return env;
}
typedef struct NVThreadInitStruct
{
void* m_arg;
void *(*m_startRoutine)(void *);
} NVThreadInitStruct;
// Implementations are in PThreadImpl.cpp
// They're used automatically if thread is created with base/thread.hpp
// @TODO: refactor and remove
void AndroidThreadAttachToJVM();
void AndroidThreadDetachFromJVM();
static void* NVThreadSpawnProc(void* arg)
{
NVThreadInitStruct* init = (NVThreadInitStruct*)arg;
void *(*start_routine)(void *) = init->m_startRoutine;
void* data = init->m_arg;
void* ret;
free(arg);
AndroidThreadAttachToJVM();
ret = start_routine(data);
AndroidThreadDetachFromJVM();
return ret;
}
int NVThreadSpawnJNIThread(pthread_t *thread, pthread_attr_t const * attr,
void *(*start_routine)(void *), void * arg)
{
if (!start_routine)
return -1;
NVThreadInitStruct * initData = new NVThreadInitStruct;
initData->m_startRoutine = start_routine;
initData->m_arg = arg;
int err = pthread_create(thread, attr, NVThreadSpawnProc, initData);
// If the thread was not started, then we need to delete the init data ourselves
if (err)
free(initData);
return err;
}
// on linuces, signals can interrupt sleep functions, so you might need to
// retry to get the full sleep going. I'm not entirely sure this is necessary
// *here* clients could retry themselves when the exposed function returns
// nonzero
inline int __sleep(const struct timespec *req, struct timespec *rem)
{
int ret = 1;
int i;
static const int sleepTries = 2;
struct timespec req_tmp={0}, rem_tmp={0};
rem_tmp = *req;
for(i = 0; i < sleepTries; ++i)
{
req_tmp = rem_tmp;
int ret = nanosleep(&req_tmp, &rem_tmp);
if(ret == 0)
{
ret = 0;
break;
}
}
if(rem)
*rem = rem_tmp;
return ret;
}
int NVThreadSleep(unsigned long millisec)
{
struct timespec req={0},rem={0};
time_t sec =(int)(millisec/1000);
millisec = millisec-(sec*1000);
req.tv_sec = sec;
req.tv_nsec = millisec*1000000L;
return __sleep(&req,&rem);
}

View file

@ -1,97 +1,97 @@
//----------------------------------------------------------------------------------
// File: libs\jni\nv_thread\nv_thread.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#ifndef __INCLUDED_NV_THREAD_H
#define __INCLUDED_NV_THREAD_H
#include <jni.h>
#include <pthread.h>
#include <stdlib.h>
#if defined(__cplusplus)
extern "C"
{
#endif
/** @file nv_thread.h
The NVThread library makes it easy to create native threads that can acess
JNI objects. By default, pthreads created in the Android NDK are NOT connected
to the JVM and JNI calls will fail. This library wraps thread creation in
such a way that pthreads created using it will connect to and disconnect from
the JVM as appropriate. Applications creating all of their threads with these
interfaces can use the provided NVThreadGetCurrentJNIEnv() function to
get the current thread's JNI context at any time.
Note that native-created threads still have JNI limitations over threads
that are calls down to native from Java. The JNI function FindClass will
NOT find application-specific classes when called from native threads.
Native code that needs to call FindClass and record the indices of Java
class members for later access must call FindClass and Get*FieldID/Get*MethodID
in threads calling from Java, such as JNI_OnLoad
*/
/**
Initializes the nv_thread system by connecting it to the JVM. This
function must be called as early as possible in the native code's
JNI_OnLoad function, so that the thread system is prepared for any
JNI-dependent library initialization calls.
@param vm The VM pointer - should be the JavaVM pointer sent to JNI_OnLoad.
*/
void NVThreadInit(JavaVM* vm);
/**
Retrieves the JNIEnv object associated with the current thread, allowing
any thread that was creating with NVThreadSpawnJNIThread() to access the
JNI at will. This JNIEnv is NOT usable across multiple calls or threads
The function should be called in each function that requires a JNIEnv
@return The current thread's JNIEnv, or NULL if the thread was not created
by NVThreadSpawnJNIThread
@see NVThreadSpawnJNIThread
*/
JNIEnv* NVThreadGetCurrentJNIEnv();
/**
Spwans a new native thread that is registered for use with JNI. Threads
created with this function will have access to JNI data via the JNIEnv
available from NVThreadGetCurrentJNIEnv().
@param thread is the same as in pthread_create
@param attr is the same as in pthread_create
@param start_routine is the same as in pthread_create
@param arg is the same as in pthread_create
@return 0 on success, -1 on failure
@see NVThreadGetCurrentJNIEnv
*/
int NVThreadSpawnJNIThread(pthread_t *thread, pthread_attr_t const * attr,
void *(*start_routine)(void *), void * arg);
/**
Sleeps the current thread for the specified number of milliseconds
@param millisec Sleep time in ms
@return 0 on success, -1 on failure
*/
int NVThreadSleep(unsigned long millisec);
#if defined(__cplusplus)
}
#endif
#endif
//----------------------------------------------------------------------------------
// File: libs\jni\nv_thread\nv_thread.h
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#ifndef __INCLUDED_NV_THREAD_H
#define __INCLUDED_NV_THREAD_H
#include <jni.h>
#include <pthread.h>
#include <stdlib.h>
#if defined(__cplusplus)
extern "C"
{
#endif
/** @file nv_thread.h
The NVThread library makes it easy to create native threads that can acess
JNI objects. By default, pthreads created in the Android NDK are NOT connected
to the JVM and JNI calls will fail. This library wraps thread creation in
such a way that pthreads created using it will connect to and disconnect from
the JVM as appropriate. Applications creating all of their threads with these
interfaces can use the provided NVThreadGetCurrentJNIEnv() function to
get the current thread's JNI context at any time.
Note that native-created threads still have JNI limitations over threads
that are calls down to native from Java. The JNI function FindClass will
NOT find application-specific classes when called from native threads.
Native code that needs to call FindClass and record the indices of Java
class members for later access must call FindClass and Get*FieldID/Get*MethodID
in threads calling from Java, such as JNI_OnLoad
*/
/**
Initializes the nv_thread system by connecting it to the JVM. This
function must be called as early as possible in the native code's
JNI_OnLoad function, so that the thread system is prepared for any
JNI-dependent library initialization calls.
@param vm The VM pointer - should be the JavaVM pointer sent to JNI_OnLoad.
*/
void NVThreadInit(JavaVM* vm);
/**
Retrieves the JNIEnv object associated with the current thread, allowing
any thread that was creating with NVThreadSpawnJNIThread() to access the
JNI at will. This JNIEnv is NOT usable across multiple calls or threads
The function should be called in each function that requires a JNIEnv
@return The current thread's JNIEnv, or NULL if the thread was not created
by NVThreadSpawnJNIThread
@see NVThreadSpawnJNIThread
*/
JNIEnv* NVThreadGetCurrentJNIEnv();
/**
Spwans a new native thread that is registered for use with JNI. Threads
created with this function will have access to JNI data via the JNIEnv
available from NVThreadGetCurrentJNIEnv().
@param thread is the same as in pthread_create
@param attr is the same as in pthread_create
@param start_routine is the same as in pthread_create
@param arg is the same as in pthread_create
@return 0 on success, -1 on failure
@see NVThreadGetCurrentJNIEnv
*/
int NVThreadSpawnJNIThread(pthread_t *thread, pthread_attr_t const * attr,
void *(*start_routine)(void *), void * arg);
/**
Sleeps the current thread for the specified number of milliseconds
@param millisec Sleep time in ms
@return 0 on success, -1 on failure
*/
int NVThreadSleep(unsigned long millisec);
#if defined(__cplusplus)
}
#endif
#endif

View file

@ -1,164 +1,164 @@
//----------------------------------------------------------------------------------
// File: libs\jni\nv_time\nv_time.cpp
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#include "nv_time.hpp"
#include "../nv_thread/nv_thread.hpp"
/*#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <EGL/eglplatform.h>*/
#include <time.h>
#include <jni.h>
#include <android/log.h>
#include <stdio.h>
#include <unistd.h>
/*#ifndef EGL_NV_system_time
#define EGL_NV_system_time 1
typedef khronos_uint64_t EGLuint64NV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
#endif
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC)(void);
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void);
#endif
*/
void nvAcquireTimeExtensionJNI(JNIEnv*, jobject)
{
nvAcquireTimeExtension();
}
jlong nvGetSystemTimeJNI(JNIEnv*, jobject)
{
return (jlong)nvGetSystemTime();
}
/*static PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC eglGetSystemTimeFrequencyNVProc = NULL;
static PFNEGLGETSYSTEMTIMENVPROC eglGetSystemTimeNVProc = NULL;
static EGLuint64NV eglSystemTimeFrequency = 0;
static bool timeExtensionQueried = false;*/
void nvAcquireTimeExtension()
{
/* if (timeExtensionQueried)
return;
timeExtensionQueried = true;
eglGetSystemTimeFrequencyNVProc = (PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) eglGetProcAddress("eglGetSystemTimeFrequencyNV");
eglGetSystemTimeNVProc = (PFNEGLGETSYSTEMTIMENVPROC) eglGetProcAddress("eglGetSystemTimeNV");
// now, we'll proceed through a series of sanity checking.
// if they all succeed, we'll return.
// if any fail, we fall out of conditional tests to end of function, null pointers, and return.
if (eglGetSystemTimeFrequencyNVProc &&
eglGetSystemTimeNVProc)
{
eglSystemTimeFrequency = eglGetSystemTimeFrequencyNVProc();
if (eglSystemTimeFrequency>0) // assume okay. quick-check it works.
{
EGLuint64NV time1, time2;
time1 = eglGetSystemTimeNVProc();
usleep(2000); // 2ms should be MORE than sufficient, right?
time2 = eglGetSystemTimeNVProc();
if (time1 != time2) // quick sanity only...
{
// we've sanity checked:
// - fn pointers non-null
// - freq non-zero
// - two calls to time sep'd by sleep non-equal
// safe to return now.
return;
}
}
}
// fall back if we've not returned already.
eglGetSystemTimeFrequencyNVProc = (PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) NULL;
eglGetSystemTimeNVProc = (PFNEGLGETSYSTEMTIMENVPROC) NULL;*/
}
bool nvValidTimeExtension()
{
/* if (NULL == eglGetSystemTimeFrequencyNVProc ||
NULL == eglGetSystemTimeNVProc)
return false;
else
return true;*/
}
long nvGetSystemTime()
{
static struct timeval start_time, end_time;
static int isinit = 0;
jlong curr_time = 0;
/* if(eglGetSystemTimeNVProc)
{
EGLuint64NV egltime;
EGLuint64NV egltimequot;
EGLuint64NV egltimerem;
egltime = eglGetSystemTimeNVProc();
egltimequot = egltime / eglSystemTimeFrequency;
egltimerem = egltime - (eglSystemTimeFrequency * egltimequot);
egltimequot *= 1000;
egltimerem *= 1000;
egltimerem /= eglSystemTimeFrequency;
egltimequot += egltimerem;
return (jlong) egltimequot;
}
*/
if (!isinit)
{
gettimeofday(&start_time, 0);
isinit = 1;
}
gettimeofday(&end_time, 0);
curr_time = (end_time.tv_sec - start_time.tv_sec) * 1000;
curr_time += (end_time.tv_usec - start_time.tv_usec) / 1000;
return curr_time;
}
void NVTimeInit()
{
JNIEnv* env = NVThreadGetCurrentJNIEnv();
JNINativeMethod methods_time[] =
{
{
"nvAcquireTimeExtension",
"()V",
(void *) nvAcquireTimeExtension
},
{
"nvGetSystemTime",
"()J",
(void *) nvGetSystemTime
},
};
jclass k_time;
k_time = (env)->FindClass ("com/nvidia/devtech/NvActivity");
(env)->RegisterNatives(k_time, methods_time, 2);
}
//----------------------------------------------------------------------------------
// File: libs\jni\nv_time\nv_time.cpp
// Samples Version: NVIDIA Android Lifecycle samples 1_0beta
// Email: tegradev@nvidia.com
// Web: http://developer.nvidia.com/category/zone/mobile-development
//
// Copyright 2009-2011 NVIDIA® Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
//----------------------------------------------------------------------------------
#include "nv_time.hpp"
#include "../nv_thread/nv_thread.hpp"
/*#include <EGL/egl.h>
#include <EGL/eglext.h>
#include <EGL/eglplatform.h>*/
#include <time.h>
#include <jni.h>
#include <android/log.h>
#include <stdio.h>
#include <unistd.h>
/*#ifndef EGL_NV_system_time
#define EGL_NV_system_time 1
typedef khronos_uint64_t EGLuint64NV;
#ifdef EGL_EGLEXT_PROTOTYPES
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeFrequencyNV(void);
EGLAPI EGLuint64NV EGLAPIENTRY eglGetSystemTimeNV(void);
#endif
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC)(void);
typedef EGLuint64NV (EGLAPIENTRYP PFNEGLGETSYSTEMTIMENVPROC)(void);
#endif
*/
void nvAcquireTimeExtensionJNI(JNIEnv*, jobject)
{
nvAcquireTimeExtension();
}
jlong nvGetSystemTimeJNI(JNIEnv*, jobject)
{
return (jlong)nvGetSystemTime();
}
/*static PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC eglGetSystemTimeFrequencyNVProc = NULL;
static PFNEGLGETSYSTEMTIMENVPROC eglGetSystemTimeNVProc = NULL;
static EGLuint64NV eglSystemTimeFrequency = 0;
static bool timeExtensionQueried = false;*/
void nvAcquireTimeExtension()
{
/* if (timeExtensionQueried)
return;
timeExtensionQueried = true;
eglGetSystemTimeFrequencyNVProc = (PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) eglGetProcAddress("eglGetSystemTimeFrequencyNV");
eglGetSystemTimeNVProc = (PFNEGLGETSYSTEMTIMENVPROC) eglGetProcAddress("eglGetSystemTimeNV");
// now, we'll proceed through a series of sanity checking.
// if they all succeed, we'll return.
// if any fail, we fall out of conditional tests to end of function, null pointers, and return.
if (eglGetSystemTimeFrequencyNVProc &&
eglGetSystemTimeNVProc)
{
eglSystemTimeFrequency = eglGetSystemTimeFrequencyNVProc();
if (eglSystemTimeFrequency>0) // assume okay. quick-check it works.
{
EGLuint64NV time1, time2;
time1 = eglGetSystemTimeNVProc();
usleep(2000); // 2ms should be MORE than sufficient, right?
time2 = eglGetSystemTimeNVProc();
if (time1 != time2) // quick sanity only...
{
// we've sanity checked:
// - fn pointers non-null
// - freq non-zero
// - two calls to time sep'd by sleep non-equal
// safe to return now.
return;
}
}
}
// fall back if we've not returned already.
eglGetSystemTimeFrequencyNVProc = (PFNEGLGETSYSTEMTIMEFREQUENCYNVPROC) NULL;
eglGetSystemTimeNVProc = (PFNEGLGETSYSTEMTIMENVPROC) NULL;*/
}
bool nvValidTimeExtension()
{
/* if (NULL == eglGetSystemTimeFrequencyNVProc ||
NULL == eglGetSystemTimeNVProc)
return false;
else
return true;*/
}
long nvGetSystemTime()
{
static struct timeval start_time, end_time;
static int isinit = 0;
jlong curr_time = 0;
/* if(eglGetSystemTimeNVProc)
{
EGLuint64NV egltime;
EGLuint64NV egltimequot;
EGLuint64NV egltimerem;
egltime = eglGetSystemTimeNVProc();
egltimequot = egltime / eglSystemTimeFrequency;
egltimerem = egltime - (eglSystemTimeFrequency * egltimequot);
egltimequot *= 1000;
egltimerem *= 1000;
egltimerem /= eglSystemTimeFrequency;
egltimequot += egltimerem;
return (jlong) egltimequot;
}
*/
if (!isinit)
{
gettimeofday(&start_time, 0);
isinit = 1;
}
gettimeofday(&end_time, 0);
curr_time = (end_time.tv_sec - start_time.tv_sec) * 1000;
curr_time += (end_time.tv_usec - start_time.tv_usec) / 1000;
return curr_time;
}
void NVTimeInit()
{
JNIEnv* env = NVThreadGetCurrentJNIEnv();
JNINativeMethod methods_time[] =
{
{
"nvAcquireTimeExtension",
"()V",
(void *) nvAcquireTimeExtension
},
{
"nvGetSystemTime",
"()J",
(void *) nvGetSystemTime
},
};
jclass k_time;
k_time = (env)->FindClass ("com/nvidia/devtech/NvActivity");
(env)->RegisterNatives(k_time, methods_time, 2);
}

View file

@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="32px" height="32px" viewBox="0 -17 792 594" enable-background="new 0 0 792 612" xml:space="preserve">
<polygon fill="#333333" points="548.591,267.392 6.923,267.392 6.923,305.663 548.634,305.663 548.718,374.713 634.646,362.949
784.07,286.093 634.646,211.018 548.506,199.825 "/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.1, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="32px" height="32px" viewBox="0 -17 792 594" enable-background="new 0 0 792 612" xml:space="preserve">
<polygon fill="#333333" points="548.591,267.392 6.923,267.392 6.923,305.663 548.634,305.663 548.718,374.713 634.646,362.949
784.07,286.093 634.646,211.018 548.506,199.825 "/>
</svg>

Before

Width:  |  Height:  |  Size: 670 B

After

Width:  |  Height:  |  Size: 662 B

View file

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#263C91" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#D7E4F0"/>
<stop offset="0.299" style="stop-color:#C1D2E8"/>
<stop offset="0.4179" style="stop-color:#96AFD8"/>
<stop offset="0.5375" style="stop-color:#7696CC"/>
<stop offset="0.6561" style="stop-color:#5D85C3"/>
<stop offset="0.7734" style="stop-color:#497ABD"/>
<stop offset="0.8887" style="stop-color:#3C74BA"/>
<stop offset="1" style="stop-color:#3772B9"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#263C91" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#D7E4F0"/>
<stop offset="0.299" style="stop-color:#C1D2E8"/>
<stop offset="0.4179" style="stop-color:#96AFD8"/>
<stop offset="0.5375" style="stop-color:#7696CC"/>
<stop offset="0.6561" style="stop-color:#5D85C3"/>
<stop offset="0.7734" style="stop-color:#497ABD"/>
<stop offset="0.8887" style="stop-color:#3C74BA"/>
<stop offset="1" style="stop-color:#3772B9"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#895121" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.1805" style="stop-color:#DBC5A4"/>
<stop offset="0.198" style="stop-color:#D9C19E"/>
<stop offset="0.334" style="stop-color:#CDA577"/>
<stop offset="0.4708" style="stop-color:#C5915A"/>
<stop offset="0.6065" style="stop-color:#BF8344"/>
<stop offset="0.7406" style="stop-color:#BB7A36"/>
<stop offset="0.8726" style="stop-color:#B9742E"/>
<stop offset="1" style="stop-color:#B8722C"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#895121" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.1805" style="stop-color:#DBC5A4"/>
<stop offset="0.198" style="stop-color:#D9C19E"/>
<stop offset="0.334" style="stop-color:#CDA577"/>
<stop offset="0.4708" style="stop-color:#C5915A"/>
<stop offset="0.6065" style="stop-color:#BF8344"/>
<stop offset="0.7406" style="stop-color:#BB7A36"/>
<stop offset="0.8726" style="stop-color:#B9742E"/>
<stop offset="1" style="stop-color:#B8722C"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(0.9858 -0.168 0.168 0.9858 -9.5425 5.6443)" opacity="0.5" fill="#808285" enable-background="new " cx="28.594" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" enable-background="new " points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="568.1318" y1="823.5293" x2="576.4692" y2="822.7785" gradientTransform="matrix(1 0 0 1 -547 -777)">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#00751E" enable-background="new " cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="570.5215" cy="797.8936" r="18.0152" fx="561.4042" fy="792.0648" gradientTransform="matrix(1 0 0 1 -547 -777)" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#E5F1DA"/>
<stop offset="0.2638" style="stop-color:#DFEED4"/>
<stop offset="0.3705" style="stop-color:#B6DCAB"/>
<stop offset="0.4785" style="stop-color:#93CD8C"/>
<stop offset="0.5857" style="stop-color:#75C273"/>
<stop offset="0.6919" style="stop-color:#5ABB5E"/>
<stop offset="0.797" style="stop-color:#41B652"/>
<stop offset="0.9003" style="stop-color:#2BB34C"/>
<stop offset="1" style="stop-color:#21B24B"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(0.9858 -0.168 0.168 0.9858 -9.5425 5.6443)" opacity="0.5" fill="#808285" enable-background="new " cx="28.594" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" enable-background="new " points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="568.1318" y1="823.5293" x2="576.4692" y2="822.7785" gradientTransform="matrix(1 0 0 1 -547 -777)">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#00751E" enable-background="new " cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="570.5215" cy="797.8936" r="18.0152" fx="561.4042" fy="792.0648" gradientTransform="matrix(1 0 0 1 -547 -777)" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#E5F1DA"/>
<stop offset="0.2638" style="stop-color:#DFEED4"/>
<stop offset="0.3705" style="stop-color:#B6DCAB"/>
<stop offset="0.4785" style="stop-color:#93CD8C"/>
<stop offset="0.5857" style="stop-color:#75C273"/>
<stop offset="0.6919" style="stop-color:#5ABB5E"/>
<stop offset="0.797" style="stop-color:#41B652"/>
<stop offset="0.9003" style="stop-color:#2BB34C"/>
<stop offset="1" style="stop-color:#21B24B"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

View file

@ -1,26 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#C86F29" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#FFF3E8"/>
<stop offset="0.2977" style="stop-color:#FFE7CD"/>
<stop offset="0.3995" style="stop-color:#FED19F"/>
<stop offset="0.5025" style="stop-color:#FCBE7A"/>
<stop offset="0.6047" style="stop-color:#FBAF5C"/>
<stop offset="0.7061" style="stop-color:#FAA342"/>
<stop offset="0.8063" style="stop-color:#F99C2F"/>
<stop offset="0.9049" style="stop-color:#F89724"/>
<stop offset="1" style="stop-color:#F89520"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#C86F29" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#FFF3E8"/>
<stop offset="0.2977" style="stop-color:#FFE7CD"/>
<stop offset="0.3995" style="stop-color:#FED19F"/>
<stop offset="0.5025" style="stop-color:#FCBE7A"/>
<stop offset="0.6047" style="stop-color:#FBAF5C"/>
<stop offset="0.7061" style="stop-color:#FAA342"/>
<stop offset="0.8063" style="stop-color:#F99C2F"/>
<stop offset="0.9049" style="stop-color:#F89724"/>
<stop offset="1" style="stop-color:#F89520"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View file

@ -1,25 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#BA2B91" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#F1D0E4"/>
<stop offset="0.2606" style="stop-color:#F0CDE2"/>
<stop offset="0.386" style="stop-color:#EAA9CC"/>
<stop offset="0.5122" style="stop-color:#E68DBB"/>
<stop offset="0.6372" style="stop-color:#E377AF"/>
<stop offset="0.7609" style="stop-color:#E166A6"/>
<stop offset="0.8826" style="stop-color:#E05AA1"/>
<stop offset="1" style="stop-color:#E0569F"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#BA2B91" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#F1D0E4"/>
<stop offset="0.2606" style="stop-color:#F0CDE2"/>
<stop offset="0.386" style="stop-color:#EAA9CC"/>
<stop offset="0.5122" style="stop-color:#E68DBB"/>
<stop offset="0.6372" style="stop-color:#E377AF"/>
<stop offset="0.7609" style="stop-color:#E166A6"/>
<stop offset="0.8826" style="stop-color:#E05AA1"/>
<stop offset="1" style="stop-color:#E0569F"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View file

@ -1,24 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#702774" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#E8CCE2"/>
<stop offset="0.3676" style="stop-color:#CBA5CD"/>
<stop offset="0.4964" style="stop-color:#B486BC"/>
<stop offset="0.6255" style="stop-color:#A371B0"/>
<stop offset="0.7532" style="stop-color:#9962A9"/>
<stop offset="0.8788" style="stop-color:#9359A4"/>
<stop offset="1" style="stop-color:#9156A2"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="48px" height="64px" viewBox="0 0 48 64" enable-background="new 0 0 48 64" xml:space="preserve">
<ellipse transform="matrix(-0.9858 0.1681 -0.1681 -0.9858 66.7396 112.8113)" opacity="0.5" fill="#808285" cx="28.595" cy="59.23" rx="7.5" ry="2.5"/>
<polygon opacity="0.6" fill="#6D6E71" points="32,60 23,61 19,32 31,31 "/>
<linearGradient id="SVGID_1_" gradientUnits="userSpaceOnUse" x1="21.1318" y1="46.5293" x2="29.4692" y2="45.7785">
<stop offset="0" style="stop-color:#E6E6E6"/>
<stop offset="1" style="stop-color:#C4C4C4"/>
</linearGradient>
<polygon fill="url(#SVGID_1_)" points="30,59 25,60 21,33 29,32 "/>
<circle opacity="0.8" fill="#702774" cx="24" cy="21.917" r="20"/>
<radialGradient id="SVGID_2_" cx="23.522" cy="20.8936" r="18.0147" fx="14.8544" fy="14.3447" gradientUnits="userSpaceOnUse">
<stop offset="0.248" style="stop-color:#E8CCE2"/>
<stop offset="0.3676" style="stop-color:#CBA5CD"/>
<stop offset="0.4964" style="stop-color:#B486BC"/>
<stop offset="0.6255" style="stop-color:#A371B0"/>
<stop offset="0.7532" style="stop-color:#9962A9"/>
<stop offset="0.8788" style="stop-color:#9359A4"/>
<stop offset="1" style="stop-color:#9156A2"/>
</radialGradient>
<circle fill="url(#SVGID_2_)" cx="24" cy="21.917" r="18.015"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB