mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
This patch also adds a Format concept to GraphicsBitmap. For now there are only two formats: RGB32 and RGBA32. Windows with alpha channel have their backing stores created in the RGBA32 format. Use this to make Terminal windows semi-transparent for that comfy rice look. There is one problem here, in that window compositing overdraw incurs multiple passes of blending of the same pixels. This leads to a mismatch in opacity which is obviously not good. I will work on this in a later patch. The alpha blending is currently straight C++. It should be relatively easy to optimize this using SSE instructions. For now I'm just happy with the cute effect. :^)
27 lines
751 B
C++
27 lines
751 B
C++
#include "Color.h"
|
|
#include <AK/Assertions.h>
|
|
|
|
Color::Color(NamedColor named)
|
|
{
|
|
struct {
|
|
byte r;
|
|
byte g;
|
|
byte b;
|
|
} rgb;
|
|
|
|
switch (named) {
|
|
case Black: rgb = { 0, 0, 0 }; break;
|
|
case White: rgb = { 255, 255, 255 }; break;
|
|
case Red: rgb = { 255, 0, 0}; break;
|
|
case Green: rgb = { 0, 255, 0}; break;
|
|
case Blue: rgb = { 0, 0, 255}; break;
|
|
case Yellow: rgb = { 255, 255, 0 }; break;
|
|
case Magenta: rgb = { 255, 0, 255 }; break;
|
|
case DarkGray: rgb = { 64, 64, 64 }; break;
|
|
case MidGray: rgb = { 127, 127, 127 }; break;
|
|
case LightGray: rgb = { 192, 192, 192 }; break;
|
|
default: ASSERT_NOT_REACHED(); break;
|
|
}
|
|
|
|
m_value = 0xff000000 | (rgb.r << 16) | (rgb.g << 8) | rgb.b;
|
|
}
|