summaryrefslogtreecommitdiff
path: root/scene/resources/texture.h
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources/texture.h')
-rw-r--r--scene/resources/texture.h111
1 files changed, 91 insertions, 20 deletions
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 4b5b504510..e535f7544a 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -37,14 +37,11 @@
#include "core/os/rw_lock.h"
#include "core/os/thread_safe.h"
#include "core/resource.h"
-#include "scene/resources/color_ramp.h"
#include "scene/resources/curve.h"
+#include "scene/resources/gradient.h"
+#include "servers/camera_server.h"
#include "servers/visual_server.h"
-/**
- @author Juan Linietsky <reduzio@gmail.com>
-*/
-
class Texture : public Resource {
GDCLASS(Texture, Resource);
@@ -111,7 +108,7 @@ private:
Size2 size_override;
float lossy_storage_quality;
mutable Ref<BitMap> alpha_cache;
- Ref<Image> image_cache;
+ bool image_stored;
protected:
virtual void reload_from_file();
@@ -126,11 +123,7 @@ protected:
void _set_data(Dictionary p_data);
- static bool keep_images_cached;
-
public:
- static void set_keep_images_cached(bool p_enable);
-
void create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT);
void create_from_image(const Ref<Image> &p_image, uint32_t p_flags = FLAGS_DEFAULT);
@@ -191,7 +184,7 @@ public:
};
private:
- Error _load_data(const String &p_path, int &tw, int &th, int &flags, Ref<Image> &image, int p_size_limit = 0);
+ Error _load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, int &flags, Ref<Image> &image, int p_size_limit = 0);
String path_to_file;
RID texture;
Image::Format format;
@@ -207,6 +200,7 @@ private:
protected:
static void _bind_methods();
+ void _validate_property(PropertyInfo &property) const;
public:
typedef void (*TextureFormatRequestCallback)(const Ref<StreamTexture> &);
@@ -241,7 +235,6 @@ public:
};
class ResourceFormatLoaderStreamTexture : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderStreamTexture, ResourceFormatLoader)
public:
virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL);
virtual void get_recognized_extensions(List<String> *p_extensions) const;
@@ -296,6 +289,49 @@ public:
AtlasTexture();
};
+class Mesh;
+
+class MeshTexture : public Texture {
+
+ GDCLASS(MeshTexture, Texture);
+ RES_BASE_EXTENSION("meshtex");
+
+ Ref<Texture> base_texture;
+ Ref<Mesh> mesh;
+ Size2i size;
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual int get_width() const;
+ virtual int get_height() const;
+ virtual RID get_rid() const;
+
+ virtual bool has_alpha() const;
+
+ virtual void set_flags(uint32_t p_flags);
+ virtual uint32_t get_flags() const;
+
+ void set_mesh(const Ref<Mesh> &p_mesh);
+ Ref<Mesh> get_mesh() const;
+
+ void set_image_size(const Size2 &p_size);
+ Size2 get_image_size() const;
+
+ void set_base_texture(const Ref<Texture> &p_texture);
+ Ref<Texture> get_base_texture() const;
+
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture> &p_normal_map = Ref<Texture>()) const;
+ 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 Ref<Texture> &p_normal_map = Ref<Texture>()) const;
+ 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, const Ref<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const;
+ virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
+
+ bool is_pixel_opaque(int p_x, int p_y) const;
+
+ MeshTexture();
+};
+
class LargeTexture : public Texture {
GDCLASS(LargeTexture, Texture);
@@ -429,7 +465,7 @@ VARIANT_ENUM_CAST(CubeMap::Storage)
class TextureLayered : public Resource {
- GDCLASS(TextureLayered, Resource)
+ GDCLASS(TextureLayered, Resource);
public:
enum Flags {
@@ -481,7 +517,8 @@ VARIANT_ENUM_CAST(TextureLayered::Flags)
class Texture3D : public TextureLayered {
- GDCLASS(Texture3D, TextureLayered)
+ GDCLASS(Texture3D, TextureLayered);
+
public:
Texture3D() :
TextureLayered(true) {}
@@ -489,14 +526,14 @@ public:
class TextureArray : public TextureLayered {
- GDCLASS(TextureArray, TextureLayered)
+ GDCLASS(TextureArray, TextureLayered);
+
public:
TextureArray() :
TextureLayered(false) {}
};
class ResourceFormatLoaderTextureLayered : public ResourceFormatLoader {
- GDCLASS(ResourceFormatLoaderTextureLayered, ResourceFormatLoader)
public:
enum Compression {
COMPRESSION_LOSSLESS,
@@ -512,7 +549,7 @@ public:
class CurveTexture : public Texture {
- GDCLASS(CurveTexture, Texture)
+ GDCLASS(CurveTexture, Texture);
RES_BASE_EXTENSION("curvetex")
private:
@@ -560,7 +597,7 @@ public:
//VARIANT_ENUM_CAST( Texture::CubeMapSide );
class GradientTexture : public Texture {
- GDCLASS(GradientTexture, Texture)
+ GDCLASS(GradientTexture, Texture);
public:
struct Point {
@@ -605,7 +642,7 @@ public:
};
class ProxyTexture : public Texture {
- GDCLASS(ProxyTexture, Texture)
+ GDCLASS(ProxyTexture, Texture);
private:
RID proxy;
@@ -632,7 +669,7 @@ public:
};
class AnimatedTexture : public Texture {
- GDCLASS(AnimatedTexture, Texture)
+ GDCLASS(AnimatedTexture, Texture);
//use readers writers lock for this, since its far more times read than written to
RWLock *rw_lock;
@@ -700,4 +737,38 @@ public:
~AnimatedTexture();
};
+class CameraTexture : public Texture {
+ GDCLASS(CameraTexture, Texture);
+
+private:
+ int camera_feed_id;
+ CameraServer::FeedImage which_feed;
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual int get_width() const;
+ virtual int get_height() const;
+ virtual RID get_rid() const;
+ virtual bool has_alpha() const;
+
+ virtual void set_flags(uint32_t p_flags);
+ virtual uint32_t get_flags() const;
+
+ virtual Ref<Image> get_data() const;
+
+ void set_camera_feed_id(int p_new_id);
+ int get_camera_feed_id() const;
+
+ void set_which_feed(CameraServer::FeedImage p_which);
+ CameraServer::FeedImage get_which_feed() const;
+
+ void set_camera_active(bool p_active);
+ bool get_camera_active() const;
+
+ CameraTexture();
+ ~CameraTexture();
+};
+
#endif