summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/image.cpp33
-rw-r--r--core/image.h3
-rw-r--r--core/io/marshalls.cpp5
-rw-r--r--core/io/packet_peer.cpp3
-rw-r--r--core/io/resource_format_binary.cpp5
-rw-r--r--core/io/resource_format_xml.cpp4
-rw-r--r--core/ring_buffer.h8
-rw-r--r--core/script_debugger_remote.cpp30
-rw-r--r--core/script_debugger_remote.h18
9 files changed, 98 insertions, 11 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/marshalls.cpp b/core/io/marshalls.cpp
index 1e76e2b4b2..62ccd81489 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -36,7 +36,10 @@ Error decode_variant(Variant& r_variant,const uint8_t *p_buffer, int p_len,int *
const uint8_t * buf=p_buffer;
int len=p_len;
- ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
+ if (len<4) {
+
+ ERR_FAIL_COND_V(len<4,ERR_INVALID_DATA);
+ }
uint32_t type=decode_uint32(buf);
diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp
index 875cace368..f6d526b512 100644
--- a/core/io/packet_peer.cpp
+++ b/core/io/packet_peer.cpp
@@ -156,7 +156,6 @@ Error PacketPeerStream::_poll_buffer() const {
Error err = peer->get_partial_data(&temp_buffer[0], ring_buffer.space_left(), read);
if (err)
return err;
-
if (read==0)
return OK;
@@ -202,7 +201,7 @@ Error PacketPeerStream::get_packet(const uint8_t **r_buffer,int &r_buffer_size)
uint8_t lbuf[4];
ring_buffer.copy(lbuf,0,4);
remaining-=4;
- uint32_t len = decode_uint32(lbuf);
+ uint32_t len = decode_uint32(lbuf);
ERR_FAIL_COND_V(remaining<(int)len,ERR_UNAVAILABLE);
ring_buffer.read(lbuf,4); //get rid of first 4 bytes
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 60bb8b658e..1a0552e8d1 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -2172,10 +2172,11 @@ Error ResourceFormatSaverBinaryInstance::save(const String &p_path,const RES& p_
save_unicode_string("local://"+itos(r->get_subindex()));
if (takeover_paths) {
- r->set_path(p_path+"::"+itos(ofs_pos.size()),true);
+ r->set_path(p_path+"::"+itos(r->get_subindex()),true);
}
- } else
+ } else {
save_unicode_string(r->get_path()); //actual external
+ }
ofs_pos.push_back(f->get_pos());
f->store_64(0); //offset in 64 bits
}
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("&","&amp;");
- p_str=p_str.replace("<","&gt;");
- p_str=p_str.replace(">","&lt;");
+ p_str=p_str.replace("<","&lt;");
+ p_str=p_str.replace(">","&gt;");
p_str=p_str.replace("'","&apos;");
p_str=p_str.replace("\"","&quot;");
for (char i=1;i<32;i++) {
diff --git a/core/ring_buffer.h b/core/ring_buffer.h
index de33de0c76..3cf9cf9064 100644
--- a/core/ring_buffer.h
+++ b/core/ring_buffer.h
@@ -141,15 +141,15 @@ public:
inline int space_left() {
int left = read_pos - write_pos;
if (left < 0) {
- return size() + left;
+ return size() + left - 1;
};
if (left == 0) {
- return size();
+ return size()-1;
};
- return left;
+ return left -1;
};
inline int data_left() {
- return size() - space_left();
+ return size() - space_left() - 1;
};
inline int size() {
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();