Changed every parameter (where it could be done) to const or a const reference.

This commit is contained in:
Relintai 2021-08-08 11:26:55 +02:00
parent dbf3c59a9c
commit a078695681
6 changed files with 61 additions and 61 deletions

View File

@ -48,7 +48,7 @@ void TextureLayerMerger::set_texture_flags(uint32_t p_flags) {
Color TextureLayerMerger::get_base_color() const { Color TextureLayerMerger::get_base_color() const {
return _base_color; return _base_color;
} }
void TextureLayerMerger::set_base_color(const Color p_color) { void TextureLayerMerger::set_base_color(const Color &p_color) {
_base_color = p_color; _base_color = p_color;
} }
@ -72,7 +72,7 @@ Ref<ImageTexture> TextureLayerMerger::get_result_as_texture() const {
return tex; return tex;
} }
void TextureLayerMerger::add_texture(Ref<Texture> p_texture, Color p_color, Vector2 p_position, Rect2 p_rect) { void TextureLayerMerger::add_texture(const Ref<Texture> &p_texture, const Color &p_color, const Vector2 &p_position, Rect2 p_rect) {
ERR_FAIL_COND(!p_texture.is_valid()); ERR_FAIL_COND(!p_texture.is_valid());
LayerMergerEntry entry; LayerMergerEntry entry;
@ -118,7 +118,7 @@ Ref<Texture> TextureLayerMerger::get_texture(const int p_index) {
return _entries.get(p_index).texture; return _entries.get(p_index).texture;
} }
void TextureLayerMerger::set_texture(const int p_index, Ref<Texture> p_texture) { void TextureLayerMerger::set_texture(const int p_index, const Ref<Texture> &p_texture) {
ERR_FAIL_INDEX(p_index, _entries.size()); ERR_FAIL_INDEX(p_index, _entries.size());
_entries.get(p_index).texture = p_texture; _entries.get(p_index).texture = p_texture;
@ -129,7 +129,7 @@ Color TextureLayerMerger::get_color(const int p_index) {
return _entries.get(p_index).color; return _entries.get(p_index).color;
} }
void TextureLayerMerger::set_color(const int p_index, Color p_color) { void TextureLayerMerger::set_color(const int p_index, const Color &p_color) {
ERR_FAIL_INDEX(p_index, _entries.size()); ERR_FAIL_INDEX(p_index, _entries.size());
_entries.get(p_index).color = p_color; _entries.get(p_index).color = p_color;
@ -140,7 +140,7 @@ Vector2 TextureLayerMerger::get_position(const int p_index) {
return _entries.get(p_index).position; return _entries.get(p_index).position;
} }
void TextureLayerMerger::set_position(const int p_index, Vector2 p_position) { void TextureLayerMerger::set_position(const int p_index, const Vector2 &p_position) {
ERR_FAIL_INDEX(p_index, _entries.size()); ERR_FAIL_INDEX(p_index, _entries.size());
_entries.get(p_index).position = p_position; _entries.get(p_index).position = p_position;
@ -151,7 +151,7 @@ Rect2 TextureLayerMerger::get_rect(const int p_index) {
return _entries.get(p_index).rect; return _entries.get(p_index).rect;
} }
void TextureLayerMerger::set_rect(const int p_index, Rect2 p_rect) { void TextureLayerMerger::set_rect(const int p_index, const Rect2 &p_rect) {
ERR_FAIL_INDEX(p_index, _entries.size()); ERR_FAIL_INDEX(p_index, _entries.size());
_entries.get(p_index).rect = p_rect; _entries.get(p_index).rect = p_rect;

View File

@ -57,29 +57,29 @@ public:
void set_height(const int p_value); void set_height(const int p_value);
uint32_t get_texture_flags() const; uint32_t get_texture_flags() const;
void set_texture_flags(uint32_t p_flags); void set_texture_flags(const uint32_t p_flags);
Color get_base_color() const; Color get_base_color() const;
void set_base_color(const Color p_color); void set_base_color(const Color &p_color);
Ref<Image> get_data() const; Ref<Image> get_data() const;
void set_data(const Ref<Image> &p_image); void set_data(const Ref<Image> &p_image);
Ref<ImageTexture> get_result_as_texture() const; Ref<ImageTexture> get_result_as_texture() const;
void add_texture(Ref<Texture> p_texture, Color p_color = Color(1, 1, 1, 1), Vector2 p_position = Vector2(), Rect2 p_rect = Rect2()); void add_texture(const Ref<Texture> &p_texture, const Color &p_color = Color(1, 1, 1, 1), const Vector2 &p_position = Vector2(), Rect2 p_rect = Rect2());
Ref<Texture> get_texture(const int p_index); Ref<Texture> get_texture(const int p_index);
void set_texture(const int p_index, Ref<Texture> p_texture); void set_texture(const int p_index, const Ref<Texture> &p_texture);
Color get_color(const int p_index); Color get_color(const int p_index);
void set_color(const int p_index, Color p_color); void set_color(const int p_index, const Color &p_color);
Vector2 get_position(const int p_index); Vector2 get_position(const int p_index);
void set_position(const int p_index, Vector2 p_position); void set_position(const int p_index, const Vector2 &p_position);
Rect2 get_rect(const int p_index); Rect2 get_rect(const int p_index);
void set_rect(const int p_index, Rect2 p_rect); void set_rect(const int p_index, const Rect2 &p_rect);
void remove_texture(const int p_index); void remove_texture(const int p_index);
int get_texture_count(); int get_texture_count();

View File

@ -59,7 +59,7 @@ void TextureMerger::set_keep_original_atlases(const bool value) {
Color TextureMerger::get_background_color() const { Color TextureMerger::get_background_color() const {
return _packer->get_background_color(); return _packer->get_background_color();
} }
void TextureMerger::set_background_color(const Color color) { void TextureMerger::set_background_color(const Color &color) {
_packer->set_background_color(color); _packer->set_background_color(color);
} }
@ -80,7 +80,7 @@ void TextureMerger::set_automatic_merge(const bool value) {
Ref<TexturePacker> TextureMerger::get_packer() const { Ref<TexturePacker> TextureMerger::get_packer() const {
return _packer; return _packer;
} }
void TextureMerger::set_packer(const Ref<TexturePacker> packer) { void TextureMerger::set_packer(const Ref<TexturePacker> &packer) {
_packer = packer; _packer = packer;
} }
@ -130,7 +130,7 @@ void TextureMerger::set_textures(const Vector<Variant> &textures) {
set_dirty(true); set_dirty(true);
} }
Ref<AtlasTexture> TextureMerger::add_texture(Ref<Texture> texture) { Ref<AtlasTexture> TextureMerger::add_texture(const Ref<Texture> &texture) {
ERR_FAIL_COND_V(!texture.is_valid(), Ref<AtlasTexture>()); ERR_FAIL_COND_V(!texture.is_valid(), Ref<AtlasTexture>());
_textures.push_back(texture); _textures.push_back(texture);
@ -151,23 +151,23 @@ Ref<AtlasTexture> TextureMerger::add_texture(Ref<Texture> texture) {
return tex; return tex;
} }
Ref<Texture> TextureMerger::get_original_texture(int index) { Ref<Texture> TextureMerger::get_original_texture(const int index) {
return _packer->get_original_texture(index); return _packer->get_original_texture(index);
} }
bool TextureMerger::contains_texture(Ref<Texture> texture) { bool TextureMerger::contains_texture(const Ref<Texture> &texture) {
return _packer->contains_texture(texture); return _packer->contains_texture(texture);
} }
Ref<AtlasTexture> TextureMerger::get_texture(Ref<Texture> texture) { Ref<AtlasTexture> TextureMerger::get_texture(const Ref<Texture> &texture) {
return _packer->get_texture(texture); return _packer->get_texture(texture);
} }
Ref<AtlasTexture> TextureMerger::get_texture_index(int index) { Ref<AtlasTexture> TextureMerger::get_texture_index(const int index) {
return _packer->get_texture_index(index); return _packer->get_texture_index(index);
} }
bool TextureMerger::unref_texture_index(int index) { bool TextureMerger::unref_texture_index(const int index) {
if (_packer->unref_texture_index(index)) { if (_packer->unref_texture_index(index)) {
if (has_method("_texture_removed")) if (has_method("_texture_removed"))
call("_texture_removed"); call("_texture_removed");
@ -182,7 +182,7 @@ bool TextureMerger::unref_texture_index(int index) {
return false; return false;
} }
bool TextureMerger::unref_texture(Ref<Texture> texture) { bool TextureMerger::unref_texture(const Ref<Texture> &texture) {
if (_packer->unref_texture(texture)) { if (_packer->unref_texture(texture)) {
if (has_method("_texture_removed")) if (has_method("_texture_removed"))
call("_texture_removed"); call("_texture_removed");
@ -197,7 +197,7 @@ bool TextureMerger::unref_texture(Ref<Texture> texture) {
return false; return false;
} }
void TextureMerger::remove_texture_index(int index) { void TextureMerger::remove_texture_index(const int index) {
_packer->remove_texture_index(index); _packer->remove_texture_index(index);
if (has_method("_texture_removed")) if (has_method("_texture_removed"))
@ -208,7 +208,7 @@ void TextureMerger::remove_texture_index(int index) {
set_dirty(true); set_dirty(true);
} }
void TextureMerger::remove_texture(Ref<Texture> texture) { void TextureMerger::remove_texture(const Ref<Texture> &texture) {
_packer->remove_texture(texture); _packer->remove_texture(texture);
if (has_method("_texture_removed")) if (has_method("_texture_removed"))
@ -227,7 +227,7 @@ void TextureMerger::clear() {
_packer->clear(); _packer->clear();
} }
Ref<ImageTexture> TextureMerger::get_generated_texture(int index) { Ref<ImageTexture> TextureMerger::get_generated_texture(const int index) {
return _packer->get_generated_texture(index); return _packer->get_generated_texture(index);
} }
int TextureMerger::get_generated_texture_count() { int TextureMerger::get_generated_texture_count() {

View File

@ -54,7 +54,7 @@ public:
void set_keep_original_atlases(const bool value); void set_keep_original_atlases(const bool value);
Color get_background_color() const; Color get_background_color() const;
void set_background_color(const Color color); void set_background_color(const Color &color);
int get_margin() const; int get_margin() const;
void set_margin(const int margin); void set_margin(const int margin);
@ -63,26 +63,26 @@ public:
void set_automatic_merge(const bool value); void set_automatic_merge(const bool value);
Ref<TexturePacker> get_packer() const; Ref<TexturePacker> get_packer() const;
void set_packer(const Ref<TexturePacker> packer); void set_packer(const Ref<TexturePacker> &packer);
Vector<Variant> get_textures(); Vector<Variant> get_textures();
void set_textures(const Vector<Variant> &textures); void set_textures(const Vector<Variant> &textures);
Ref<AtlasTexture> add_texture(Ref<Texture> texture); Ref<AtlasTexture> add_texture(const Ref<Texture> &texture);
Ref<AtlasTexture> get_texture(Ref<Texture> texture); Ref<AtlasTexture> get_texture(const Ref<Texture> &texture);
Ref<AtlasTexture> get_texture_index(int index); Ref<AtlasTexture> get_texture_index(const int index);
Ref<Texture> get_original_texture(int index); Ref<Texture> get_original_texture(const int index);
bool contains_texture(Ref<Texture> texture); bool contains_texture(const Ref<Texture> &texture);
bool unref_texture_index(int index); bool unref_texture_index(const int index);
bool unref_texture(Ref<Texture> texture); bool unref_texture(const Ref<Texture> &texture);
void remove_texture_index(int index); void remove_texture_index(const int index);
void remove_texture(Ref<Texture> texture); void remove_texture(const Ref<Texture> &texture);
int get_texture_count(); int get_texture_count();
void clear(); void clear();
Ref<ImageTexture> get_generated_texture(int index); Ref<ImageTexture> get_generated_texture(const int index);
int get_generated_texture_count(); int get_generated_texture_count();
void merge(); void merge();

View File

@ -46,7 +46,7 @@ void TexturePacker::set_keep_original_atlases(const bool value) {
Color TexturePacker::get_background_color() const { Color TexturePacker::get_background_color() const {
return _background_color; return _background_color;
} }
void TexturePacker::set_background_color(const Color color) { void TexturePacker::set_background_color(const Color &color) {
_background_color = color; _background_color = color;
} }
@ -57,7 +57,7 @@ void TexturePacker::set_margin(const int margin) {
_margin = margin; _margin = margin;
} }
Ref<AtlasTexture> TexturePacker::add_texture(Ref<Texture> texture) { Ref<AtlasTexture> TexturePacker::add_texture(const Ref<Texture> &texture) {
ERR_FAIL_COND_V(!texture.is_valid(), Ref<AtlasTexture>()); ERR_FAIL_COND_V(!texture.is_valid(), Ref<AtlasTexture>());
Ref<AtlasTexture> atlas_text = texture; Ref<AtlasTexture> atlas_text = texture;
@ -140,7 +140,7 @@ Ref<AtlasTexture> TexturePacker::add_texture(Ref<Texture> texture) {
return tex; return tex;
} }
Ref<AtlasTexture> TexturePacker::get_texture(Ref<Texture> texture) { Ref<AtlasTexture> TexturePacker::get_texture(const Ref<Texture> &texture) {
for (int i = 0; i < _rects.size(); ++i) { for (int i = 0; i < _rects.size(); ++i) {
rect_xywhf *r = _rects.get(i); rect_xywhf *r = _rects.get(i);
@ -160,19 +160,19 @@ Ref<AtlasTexture> TexturePacker::get_texture(Ref<Texture> texture) {
return Ref<Texture>(); return Ref<Texture>();
} }
Ref<AtlasTexture> TexturePacker::get_texture_index(int index) { Ref<AtlasTexture> TexturePacker::get_texture_index(const int index) {
ERR_FAIL_INDEX_V(index, _rects.size(), Ref<AtlasTexture>()); ERR_FAIL_INDEX_V(index, _rects.size(), Ref<AtlasTexture>());
return _rects.get(index)->atlas_texture; return _rects.get(index)->atlas_texture;
} }
Ref<Texture> TexturePacker::get_original_texture(int index) { Ref<Texture> TexturePacker::get_original_texture(const int index) {
ERR_FAIL_INDEX_V(index, _rects.size(), Ref<Texture>()); ERR_FAIL_INDEX_V(index, _rects.size(), Ref<Texture>());
return _rects.get(index)->original_texture; return _rects.get(index)->original_texture;
} }
bool TexturePacker::contains_texture(Ref<Texture> texture) { bool TexturePacker::contains_texture(const Ref<Texture> &texture) {
for (int i = 0; i < _rects.size(); ++i) { for (int i = 0; i < _rects.size(); ++i) {
rect_xywhf *r = _rects.get(i); rect_xywhf *r = _rects.get(i);
@ -192,7 +192,7 @@ bool TexturePacker::contains_texture(Ref<Texture> texture) {
return false; return false;
} }
bool TexturePacker::unref_texture_index(int index) { bool TexturePacker::unref_texture_index(const int index) {
ERR_FAIL_INDEX_V(index, _rects.size(), false); ERR_FAIL_INDEX_V(index, _rects.size(), false);
rect_xywhf *r = _rects.get(index); rect_xywhf *r = _rects.get(index);
@ -213,7 +213,7 @@ bool TexturePacker::unref_texture_index(int index) {
return false; return false;
} }
bool TexturePacker::unref_texture(Ref<Texture> texture) { bool TexturePacker::unref_texture(const Ref<Texture> &texture) {
for (int i = 0; i < _rects.size(); ++i) { for (int i = 0; i < _rects.size(); ++i) {
rect_xywhf *r = _rects.get(i); rect_xywhf *r = _rects.get(i);
@ -247,7 +247,7 @@ bool TexturePacker::unref_texture(Ref<Texture> texture) {
return false; return false;
} }
void TexturePacker::remove_texture_index(int index) { void TexturePacker::remove_texture_index(const int index) {
ERR_FAIL_INDEX(index, _rects.size()); ERR_FAIL_INDEX(index, _rects.size());
rect_xywhf *r = _rects.get(index); rect_xywhf *r = _rects.get(index);
@ -258,7 +258,7 @@ void TexturePacker::remove_texture_index(int index) {
memdelete(r); memdelete(r);
} }
void TexturePacker::remove_texture(Ref<Texture> texture) { void TexturePacker::remove_texture(const Ref<Texture> &texture) {
for (int i = 0; i < _rects.size(); ++i) { for (int i = 0; i < _rects.size(); ++i) {
rect_xywhf *r = _rects.get(i); rect_xywhf *r = _rects.get(i);
@ -307,7 +307,7 @@ void TexturePacker::clear() {
_generated_textures.clear(); _generated_textures.clear();
} }
Ref<ImageTexture> TexturePacker::get_generated_texture(int index) { Ref<ImageTexture> TexturePacker::get_generated_texture(const int index) {
ERR_FAIL_INDEX_V(index, _generated_textures.size(), Ref<ImageTexture>()); ERR_FAIL_INDEX_V(index, _generated_textures.size(), Ref<ImageTexture>());
return _generated_textures.get(index); return _generated_textures.get(index);
@ -418,7 +418,7 @@ void TexturePacker::merge() {
} }
} }
int TexturePacker::get_offset_for_format(Image::Format format) { int TexturePacker::get_offset_for_format(const Image::Format format) {
switch (format) { switch (format) {
case Image::FORMAT_RGB8: case Image::FORMAT_RGB8:
return 3; return 3;

View File

@ -66,34 +66,34 @@ public:
void set_keep_original_atlases(const bool value); void set_keep_original_atlases(const bool value);
Color get_background_color() const; Color get_background_color() const;
void set_background_color(const Color color); void set_background_color(const Color &color);
int get_margin() const; int get_margin() const;
void set_margin(const int margin); void set_margin(const int margin);
Ref<AtlasTexture> add_texture(Ref<Texture> texture); Ref<AtlasTexture> add_texture(const Ref<Texture> &texture);
Ref<AtlasTexture> get_texture(Ref<Texture> texture); Ref<AtlasTexture> get_texture(const Ref<Texture> &texture);
Ref<AtlasTexture> get_texture_index(int index); Ref<AtlasTexture> get_texture_index(const int index);
Ref<Texture> get_original_texture(int index); Ref<Texture> get_original_texture(const int index);
bool contains_texture(Ref<Texture> texture); bool contains_texture(const Ref<Texture> &texture);
bool unref_texture_index(int index); bool unref_texture_index(const int index);
bool unref_texture(Ref<Texture> texture); bool unref_texture(const Ref<Texture> &texture);
void remove_texture_index(int index); void remove_texture_index(const int index);
void remove_texture(Ref<Texture> texture); void remove_texture(const Ref<Texture> &texture);
int get_texture_count(); int get_texture_count();
void clear(); void clear();
Ref<ImageTexture> get_generated_texture(int index); Ref<ImageTexture> get_generated_texture(const int index);
int get_generated_texture_count(); int get_generated_texture_count();
void merge(); void merge();
int get_offset_for_format(Image::Format format); int get_offset_for_format(const Image::Format format);
TexturePacker(); TexturePacker();
~TexturePacker(); ~TexturePacker();