aboutsummaryrefslogtreecommitdiffstats
path: root/lib/percept/src/egd_render.erl
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2010-02-17 11:13:42 +0000
committerErlang/OTP <[email protected]>2010-02-17 11:13:42 +0000
commit40b76c2e854c9771f8699fd143299ad2d6de4603 (patch)
tree0785b7428656150c1ee6d19345dee941355ab4f6 /lib/percept/src/egd_render.erl
parent4a33e37e8c1b4f60a6890dccae438cd8fbbb05ef (diff)
parenta8bf1fe3b9f5f69354403231a3c47489d9015977 (diff)
downloadotp-40b76c2e854c9771f8699fd143299ad2d6de4603.tar.gz
otp-40b76c2e854c9771f8699fd143299ad2d6de4603.tar.bz2
otp-40b76c2e854c9771f8699fd143299ad2d6de4603.zip
Merge branch 'ks/cleanups' into ccase/r13b04_dev
* ks/cleanups: percept: Clean up as suggested by tidier percept: Modernize types and specs parsetools: Don't use 'try...of' when 'try' will do parsetools: Use %% for comments at the beginning of a line parsetools: Replace lists:keysearch/3 with lists:keyfind/3 parsetools: Modernize types and specs parsetools: Replace TABs with spaces runtime_tools: Modernize specs sasl: Eliminate tuple used as fun sasl: Add missing modules to app file asn1: Clean up as suggested by tidier os_mon: Modernize types and specs wx: Clean up as suggested by tidier OTP-8455 ks/cleanups
Diffstat (limited to 'lib/percept/src/egd_render.erl')
-rw-r--r--lib/percept/src/egd_render.erl22
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/percept/src/egd_render.erl b/lib/percept/src/egd_render.erl
index 4a0247dd33..7fd1072ab1 100644
--- a/lib/percept/src/egd_render.erl
+++ b/lib/percept/src/egd_render.erl
@@ -29,7 +29,8 @@
-include("egd.hrl").
-define('DummyC',0).
-binary(Image) -> binary(Image, opaque).
+binary(Image) ->
+ binary(Image, opaque).
binary(Image, Type) ->
parallel_binary(precompile(Image),Type).
@@ -42,9 +43,8 @@ parallel_binary(Image = #image{ height = Height },Type) ->
W = Image#image.width,
Bg = Image#image.background,
Os = Image#image.objects,
- erlang:list_to_binary(lists:map(fun
- (Y) -> scanline(Y, Os, {0,0,W - 1, Bg}, Type)
- end, lists:seq(1, Height)));
+ erlang:list_to_binary([scanline(Y, Os, {0,0,W - 1, Bg}, Type)
+ || Y <- lists:seq(1, Height)]);
Np ->
Pids = start_workers(Np, Type),
Handler = handle_workers(Height, Pids),
@@ -54,7 +54,9 @@ parallel_binary(Image = #image{ height = Height },Type) ->
Res
end.
-start_workers(Np, Type) -> start_workers(Np, Type, []).
+start_workers(Np, Type) ->
+ start_workers(Np, Type, []).
+
start_workers( 0, _, Pids) -> Pids;
start_workers(Np, Type, Pids) when Np > 0 ->
start_workers(Np - 1, Type, [spawn_link(fun() -> worker(Type) end)|Pids]).
@@ -90,7 +92,9 @@ init_workers(Image, Handler, [Pid|Pids]) ->
Handler ! {Pid, scan_complete},
init_workers(Image, Handler, Pids).
-handle_workers(H, Pids) -> spawn_link(fun() -> handle_workers(H, H, length(Pids)) end).
+handle_workers(H, Pids) ->
+ spawn_link(fun() -> handle_workers(H, H, length(Pids)) end).
+
handle_workers(_, 0, _) -> ok;
handle_workers(H, Hi, Np) when H > 0 ->
N = trunc(Hi/(2*Np)),
@@ -110,7 +114,9 @@ finish_workers([Pid|Pids]) ->
Pid ! {self(), done},
finish_workers(Pids).
-receive_binaries(H) -> receive_binaries(H, []).
+receive_binaries(H) ->
+ receive_binaries(H, []).
+
receive_binaries(0, Bins) -> erlang:list_to_binary(Bins);
receive_binaries(H, Bins) when H > 0 ->
receive
@@ -118,7 +124,6 @@ receive_binaries(H, Bins) when H > 0 ->
receive_binaries(H - 1, [Bin|Bins])
end.
-
scanline(Y, Os, {_,_,Width,_}=LSB, Type) ->
OLSs = parse_objects_on_line(Y-1, Width, Os),
RLSs = resulting_line_spans([LSB|OLSs],Type),
@@ -190,7 +195,6 @@ modify_layers(Layers,[{{_,Z,start},C}|Trans]) ->
modify_layers(Layers,[{{_,Z,stop },C}|Trans]) ->
modify_layers(remove_layer(Layers, Z, C), Trans).
-
add_layer([{Z1,_}=H|Layers],Z,C) when Z1 > Z ->
[H|add_layer(Layers,Z,C)];
add_layer(Layers,Z,C) ->