mirror of
https://github.com/thunderbrewhq/squall.git
synced 2026-02-04 00:49:08 +00:00
chore(region): add region constants
This commit is contained in:
parent
62121bef6f
commit
f6d4a93652
4 changed files with 44 additions and 46 deletions
|
|
@ -39,7 +39,7 @@ void DeleteRect(RECTF* rect) {
|
||||||
|
|
||||||
void FragmentSourceRectangles(TSGrowableArray<SOURCE>* sourceArray, uint32_t firstIndex, uint32_t lastIndex, int32_t previousOverlap, const RECTF* rect, void* param, int32_t sequence) {
|
void FragmentSourceRectangles(TSGrowableArray<SOURCE>* sourceArray, uint32_t firstIndex, uint32_t lastIndex, int32_t previousOverlap, const RECTF* rect, void* param, int32_t sequence) {
|
||||||
if (firstIndex >= lastIndex) {
|
if (firstIndex >= lastIndex) {
|
||||||
AddSourceRect(sourceArray, rect, param, sequence, 0x1 | (previousOverlap ? 0x2 : 0x0));
|
AddSourceRect(sourceArray, rect, param, sequence, SF_ADDING | (previousOverlap ? SF_OVERLAPS : SF_NONE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,12 +53,12 @@ void FragmentSourceRectangles(TSGrowableArray<SOURCE>* sourceArray, uint32_t fir
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
source->flags |= 0x2;
|
source->flags |= SF_OVERLAPS;
|
||||||
overlapsExisting = 1;
|
overlapsExisting = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i + 1 == lastIndex) {
|
if (i + 1 == lastIndex) {
|
||||||
AddSourceRect(sourceArray, rect, param, sequence, 0x1 | (previousOverlap ? 0x2 : 0x0));
|
AddSourceRect(sourceArray, rect, param, sequence, SF_ADDING | (previousOverlap ? SF_OVERLAPS : SF_NONE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -92,7 +92,7 @@ void DeleteSourceRect(TSGrowableArray<SOURCE>* sourceArray, uint32_t index) {
|
||||||
DeleteRect(&source->rect);
|
DeleteRect(&source->rect);
|
||||||
source->param = nullptr;
|
source->param = nullptr;
|
||||||
source->sequence = -1;
|
source->sequence = -1;
|
||||||
source->flags = 0x0;
|
source->flags = SF_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptimizeSource(TSGrowableArray<SOURCE>* sourceArray) {
|
void OptimizeSource(TSGrowableArray<SOURCE>* sourceArray) {
|
||||||
|
|
@ -117,44 +117,27 @@ void ProcessBooleanOperation(TSGrowableArray<SOURCE>* sourceArray, int32_t combi
|
||||||
for (uint32_t i = 0; i < sourceArray->Count(); i++) {
|
for (uint32_t i = 0; i < sourceArray->Count(); i++) {
|
||||||
auto source = &(*sourceArray)[i];
|
auto source = &(*sourceArray)[i];
|
||||||
|
|
||||||
|
int32_t remove = 0;
|
||||||
switch (combineMode) {
|
switch (combineMode) {
|
||||||
case 1: {
|
case SRGN_AND:
|
||||||
if ((~source->flags >> 1) & 0x1) {
|
remove = !(source->flags & SF_OVERLAPS);
|
||||||
DeleteSourceRect(sourceArray, i);
|
break;
|
||||||
}
|
case SRGN_XOR:
|
||||||
|
remove = source->flags & SF_OVERLAPS;
|
||||||
|
break;
|
||||||
|
case SRGN_DIFF:
|
||||||
|
remove = source->flags & (SF_ADDING | SF_OVERLAPS);
|
||||||
|
break;
|
||||||
|
case SRGN_COPY:
|
||||||
|
remove = source->flags & SF_ADDING;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 3: {
|
if (remove) {
|
||||||
if (source->flags & 0x2) {
|
DeleteSourceRect(sourceArray, i);
|
||||||
DeleteSourceRect(sourceArray, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
case 4: {
|
source->flags = SF_NONE;
|
||||||
if (source->flags & (0x1 | 0x2)) {
|
|
||||||
DeleteSourceRect(sourceArray, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 5: {
|
|
||||||
if (source->flags & 0x1) {
|
|
||||||
DeleteSourceRect(sourceArray, i);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
source->flags = 0x0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -170,10 +153,10 @@ void SRgnCombineRectf(HSRGN handle, RECTF* rect, void* param, int32_t combineMod
|
||||||
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
auto rgn = s_rgntable.Lock(handle, &lockedHandle, 0);
|
||||||
|
|
||||||
if (rgn) {
|
if (rgn) {
|
||||||
if (combineMode == 2 || combineMode == 6) {
|
if (combineMode == SRGN_OR || combineMode == SRGN_PARAMONLY) {
|
||||||
if (!IsNullRect(rect)) {
|
if (!IsNullRect(rect)) {
|
||||||
rgn->sequence++;
|
rgn->sequence++;
|
||||||
AddSourceRect(&rgn->source, rect, param, rgn->sequence, combineMode == 6 ? 0x10000 : 0x0);
|
AddSourceRect(&rgn->source, rect, param, rgn->sequence, combineMode == SRGN_PARAMONLY ? SF_PARAMONLY : SF_NONE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!IsNullRect(rect)) {
|
if (!IsNullRect(rect)) {
|
||||||
|
|
@ -235,7 +218,7 @@ void SRgnGetBoundingRectf(HSRGN handle, RECTF* rect) {
|
||||||
for (uint32_t i = 0; i < rgn->source.Count(); i++) {
|
for (uint32_t i = 0; i < rgn->source.Count(); i++) {
|
||||||
auto source = &rgn->source[i];
|
auto source = &rgn->source[i];
|
||||||
|
|
||||||
if (!(source->flags & 0x10000)) {
|
if (!(source->flags & SF_PARAMONLY)) {
|
||||||
rect->left = std::min(source->rect.left, rect->left);
|
rect->left = std::min(source->rect.left, rect->left);
|
||||||
rect->bottom = std::min(source->rect.bottom, rect->bottom);
|
rect->bottom = std::min(source->rect.bottom, rect->bottom);
|
||||||
rect->right = std::max(source->rect.right, rect->right);
|
rect->right = std::max(source->rect.right, rect->right);
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,13 @@
|
||||||
#include "storm/Hash.hpp"
|
#include "storm/Hash.hpp"
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
|
// region flgs
|
||||||
|
#define SF_NONE 0x00
|
||||||
|
#define SF_ADDING 0x00000001
|
||||||
|
#define SF_OVERLAPS 0x00000002
|
||||||
|
#define SF_TEMPMASK 0x00000003
|
||||||
|
#define SF_PARAMONLY 0x00010000
|
||||||
|
|
||||||
struct SOURCE {
|
struct SOURCE {
|
||||||
RECTF rect;
|
RECTF rect;
|
||||||
void* param;
|
void* param;
|
||||||
|
|
|
||||||
|
|
@ -15,4 +15,12 @@ struct RECTF {
|
||||||
float top;
|
float top;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Combine modes
|
||||||
|
#define SRGN_AND 1
|
||||||
|
#define SRGN_OR 2
|
||||||
|
#define SRGN_XOR 3
|
||||||
|
#define SRGN_DIFF 4
|
||||||
|
#define SRGN_COPY 5
|
||||||
|
#define SRGN_PARAMONLY 6
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ TEST_CASE("SRgnCombineRectf", "[region]") {
|
||||||
SRgnCreate(®ion, 0);
|
SRgnCreate(®ion, 0);
|
||||||
|
|
||||||
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
SRgnCombineRectf(region, &baseRect, nullptr, 2);
|
SRgnCombineRectf(region, &baseRect, nullptr, SRGN_OR);
|
||||||
|
|
||||||
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
SRgnGetBoundingRectf(region, &boundingRect);
|
SRgnGetBoundingRectf(region, &boundingRect);
|
||||||
|
|
@ -36,10 +36,10 @@ TEST_CASE("SRgnCombineRectf", "[region]") {
|
||||||
SRgnCreate(®ion, 0);
|
SRgnCreate(®ion, 0);
|
||||||
|
|
||||||
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
SRgnCombineRectf(region, &baseRect, nullptr, 2);
|
SRgnCombineRectf(region, &baseRect, nullptr, SRGN_OR);
|
||||||
|
|
||||||
RECTF newRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
RECTF newRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
SRgnCombineRectf(region, &newRect, nullptr, 4);
|
SRgnCombineRectf(region, &newRect, nullptr, SRGN_DIFF);
|
||||||
|
|
||||||
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
SRgnGetBoundingRectf(region, &boundingRect);
|
SRgnGetBoundingRectf(region, &boundingRect);
|
||||||
|
|
@ -57,10 +57,10 @@ TEST_CASE("SRgnCombineRectf", "[region]") {
|
||||||
SRgnCreate(®ion, 0);
|
SRgnCreate(®ion, 0);
|
||||||
|
|
||||||
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
SRgnCombineRectf(region, &baseRect, nullptr, 2);
|
SRgnCombineRectf(region, &baseRect, nullptr, SRGN_OR);
|
||||||
|
|
||||||
RECTF newRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
RECTF newRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
SRgnCombineRectf(region, &newRect, nullptr, 4);
|
SRgnCombineRectf(region, &newRect, nullptr, SRGN_DIFF);
|
||||||
|
|
||||||
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
SRgnGetBoundingRectf(region, &boundingRect);
|
SRgnGetBoundingRectf(region, &boundingRect);
|
||||||
|
|
@ -78,10 +78,10 @@ TEST_CASE("SRgnCombineRectf", "[region]") {
|
||||||
SRgnCreate(®ion, 0);
|
SRgnCreate(®ion, 0);
|
||||||
|
|
||||||
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
RECTF baseRect = { 0.0f, 0.0f, 1.0f, 1.0f };
|
||||||
SRgnCombineRectf(region, &baseRect, nullptr, 2);
|
SRgnCombineRectf(region, &baseRect, nullptr, SRGN_OR);
|
||||||
|
|
||||||
RECTF newRect = { 0.0f, 1.0f, 1.0f, 1.0f };
|
RECTF newRect = { 0.0f, 1.0f, 1.0f, 1.0f };
|
||||||
SRgnCombineRectf(region, &newRect, nullptr, 4);
|
SRgnCombineRectf(region, &newRect, nullptr, SRGN_DIFF);
|
||||||
|
|
||||||
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
RECTF boundingRect = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||||
SRgnGetBoundingRectf(region, &boundingRect);
|
SRgnGetBoundingRectf(region, &boundingRect);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue