nano3d: get rid of env() calls

Issue #1987
This commit is contained in:
Martin Stein 2017-02-24 17:19:21 +01:00 committed by Christian Helmuth
parent 128faadc31
commit 9b8fcb5fd0
2 changed files with 13 additions and 10 deletions

View File

@ -69,6 +69,8 @@ class Nano3d::Scene
{ {
enum { NUM_BUFFERS = 3 }; enum { NUM_BUFFERS = 3 };
Genode::Region_map &rm;
static Framebuffer::Session & static Framebuffer::Session &
_init_framebuffer(Nitpicker::Connection &nitpicker, _init_framebuffer(Nitpicker::Connection &nitpicker,
Nitpicker::Area const size) Nitpicker::Area const size)
@ -104,7 +106,7 @@ class Nano3d::Scene
return Nitpicker::Area(mode.width(), mode.height()/NUM_BUFFERS); return Nitpicker::Area(mode.width(), mode.height()/NUM_BUFFERS);
} }
Genode::Attached_dataspace ds { framebuffer.dataspace() }; Genode::Attached_dataspace ds { rm, framebuffer.dataspace() };
PT *pixel_base(unsigned i) PT *pixel_base(unsigned i)
{ {
@ -134,12 +136,13 @@ class Nano3d::Scene
NUM_BUFFERS*size().count()); NUM_BUFFERS*size().count());
} }
Mapped_framebuffer(Nitpicker::Connection &nitpicker, Nitpicker::Area size) Mapped_framebuffer(Nitpicker::Connection &nitpicker, Nitpicker::Area size,
Genode::Region_map &rm)
: :
framebuffer(_init_framebuffer(nitpicker, size)) rm(rm), framebuffer(_init_framebuffer(nitpicker, size))
{ } { }
} _framebuffer { _nitpicker, _size }; } _framebuffer { _nitpicker, _size, _env.rm() };
Nitpicker::Session::View_handle _view_handle = _nitpicker.create_view(); Nitpicker::Session::View_handle _view_handle = _nitpicker.create_view();
@ -189,7 +192,7 @@ class Nano3d::Scene
Timer::Connection _timer { _env }; Timer::Connection _timer { _env };
Genode::Attached_dataspace _input_ds { _nitpicker.input()->dataspace() }; Genode::Attached_dataspace _input_ds { _env.rm(), _nitpicker.input()->dataspace() };
Input_handler *_input_handler_callback = nullptr; Input_handler *_input_handler_callback = nullptr;

View File

@ -12,6 +12,7 @@
*/ */
/* Genode includes */ /* Genode includes */
#include <base/heap.h>
#include <base/component.h> #include <base/component.h>
#include <base/attached_rom_dataspace.h> #include <base/attached_rom_dataspace.h>
#include <polygon_gfx/shaded_polygon_painter.h> #include <polygon_gfx/shaded_polygon_painter.h>
@ -34,6 +35,7 @@ class Scene : public Nano3d::Scene<PT>
private: private:
Genode::Env &_env; Genode::Env &_env;
Genode::Heap _heap { _env.ram(), _env.rm() };
Nitpicker::Area const _size; Nitpicker::Area const _size;
@ -114,10 +116,8 @@ class Scene : public Nano3d::Scene<PT>
private: private:
Polygon::Shaded_painter _shaded_painter { Polygon::Shaded_painter _shaded_painter { _heap, _size.h() };
*Genode::env()->heap(), _size.h() }; Polygon::Textured_painter _textured_painter { _heap, _size.h() };
Polygon::Textured_painter _textured_painter {
*Genode::env()->heap(), _size.h() };
Nano3d::Cube_shape const _cube { 7000 }; Nano3d::Cube_shape const _cube { 7000 };
Nano3d::Dodecahedron_shape const _dodecahedron { 10000 }; Nano3d::Dodecahedron_shape const _dodecahedron { 10000 };