You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-27 15:57:02 +00:00
Batching - Add MultiRect command
Large groups of similar rects can be processed more efficiently using the MultiRect command. Processing common to the group can be done as a one off, instead of per rect. Adds the new API to VisualServerCanvas, and uses the new functionality from Font, BitmapFont, DynamicFont and TileMap, via the VisualServerCanvasHelper class.
This commit is contained in:
@@ -808,6 +808,7 @@ public:
|
||||
TYPE_CIRCLE,
|
||||
TYPE_TRANSFORM,
|
||||
TYPE_CLIP_IGNORE,
|
||||
TYPE_MULTIRECT,
|
||||
};
|
||||
|
||||
Type type;
|
||||
@@ -849,6 +850,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
struct CommandMultiRect : public Command {
|
||||
RID texture;
|
||||
RID normal_map;
|
||||
Color modulate;
|
||||
Vector<Rect2> rects;
|
||||
Vector<Rect2> sources;
|
||||
uint8_t flags;
|
||||
|
||||
CommandMultiRect() {
|
||||
flags = 0;
|
||||
type = TYPE_MULTIRECT;
|
||||
}
|
||||
};
|
||||
|
||||
struct CommandNinePatch : public Command {
|
||||
Rect2 rect;
|
||||
Rect2 source;
|
||||
@@ -1055,6 +1070,16 @@ public:
|
||||
r = crect->rect;
|
||||
|
||||
} break;
|
||||
case Item::Command::TYPE_MULTIRECT: {
|
||||
const Item::CommandMultiRect *mrect = static_cast<const Item::CommandMultiRect *>(c);
|
||||
int num_rects = mrect->rects.size();
|
||||
if (num_rects) {
|
||||
r = mrect->rects[0];
|
||||
for (int n = 1; n < num_rects; n++) {
|
||||
r = mrect->rects[n].merge(r);
|
||||
}
|
||||
}
|
||||
} break;
|
||||
case Item::Command::TYPE_NINEPATCH: {
|
||||
const Item::CommandNinePatch *style = static_cast<const Item::CommandNinePatch *>(c);
|
||||
r = style->rect;
|
||||
|
||||
Reference in New Issue
Block a user