Debian Codegraph @

scene/resources/texture.h

raw symbols SCIP
1 /**************************************************************************/
2 /* texture.h */
3 /**************************************************************************/
4 /* This file is part of: */
5 /* GODOT ENGINE */
6 /* https://godotengine.org */
7 /**************************************************************************/
8 /* Copyright (c) 2014-present Godot Engine contributors (see AUTHORS.md). */
9 /* Copyright (c) 2007-2014 Juan Linietsky, Ariel Manzur. */
10 /* */
11 /* Permission is hereby granted, free of charge, to any person obtaining */
12 /* a copy of this software and associated documentation files (the */
13 /* "Software"), to deal in the Software without restriction, including */
14 /* without limitation the rights to use, copy, modify, merge, publish, */
15 /* distribute, sublicense, and/or sell copies of the Software, and to */
16 /* permit persons to whom the Software is furnished to do so, subject to */
17 /* the following conditions: */
18 /* */
19 /* The above copyright notice and this permission notice shall be */
20 /* included in all copies or substantial portions of the Software. */
21 /* */
22 /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
23 /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
24 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. */
25 /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
26 /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
27 /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
28 /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
29 /**************************************************************************/
30
31 #pragma once
32
33 #include "core/io/image.h"
34 #include "core/io/resource.h"
35 #include "core/variant/typed_array.h"
36 #include "scene/resources/curve.h"
37
38 class Texture : public Resource {
39 GDCLASS(Texture, Resource);
40 };
41
42 class Texture2D : public Texture {
43 GDCLASS(Texture2D, Texture);
44 OBJ_SAVE_TYPE(Texture2D); // Saves derived classes with common type so they can be interchanged.
45
46 protected:
47 static void _bind_methods();
48
49 GDVIRTUAL0RC_REQUIRED(int, _get_width)
50 GDVIRTUAL0RC_REQUIRED(int, _get_height)
51 GDVIRTUAL2RC(bool, _is_pixel_opaque, int, int)
52 GDVIRTUAL0RC(bool, _has_alpha)
53
54 GDVIRTUAL4C(_draw, RID, Point2, Color, bool)
55 GDVIRTUAL5C(_draw_rect, RID, Rect2, bool, Color, bool)
56 GDVIRTUAL6C(_draw_rect_region, RID, Rect2, Rect2, Color, bool, bool)
57
58 public:
59 virtual int get_width() const;
60 virtual int get_height() const;
61 virtual Size2 get_size() const;
62
63 virtual bool is_pixel_opaque(int p_x, int p_y) const;
64
65 virtual bool has_alpha() const;
66
67 virtual RID get_scaled_rid() const { return get_rid(); }
68 virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
69 virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
70 virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const;
71 virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
72
73 virtual Ref<Image> get_image() const { return Ref<Image>(); }
74
75 virtual Ref<Resource> create_placeholder() const;
76
77 Texture2D();
78 };
79
80 class TextureLayered : public Texture {
81 GDCLASS(TextureLayered, Texture);
82
83 protected:
84 static void _bind_methods();
85
86 GDVIRTUAL0RC_REQUIRED(Image::Format, _get_format)
87 GDVIRTUAL0RC_REQUIRED(uint32_t, _get_layered_type)
88 GDVIRTUAL0RC_REQUIRED(int, _get_width)
89 GDVIRTUAL0RC_REQUIRED(int, _get_height)
90 GDVIRTUAL0RC_REQUIRED(int, _get_layers)
91 GDVIRTUAL0RC_REQUIRED(bool, _has_mipmaps)
92 GDVIRTUAL1RC_REQUIRED(Ref<Image>, _get_layer_data, int)
93 public:
94 enum LayeredType {
95 LAYERED_TYPE_2D_ARRAY,
96 LAYERED_TYPE_CUBEMAP,
97 LAYERED_TYPE_CUBEMAP_ARRAY
98 };
99
100 virtual Image::Format get_format() const;
101 virtual LayeredType get_layered_type() const;
102 virtual int get_width() const;
103 virtual int get_height() const;
104 virtual int get_layers() const;
105 virtual bool has_mipmaps() const;
106 virtual Ref<Image> get_layer_data(int p_layer) const;
107 };
108
109 VARIANT_ENUM_CAST(TextureLayered::LayeredType)
110
111 class Texture3D : public Texture {
112 GDCLASS(Texture3D, Texture);
113
114 protected:
115 static void _bind_methods();
116
117 TypedArray<Image> _get_datai() const;
118
119 GDVIRTUAL0RC_REQUIRED(Image::Format, _get_format)
120 GDVIRTUAL0RC_REQUIRED(int, _get_width)
121 GDVIRTUAL0RC_REQUIRED(int, _get_height)
122 GDVIRTUAL0RC_REQUIRED(int, _get_depth)
123 GDVIRTUAL0RC_REQUIRED(bool, _has_mipmaps)
124 GDVIRTUAL0RC_REQUIRED(TypedArray<Image>, _get_data)
125 public:
126 virtual Image::Format get_format() const;
127 virtual int get_width() const;
128 virtual int get_height() const;
129 virtual int get_depth() const;
130 virtual bool has_mipmaps() const;
131 virtual Vector<Ref<Image>> get_data() const;
132 virtual Ref<Resource> create_placeholder() const;
133 };