diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-05-04 12:36:51 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-05-04 12:37:07 -0300 |
commit | 89d87294dbc84df8dd7740cd04cc4842b8738e96 (patch) | |
tree | 62d1015ed08cb12c6e57e6391d4f8cc9f32c355e /drivers | |
parent | 0fa5154c0af7895b0a5e11ff4899e12cc0cbbdd2 (diff) |
ability to shrink all images x2 on load
this is for extreme cases when running on devices with very low video
memory, so you can still retain compatibility.
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 19 | ||||
-rw-r--r-- | drivers/gles2/rasterizer_gles2.h | 4 |
2 files changed, 22 insertions, 1 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 373de2bb22..20d1ca956a 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -921,6 +921,11 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I texture->alloc_height = texture->height; }; + if (shrink_textures_x2) { + texture->alloc_height = MAX(1,texture->alloc_height/2); + texture->alloc_width = MAX(1,texture->alloc_width/2); + } + texture->gl_components_cache=components; texture->gl_format_cache=format; @@ -970,8 +975,15 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu if (texture->alloc_width != img.get_width() || texture->alloc_height != img.get_height()) { - if (img.get_format() <= Image::FORMAT_INDEXED_ALPHA) + + if (texture->alloc_width == img.get_width()/2 && texture->alloc_height == img.get_height()/2) { + + img.shrink_x2(); + } else if (img.get_format() <= Image::FORMAT_INDEXED_ALPHA) { + img.resize(texture->alloc_width, texture->alloc_height, Image::INTERPOLATE_BILINEAR); + + } }; @@ -1452,6 +1464,11 @@ void RasterizerGLES2::texture_debug_usage(List<VS::TextureInfo> *r_info){ } +void RasterizerGLES2::texture_set_shrink_all_x2_on_set_data(bool p_enable) { + + shrink_textures_x2=p_enable; +} + /* SHADER API */ RID RasterizerGLES2::shader_create(VS::ShaderMode p_mode) { diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index 2a2f587f11..b52918c02f 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -108,6 +108,8 @@ class RasterizerGLES2 : public Rasterizer { bool use_half_float; bool low_memory_2d; + bool shrink_textures_x2; + Vector<float> skel_default; Image _get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,GLenum& r_gl_internal_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed); @@ -1336,6 +1338,8 @@ public: virtual String texture_get_path(RID p_texture) const; virtual void texture_debug_usage(List<VS::TextureInfo> *r_info); + virtual void texture_set_shrink_all_x2_on_set_data(bool p_enable); + GLuint _texture_get_name(RID p_tex); /* SHADER API */ |