diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/image.cpp | 33 | ||||
-rw-r--r-- | core/image.h | 3 | ||||
-rw-r--r-- | core/io/resource_format_xml.cpp | 4 | ||||
-rw-r--r-- | core/script_debugger_remote.cpp | 30 | ||||
-rw-r--r-- | core/script_debugger_remote.h | 18 |
5 files changed, 86 insertions, 2 deletions
diff --git a/core/image.cpp b/core/image.cpp index 4c0a23492b..06b7a78488 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -34,6 +34,33 @@ #include "print_string.h" #include <stdio.h> + +const char* Image::format_names[Image::FORMAT_MAX]={ + "Grayscale", + "Intensity", + "GrayscaleAlpha", + "RGB", + "RGBA", + "Indexed", + "IndexedAlpha", + "YUV422", + "YUV444", + "BC1", + "BC2", + "BC3", + "BC4", + "BC5", + "PVRTC2", + "PVRTC2Alpha", + "PVRTC4", + "PVRTC4Alpha", + "ETC", + "ATC", + "ATCAlphaExp", + "ATCAlphaInterp", + +}; + SavePNGFunc Image::save_png_func = NULL; void Image::_put_pixel(int p_x,int p_y, const BColor& p_color, unsigned char *p_data) { @@ -2355,6 +2382,12 @@ void Image::fix_alpha_edges() { } +String Image::get_format_name(Format p_format) { + + ERR_FAIL_INDEX_V(p_format,FORMAT_MAX,String()); + return format_names[p_format]; +} + Image::Image(const uint8_t* p_png,int p_len) { width=0; diff --git a/core/image.h b/core/image.h index 4461e97144..a155823af7 100644 --- a/core/image.h +++ b/core/image.h @@ -87,6 +87,7 @@ public: FORMAT_MAX }; + static const char* format_names[FORMAT_MAX]; enum Interpolation { INTERPOLATE_NEAREST, @@ -352,6 +353,8 @@ public: Image get_rect(const Rect2& p_area) const; static void set_compress_bc_func(void (*p_compress_func)(Image *)); + static String get_format_name(Format p_format); + Image(const uint8_t* p_mem_png, int p_len=-1); Image(const char **p_xpm); ~Image(); diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index 9019b4e3c0..66ae014dbc 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -2056,8 +2056,8 @@ Error ResourceFormatLoaderXML::rename_dependencies(const String &p_path,const Ma void ResourceFormatSaverXMLInstance::escape(String& p_str) { p_str=p_str.replace("&","&"); - p_str=p_str.replace("<",">"); - p_str=p_str.replace(">","<"); + p_str=p_str.replace("<","<"); + p_str=p_str.replace(">",">"); p_str=p_str.replace("'","'"); p_str=p_str.replace("\"","""); for (char i=1;i<32;i++) { diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index d42f879441..d72c9f7532 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -31,6 +31,28 @@ #include "io/ip.h" #include "globals.h" +void ScriptDebuggerRemote::_send_video_memory() { + + List<ResourceUsage> usage; + if (resource_usage_func) + resource_usage_func(&usage); + + usage.sort(); + + packet_peer_stream->put_var("message:video_mem"); + packet_peer_stream->put_var(usage.size()*4); + + + for(List<ResourceUsage>::Element *E=usage.front();E;E=E->next()) { + + packet_peer_stream->put_var(E->get().path); + packet_peer_stream->put_var(E->get().type); + packet_peer_stream->put_var(E->get().format); + packet_peer_stream->put_var(E->get().vram); + } + +} + Error ScriptDebuggerRemote::connect_to_host(const String& p_host,uint16_t p_port) { @@ -248,6 +270,9 @@ void ScriptDebuggerRemote::debug(ScriptLanguage *p_script,bool p_can_continue) { if (request_scene_tree) request_scene_tree(request_scene_tree_ud); + } else if (command=="request_video_mem") { + + _send_video_memory(); } else if (command=="breakpoint") { bool set = cmd[3]; @@ -531,6 +556,9 @@ void ScriptDebuggerRemote::_poll_events() { if (request_scene_tree) request_scene_tree(request_scene_tree_ud); + } else if (command=="request_video_mem") { + + _send_video_memory(); } else if (command=="breakpoint") { bool set = cmd[3]; @@ -652,6 +680,8 @@ void ScriptDebuggerRemote::set_live_edit_funcs(LiveEditFuncs *p_funcs) { live_edit_funcs=p_funcs; } +ScriptDebuggerRemote::ResourceUsageFunc ScriptDebuggerRemote::resource_usage_func=NULL; + ScriptDebuggerRemote::ScriptDebuggerRemote() { tcp_client = StreamPeerTCP::create_ref(); diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index c2642782a9..973fa23212 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -34,6 +34,7 @@ #include "io/stream_peer_tcp.h" #include "io/packet_peer.h" #include "list.h" + class ScriptDebuggerRemote : public ScriptDebugger { struct Message { @@ -42,6 +43,8 @@ class ScriptDebuggerRemote : public ScriptDebugger { Array data; }; + + Ref<StreamPeerTCP> tcp_client; Ref<PacketPeerStream> packet_peer_stream; @@ -90,6 +93,7 @@ class ScriptDebuggerRemote : public ScriptDebugger { RequestSceneTreeMessageFunc request_scene_tree; void *request_scene_tree_ud; + void _send_video_memory(); LiveEditFuncs *live_edit_funcs; ErrorHandlerList eh; @@ -98,6 +102,20 @@ class ScriptDebuggerRemote : public ScriptDebugger { public: + struct ResourceUsage { + + String path; + String format; + String type; + RID id; + int vram; + bool operator<(const ResourceUsage& p_img) const { return vram==p_img.vram ? id<p_img.id : vram > p_img.vram; } + }; + + typedef void (*ResourceUsageFunc)(List<ResourceUsage>*); + + static ResourceUsageFunc resource_usage_func; + Error connect_to_host(const String& p_host,uint16_t p_port); virtual void debug(ScriptLanguage *p_script,bool p_can_continue=true); virtual void idle_poll(); |