summaryrefslogtreecommitdiff
path: root/scene/main/canvas_item.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/main/canvas_item.h')
-rw-r--r--scene/main/canvas_item.h125
1 files changed, 4 insertions, 121 deletions
diff --git a/scene/main/canvas_item.h b/scene/main/canvas_item.h
index f264764870..dc7ad2bf5d 100644
--- a/scene/main/canvas_item.h
+++ b/scene/main/canvas_item.h
@@ -33,132 +33,15 @@
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
-#include "scene/resources/material.h"
-#include "scene/resources/multimesh.h"
-#include "scene/resources/shader.h"
-#include "scene/resources/texture.h"
+#include "scene/resources/canvas_item_material.h"
#include "servers/text_server.h"
class CanvasLayer;
-class Viewport;
class Font;
-
+class MultiMesh;
class StyleBox;
-
-class CanvasItemMaterial : public Material {
- GDCLASS(CanvasItemMaterial, Material);
-
-public:
- enum BlendMode {
- BLEND_MODE_MIX,
- BLEND_MODE_ADD,
- BLEND_MODE_SUB,
- BLEND_MODE_MUL,
- BLEND_MODE_PREMULT_ALPHA,
- BLEND_MODE_DISABLED
- };
-
- enum LightMode {
- LIGHT_MODE_NORMAL,
- LIGHT_MODE_UNSHADED,
- LIGHT_MODE_LIGHT_ONLY
- };
-
-private:
- union MaterialKey {
- struct {
- uint32_t blend_mode : 4;
- uint32_t light_mode : 4;
- uint32_t particles_animation : 1;
- uint32_t invalid_key : 1;
- };
-
- uint32_t key = 0;
-
- bool operator<(const MaterialKey &p_key) const {
- return key < p_key.key;
- }
- };
-
- struct ShaderNames {
- StringName particles_anim_h_frames;
- StringName particles_anim_v_frames;
- StringName particles_anim_loop;
- };
-
- static ShaderNames *shader_names;
-
- struct ShaderData {
- RID shader;
- int users = 0;
- };
-
- static Map<MaterialKey, ShaderData> shader_map;
-
- MaterialKey current_key;
-
- _FORCE_INLINE_ MaterialKey _compute_key() const {
- MaterialKey mk;
- mk.key = 0;
- mk.blend_mode = blend_mode;
- mk.light_mode = light_mode;
- mk.particles_animation = particles_animation;
- return mk;
- }
-
- static Mutex material_mutex;
- static SelfList<CanvasItemMaterial>::List *dirty_materials;
- SelfList<CanvasItemMaterial> element;
-
- void _update_shader();
- _FORCE_INLINE_ void _queue_shader_change();
- _FORCE_INLINE_ bool _is_shader_dirty() const;
-
- BlendMode blend_mode = BLEND_MODE_MIX;
- LightMode light_mode = LIGHT_MODE_NORMAL;
- bool particles_animation = false;
-
- // Initialized in the constructor.
- int particles_anim_h_frames;
- int particles_anim_v_frames;
- bool particles_anim_loop;
-
-protected:
- static void _bind_methods();
- void _validate_property(PropertyInfo &property) const override;
-
-public:
- void set_blend_mode(BlendMode p_blend_mode);
- BlendMode get_blend_mode() const;
-
- void set_light_mode(LightMode p_light_mode);
- LightMode get_light_mode() const;
-
- void set_particles_animation(bool p_particles_anim);
- bool get_particles_animation() const;
-
- void set_particles_anim_h_frames(int p_frames);
- int get_particles_anim_h_frames() const;
- void set_particles_anim_v_frames(int p_frames);
- int get_particles_anim_v_frames() const;
-
- void set_particles_anim_loop(bool p_loop);
- bool get_particles_anim_loop() const;
-
- static void init_shaders();
- static void finish_shaders();
- static void flush_changes();
-
- virtual RID get_shader_rid() const override;
-
- virtual Shader::Mode get_shader_mode() const override;
-
- CanvasItemMaterial();
- virtual ~CanvasItemMaterial();
-};
-
-VARIANT_ENUM_CAST(CanvasItemMaterial::BlendMode)
-VARIANT_ENUM_CAST(CanvasItemMaterial::LightMode)
+class Window;
+class World2D;
class CanvasItem : public Node {
GDCLASS(CanvasItem, Node);