diff --git a/repos/gems/src/app/backdrop/chunky_texture.h b/repos/gems/include/gems/chunky_texture.h similarity index 90% rename from repos/gems/src/app/backdrop/chunky_texture.h rename to repos/gems/include/gems/chunky_texture.h index f7564da22..5c33790fa 100644 --- a/repos/gems/src/app/backdrop/chunky_texture.h +++ b/repos/gems/include/gems/chunky_texture.h @@ -11,8 +11,8 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _CHUNKY_TEXTURE_H_ -#define _CHUNKY_TEXTURE_H_ +#ifndef _INCLUDE__GEMS__CHUNKY_TEXTURE_H_ +#define _INCLUDE__GEMS__CHUNKY_TEXTURE_H_ #include #include @@ -59,4 +59,4 @@ class Chunky_texture : Genode::Attached_ram_dataspace, public Genode::Texture @@ -46,5 +46,5 @@ class File Genode::size_t size() const { return _file_size; } }; -#endif /* _FILE_H_ */ +#endif /* _INCLUDE__GEMS__FILE_H_ */ diff --git a/repos/gems/src/app/backdrop/png_image.h b/repos/gems/include/gems/png_image.h similarity index 94% rename from repos/gems/src/app/backdrop/png_image.h rename to repos/gems/include/gems/png_image.h index 4a9900269..86e32ebde 100644 --- a/repos/gems/src/app/backdrop/png_image.h +++ b/repos/gems/include/gems/png_image.h @@ -11,8 +11,8 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _PNG_IMAGE_H_ -#define _PNG_IMAGE_H_ +#ifndef _INCLUDE__GEMS__PNG_IMAGE_H_ +#define _INCLUDE__GEMS__PNG_IMAGE_H_ /* Genode includes */ #include @@ -20,9 +20,9 @@ /* libpng include */ #include -/* local includes */ -#include "chunky_texture.h" -#include "texture_utils.h" +/* gems includes */ +#include +#include class Png_image { @@ -178,4 +178,4 @@ class Png_image } }; -#endif /* _PNG_IMAGE_H_ */ +#endif /* _INCLUDE__GEMS__PNG_IMAGE_H_ */ diff --git a/repos/gems/src/app/backdrop/texture.cc b/repos/gems/include/gems/texture_rgb565.h similarity index 62% rename from repos/gems/src/app/backdrop/texture.cc rename to repos/gems/include/gems/texture_rgb565.h index 0ecdf26b5..7159980eb 100644 --- a/repos/gems/src/app/backdrop/texture.cc +++ b/repos/gems/include/gems/texture_rgb565.h @@ -11,10 +11,12 @@ * under the terms of the GNU General Public License version 2. */ +#ifndef _INCLUDE__GEMS__TEXTURE_RGB565_H_ +#define _INCLUDE__GEMS__TEXTURE_RGB565_H_ + /* Genode includes */ #include #include -#include #include namespace Genode { @@ -47,33 +49,6 @@ namespace Genode { dst_alpha[i] = min(a, 255); } } - - - template <> - void - Texture::rgba(unsigned char const *rgba, unsigned len, int y) - { - if (len > size().w()) len = size().w(); - if (y < 0 || y >= (int)size().h()) return; - - Pixel_rgb888 *dst_pixel = pixel() + y*size().w(); - unsigned char *dst_alpha = alpha() ? alpha() + y*size().w() : 0; - - for (unsigned i = 0; i < len; i++) { - - int r = *rgba++; - int g = *rgba++; - int b = *rgba++; - int a = *rgba++; - - dst_pixel[i].rgba(r, g, b); - - if (dst_alpha) - dst_alpha[i] = min(a, 255); - } - } } - -template class Genode::Texture; -template class Genode::Texture; +#endif /* _INCLUDE__GEMS__TEXTURE_RGB565_H_ */ diff --git a/repos/gems/include/gems/texture_rgb888.h b/repos/gems/include/gems/texture_rgb888.h new file mode 100644 index 000000000..8a0a79ffb --- /dev/null +++ b/repos/gems/include/gems/texture_rgb888.h @@ -0,0 +1,48 @@ +/* + * \brief Support for Genode::Texture + * \author Norman Feske + * \date 2014-08-14 + */ + +/* + * Copyright (C) 2014 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +#ifndef _INCLUDE__GEMS__TEXTURE_RGB888_H_ +#define _INCLUDE__GEMS__TEXTURE_RGB888_H_ + +/* Genode includes */ +#include +#include + +namespace Genode { + + template <> + void + Texture::rgba(unsigned char const *rgba, unsigned len, int y) + { + if (len > size().w()) len = size().w(); + if (y < 0 || y >= (int)size().h()) return; + + Pixel_rgb888 *dst_pixel = pixel() + y*size().w(); + unsigned char *dst_alpha = alpha() ? alpha() + y*size().w() : 0; + + for (unsigned i = 0; i < len; i++) { + + int r = *rgba++; + int g = *rgba++; + int b = *rgba++; + int a = *rgba++; + + dst_pixel[i].rgba(r, g, b); + + if (dst_alpha) + dst_alpha[i] = min(a, 255); + } + } +} + +#endif /* _INCLUDE__GEMS__TEXTURE_RGB888_H_ */ diff --git a/repos/gems/src/app/backdrop/texture_utils.h b/repos/gems/include/gems/texture_utils.h similarity index 95% rename from repos/gems/src/app/backdrop/texture_utils.h rename to repos/gems/include/gems/texture_utils.h index e8fbf1159..f0f1551cc 100644 --- a/repos/gems/src/app/backdrop/texture_utils.h +++ b/repos/gems/include/gems/texture_utils.h @@ -11,8 +11,8 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _TEXTURE_UTILS_H_ -#define _TEXTURE_UTILS_H_ +#ifndef _INCLUDE__GEMS__TEXTURE_UTILS_H_ +#define _INCLUDE__GEMS__TEXTURE_UTILS_H_ #include @@ -94,4 +94,4 @@ static void convert_pixel_format(Genode::Texture const &src, Genode::env()->heap()->free(row, row_num_bytes); } -#endif /* _TEXTURE_UTILS_H_ */ +#endif /* _INCLUDE__GEMS__TEXTURE_UTILS_H_ */ diff --git a/repos/gems/src/app/backdrop/xml_anchor.h b/repos/gems/include/gems/xml_anchor.h similarity index 93% rename from repos/gems/src/app/backdrop/xml_anchor.h rename to repos/gems/include/gems/xml_anchor.h index 2b42dbea6..c5144981a 100644 --- a/repos/gems/src/app/backdrop/xml_anchor.h +++ b/repos/gems/include/gems/xml_anchor.h @@ -11,8 +11,8 @@ * under the terms of the GNU General Public License version 2. */ -#ifndef _XML_ANCHOR_H_ -#define _XML_ANCHOR_H_ +#ifndef _INCLUDE__GEMS__XML_ANCHOR_H_ +#define _INCLUDE__GEMS__XML_ANCHOR_H_ #include @@ -68,4 +68,4 @@ class Anchor } }; -#endif /* _XML_ANCHOR_H_ */ +#endif /* _INCLUDE__GEMS__XML_ANCHOR_H_ */ diff --git a/repos/gems/lib/mk/file.mk b/repos/gems/lib/mk/file.mk new file mode 100644 index 000000000..0451d4d99 --- /dev/null +++ b/repos/gems/lib/mk/file.mk @@ -0,0 +1,4 @@ +SRC_CC = file.cc +LIBS += libc + +vpath file.cc $(REP_DIR)/src/lib/file diff --git a/repos/gems/src/app/backdrop/main.cc b/repos/gems/src/app/backdrop/main.cc index 6a9bd4c8e..d542f1da4 100644 --- a/repos/gems/src/app/backdrop/main.cc +++ b/repos/gems/src/app/backdrop/main.cc @@ -21,14 +21,14 @@ #include #include #include -#include -#include -/* local includes */ -#include "png_image.h" -#include "file.h" -#include "xml_anchor.h" -#include "texture_utils.h" +/* gems includes */ +#include +#include +#include +#include +#include +#include using namespace Genode; diff --git a/repos/gems/src/app/backdrop/target.mk b/repos/gems/src/app/backdrop/target.mk index c7a61f941..3e087f3f7 100644 --- a/repos/gems/src/app/backdrop/target.mk +++ b/repos/gems/src/app/backdrop/target.mk @@ -1,3 +1,3 @@ -TARGET = backdrop -SRC_CC = main.cc file.cc texture.cc -LIBS = base config libc libpng zlib blit +TARGET = backdrop +SRC_CC = main.cc +LIBS = base config libc libpng zlib blit file diff --git a/repos/gems/src/app/backdrop/file.cc b/repos/gems/src/lib/file/file.cc similarity index 95% rename from repos/gems/src/app/backdrop/file.cc rename to repos/gems/src/lib/file/file.cc index 23fc98734..ac07a3dcd 100644 --- a/repos/gems/src/app/backdrop/file.cc +++ b/repos/gems/src/lib/file/file.cc @@ -14,8 +14,8 @@ /* Genode includes */ #include -/* local includes */ -#include "file.h" +/* gems includes */ +#include /* libc includes */ #include