Properly get proxy texture size for canvas light, fixes #17067

This commit is contained in:
Juan Linietsky 2019-01-27 16:57:05 -03:00
parent 953cd03ea6
commit 0c60d4c682
7 changed files with 28 additions and 1 deletions

View file

@ -241,6 +241,7 @@ public:
void textures_keep_original(bool p_enable) {}
void texture_set_proxy(RID p_proxy, RID p_base) {}
virtual Size2 texture_size_with_proxy(RID p_texture) const { return Size2(); }
void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) {}
/* SKY API */

View file

@ -846,6 +846,17 @@ void RasterizerStorageGLES2::textures_keep_original(bool p_enable) {
config.keep_original_textures = p_enable;
}
Size2 RasterizerStorageGLES2::texture_size_with_proxy(RID p_texture) const {
const Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Size2());
if (texture->proxy) {
return Size2(texture->proxy->width, texture->proxy->height);
} else {
return Size2(texture->width, texture->height);
}
}
void RasterizerStorageGLES2::texture_set_proxy(RID p_texture, RID p_proxy) {
Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND(!texture);

View file

@ -342,6 +342,7 @@ public:
virtual void textures_keep_original(bool p_enable);
virtual void texture_set_proxy(RID p_texture, RID p_proxy);
virtual Size2 texture_size_with_proxy(RID p_texture) const;
virtual void texture_set_detect_3d_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
virtual void texture_set_detect_srgb_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);

View file

@ -1687,6 +1687,17 @@ RID RasterizerStorageGLES3::texture_create_radiance_cubemap(RID p_source, int p_
return texture_owner.make_rid(ctex);
}
Size2 RasterizerStorageGLES3::texture_size_with_proxy(RID p_texture) const {
const Texture *texture = texture_owner.getornull(p_texture);
ERR_FAIL_COND_V(!texture, Size2());
if (texture->proxy) {
return Size2(texture->proxy->width, texture->proxy->height);
} else {
return Size2(texture->width, texture->height);
}
}
void RasterizerStorageGLES3::texture_set_proxy(RID p_texture, RID p_proxy) {
Texture *texture = texture_owner.get(p_texture);

View file

@ -375,6 +375,8 @@ public:
virtual void texture_set_detect_normal_callback(RID p_texture, VisualServer::TextureDetectCallback p_callback, void *p_userdata);
virtual void texture_set_proxy(RID p_texture, RID p_proxy);
virtual Size2 texture_size_with_proxy(RID p_texture) const;
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable);
/* SKY API */

View file

@ -221,6 +221,7 @@ public:
virtual void textures_keep_original(bool p_enable) = 0;
virtual void texture_set_proxy(RID p_proxy, RID p_base) = 0;
virtual Size2 texture_size_with_proxy(RID p_texture) const = 0;
virtual void texture_set_force_redraw_if_visible(RID p_texture, bool p_enable) = 0;
/* SKY API */

View file

@ -97,7 +97,7 @@ void VisualServerViewport::_draw_viewport(Viewport *p_viewport, ARVRInterface::E
RasterizerCanvas::Light *cl = F->get();
if (cl->enabled && cl->texture.is_valid()) {
//not super efficient..
Size2 tsize(VSG::storage->texture_get_width(cl->texture), VSG::storage->texture_get_height(cl->texture));
Size2 tsize = VSG::storage->texture_size_with_proxy(cl->texture);
tsize *= cl->scale;
Vector2 offset = tsize / 2.0;