1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-21 16:55:01 -05:00

Merge branch 'master' into mem-clean

This commit is contained in:
Merlijn Wajer 2011-07-07 12:09:04 +02:00
commit 83f852db83
6 changed files with 360 additions and 5 deletions

View File

@ -41,7 +41,7 @@ master_doc = 'index'
# General information about the project.
project = u'Simba'
copyright = u'2010, Merlijn Wajer'
copyright = u'2010, Merlijn Wajer, Raymond van Venetie'
# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
@ -176,7 +176,7 @@ htmlhelp_basename = 'Simbadoc'
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'Simba.tex', u'Simba Documentation',
u'Merlijn Wajer', 'manual'),
u'Merlijn Wajer, Raymond van Venetie', 'manual'),
]
# The name of an image file (relative to this directory) to place at the top of

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

View File

@ -0,0 +1,199 @@
<?xml version="1.0"?>
<CONFIG>
<ProjectOptions>
<Version Value="9"/>
<General>
<Flags>
<MainUnitHasCreateFormStatements Value="False"/>
</Flags>
<MainUnit Value="0"/>
<ResourceType Value="res"/>
<UseXPManifest Value="True"/>
<Icon Value="0"/>
<ActiveWindowIndexAtStart Value="0"/>
</General>
<i18n>
<EnableI18N LFM="False"/>
</i18n>
<VersionInfo>
<StringTable ProductVersion=""/>
</VersionInfo>
<BuildModes Count="1" Active="Default">
<Item1 Name="Default" Default="True"/>
</BuildModes>
<PublishOptions>
<Version Value="2"/>
<IncludeFileFilter Value="*.(pas|pp|inc|lfm|lpr|lrs|lpi|lpk|sh|xml)"/>
<ExcludeFileFilter Value="*.(bak|ppu|o|so);*~;backup"/>
</PublishOptions>
<RunParams>
<local>
<FormatVersion Value="1"/>
</local>
</RunParams>
<Units Count="6">
<Unit0>
<Filename Value="project1.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="project1"/>
<IsVisibleTab Value="True"/>
<EditorIndex Value="0"/>
<WindowIndex Value="0"/>
<TopLine Value="47"/>
<CursorPos X="25" Y="58"/>
<UsageCount Value="20"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="../../Units/MMLCore/client.pas"/>
<UnitName Value="Client"/>
<EditorIndex Value="4"/>
<WindowIndex Value="0"/>
<TopLine Value="1"/>
<CursorPos X="89" Y="10"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="../../../fpc/packages/fcl-base/src/custapp.pp"/>
<UnitName Value="CustApp"/>
<WindowIndex Value="0"/>
<TopLine Value="42"/>
<CursorPos X="14" Y="63"/>
<UsageCount Value="10"/>
</Unit2>
<Unit3>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<UnitName Value="bitmaps"/>
<EditorIndex Value="2"/>
<WindowIndex Value="0"/>
<TopLine Value="863"/>
<CursorPos X="12" Y="883"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
<UnitName Value="os_linux"/>
<EditorIndex Value="3"/>
<WindowIndex Value="0"/>
<TopLine Value="9"/>
<CursorPos X="79" Y="32"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="../../Units/MMLCore/colour_conv.pas"/>
<UnitName Value="colour_conv"/>
<EditorIndex Value="1"/>
<WindowIndex Value="0"/>
<TopLine Value="12"/>
<CursorPos X="60" Y="33"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit5>
</Units>
<JumpHistory Count="15" HistoryIndex="14">
<Position1>
<Filename Value="project1.lpr"/>
<Caret Line="34" Column="11" TopLine="13"/>
</Position1>
<Position2>
<Filename Value="project1.lpr"/>
<Caret Line="42" Column="21" TopLine="13"/>
</Position2>
<Position3>
<Filename Value="project1.lpr"/>
<Caret Line="34" Column="11" TopLine="1"/>
</Position3>
<Position4>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position4>
<Position5>
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position5>
<Position6>
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
<Caret Line="34" Column="103" TopLine="8"/>
</Position6>
<Position7>
<Filename Value="../../Units/MMLCore/os_linux.pas"/>
<Caret Line="29" Column="64" TopLine="8"/>
</Position7>
<Position8>
<Filename Value="../../Units/MMLCore/colour_conv.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position8>
<Position9>
<Filename Value="project1.lpr"/>
<Caret Line="10" Column="48" TopLine="1"/>
</Position9>
<Position10>
<Filename Value="project1.lpr"/>
<Caret Line="17" Column="45" TopLine="1"/>
</Position10>
<Position11>
<Filename Value="project1.lpr"/>
<Caret Line="34" Column="19" TopLine="13"/>
</Position11>
<Position12>
<Filename Value="project1.lpr"/>
<Caret Line="40" Column="20" TopLine="25"/>
</Position12>
<Position13>
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<Caret Line="27" Column="82" TopLine="1"/>
</Position13>
<Position14>
<Filename Value="project1.lpr"/>
<Caret Line="34" Column="16" TopLine="20"/>
</Position14>
<Position15>
<Filename Value="project1.lpr"/>
<Caret Line="43" Column="32" TopLine="24"/>
</Position15>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="10"/>
<Target>
<Filename Value="project1"/>
</Target>
<SearchPaths>
<IncludeFiles Value="$(ProjOutDir)"/>
<OtherUnitFiles Value="../../Units/MMLCore;../../Units/Linux;../../Units/Misc;$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS);$(LazarusDir)/lcl/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType);$(LazarusDir)/components/mouseandkeyinput"/>
<UnitOutputDirectory Value="lib/$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
<CodeGeneration>
<Optimizations>
<OptimizationLevel Value="3"/>
</Optimizations>
</CodeGeneration>
<Linking>
<Debugging>
<GenerateDebugInfo Value="True"/>
</Debugging>
</Linking>
<Other>
<CompilerMessages>
<UseMsgFile Value="True"/>
</CompilerMessages>
<CompilerPath Value="$(CompPath)"/>
</Other>
</CompilerOptions>
<Debugging>
<Exceptions Count="3">
<Item1>
<Name Value="EAbort"/>
</Item1>
<Item2>
<Name Value="ECodetoolError"/>
</Item2>
<Item3>
<Name Value="EFOpenError"/>
</Item3>
</Exceptions>
</Debugging>
</CONFIG>

View File

@ -0,0 +1,139 @@
program project1;
{$mode objfpc}{$H+}
uses
{$IFDEF UNIX}{$IFDEF UseCThreads}
cthreads,
{$ENDIF}{$ENDIF}
Classes, SysUtils, CustApp,
interfaces, // to prevent linking errors. :|
client, MufasaTypes,
lclintf;
type
{ TMMLBenchmark }
TMMLBenchmark = class(TCustomApplication)
protected
procedure DoRun; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
procedure WriteHelp; virtual;
end;
var
bmp: Integer;
MMLClient: TClient;
{ TMMLBenchmark }
procedure init;
begin
MMLClient := TClient.Create('');
bmp := MMLClient.MBitmaps.CreateBMP(0, 0);
MMLClient.MBitmaps.GetBMP(bmp).LoadFromFile('/home/merlijn/Programs/simba/wall.bmp');
MMLClient.IOManager.SetTarget(MMLClient.MBitmaps[bmp]);
end;
procedure free;
begin
MMLClient.IOManager.SetDesktop;
MMLClient.MBitmaps.FreeBMP(bmp);
MMLClient.Free;
end;
procedure Benchmark;
var
t, t2, t3: PtrUInt;
i, c, w, h: integer;
col, tol: integer;
dummytpa: TPointArray;
begin
init;
t := gettickcount;
MMLClient.IOManager.GetDimensions(w, h);
col := 16777215; tol := 30;
for c := 0 to 2 do // benchmark all CTS'es
begin
MMLClient.MFinder.SetToleranceSpeed(c);
t2 := gettickcount;
for i := 0 to 100 do
begin
MMLClient.MFinder.FindColorsTolerance(dummytpa, col, 0, 0, w-1,h-1, tol);
end;
t3 := gettickcount;
writeln(format('FindColorsTolerance'+#10+
'Time spent: %d ms (per %f ms), matches: %d, CTS: %d, Colour: %d, Tolerance %d',
[t3-t2, (t3-t2) / 100.0, length(dummytpa), c, col, tol]));
end;
free;
end;
procedure TMMLBenchmark.DoRun;
var
ErrorMsg: String;
begin
// quick check parameters
ErrorMsg:=CheckOptions('h','help');
if ErrorMsg<>'' then begin
ShowException(Exception.Create(ErrorMsg));
Terminate;
Exit;
end;
// parse parameters
if HasOption('h','help') then begin
WriteHelp;
Terminate;
Exit;
end;
Benchmark;
{ add your program here }
// stop program loop
Terminate;
end;
constructor TMMLBenchmark.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
StopOnException:=True;
end;
destructor TMMLBenchmark.Destroy;
begin
inherited Destroy;
end;
procedure TMMLBenchmark.WriteHelp;
begin
{ add your help code here }
writeln('Usage: ',ExeName,' -h');
end;
var
Application: TMMLBenchmark;
{$R *.res}
begin
Application:=TMMLBenchmark.Create(nil);
Application.Run;
Application.Free;
end.

21
TODO
View File

@ -6,8 +6,25 @@ Simple stuff, not required, may not be possible/useful:
- --no-extensions flag for Simba. [ ]
- CTS rewrite to add CTS 3 and others. [ ]
- CTS/finder speedups. [ ]
- CTS/finder speedups and changes [ ]
General ideas:
- everything subprocedure (lots of code)
- jit + comparison function (per cts) generated, call in loop
- comparison function (per cts), not generated, call in loop
- JIT (Generate comparison functions) [ ]
- Comparison functions for HSL/XYZ/L*a*b should check for
match on each component before calculating the next.
(see FindColorsToleranceOptimised)
- Pass color information in struct [ ]
- Precalculate screen bitmap in current cts / keep a cache
to save comparisons [ ]
- Add CTS 3 [ ]
- Add a direct RGB -> CIE L*a*b conversion [ ]
- Make sure colour conversions are inline [ ]
- More documentation:
- Cover all functions by at least mentioning the definition [ ]

@ -1 +1 @@
Subproject commit 04cea473001dd095581698a70ec1dc1d8c1aee35
Subproject commit 1b8211db373428cd2916905980ad51be8fab1f83