From ebf86c96e9b648ce1f7d654032e21d4aa84b8985 Mon Sep 17 00:00:00 2001 From: Micky Date: Sun, 18 Sep 2022 02:19:55 +0200 Subject: [PATCH] Rename Image's `get_rect` to `get_region` Also renames its parameter to from "rect" to "region". --- core/io/image.cpp | 8 ++++---- core/io/image.h | 2 +- doc/classes/Image.xml | 6 +++--- editor/import/resource_importer_layered_texture.cpp | 2 +- editor/plugins/editor_preview_plugins.cpp | 2 +- scene/resources/texture.cpp | 2 +- tests/core/io/test_image.h | 2 +- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/io/image.cpp b/core/io/image.cpp index 16dd66fc98f..bb715a8cb32 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -2636,9 +2636,9 @@ Rect2i Image::get_used_rect() const { } } -Ref Image::get_rect(const Rect2i &p_area) const { - Ref img = memnew(Image(p_area.size.x, p_area.size.y, mipmaps, format)); - img->blit_rect(Ref((Image *)this), p_area, Point2i(0, 0)); +Ref Image::get_region(const Rect2i &p_region) const { + Ref img = memnew(Image(p_region.size.x, p_region.size.y, mipmaps, format)); + img->blit_rect(Ref((Image *)this), p_region, Point2i(0, 0)); return img; } @@ -3362,7 +3362,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("fill_rect", "rect", "color"), &Image::fill_rect); ClassDB::bind_method(D_METHOD("get_used_rect"), &Image::get_used_rect); - ClassDB::bind_method(D_METHOD("get_rect", "rect"), &Image::get_rect); + ClassDB::bind_method(D_METHOD("get_region", "region"), &Image::get_region); ClassDB::bind_method(D_METHOD("copy_from", "src"), &Image::copy_internals_from); diff --git a/core/io/image.h b/core/io/image.h index 194ee05bc7b..62df81e7c82 100644 --- a/core/io/image.h +++ b/core/io/image.h @@ -377,7 +377,7 @@ public: void fill_rect(const Rect2i &p_rect, const Color &p_color); Rect2i get_used_rect() const; - Ref get_rect(const Rect2i &p_area) const; + Ref get_region(const Rect2i &p_area) const; static void set_compress_bc_func(void (*p_compress_func)(Image *, float, UsedChannels)); static void set_compress_bptc_func(void (*p_compress_func)(Image *, float, UsedChannels)); diff --git a/doc/classes/Image.xml b/doc/classes/Image.xml index 88cea6820e9..55b8ad2d575 100644 --- a/doc/classes/Image.xml +++ b/doc/classes/Image.xml @@ -241,11 +241,11 @@ This is the same as [method get_pixel], but with a [Vector2i] argument instead of two integer arguments. - + - + - Returns a new image that is a copy of the image's area specified with [param rect]. + Returns a new [Image] that is a copy of this [Image]'s area specified with [param region]. diff --git a/editor/import/resource_importer_layered_texture.cpp b/editor/import/resource_importer_layered_texture.cpp index ab15aa4fdc1..9adabfb5d1b 100644 --- a/editor/import/resource_importer_layered_texture.cpp +++ b/editor/import/resource_importer_layered_texture.cpp @@ -368,7 +368,7 @@ Error ResourceImporterLayeredTexture::import(const String &p_source_file, const for (int j = 0; j < hslices; j++) { int x = slice_w * j; int y = slice_h * i; - Ref slice = image->get_rect(Rect2i(x, y, slice_w, slice_h)); + Ref slice = image->get_region(Rect2i(x, y, slice_w, slice_h)); ERR_CONTINUE(slice.is_null() || slice->is_empty()); if (slice->get_width() != slice_w || slice->get_height() != slice_h) { slice->resize(slice_w, slice_h); diff --git a/editor/plugins/editor_preview_plugins.cpp b/editor/plugins/editor_preview_plugins.cpp index 997dc0b2b5e..5f9446c3b1f 100644 --- a/editor/plugins/editor_preview_plugins.cpp +++ b/editor/plugins/editor_preview_plugins.cpp @@ -93,7 +93,7 @@ Ref EditorTexturePreviewPlugin::generate(const Ref &p_from, return Ref(); } - img = atlas->get_rect(atex->get_region()); + img = atlas->get_region(atex->get_region()); } else { Ref tex = p_from; if (tex.is_valid()) { diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 5232e8fcabd..a6fb359051d 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -1663,7 +1663,7 @@ Ref AtlasTexture::get_image() const { return Ref(); } - return atlas->get_image()->get_rect(region); + return atlas->get_image()->get_region(region); } AtlasTexture::AtlasTexture() {} diff --git a/tests/core/io/test_image.h b/tests/core/io/test_image.h index 181d9a8a541..1559c59b5ce 100644 --- a/tests/core/io/test_image.h +++ b/tests/core/io/test_image.h @@ -162,7 +162,7 @@ TEST_CASE("[Image] Basic getters") { CHECK(image->get_size() == Vector2(8, 4)); CHECK(image->get_format() == Image::FORMAT_LA8); CHECK(image->get_used_rect() == Rect2i(0, 0, 0, 0)); - Ref image_get_rect = image->get_rect(Rect2i(0, 0, 2, 1)); + Ref image_get_rect = image->get_region(Rect2i(0, 0, 2, 1)); CHECK(image_get_rect->get_size() == Vector2(2, 1)); }