diff options
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/rasterizer.h | 6 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.cpp | 2 | ||||
-rw-r--r-- | servers/visual/visual_server_raster.h | 6 | ||||
-rw-r--r-- | servers/visual_server.cpp | 11 | ||||
-rw-r--r-- | servers/visual_server.h | 9 |
5 files changed, 18 insertions, 16 deletions
diff --git a/servers/visual/rasterizer.h b/servers/visual/rasterizer.h index ff679bc15f..624bd1dad7 100644 --- a/servers/visual/rasterizer.h +++ b/servers/visual/rasterizer.h @@ -163,8 +163,8 @@ public: virtual RID texture_create() = 0; virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = VS::TEXTURE_FLAGS_DEFAULT) = 0; - virtual void texture_set_data(RID p_texture, const Image &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) = 0; - virtual Image texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const = 0; + virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) = 0; + virtual Ref<Image> texture_get_data(RID p_texture, VS::CubeMapSide p_cube_side = VS::CUBEMAP_LEFT) const = 0; virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0; virtual uint32_t texture_get_flags(RID p_texture) const = 0; virtual Image::Format texture_get_format(RID p_texture) const = 0; @@ -931,7 +931,7 @@ public: virtual RasterizerCanvas *get_canvas() = 0; virtual RasterizerScene *get_scene() = 0; - virtual void set_boot_image(const Image &p_image, const Color &p_color, bool p_scale) = 0; + virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale) = 0; virtual void initialize() = 0; virtual void begin_frame() = 0; diff --git a/servers/visual/visual_server_raster.cpp b/servers/visual/visual_server_raster.cpp index 5ba975d193..2fdff29f0a 100644 --- a/servers/visual/visual_server_raster.cpp +++ b/servers/visual/visual_server_raster.cpp @@ -121,7 +121,7 @@ int VisualServerRaster::get_render_info(RenderInfo p_info) { /* TESTING */ -void VisualServerRaster::set_boot_image(const Image &p_image, const Color &p_color, bool p_scale) { +void VisualServerRaster::set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale) { redraw_request(); VSG::rasterizer->set_boot_image(p_image, p_color, p_scale); diff --git a/servers/visual/visual_server_raster.h b/servers/visual/visual_server_raster.h index 7de497d529..db3c7f822a 100644 --- a/servers/visual/visual_server_raster.h +++ b/servers/visual/visual_server_raster.h @@ -623,8 +623,8 @@ public: BIND0R(RID, texture_create) BIND5(texture_allocate, RID, int, int, Image::Format, uint32_t) - BIND3(texture_set_data, RID, const Image &, CubeMapSide) - BIND2RC(Image, texture_get_data, RID, CubeMapSide) + BIND3(texture_set_data, RID, const Ref<Image> &, CubeMapSide) + BIND2RC(Ref<Image>, texture_get_data, RID, CubeMapSide) BIND2(texture_set_flags, RID, uint32_t) BIND1RC(uint32_t, texture_get_flags, RID) BIND1RC(Image::Format, texture_get_format, RID) @@ -1109,7 +1109,7 @@ public: /* TESTING */ - virtual void set_boot_image(const Image &p_image, const Color &p_color, bool p_scale); + virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale); virtual void set_default_clear_color(const Color &p_color); virtual bool has_feature(Features p_feature) const; diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 5a7ae93a31..5df1ca456b 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -68,10 +68,11 @@ VisualServer *VisualServer::create() { return NULL; } -RID VisualServer::texture_create_from_image(const Image &p_image, uint32_t p_flags) { +RID VisualServer::texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags) { + ERR_FAIL_COND_V(!p_image.is_valid(), RID()); RID texture = texture_create(); - texture_allocate(texture, p_image.get_width(), p_image.get_height(), p_image.get_format(), p_flags); //if it has mipmaps, use, else generate + texture_allocate(texture, p_image->get_width(), p_image->get_height(), p_image->get_format(), p_flags); //if it has mipmaps, use, else generate ERR_FAIL_COND_V(!texture.is_valid(), texture); texture_set_data(texture, p_image); @@ -120,12 +121,12 @@ RID VisualServer::get_test_texture() { } } - Image data(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data); + Ref<Image> data = memnew(Image(TEST_TEXTURE_SIZE, TEST_TEXTURE_SIZE, false, Image::FORMAT_RGB8, test_data)); test_texture = texture_create_from_image(data); return test_texture; -}; +} void VisualServer::_free_internal_rids() { @@ -324,7 +325,7 @@ RID VisualServer::get_white_texture() { for (int i = 0; i < 16 * 3; i++) w[i] = 255; } - Image white(4, 4, 0, Image::FORMAT_RGB8, wt); + Ref<Image> white = memnew(Image(4, 4, 0, Image::FORMAT_RGB8, wt)); white_texture = texture_create(); texture_allocate(white_texture, 4, 4, Image::FORMAT_RGB8); texture_set_data(white_texture, white); diff --git a/servers/visual_server.h b/servers/visual_server.h index 7accc7d904..28f21a36eb 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -32,6 +32,7 @@ #include "bsp_tree.h" #include "geometry.h" +#include "image.h" #include "math_2d.h" #include "object.h" #include "rid.h" @@ -106,10 +107,10 @@ public: }; virtual RID texture_create() = 0; - RID texture_create_from_image(const Image &p_image, uint32_t p_flags = TEXTURE_FLAGS_DEFAULT); // helper + RID texture_create_from_image(const Ref<Image> &p_image, uint32_t p_flags = TEXTURE_FLAGS_DEFAULT); // helper virtual void texture_allocate(RID p_texture, int p_width, int p_height, Image::Format p_format, uint32_t p_flags = TEXTURE_FLAGS_DEFAULT) = 0; - virtual void texture_set_data(RID p_texture, const Image &p_image, CubeMapSide p_cube_side = CUBEMAP_LEFT) = 0; - virtual Image texture_get_data(RID p_texture, CubeMapSide p_cube_side = CUBEMAP_LEFT) const = 0; + virtual void texture_set_data(RID p_texture, const Ref<Image> &p_image, CubeMapSide p_cube_side = CUBEMAP_LEFT) = 0; + virtual Ref<Image> texture_get_data(RID p_texture, CubeMapSide p_cube_side = CUBEMAP_LEFT) const = 0; virtual void texture_set_flags(RID p_texture, uint32_t p_flags) = 0; virtual uint32_t texture_get_flags(RID p_texture) const = 0; virtual Image::Format texture_get_format(RID p_texture) const = 0; @@ -884,7 +885,7 @@ public: virtual void mesh_add_surface_from_mesh_data(RID p_mesh, const Geometry::MeshData &p_mesh_data); virtual void mesh_add_surface_from_planes(RID p_mesh, const PoolVector<Plane> &p_planes); - virtual void set_boot_image(const Image &p_image, const Color &p_color, bool p_scale) = 0; + virtual void set_boot_image(const Ref<Image> &p_image, const Color &p_color, bool p_scale) = 0; virtual void set_default_clear_color(const Color &p_color) = 0; enum Features { |