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;
|
||||
|
||||
@ -670,6 +670,32 @@ void VisualServerCanvas::canvas_item_add_texture_rect(RID p_item, const Rect2 &p
|
||||
canvas_item->commands.push_back(rect);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_texture_multirect_region(RID p_item, const Vector<Rect2> &p_rects, RID p_texture, const Vector<Rect2> &p_src_rects, const Color &p_modulate, uint32_t p_canvas_rect_flags, RID p_normal_map) {
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
ERR_FAIL_COND(p_rects.size() != p_src_rects.size());
|
||||
ERR_FAIL_COND(!p_rects.size());
|
||||
|
||||
Item::CommandMultiRect *rect = memnew(Item::CommandMultiRect);
|
||||
ERR_FAIL_COND(!rect);
|
||||
rect->modulate = p_modulate;
|
||||
rect->texture = p_texture;
|
||||
rect->normal_map = p_normal_map;
|
||||
|
||||
// Rects should have flips and transposes pre-applied, and the relevant
|
||||
// flags added to p_canvas_rect_flags.
|
||||
// A single Multirect should contain rects ALL of the same flag type.
|
||||
// The idea is to simplify the renderer as much as possible, and push the complexity
|
||||
// to the one off creation code.
|
||||
rect->flags = p_canvas_rect_flags | RasterizerCanvas::CANVAS_RECT_REGION;
|
||||
|
||||
rect->rects = p_rects;
|
||||
rect->sources = p_src_rects;
|
||||
|
||||
canvas_item->rect_dirty = true;
|
||||
canvas_item->commands.push_back(rect);
|
||||
}
|
||||
|
||||
void VisualServerCanvas::canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, bool p_clip_uv) {
|
||||
Item *canvas_item = canvas_item_owner.getornull(p_item);
|
||||
ERR_FAIL_COND(!canvas_item);
|
||||
|
||||
@ -194,6 +194,7 @@ public:
|
||||
void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color);
|
||||
void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID());
|
||||
void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false);
|
||||
void canvas_item_add_texture_multirect_region(RID p_item, const Vector<Rect2> &p_rects, RID p_texture, const Vector<Rect2> &p_src_rects, const Color &p_modulate = Color(1, 1, 1), uint32_t p_canvas_rect_flags = 0, RID p_normal_map = RID());
|
||||
void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, VS::NinePatchAxisMode p_x_axis_mode = VS::NINE_PATCH_STRETCH, VS::NinePatchAxisMode p_y_axis_mode = VS::NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID());
|
||||
void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID());
|
||||
void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false);
|
||||
|
||||
280
servers/visual/visual_server_canvas_helper.cpp
Normal file
280
servers/visual/visual_server_canvas_helper.cpp
Normal file
@ -0,0 +1,280 @@
|
||||
/**************************************************************************/
|
||||
/* visual_server_canvas_helper.cpp */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#include "visual_server_canvas_helper.h"
|
||||
|
||||
#include "servers/visual/rasterizer.h"
|
||||
#include "servers/visual_server.h"
|
||||
|
||||
LocalVector<MultiRect> VisualServerCanvasHelper::_tilemap_multirects;
|
||||
Mutex VisualServerCanvasHelper::_tilemap_mutex;
|
||||
|
||||
bool VisualServerCanvasHelper::_multirect_enabled = true;
|
||||
|
||||
MultiRect::MultiRect() {
|
||||
begin();
|
||||
}
|
||||
MultiRect::~MultiRect() {
|
||||
end();
|
||||
}
|
||||
|
||||
void MultiRect::begin() {
|
||||
DEV_CHECK_ONCE(!rects.size());
|
||||
rects.clear();
|
||||
sources.clear();
|
||||
|
||||
state.flags = 0;
|
||||
state_set = false;
|
||||
}
|
||||
|
||||
void MultiRect::add_rect(RID p_canvas_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, bool p_clip_uv) {
|
||||
bool new_common_data = true;
|
||||
|
||||
Rect2 rect = p_rect;
|
||||
Rect2 source = p_src_rect;
|
||||
|
||||
// To make the rendering code as efficient as possible,
|
||||
// a single MultiRect command should have identical flips and transpose etc.
|
||||
// If these change, it flushes the previous multirect and starts a new one.
|
||||
uint32_t flags = 0;
|
||||
|
||||
if (p_rect.size.x < 0) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
|
||||
rect.size.x = -rect.size.x;
|
||||
}
|
||||
if (source.size.x < 0) {
|
||||
flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_H;
|
||||
source.size.x = -source.size.x;
|
||||
}
|
||||
if (p_rect.size.y < 0) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
|
||||
rect.size.y = -rect.size.y;
|
||||
}
|
||||
if (source.size.y < 0) {
|
||||
flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_V;
|
||||
source.size.y = -source.size.y;
|
||||
}
|
||||
|
||||
if (p_transpose) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
|
||||
SWAP(rect.size.x, rect.size.y);
|
||||
}
|
||||
|
||||
if (p_clip_uv) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_CLIP_UV;
|
||||
}
|
||||
|
||||
VisualServerCanvasHelper::State s;
|
||||
s.item = p_canvas_item;
|
||||
s.texture = p_texture;
|
||||
s.modulate = p_modulate;
|
||||
s.normal_map = p_normal_map;
|
||||
s.flags = flags;
|
||||
|
||||
if (!is_empty()) {
|
||||
if ((state != s) ||
|
||||
(rects.size() >= MAX_RECTS)) {
|
||||
end();
|
||||
} else {
|
||||
new_common_data = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (new_common_data) {
|
||||
state = s;
|
||||
}
|
||||
|
||||
rects.push_back(rect);
|
||||
sources.push_back(source);
|
||||
}
|
||||
|
||||
void MultiRect::begin(const VisualServerCanvasHelper::State &p_state) {
|
||||
DEV_CHECK_ONCE(!rects.size());
|
||||
rects.clear();
|
||||
sources.clear();
|
||||
|
||||
state = p_state;
|
||||
state_set = true;
|
||||
}
|
||||
|
||||
uint32_t MultiRect::flags_from_rects(Rect2 &r_rect, Rect2 &r_source) {
|
||||
uint32_t flags = 0;
|
||||
|
||||
if (r_rect.size.x < 0) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_FLIP_H;
|
||||
r_rect.size.x = -r_rect.size.x;
|
||||
}
|
||||
if (r_rect.size.y < 0) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_FLIP_V;
|
||||
r_rect.size.y = -r_rect.size.y;
|
||||
}
|
||||
|
||||
if (r_source.size.x < 0) {
|
||||
flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_H;
|
||||
r_source.size.x = -r_source.size.x;
|
||||
}
|
||||
if (r_source.size.y < 0) {
|
||||
flags ^= RasterizerCanvas::CANVAS_RECT_FLIP_V;
|
||||
r_source.size.y = -r_source.size.y;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
bool MultiRect::add_pre_flipped(const Rect2 &p_rect, const Rect2 &p_src_rect) {
|
||||
if (rects.is_full()) {
|
||||
return false;
|
||||
}
|
||||
*rects.request() = p_rect;
|
||||
*sources.request() = p_src_rect;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MultiRect::add(const Rect2 &p_rect, const Rect2 &p_src_rect, bool p_commit_on_flip_change) {
|
||||
if (rects.is_full()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Rect2 rect = p_rect;
|
||||
Rect2 source = p_src_rect;
|
||||
|
||||
uint32_t flags = flags_from_rects(rect, source);
|
||||
|
||||
if (state_set) {
|
||||
// if we are changing these flips, we can no longer continue the same multirect
|
||||
if ((state.flags & (RasterizerCanvas::CANVAS_RECT_FLIP_H | RasterizerCanvas::CANVAS_RECT_FLIP_V)) != flags) {
|
||||
// different state requires a new multirect
|
||||
return false;
|
||||
}
|
||||
|
||||
} else {
|
||||
state.flags |= flags;
|
||||
state_set = true;
|
||||
}
|
||||
|
||||
*rects.request() = rect;
|
||||
*sources.request() = source;
|
||||
return true;
|
||||
}
|
||||
|
||||
void MultiRect::end() {
|
||||
if (!is_empty()) {
|
||||
if (VisualServerCanvasHelper::_multirect_enabled) {
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_multirect_region(state.item, rects, state.texture, sources, state.modulate, state.flags, state.normal_map);
|
||||
|
||||
} else {
|
||||
// legacy path
|
||||
bool transpose = state.flags & RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
|
||||
bool clip_uv = state.flags & RasterizerCanvas::CANVAS_RECT_CLIP_UV;
|
||||
|
||||
for (uint32_t n = 0; n < rects.size(); n++) {
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(state.item, rects[n], state.texture, sources[n], state.modulate, transpose, state.normal_map, clip_uv);
|
||||
}
|
||||
}
|
||||
|
||||
rects.clear();
|
||||
sources.clear();
|
||||
}
|
||||
state_set = false;
|
||||
}
|
||||
|
||||
void VisualServerCanvasHelper::tilemap_begin() {
|
||||
if (_multirect_enabled) {
|
||||
_tilemap_mutex.lock();
|
||||
}
|
||||
}
|
||||
|
||||
void VisualServerCanvasHelper::tilemap_add_rect(RID p_canvas_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, RID p_normal_map, bool p_clip_uv) {
|
||||
if (!_multirect_enabled) {
|
||||
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, p_texture, p_src_rect, p_modulate, p_transpose, p_normal_map, p_clip_uv);
|
||||
return;
|
||||
}
|
||||
|
||||
Rect2 rect = p_rect;
|
||||
Rect2 source = p_src_rect;
|
||||
|
||||
// To make the rendering code as efficient as possible,
|
||||
// a single MultiRect command should have identical flips and transpose etc.
|
||||
// If these change, it flushes the previous multirect and starts a new one.
|
||||
uint32_t flags = MultiRect::flags_from_rects(rect, source);
|
||||
|
||||
if (p_transpose) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_TRANSPOSE;
|
||||
SWAP(rect.size.x, rect.size.y);
|
||||
}
|
||||
|
||||
if (p_clip_uv) {
|
||||
flags |= RasterizerCanvas::CANVAS_RECT_CLIP_UV;
|
||||
}
|
||||
|
||||
State state;
|
||||
state.item = p_canvas_item;
|
||||
state.texture = p_texture;
|
||||
state.modulate = p_modulate;
|
||||
state.normal_map = p_normal_map;
|
||||
state.flags = flags;
|
||||
|
||||
// attempt to add to existing multirect
|
||||
for (int n = _tilemap_multirects.size() - 1; n >= 0; n--) {
|
||||
MultiRect &mr = _tilemap_multirects[n];
|
||||
|
||||
// matches state?
|
||||
if (mr.state == state) {
|
||||
// add .. this may fail if the multirect is full
|
||||
if (mr.add_pre_flipped(rect, source)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// disallow if we overlap a multirect
|
||||
if (mr.overlaps(rect)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// create new multirect
|
||||
_tilemap_multirects.resize(_tilemap_multirects.size() + 1);
|
||||
MultiRect &mr = _tilemap_multirects[_tilemap_multirects.size() - 1];
|
||||
mr.begin(state);
|
||||
mr.add_pre_flipped(rect, source);
|
||||
}
|
||||
|
||||
void VisualServerCanvasHelper::tilemap_end() {
|
||||
if (!_multirect_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint32_t n = 0; n < _tilemap_multirects.size(); n++) {
|
||||
_tilemap_multirects[n].end();
|
||||
}
|
||||
|
||||
_tilemap_multirects.clear();
|
||||
_tilemap_mutex.unlock();
|
||||
}
|
||||
114
servers/visual/visual_server_canvas_helper.h
Normal file
114
servers/visual/visual_server_canvas_helper.h
Normal file
@ -0,0 +1,114 @@
|
||||
/**************************************************************************/
|
||||
/* visual_server_canvas_helper.h */
|
||||
/**************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/**************************************************************************/
|
||||
/* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
|
||||
/* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/**************************************************************************/
|
||||
|
||||
#ifndef VISUAL_SERVER_CANVAS_HELPER_H
|
||||
#define VISUAL_SERVER_CANVAS_HELPER_H
|
||||
|
||||
#include "core/color.h"
|
||||
#include "core/fixed_array.h"
|
||||
#include "core/local_vector.h"
|
||||
#include "core/math/rect2.h"
|
||||
#include "core/rid.h"
|
||||
|
||||
class MultiRect;
|
||||
|
||||
class VisualServerCanvasHelper {
|
||||
public:
|
||||
struct State {
|
||||
RID item;
|
||||
RID texture;
|
||||
Color modulate;
|
||||
RID normal_map;
|
||||
uint32_t flags = 0;
|
||||
|
||||
bool operator==(const State &p_state) const {
|
||||
return ((item == p_state.item) &&
|
||||
(texture == p_state.texture) &&
|
||||
(modulate == p_state.modulate) &&
|
||||
(normal_map == p_state.normal_map) &&
|
||||
(flags == p_state.flags));
|
||||
}
|
||||
bool operator!=(const State &p_state) const { return !(*this == p_state); }
|
||||
};
|
||||
|
||||
private:
|
||||
// There is a single mutex for tilemaps, only one quadrant can be adding
|
||||
// at a time.
|
||||
static LocalVector<MultiRect> _tilemap_multirects;
|
||||
static Mutex _tilemap_mutex;
|
||||
|
||||
public:
|
||||
static void tilemap_begin();
|
||||
static void tilemap_add_rect(RID p_canvas_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false);
|
||||
static void tilemap_end();
|
||||
|
||||
static bool _multirect_enabled;
|
||||
};
|
||||
|
||||
class MultiRect {
|
||||
friend class VisualServerCanvasHelper;
|
||||
|
||||
public:
|
||||
enum { MAX_RECTS = 2048 };
|
||||
|
||||
private:
|
||||
VisualServerCanvasHelper::State state;
|
||||
bool state_set = false;
|
||||
FixedArray<Rect2, MAX_RECTS, true> rects;
|
||||
FixedArray<Rect2, MAX_RECTS, true> sources;
|
||||
|
||||
static uint32_t flags_from_rects(Rect2 &r_rect, Rect2 &r_source);
|
||||
bool overlaps(const Rect2 &p_rect) const {
|
||||
for (uint32_t n = 0; n < rects.size(); n++) {
|
||||
if (rects[n].intersects(p_rect)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool add_pre_flipped(const Rect2 &p_rect, const Rect2 &p_src_rect);
|
||||
|
||||
public:
|
||||
// Simple API
|
||||
void begin();
|
||||
void add_rect(RID p_canvas_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false);
|
||||
|
||||
// Efficient API
|
||||
void begin(const VisualServerCanvasHelper::State &p_state);
|
||||
bool add(const Rect2 &p_rect, const Rect2 &p_src_rect, bool p_commit_on_flip_change = true);
|
||||
bool is_empty() const { return rects.is_empty(); }
|
||||
bool is_full() const { return rects.is_full(); }
|
||||
void end();
|
||||
|
||||
MultiRect();
|
||||
~MultiRect();
|
||||
};
|
||||
|
||||
#endif // VISUAL_SERVER_CANVAS_HELPER_H
|
||||
@ -704,6 +704,7 @@ public:
|
||||
BIND4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
|
||||
BIND7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
|
||||
BIND8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
|
||||
BIND7(canvas_item_add_texture_multirect_region, RID, const Vector<Rect2> &, RID, const Vector<Rect2> &, const Color &, uint32_t, RID)
|
||||
BIND11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
||||
BIND7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
||||
BIND7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
||||
|
||||
@ -605,6 +605,7 @@ public:
|
||||
FUNC4(canvas_item_add_circle, RID, const Point2 &, float, const Color &)
|
||||
FUNC7(canvas_item_add_texture_rect, RID, const Rect2 &, RID, bool, const Color &, bool, RID)
|
||||
FUNC8(canvas_item_add_texture_rect_region, RID, const Rect2 &, RID, const Rect2 &, const Color &, bool, RID, bool)
|
||||
FUNC7(canvas_item_add_texture_multirect_region, RID, const Vector<Rect2> &, RID, const Vector<Rect2> &, const Color &, uint32_t, RID)
|
||||
FUNC11(canvas_item_add_nine_patch, RID, const Rect2 &, const Rect2 &, RID, const Vector2 &, const Vector2 &, NinePatchAxisMode, NinePatchAxisMode, bool, const Color &, RID)
|
||||
FUNC7(canvas_item_add_primitive, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, float, RID)
|
||||
FUNC7(canvas_item_add_polygon, RID, const Vector<Point2> &, const Vector<Color> &, const Vector<Point2> &, RID, RID, bool)
|
||||
|
||||
@ -2704,6 +2704,7 @@ VisualServer::VisualServer() {
|
||||
GLOBAL_DEF("rendering/batching/options/use_batching", true);
|
||||
GLOBAL_DEF_RST("rendering/batching/options/use_batching_in_editor", true);
|
||||
GLOBAL_DEF("rendering/batching/options/single_rect_fallback", false);
|
||||
GLOBAL_DEF("rendering/batching/options/use_multirect", true);
|
||||
GLOBAL_DEF("rendering/batching/parameters/max_join_item_commands", 16);
|
||||
GLOBAL_DEF("rendering/batching/parameters/colored_vertex_format_threshold", 0.25f);
|
||||
GLOBAL_DEF("rendering/batching/lights/scissor_area_threshold", 1.0f);
|
||||
@ -2720,7 +2721,7 @@ VisualServer::VisualServer() {
|
||||
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/max_join_item_commands", PropertyInfo(Variant::INT, "rendering/batching/parameters/max_join_item_commands", PROPERTY_HINT_RANGE, "0,65535"));
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/colored_vertex_format_threshold", PropertyInfo(Variant::REAL, "rendering/batching/parameters/colored_vertex_format_threshold", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"));
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/batch_buffer_size", PropertyInfo(Variant::INT, "rendering/batching/parameters/batch_buffer_size", PROPERTY_HINT_RANGE, "1024,65535,1024"));
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/batch_buffer_size", PropertyInfo(Variant::INT, "rendering/batching/parameters/batch_buffer_size", PROPERTY_HINT_RANGE, "8192,65536,1024"));
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/scissor_area_threshold", PropertyInfo(Variant::REAL, "rendering/batching/lights/scissor_area_threshold", PROPERTY_HINT_RANGE, "0.0,1.0"));
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/lights/max_join_items", PropertyInfo(Variant::INT, "rendering/batching/lights/max_join_items", PROPERTY_HINT_RANGE, "0,512"));
|
||||
ProjectSettings::get_singleton()->set_custom_property_info("rendering/batching/parameters/item_reordering_lookahead", PropertyInfo(Variant::INT, "rendering/batching/parameters/item_reordering_lookahead", PROPERTY_HINT_RANGE, "0,256"));
|
||||
|
||||
@ -1037,6 +1037,7 @@ public:
|
||||
virtual void canvas_item_add_circle(RID p_item, const Point2 &p_pos, float p_radius, const Color &p_color) = 0;
|
||||
virtual void canvas_item_add_texture_rect(RID p_item, const Rect2 &p_rect, RID p_texture, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_texture_rect_region(RID p_item, const Rect2 &p_rect, RID p_texture, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, RID p_normal_map = RID(), bool p_clip_uv = false) = 0;
|
||||
virtual void canvas_item_add_texture_multirect_region(RID p_item, const Vector<Rect2> &p_rects, RID p_texture, const Vector<Rect2> &p_src_rects, const Color &p_modulate = Color(1, 1, 1), uint32_t p_canvas_rect_flags = 0, RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_nine_patch(RID p_item, const Rect2 &p_rect, const Rect2 &p_source, RID p_texture, const Vector2 &p_topleft, const Vector2 &p_bottomright, NinePatchAxisMode p_x_axis_mode = NINE_PATCH_STRETCH, NinePatchAxisMode p_y_axis_mode = NINE_PATCH_STRETCH, bool p_draw_center = true, const Color &p_modulate = Color(1, 1, 1), RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_primitive(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs, RID p_texture, float p_width = 1.0, RID p_normal_map = RID()) = 0;
|
||||
virtual void canvas_item_add_polygon(RID p_item, const Vector<Point2> &p_points, const Vector<Color> &p_colors, const Vector<Point2> &p_uvs = Vector<Point2>(), RID p_texture = RID(), RID p_normal_map = RID(), bool p_antialiased = false) = 0;
|
||||
|
||||
Reference in New Issue
Block a user