summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2018-11-27 21:58:00 -0500
committerAaron Franke <arnfranke@yahoo.com>2018-11-28 05:03:24 -0500
commitcb01268562a47e6a1c32559f58fbadd46e52d304 (patch)
tree8466e05cbf670863759899e0fd7d67d6a44ca1cb /scene/resources
parentaa08ef2bed34510cfb18ce3e1e5cdd9c009981be (diff)
Fix many errors found by PVS-Studio
Fix errors 2, 3, 4, 6, 8, 9, 11, 12, 13, 14, and 15.
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/texture.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 682bfebdd2..4f4d375481 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -994,11 +994,11 @@ void AtlasTexture::_bind_methods() {
void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
- Rect2 rc = region;
-
if (!atlas.is_valid())
return;
+ Rect2 rc = region;
+
if (rc.size.width == 0) {
rc.size.width = atlas->get_width();
}
@@ -1013,11 +1013,11 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
- Rect2 rc = region;
-
if (!atlas.is_valid())
return;
+ Rect2 rc = region;
+
if (rc.size.width == 0) {
rc.size.width = atlas->get_width();
}
@@ -1048,11 +1048,11 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
- Rect2 rc = region;
-
if (!atlas.is_valid())
return false;
+ Rect2 rc = region;
+
Rect2 src = p_src_rect;
if (src.size == Size2()) {
src.size = rc.size;
@@ -1084,11 +1084,13 @@ bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect,
bool AtlasTexture::is_pixel_opaque(int p_x, int p_y) const {
- if (atlas.is_valid()) {
- return atlas->is_pixel_opaque(p_x + region.position.x + margin.position.x, p_x + region.position.y + margin.position.y);
- }
+ if (!atlas.is_valid())
+ return true;
- return true;
+ int x = p_x + region.position.x + margin.position.x;
+ int y = p_y + region.position.y + margin.position.y;
+
+ return atlas->is_pixel_opaque(x, y);
}
AtlasTexture::AtlasTexture() {