genode/repos/os/include/os/texture_rgb888.h
Norman Feske c629c54153 Make util/geometry.h C++20 friendly
- Move header to base/include to make it applicable for base types
  like 'Affinity' down the road.
- Represent 'Rect' as typle of point and area, which is the most
  common form of initialization, creates in valid 'Rect' by default.
- Turn Point, Area, and Rect into compound types, making x, y, w, h, at,
  area accessible without a method call
- 'Rect::Compound' function for constructing a 'Rect' from two points,
  replacing a former constructor
- Use result type 'Rect::Cut_remainder' instead of out parameters.

Fixes #5239
2024-06-20 12:54:30 +02:00

49 lines
1.0 KiB
C++

/*
* \brief Support for Genode::Texture
* \author Norman Feske
* \date 2014-08-14
*/
/*
* Copyright (C) 2014-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _INCLUDE__GEMS__TEXTURE_RGB888_H_
#define _INCLUDE__GEMS__TEXTURE_RGB888_H_
/* Genode includes */
#include <os/texture.h>
#include <os/pixel_rgb888.h>
namespace Genode {
template <>
inline void
Texture<Pixel_rgb888>::rgba(unsigned char const *rgba, size_t 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] = (unsigned char)min(a, 255);
}
}
}
#endif /* _INCLUDE__GEMS__TEXTURE_RGB888_H_ */