diff options
Diffstat (limited to 'drivers/gles2/rasterizer_gles2.cpp')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 373de2bb22..c7b2d65a13 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 (!(p_flags&VS::TEXTURE_FLAG_VIDEO_SURFACE) && 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) { @@ -11342,7 +11359,7 @@ void RasterizerGLES2::set_force_16_bits_fbo(bool p_force) { RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,bool p_default_fragment_lighting,bool p_use_reload_hooks) { _singleton = this; - + shrink_textures_x2=false; RenderList::max_elements=GLOBAL_DEF("rasterizer/max_render_elements",(int)RenderList::DEFAULT_MAX_ELEMENTS); if (RenderList::max_elements>64000) RenderList::max_elements=64000; |