22#include "pedigree/kernel/compiler.h"
23#include "pedigree/kernel/processor/types.h"
31inline uint32_t createRgb(uint32_t r, uint32_t g, uint32_t b) {
32 return (r << 16) | (g << 8) | b;
52inline size_t bitsPerPixel(PixelFormat format) {
74inline size_t bytesPerPixel(PixelFormat format) {
75 return bitsPerPixel(format) / 8;
103inline bool convertPixel(uint32_t source, PixelFormat srcFormat, uint32_t& dest,
104 PixelFormat destFormat) {
105 if ((srcFormat == destFormat) || (!source)) {
111 uint8_t amtRed = 0, amtGreen = 0, amtBlue = 0, amtAlpha = 0;
114 if ((srcFormat == Bits32_Argb) || (srcFormat == Bits32_Rgb) || (srcFormat == Bits24_Rgb)) {
115 if (srcFormat != Bits24_Rgb)
116 amtAlpha = (source & 0xff000000) >> 24;
117 amtRed = (source & 0xff0000) >> 16;
118 amtGreen = (source & 0xff00) >> 8;
119 amtBlue = (source & 0xff);
120 }
else if (srcFormat == Bits32_Rgba) {
121 amtRed = (source & 0xff000000) >> 24;
122 amtGreen = (source & 0xff0000) >> 16;
123 amtBlue = (source & 0xff00) >> 8;
124 amtAlpha = (source & 0xff);
125 }
else if ((srcFormat == Bits32_Bgr) || (srcFormat == Bits24_Bgr)) {
126 amtBlue = (source & 0xff0000) >> 16;
127 amtGreen = (source & 0xff00) >> 8;
128 amtRed = (source & 0xff);
129 }
else if (srcFormat == Bits16_Argb) {
130 amtAlpha = (((source & 0xF000) >> 12) / 0xF) * 0xFF;
131 amtRed = (((source & 0xF00) >> 8) / 0xF) * 0xFF;
132 amtGreen = (((source & 0xF0) >> 4) / 0xF) * 0xFF;
133 amtBlue = ((source & 0xF) / 0xF) * 0xFF;
134 }
else if (srcFormat == Bits16_Rgb565) {
135 amtRed = (((source & 0xF800) >> 11) / 0x1F) * 0xFF;
136 amtGreen = (((source & 0x7E0) >> 5) / 0x3F) * 0xFF;
137 amtBlue = ((source & 0x1F) / 0x1F) * 0xFF;
138 }
else if (srcFormat == Bits16_Rgb555) {
139 amtRed = (((source & 0xF800) >> 10) / 0x1F) * 0xFF;
140 amtGreen = (((source & 0x3E0) >> 5) / 0x1F) * 0xFF;
141 amtBlue = ((source & 0x1F) / 0x1F) * 0xFF;
142 }
else if (srcFormat == Bits8_Rgb332) {
143 amtRed = (((source & 0xE0) >> 5) / 0x7) * 0xFF;
144 amtGreen = (((source & 0x1C) >> 2) / 0x7) * 0xFF;
145 amtBlue = ((source & 0x3) / 0x3) * 0xFF;
149 switch (destFormat) {
151 dest = (amtAlpha << 24) | (amtRed << 16) | (amtGreen << 8) | amtBlue;
154 dest = (amtRed << 24) | (amtGreen << 16) | (amtBlue << 8) | amtAlpha;
157 dest = (amtRed << 16) | (amtGreen << 8) | amtBlue;
160 dest = (amtRed << 8) | (amtGreen << 16) | amtBlue;
163 dest = (amtRed << 16) | (amtGreen << 8) | amtBlue;
166 dest = (amtBlue << 16) | (amtGreen << 8) | amtRed;
174 dest = (amtRed << 10) | (amtGreen << 5) | (amtBlue);
182 dest = (amtRed << 11) | (amtGreen << 5) | (amtBlue);
191 dest = (amtAlpha << 12) | (amtRed << 8) | (amtGreen << 4) | (amtBlue);
201 dest = (amtRed << 5) | (amtGreen << 2) | amtBlue;
212 size_t h,
void* pFbOverride = 0);
215EXPORTED_PUBLIC
void destroyFramebuffer(
Framebuffer* pFramebuffer);
size_t bytesPerPixel
Number of bytes per pixel (as it may be different to the format).
size_t width
Width of the buffer in pixels.
uintptr_t base
Base of this buffer in memory. For internal use only.
size_t height
Height of the buffer in pixels.
size_t bufferId
Buffer ID, for easy identification within drivers.