semi opaque
This commit is contained in:
parent
615d90c36f
commit
0329616148
6 changed files with 80 additions and 91 deletions
|
|
@ -139,6 +139,7 @@ inline void blend_pixel_optimized(Pixel_BU8_GU8_RU8_AU8& dst, const Pixel_BU8_GU
|
|||
if(src.a == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
float srcA = src.a / 255.0f;
|
||||
float dstA = dst.a / 255.0f;
|
||||
|
||||
|
|
@ -173,26 +174,49 @@ void WindowWayland::RenderElement(Transform* transform) {
|
|||
const Pixel_BU8_GU8_RU8_AU8* src_buffer = element->bufferScaled.data();
|
||||
std::int_fast32_t src_width = element->scaled.width;
|
||||
std::int_fast32_t src_height = element->scaled.height;
|
||||
|
||||
if (element->opaque) {
|
||||
for (std::int_fast32_t y = dirty.top; y < dirty.bottom; y++) {
|
||||
std::int_fast32_t src_y = y - element->scaled.y;
|
||||
|
||||
for (std::int_fast32_t x = dirty.left; x < dirty.right; x++) {
|
||||
std::int_fast32_t src_x = x - element->scaled.x;
|
||||
|
||||
switch (element->opaque) {
|
||||
case OpaqueType::FullyOpaque:
|
||||
// For fully opaque, just copy pixels directly
|
||||
for (std::int_fast32_t y = dirty.top; y < dirty.bottom; y++) {
|
||||
std::int_fast32_t src_y = y - element->scaled.y;
|
||||
|
||||
framebuffer[y * width + x] = src_buffer[src_y * src_width + src_x];
|
||||
for (std::int_fast32_t x = dirty.left; x < dirty.right; x++) {
|
||||
std::int_fast32_t src_x = x - element->scaled.x;
|
||||
|
||||
framebuffer[y * width + x] = src_buffer[src_y * src_width + src_x];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (std::int_fast32_t y = dirty.top; y < dirty.bottom; y++) {
|
||||
std::int_fast32_t src_y = y - element->scaled.y;
|
||||
break;
|
||||
|
||||
for (std::int_fast32_t x = dirty.left; x < dirty.right; x++) {
|
||||
std::int_fast32_t src_x = x - element->scaled.x;
|
||||
blend_pixel_optimized(framebuffer[y * width + x], src_buffer[src_y * src_width + src_x]);
|
||||
case OpaqueType::SemiOpaque:
|
||||
// For semi-opaque, we can avoid blending when alpha is 0 or 255
|
||||
for (std::int_fast32_t y = dirty.top; y < dirty.bottom; y++) {
|
||||
std::int_fast32_t src_y = y - element->scaled.y;
|
||||
|
||||
for (std::int_fast32_t x = dirty.left; x < dirty.right; x++) {
|
||||
std::int_fast32_t src_x = x - element->scaled.x;
|
||||
Pixel_BU8_GU8_RU8_AU8 src_pixel = src_buffer[src_y * src_width + src_x];
|
||||
|
||||
if (src_pixel.a == 0) {
|
||||
continue;
|
||||
}
|
||||
framebuffer[y * width + x] = src_pixel;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case OpaqueType::Transparent:
|
||||
// For transparent, always perform blending
|
||||
for (std::int_fast32_t y = dirty.top; y < dirty.bottom; y++) {
|
||||
std::int_fast32_t src_y = y - element->scaled.y;
|
||||
|
||||
for (std::int_fast32_t x = dirty.left; x < dirty.right; x++) {
|
||||
std::int_fast32_t src_x = x - element->scaled.x;
|
||||
blend_pixel_optimized(framebuffer[y * width + x], src_buffer[src_y * src_width + src_x]);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue