summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/typedefs.h15
-rw-r--r--core/undo_redo.cpp7
2 files changed, 16 insertions, 6 deletions
diff --git a/core/typedefs.h b/core/typedefs.h
index 966360d4f2..03514466c0 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -250,21 +250,34 @@ static inline int get_shift_from_power_of_2(unsigned int p_pixel) {
}
/** Swap 16 bits value for endianness */
+#if defined(__GNUC__) || _llvm_has_builtin(__builtin_bswap16)
+#define BSWAP16(x) __builtin_bswap16(x)
+#else
static inline uint16_t BSWAP16(uint16_t x) {
return (x >> 8) | (x << 8);
}
+#endif
+
/** Swap 32 bits value for endianness */
+#if defined(__GNUC__) || _llvm_has_builtin(__builtin_bswap32)
+#define BSWAP32(x) __builtin_bswap32(x)
+#else
static inline uint32_t BSWAP32(uint32_t x) {
return ((x << 24) | ((x << 8) & 0x00FF0000) | ((x >> 8) & 0x0000FF00) | (x >> 24));
}
-/** Swap 64 bits value for endianness */
+#endif
+/** Swap 64 bits value for endianness */
+#if defined(__GNUC__) || _llvm_has_builtin(__builtin_bswap64)
+#define BSWAP64(x) __builtin_bswap64(x)
+#else
static inline uint64_t BSWAP64(uint64_t x) {
x = (x & 0x00000000FFFFFFFF) << 32 | (x & 0xFFFFFFFF00000000) >> 32;
x = (x & 0x0000FFFF0000FFFF) << 16 | (x & 0xFFFF0000FFFF0000) >> 16;
x = (x & 0x00FF00FF00FF00FF) << 8 | (x & 0xFF00FF00FF00FF00) >> 8;
return x;
}
+#endif
/** When compiling with RTTI, we can add an "extra"
* layer of safeness in many operations, so dynamic_cast
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index 9a10e0585d..e13164d50f 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -250,8 +250,9 @@ void UndoRedo::commit_action() {
if (action_level > 0)
return; //still nested
+ commiting++;
redo(); // perform action
-
+ commiting--;
if (callback && actions.size() > 0) {
callback(callback_ud, actions[actions.size() - 1].name);
}
@@ -326,12 +327,10 @@ bool UndoRedo::redo() {
if ((current_action + 1) >= actions.size())
return false; //nothing to redo
- commiting++;
current_action++;
_process_operation_list(actions.write[current_action].do_ops.front());
version++;
- commiting--;
return true;
}
@@ -341,11 +340,9 @@ bool UndoRedo::undo() {
ERR_FAIL_COND_V(action_level > 0, false);
if (current_action < 0)
return false; //nothing to redo
- commiting++;
_process_operation_list(actions.write[current_action].undo_ops.front());
current_action--;
version--;
- commiting--;
return true;
}