Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batching - fix ninepatch proxy textures (e.g. animated) #44790

Merged
merged 1 commit into from
Dec 29, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions drivers/gles_common/rasterizer_canvas_batcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,17 +605,30 @@ class RasterizerCanvasBatcher {
return TM_ALL;
}
bool _software_skin_poly(RasterizerCanvas::Item::CommandPolygon *p_poly, RasterizerCanvas::Item *p_item, BatchVertex *bvs, BatchColor *vertex_colors, const FillState &p_fill_state, const BatchColor *p_precalced_colors);

typename T_STORAGE::Texture *_get_canvas_texture(const RID &p_texture) const {
if (p_texture.is_valid()) {

typename T_STORAGE::Texture *texture = get_storage()->texture_owner.getornull(p_texture);

if (texture) {

// could be a proxy texture (e.g. animated)
if (texture->proxy) {
// take care to prevent infinite loop
int count = 0;
while (texture->proxy) {
texture = texture->proxy;
count++;
ERR_FAIL_COND_V_MSG(count == 16, nullptr, "Texture proxy infinite loop detected.");
}
}

return texture->get_ptr();
}
}

return 0;
return nullptr;
}

public:
Expand Down Expand Up @@ -1351,13 +1364,14 @@ PREAMBLE(bool)::_prefill_line(RasterizerCanvas::Item::CommandLine *p_line, FillS
T_PREAMBLE
template <bool SEND_LIGHT_ANGLES>
bool C_PREAMBLE::_prefill_ninepatch(RasterizerCanvas::Item::CommandNinePatch *p_np, FillState &r_fill_state, int &r_command_start, int command_num, int command_count, RasterizerCanvas::Item *p_item, bool multiply_final_modulate) {
typename T_STORAGE::Texture *tex = get_storage()->texture_owner.getornull(p_np->texture);
typename T_STORAGE::Texture *tex = _get_canvas_texture(p_np->texture);

if (!tex) {
// FIXME: Handle textureless ninepatch gracefully
WARN_PRINT("NinePatch without texture not supported yet, skipping.");
return false;
}

if (tex->width == 0 || tex->height == 0) {
WARN_PRINT("Cannot set empty texture to NinePatch.");
return false;
Expand Down