1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Dummy mnit platform for headless executions
17 # Extends `mnit_injected_input` so that the whole application is simulated.
18 # This permits more debugging and benchmarking, even without screen (thinks
21 # Assets loading and display operations are executed with an empty body,
22 # Except on frames that have some injected input events, in theses the
23 # description of all blit operations are printed to screen.
27 intrude import mnit_injected_input
31 # Dummy display that just display nothing
35 redef var height
= 480
36 redef fun begin
do end
37 redef fun finish
do end
38 redef fun clear
(r
,g
,b
)
40 if not app
.verbose
then return
41 print
"CLEAR rgb({r};{g};{b})"
43 redef fun blit
(image
, x
, y
)
45 if not app
.verbose
then return
46 print
"BLIT {image} ({x},{y})"
48 redef fun blit_centered
(image
, x
, y
)
50 if not app
.verbose
then return
51 print
"BLIT {image} CENTERED ({x},{y})"
53 redef fun blit_rotated
(image
, x
, y
, a
)
55 if not app
.verbose
then return
56 print
"BLIT {image} CENTERED ({x},{y}) ROTATED {a}"
58 redef fun blit_rotated_scaled
(image
, x
, y
, a
, s
)
60 if not app
.verbose
then return
61 print
"BLIT {image} CENTERED ({x},{y}) ROTATED {a} SCALED {s}"
63 redef fun blit_scaled
(image
, x
, y
, w
, h
)
65 if not app
.verbose
then return
66 print
"BLIT {image} ({x},{y}) -- ({x+w},{y+h})"
68 redef fun blit_stretched
(image
, ax
, ay
, bx
, by
, cx
, cy
, dx
, dy
)
70 if not app
.verbose
then return
71 print
"BLIT {image} ({ax},{ay}) -- ({bx},{by}) -- ({cx},{cy}) -- ({dx},{dy})"
75 # Dummy image for a NullDisplay
79 redef fun to_s
do return path
80 redef var scale
= 1.0 is redef writable
89 display
= new NullDisplay
93 # Force the printing of blit operations
94 # So traces of execution can be generated
95 # Managed by `generate_injected_input`
96 private var verbose
= false
98 redef fun limit_fps
do return
100 redef fun generate_injected_input
106 redef fun generate_input
108 # An implementation is required but to avoid infinite loops
109 # we just `quit` when the stream is closed.
110 if injected_input_stream
== null then
116 redef fun try_loading_asset
(path
)
119 return new NullImage(path
)