2014-07-02 22:00:15 +02:00
|
|
|
/*
|
|
|
|
* \brief Minimalistic nitpicker pointer
|
|
|
|
* \author Norman Feske
|
|
|
|
* \date 2014-07-02
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2017-02-20 13:23:52 +01:00
|
|
|
* Copyright (C) 2014-2017 Genode Labs GmbH
|
2014-07-02 22:00:15 +02:00
|
|
|
*
|
|
|
|
* This file is part of the Genode OS framework, which is distributed
|
2017-02-20 13:23:52 +01:00
|
|
|
* under the terms of the GNU Affero General Public License version 3.
|
2014-07-02 22:00:15 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* Genode includes */
|
|
|
|
#include <nitpicker_session/connection.h>
|
|
|
|
#include <os/surface.h>
|
|
|
|
#include <os/pixel_rgb565.h>
|
2017-01-02 14:25:51 +01:00
|
|
|
#include <base/attached_dataspace.h>
|
|
|
|
#include <base/component.h>
|
2014-07-02 22:00:15 +02:00
|
|
|
|
|
|
|
/* local includes */
|
|
|
|
#include "big_mouse.h"
|
|
|
|
|
|
|
|
|
|
|
|
template <typename PT>
|
|
|
|
void convert_cursor_data_to_pixels(PT *pixel, Nitpicker::Area size)
|
|
|
|
{
|
|
|
|
unsigned char *alpha = (unsigned char *)(pixel + size.count());
|
|
|
|
|
|
|
|
for (unsigned y = 0; y < size.h(); y++) {
|
|
|
|
for (unsigned x = 0; x < size.w(); x++) {
|
|
|
|
|
|
|
|
/* the source is known to be in RGB565 format */
|
|
|
|
Genode::Pixel_rgb565 src =
|
|
|
|
*(Genode::Pixel_rgb565 *)(&big_mouse.pixels[y][x]);
|
|
|
|
|
|
|
|
unsigned const i = y*size.w() + x;
|
|
|
|
pixel[i] = PT(src.r(), src.g(), src.b());
|
|
|
|
alpha[i] = src.r() ? 255 : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-01-02 14:25:51 +01:00
|
|
|
void Component::construct(Genode::Env &env)
|
2014-07-02 22:00:15 +02:00
|
|
|
{
|
2017-01-02 14:25:51 +01:00
|
|
|
static Nitpicker::Connection nitpicker { env, "cursor" };
|
2014-07-02 22:00:15 +02:00
|
|
|
|
|
|
|
Nitpicker::Area const cursor_size(big_mouse.w, big_mouse.h);
|
|
|
|
|
|
|
|
Framebuffer::Mode const mode(cursor_size.w(), cursor_size.h(),
|
|
|
|
Framebuffer::Mode::RGB565);
|
|
|
|
nitpicker.buffer(mode, true);
|
|
|
|
|
2017-01-02 14:25:51 +01:00
|
|
|
Genode::Attached_dataspace ds(
|
|
|
|
env.rm(), nitpicker.framebuffer()->dataspace());
|
2014-07-02 22:00:15 +02:00
|
|
|
|
2017-01-02 14:25:51 +01:00
|
|
|
convert_cursor_data_to_pixels(
|
|
|
|
ds.local_addr<Genode::Pixel_rgb565>(), cursor_size);
|
2014-07-02 22:00:15 +02:00
|
|
|
|
|
|
|
Nitpicker::Session::View_handle view = nitpicker.create_view();
|
|
|
|
Nitpicker::Rect geometry(Nitpicker::Point(0, 0), cursor_size);
|
|
|
|
nitpicker.enqueue<Nitpicker::Session::Command::Geometry>(view, geometry);
|
|
|
|
nitpicker.enqueue<Nitpicker::Session::Command::To_front>(view);
|
|
|
|
nitpicker.execute();
|
|
|
|
}
|