Merge pull request #29587 from Calinou/remove-hq2x

Remove HQ2X and the `Image.expand_2x_hq2x()` method
This commit is contained in:
Rémi Verschelde 2020-05-16 16:51:08 +02:00 committed by GitHub
commit 2fa795dea9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 7 additions and 2742 deletions

View File

@ -257,12 +257,6 @@ Comment: FastLZ
Copyright: 2005-2020, Ariya Hidayat
License: Expat
Files: ./thirdparty/misc/hq2x.cpp
./thirdparty/misc/hq2x.h
Comment: hq2x implementation
Copyright: 2016, Bruno Ribeiro
License: Apache-2.0
Files: ./thirdparty/misc/ifaddrs-android.cc
./thirdparty/misc/ifaddrs-android.h
Comment: libjingle
@ -334,7 +328,7 @@ License: Zlib
Files: ./thirdparty/rvo2/
Comment: RVO2
Copyright: 2016, University of North Carolina at Chapel Hill
Copyright: 2016, University of North Carolina at Chapel Hill
License: Apache 2.0
Files: ./thirdparty/squish/

View File

@ -52,7 +52,6 @@ thirdparty_misc_sources = [
"r128.c",
"smaz.c",
# C++ sources
"hq2x.cpp",
"pcg.cpp",
"triangulator.cpp",
"clipper.cpp",

View File

@ -37,8 +37,6 @@
#include "core/os/copymem.h"
#include "core/print_string.h"
#include "thirdparty/misc/hq2x.h"
#include <stdio.h>
const char *Image::format_names[Image::FORMAT_MAX] = {
@ -1445,47 +1443,6 @@ static void _generate_po2_mipmap(const Component *p_src, Component *p_dst, uint3
}
}
void Image::expand_x2_hq2x() {
ERR_FAIL_COND(!_can_modify(format));
bool used_mipmaps = has_mipmaps();
if (used_mipmaps) {
clear_mipmaps();
}
Format current = format;
if (current != FORMAT_RGBA8) {
convert(FORMAT_RGBA8);
}
Vector<uint8_t> dest;
dest.resize(width * 2 * height * 2 * 4);
{
const uint8_t *r = data.ptr();
uint8_t *w = dest.ptrw();
ERR_FAIL_COND(!r);
hq2x_resize((const uint32_t *)r, width, height, (uint32_t *)w);
}
width *= 2;
height *= 2;
data = dest;
if (current != FORMAT_RGBA8) {
convert(current);
}
// FIXME: This is likely meant to use "used_mipmaps" as defined above, but if we do,
// we end up with a regression: GH-22747
if (mipmaps) {
generate_mipmaps();
}
}
void Image::shrink_x2() {
ERR_FAIL_COND(data.size() == 0);
@ -3047,7 +3004,6 @@ void Image::_bind_methods() {
ClassDB::bind_method(D_METHOD("resize_to_po2", "square"), &Image::resize_to_po2, DEFVAL(false));
ClassDB::bind_method(D_METHOD("resize", "width", "height", "interpolation"), &Image::resize, DEFVAL(INTERPOLATE_BILINEAR));
ClassDB::bind_method(D_METHOD("shrink_x2"), &Image::shrink_x2);
ClassDB::bind_method(D_METHOD("expand_x2_hq2x"), &Image::expand_x2_hq2x);
ClassDB::bind_method(D_METHOD("crop", "width", "height"), &Image::crop);
ClassDB::bind_method(D_METHOD("flip_x"), &Image::flip_x);

View File

@ -235,7 +235,6 @@ public:
void resize_to_po2(bool p_square = false);
void resize(int p_width, int p_height, Interpolation p_interpolation = INTERPOLATE_BILINEAR);
void shrink_x2();
void expand_x2_hq2x();
bool is_size_po2() const;
/**
* Crop the image to a specific size, if larger, then the image is filled by black

View File

@ -190,13 +190,6 @@
<description>
</description>
</method>
<method name="expand_x2_hq2x">
<return type="void">
</return>
<description>
Stretches the image and enlarges it by a factor of 2. No interpolation is done.
</description>
</method>
<method name="fill">
<return type="void">
</return>

View File

@ -52,20 +52,9 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, fl
} else {
texture = Ref<ImageTexture>(memnew(ImageTexture));
Ref<Image> img = memnew(Image(p_src));
if (scale > 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->expand_x2_hq2x();
if (scale != 2.0) {
img->resize(orig_size.x * scale, orig_size.y * scale);
}
} else if (scale < 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->resize(orig_size.x * scale, orig_size.y * scale);
}
const Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->resize(orig_size.x * scale, orig_size.y * scale);
texture->create_from_image(img);
(*tex_cache)[p_src] = texture;
@ -98,19 +87,9 @@ template <class T>
static Ref<Texture2D> make_icon(T p_src) {
Ref<ImageTexture> texture(memnew(ImageTexture));
Ref<Image> img = memnew(Image(p_src));
if (scale > 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->expand_x2_hq2x();
if (scale != 2.0) {
img->resize(orig_size.x * scale, orig_size.y * scale);
}
} else if (scale < 1) {
Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->resize(orig_size.x * scale, orig_size.y * scale);
}
const Size2 orig_size = Size2(img->get_width(), img->get_height());
img->convert(Image::FORMAT_RGBA8);
img->resize(orig_size.x * scale, orig_size.y * scale);
texture->create_from_image(img);
return texture;

2636
thirdparty/misc/hq2x.cpp vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +0,0 @@
#ifndef HQ2X_H
#define HQ2X_H
#include "core/typedefs.h"
uint32_t *hq2x_resize(
const uint32_t *image,
uint32_t width,
uint32_t height,
uint32_t *output,
uint32_t trY = 0x30,
uint32_t trU = 0x07,
uint32_t trV = 0x06,
uint32_t trA = 0x50,
bool wrapX = false,
bool wrapY = false );
#endif // HQ2X_H