23 #include "pedigree/kernel/compiler.h" 24 #include "pedigree/kernel/processor/types.h" 31 inline uint32_t createRgb(uint32_t r, uint32_t g, uint32_t b)
33 return (r << 16) | (g << 8) | b;
54 inline size_t bitsPerPixel(PixelFormat format)
78 inline size_t bytesPerPixel(PixelFormat format)
80 return bitsPerPixel(format) / 8;
109 inline bool convertPixel(
110 uint32_t source, PixelFormat srcFormat, uint32_t &dest,
111 PixelFormat destFormat)
113 if ((srcFormat == destFormat) || (!source))
120 uint8_t amtRed = 0, amtGreen = 0, amtBlue = 0, amtAlpha = 0;
123 if ((srcFormat == Bits32_Argb) || (srcFormat == Bits32_Rgb) ||
124 (srcFormat == Bits24_Rgb))
126 if (srcFormat != Bits24_Rgb)
127 amtAlpha = (source & 0xff000000) >> 24;
128 amtRed = (source & 0xff0000) >> 16;
129 amtGreen = (source & 0xff00) >> 8;
130 amtBlue = (source & 0xff);
132 else if (srcFormat == Bits32_Rgba)
134 amtRed = (source & 0xff000000) >> 24;
135 amtGreen = (source & 0xff0000) >> 16;
136 amtBlue = (source & 0xff00) >> 8;
137 amtAlpha = (source & 0xff);
139 else if ((srcFormat == Bits32_Bgr) || (srcFormat == Bits24_Bgr))
141 amtBlue = (source & 0xff0000) >> 16;
142 amtGreen = (source & 0xff00) >> 8;
143 amtRed = (source & 0xff);
145 else if (srcFormat == Bits16_Argb)
147 amtAlpha = (((source & 0xF000) >> 12) / 0xF) * 0xFF;
148 amtRed = (((source & 0xF00) >> 8) / 0xF) * 0xFF;
149 amtGreen = (((source & 0xF0) >> 4) / 0xF) * 0xFF;
150 amtBlue = ((source & 0xF) / 0xF) * 0xFF;
152 else if (srcFormat == Bits16_Rgb565)
154 amtRed = (((source & 0xF800) >> 11) / 0x1F) * 0xFF;
155 amtGreen = (((source & 0x7E0) >> 5) / 0x3F) * 0xFF;
156 amtBlue = ((source & 0x1F) / 0x1F) * 0xFF;
158 else if (srcFormat == Bits16_Rgb555)
160 amtRed = (((source & 0xF800) >> 10) / 0x1F) * 0xFF;
161 amtGreen = (((source & 0x3E0) >> 5) / 0x1F) * 0xFF;
162 amtBlue = ((source & 0x1F) / 0x1F) * 0xFF;
164 else if (srcFormat == Bits8_Rgb332)
166 amtRed = (((source & 0xE0) >> 5) / 0x7) * 0xFF;
167 amtGreen = (((source & 0x1C) >> 2) / 0x7) * 0xFF;
168 amtBlue = ((source & 0x3) / 0x3) * 0xFF;
176 (amtAlpha << 24) | (amtRed << 16) | (amtGreen << 8) | amtBlue;
180 (amtRed << 24) | (amtGreen << 16) | (amtBlue << 8) | amtAlpha;
183 dest = (amtRed << 16) | (amtGreen << 8) | amtBlue;
186 dest = (amtRed << 8) | (amtGreen << 16) | amtBlue;
189 dest = (amtRed << 16) | (amtGreen << 8) | amtBlue;
192 dest = (amtBlue << 16) | (amtGreen << 8) | amtRed;
200 dest = (amtRed << 10) | (amtGreen << 5) | (amtBlue);
208 dest = (amtRed << 11) | (amtGreen << 5) | (amtBlue);
218 (amtAlpha << 12) | (amtRed << 8) | (amtGreen << 4) | (amtBlue);
228 dest = (amtRed << 5) | (amtGreen << 2) | amtBlue;
239 Framebuffer *pParent,
size_t x,
size_t y,
size_t w,
size_t h,
240 void *pFbOverride = 0);
uintptr_t base
Base of this buffer in memory. For internal use only.
size_t bufferId
Buffer ID, for easy identification within drivers.
Abstracts the system's framebuffer offering.
size_t width
Width of the buffer in pixels.
size_t height
Height of the buffer in pixels.
size_t bytesPerPixel
Number of bytes per pixel (as it may be different to the format).