summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2017-06-09 00:23:50 -0300
committerJuan Linietsky <reduzio@gmail.com>2017-06-09 00:24:18 -0300
commit612ab8fcdb94bf0cd9d7b4a3006b4e4f76c9a13b (patch)
tree1e7b4fdb8154098319b0c44ee0289288610a77c3 /core
parent01ed55987c4c044191e50ecc94c277b97962ffc7 (diff)
-Restored multithread capability to VisualServer
-Restored resource previews!
Diffstat (limited to 'core')
-rw-r--r--core/command_queue_mt.h83
-rw-r--r--core/image.cpp16
-rw-r--r--core/image.h4
-rw-r--r--core/object.cpp12
-rw-r--r--core/object.h12
5 files changed, 105 insertions, 22 deletions
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index bae8cf7fca..83c90a925c 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -170,6 +170,43 @@ class CommandQueueMT {
virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8); }
};
+ template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
+ struct Command9 : public CommandBase {
+
+ T *instance;
+ M method;
+ typename GetSimpleTypeT<P1>::type_t p1;
+ typename GetSimpleTypeT<P2>::type_t p2;
+ typename GetSimpleTypeT<P3>::type_t p3;
+ typename GetSimpleTypeT<P4>::type_t p4;
+ typename GetSimpleTypeT<P5>::type_t p5;
+ typename GetSimpleTypeT<P6>::type_t p6;
+ typename GetSimpleTypeT<P7>::type_t p7;
+ typename GetSimpleTypeT<P8>::type_t p8;
+ typename GetSimpleTypeT<P9>::type_t p9;
+
+ virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9); }
+ };
+
+ template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
+ struct Command10 : public CommandBase {
+
+ T *instance;
+ M method;
+ typename GetSimpleTypeT<P1>::type_t p1;
+ typename GetSimpleTypeT<P2>::type_t p2;
+ typename GetSimpleTypeT<P3>::type_t p3;
+ typename GetSimpleTypeT<P4>::type_t p4;
+ typename GetSimpleTypeT<P5>::type_t p5;
+ typename GetSimpleTypeT<P6>::type_t p6;
+ typename GetSimpleTypeT<P7>::type_t p7;
+ typename GetSimpleTypeT<P8>::type_t p8;
+ typename GetSimpleTypeT<P9>::type_t p9;
+ typename GetSimpleTypeT<P10>::type_t p10;
+
+ virtual void call() { (instance->*method)(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); }
+ };
+
/* comands that return */
template <class T, class M, class R>
@@ -779,6 +816,52 @@ public:
if (sync) sync->post();
}
+
+ template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9>
+ void push(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9) {
+
+ Command9<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9> *cmd = allocate_and_lock<Command9<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9> >();
+
+ cmd->instance = p_instance;
+ cmd->method = p_method;
+ cmd->p1 = p1;
+ cmd->p2 = p2;
+ cmd->p3 = p3;
+ cmd->p4 = p4;
+ cmd->p5 = p5;
+ cmd->p6 = p6;
+ cmd->p7 = p7;
+ cmd->p8 = p8;
+ cmd->p9 = p9;
+
+ unlock();
+
+ if (sync) sync->post();
+ }
+
+ template <class T, class M, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8, class P9, class P10>
+ void push(T *p_instance, M p_method, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5, P6 p6, P7 p7, P8 p8, P9 p9, P10 p10) {
+
+ Command10<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> *cmd = allocate_and_lock<Command10<T, M, P1, P2, P3, P4, P5, P6, P7, P8, P9, P10> >();
+
+ cmd->instance = p_instance;
+ cmd->method = p_method;
+ cmd->p1 = p1;
+ cmd->p2 = p2;
+ cmd->p3 = p3;
+ cmd->p4 = p4;
+ cmd->p5 = p5;
+ cmd->p6 = p6;
+ cmd->p7 = p7;
+ cmd->p8 = p8;
+ cmd->p9 = p9;
+ cmd->p10 = p10;
+
+ unlock();
+
+ if (sync) sync->post();
+ }
+
/*** PUSH AND RET COMMANDS ***/
template <class T, class M, class R>
diff --git a/core/image.cpp b/core/image.cpp
index 2da91c7b13..686735c906 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -81,21 +81,21 @@ const char *Image::format_names[Image::FORMAT_MAX] = {
SavePNGFunc Image::save_png_func = NULL;
-void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_dst, const uint8_t *p_src) {
+void Image::_put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel) {
uint32_t ofs = (p_y * width + p_x) * p_pixelsize;
for (uint32_t i = 0; i < p_pixelsize; i++) {
- p_dst[ofs + i] = p_src[i];
+ p_data[ofs + i] = p_pixel[i];
}
}
-void Image::_get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_src, uint8_t *p_dst) {
+void Image::_get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_data, uint8_t *p_pixel) {
uint32_t ofs = (p_y * width + p_x) * p_pixelsize;
for (uint32_t i = 0; i < p_pixelsize; i++) {
- p_dst[i] = p_src[ofs + i];
+ p_pixel[i] = p_data[ofs + i];
}
}
@@ -818,7 +818,7 @@ void Image::flip_y() {
uint8_t down[16];
uint32_t pixel_size = get_format_pixel_size(format);
- for (int y = 0; y < height; y++) {
+ for (int y = 0; y < height / 2; y++) {
for (int x = 0; x < width; x++) {
@@ -854,7 +854,7 @@ void Image::flip_x() {
for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
+ for (int x = 0; x < width / 2; x++) {
_get_pixelb(x, y, pixel_size, w.ptr(), up);
_get_pixelb(width - x - 1, y, pixel_size, w.ptr(), down);
@@ -1457,7 +1457,7 @@ Error Image::save_png(const String &p_path) const {
if (save_png_func == NULL)
return ERR_UNAVAILABLE;
- return save_png_func(p_path, Ref<Image>(this));
+ return save_png_func(p_path, Ref<Image>((Image *)this));
}
int Image::get_image_data_size(int p_width, int p_height, Format p_format, int p_mipmaps) {
@@ -1599,7 +1599,7 @@ Rect2 Image::get_used_rect() const {
Ref<Image> Image::get_rect(const Rect2 &p_area) const {
Ref<Image> img = memnew(Image(p_area.size.x, p_area.size.y, mipmaps, format));
- img->blit_rect(Ref<Image>(this), p_area, Point2(0, 0));
+ img->blit_rect(Ref<Image>((Image *)this), p_area, Point2(0, 0));
return img;
}
diff --git a/core/image.h b/core/image.h
index 2a78870f53..e3174a2899 100644
--- a/core/image.h
+++ b/core/image.h
@@ -162,8 +162,8 @@ private:
static int _get_dst_image_size(int p_width, int p_height, Format p_format, int &r_mipmaps, int p_mipmaps = -1);
bool _can_modify(Format p_format) const;
- _FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_dst, const uint8_t *p_src);
- _FORCE_INLINE_ void _get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_src, uint8_t *p_dst);
+ _FORCE_INLINE_ void _put_pixelb(int p_x, int p_y, uint32_t p_pixelsize, uint8_t *p_data, const uint8_t *p_pixel);
+ _FORCE_INLINE_ void _get_pixelb(int p_x, int p_y, uint32_t p_pixelsize, const uint8_t *p_data, uint8_t *p_pixel);
void _set_data(const Dictionary &p_data);
Dictionary _get_data() const;
diff --git a/core/object.cpp b/core/object.cpp
index 7aee936a2d..f20e93f9d7 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1831,10 +1831,10 @@ void postinitialize_handler(Object *p_object) {
p_object->_postinitialize();
}
-HashMap<uint32_t, Object *> ObjectDB::instances;
-uint32_t ObjectDB::instance_counter = 1;
+HashMap<ObjectID, Object *> ObjectDB::instances;
+ObjectID ObjectDB::instance_counter = 1;
HashMap<Object *, ObjectID, ObjectDB::ObjectPtrHash> ObjectDB::instance_checks;
-uint32_t ObjectDB::add_instance(Object *p_object) {
+ObjectID ObjectDB::add_instance(Object *p_object) {
ERR_FAIL_COND_V(p_object->get_instance_ID() != 0, 0);
@@ -1859,7 +1859,7 @@ void ObjectDB::remove_instance(Object *p_object) {
rw_lock->write_unlock();
}
-Object *ObjectDB::get_instance(uint32_t p_instance_ID) {
+Object *ObjectDB::get_instance(ObjectID p_instance_ID) {
rw_lock->read_lock();
Object **obj = instances.getptr(p_instance_ID);
@@ -1874,7 +1874,7 @@ void ObjectDB::debug_objects(DebugFunc p_func) {
rw_lock->read_lock();
- const uint32_t *K = NULL;
+ const ObjectID *K = NULL;
while ((K = instances.next(K))) {
p_func(instances[*K]);
@@ -1909,7 +1909,7 @@ void ObjectDB::cleanup() {
WARN_PRINT("ObjectDB Instances still exist!");
if (OS::get_singleton()->is_stdout_verbose()) {
- const uint32_t *K = NULL;
+ const ObjectID *K = NULL;
while ((K = instances.next(K))) {
String node_name;
diff --git a/core/object.h b/core/object.h
index 3b39224af0..83b03b9239 100644
--- a/core/object.h
+++ b/core/object.h
@@ -350,7 +350,7 @@ public: \
private:
class ScriptInstance;
-typedef uint32_t ObjectID;
+typedef uint64_t ObjectID;
class Object {
public:
@@ -423,7 +423,7 @@ private:
bool _block_signals;
int _predelete_ok;
Set<Object *> change_receptors;
- uint32_t _instance_ID;
+ ObjectID _instance_ID;
bool _predelete();
void _postinitialize();
bool _can_translate;
@@ -690,16 +690,16 @@ class ObjectDB {
}
};
- static HashMap<uint32_t, Object *> instances;
+ static HashMap<ObjectID, Object *> instances;
static HashMap<Object *, ObjectID, ObjectPtrHash> instance_checks;
- static uint32_t instance_counter;
+ static ObjectID instance_counter;
friend class Object;
friend void unregister_core_types();
static RWLock *rw_lock;
static void cleanup();
- static uint32_t add_instance(Object *p_object);
+ static ObjectID add_instance(Object *p_object);
static void remove_instance(Object *p_object);
friend void register_core_types();
static void setup();
@@ -707,7 +707,7 @@ class ObjectDB {
public:
typedef void (*DebugFunc)(Object *p_obj);
- static Object *get_instance(uint32_t p_instance_ID);
+ static Object *get_instance(ObjectID p_instance_ID);
static void debug_objects(DebugFunc p_func);
static int get_object_count();