typo
This commit is contained in:
parent
7fdab4f62b
commit
44a2960415
1 changed files with 66 additions and 18 deletions
|
|
@ -78,25 +78,69 @@ export namespace Crafter {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case OpaqueType::SemiOpaque:
|
||||||
case OpaqueType::Transparent:
|
case OpaqueType::Transparent:
|
||||||
// For transparent, always perform blending
|
if constexpr(std::same_as<T, _Float16>) {
|
||||||
for (std::uint16_t y = dirty.top; y < dirty.bottom; y++) {
|
for (std::uint16_t y = dirty.top; y < dirty.bottom; y++) {
|
||||||
std::uint16_t src_y = y - element->scaled.position.y;
|
std::uint16_t src_y = y - element->scaled.position.y;
|
||||||
for (std::uint16_t x = dirty.left; x < dirty.right; x++) {
|
std::uint16_t rowSize = dirty.right - dirty.left;
|
||||||
std::uint16_t src_x = x - element->scaled.position.x;
|
constexpr std::uint8_t elementsPerVector = VectorF16L<1, 1, 1>::MaxSize/VectorF16L<1, 1, 1>::MaxElement;
|
||||||
Vector<T, Channels, Alignment> src = src_buffer[src_y * src_width + src_x];
|
while(rowSize > 0) {
|
||||||
Vector<T, Channels, Alignment> dst = buffer[frame][y * this->sizeX + x];
|
if(rowSize < elementsPerVector) {
|
||||||
|
for(; rowSize > 0; rowSize--) {
|
||||||
|
std::uint16_t src_x = rowSize - element->scaled.position.x;
|
||||||
|
Vector<T, Channels, Alignment> src = src_buffer[src_y * src_width + src_x];
|
||||||
|
Vector<T, Channels, Alignment> dst = buffer[frame][y * this->sizeX + rowSize];
|
||||||
|
|
||||||
float srcA = src.a / 255.0f;
|
_Float16 outA = src.a + dst.a * (1.0f - src.a);
|
||||||
float dstA = dst.a / 255.0f;k
|
this->buffer[frame][y * this->sizeX + rowSize] = Vector<T, Channels, Alignment>(
|
||||||
|
static_cast<T>((src.r + dst.r * (1.0f - src.a)) / outA),
|
||||||
|
static_cast<T>((src.g + dst.g * (1.0f - src.a)) / outA),
|
||||||
|
static_cast<T>((src.b + dst.b * (1.0f - src.a)) / outA),
|
||||||
|
static_cast<T>(outA * 255)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
std::uint16_t src_x = rowSize - element->scaled.position.x;
|
||||||
|
using VectorType = VectorF16L<4, VectorF16L<1, 1, 1>::MaxElement / 4, VectorF16L<1, 1, 1>::MaxSize/((VectorF16L<1, 1, 1>::MaxElement / 4)*4)>;
|
||||||
|
VectorType src(src_buffer[src_y * src_width + src_x].v);
|
||||||
|
VectorType dst(buffer[frame][y * this->sizeX + rowSize].v);
|
||||||
|
|
||||||
float outA = srcA + dstA * (1.0f - srcA);
|
VectorType srcA = src.ShufflePacked<3,3,3,3>();
|
||||||
this->buffer[frame][y * this->sizeX + x] = Vector<T, Channels, Alignment>(
|
VectorType dstA = dst.ShufflePacked<3,3,3,3>();
|
||||||
static_cast<T>((src.r + dst.r * (1.0f - srcA)) / outA),
|
|
||||||
static_cast<T>((src.g + dst.g * (1.0f - srcA)) / outA),
|
VectorType srcANeg = -srcA;
|
||||||
static_cast<T>((src.b + dst.b * (1.0f - srcA)) / outA),
|
|
||||||
static_cast<T>(outA * 255)
|
VectorType outA = VectorType::MulitplyAdd(dstA, srcANeg, srcA);
|
||||||
);
|
|
||||||
|
VectorType result = src + dst * srcANeg / outA;
|
||||||
|
result = VectorType::BlendPacked<0,0,0,1>(dst, outA);
|
||||||
|
result.Store(buffer[frame][y * this->sizeX + rowSize].v);
|
||||||
|
|
||||||
|
rowSize -= elementsPerVector;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (std::uint16_t y = dirty.top; y < dirty.bottom; y++) {
|
||||||
|
std::uint16_t src_y = y - element->scaled.position.y;
|
||||||
|
for (std::uint16_t x = dirty.left; x < dirty.right; x++) {
|
||||||
|
std::uint16_t src_x = x - element->scaled.position.x;
|
||||||
|
Vector<T, Channels, Alignment> src = src_buffer[src_y * src_width + src_x];
|
||||||
|
Vector<T, Channels, Alignment> dst = buffer[frame][y * this->sizeX + x];
|
||||||
|
|
||||||
|
float srcA = src.a / 255.0f;
|
||||||
|
float dstA = dst.a / 255.0f;
|
||||||
|
|
||||||
|
float outA = srcA + dstA * (1.0f - srcA);
|
||||||
|
this->buffer[frame][y * this->sizeX + x] = Vector<T, Channels, Alignment>(
|
||||||
|
static_cast<T>((src.r + dst.r * (1.0f - srcA)) / outA),
|
||||||
|
static_cast<T>((src.g + dst.g * (1.0f - srcA)) / outA),
|
||||||
|
static_cast<T>((src.b + dst.b * (1.0f - srcA)) / outA),
|
||||||
|
static_cast<T>(outA * 255)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -121,6 +165,10 @@ export namespace Crafter {
|
||||||
clipRects.emplace_back(std::max(element->oldScale[frame].position.x, std::int32_t(0)), std::min(element->oldScale[frame].position.x + element->oldScale[frame].size.x, this->sizeX), std::max(element->oldScale[frame].position.y, std::int32_t(0)), std::min(element->oldScale[frame].position.y + element->oldScale[frame].size.y, this->sizeY));
|
clipRects.emplace_back(std::max(element->oldScale[frame].position.x, std::int32_t(0)), std::min(element->oldScale[frame].position.x + element->oldScale[frame].size.x, this->sizeX), std::max(element->oldScale[frame].position.y, std::int32_t(0)), std::min(element->oldScale[frame].position.y + element->oldScale[frame].size.y, this->sizeY));
|
||||||
element->oldScale[frame] = element->scaled;
|
element->oldScale[frame] = element->scaled;
|
||||||
element->redraw[frame] = false;
|
element->redraw[frame] = false;
|
||||||
|
} else if(element->redraw[frame]) {
|
||||||
|
clipRects.emplace_back(std::max(element->scaled.position.x, std::int32_t(0)), std::min(element->scaled.position.x + element->scaled.size.x, this->sizeX), std::max(element->scaled.position.y, std::int32_t(0)), std::min(element->scaled.position.y + element->scaled.size.y, this->sizeY));
|
||||||
|
element->oldScale[frame] = element->scaled;
|
||||||
|
element->redraw[frame] = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for(Transform2D* child : elementTransform->children) {
|
for(Transform2D* child : elementTransform->children) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue