浏览代码

Merge pull request #253 from ytsarko/master

Implemented drawing command memory zeroing for quick buffer compares
Micha Mettke 9 年之前
父节点
当前提交
51a63af252
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      nuklear.h

+ 11 - 0
nuklear.h

@@ -214,6 +214,13 @@ OPTIONAL DEFINES:
         will be selected and compile time validated. If they are incorrect you can
         will be selected and compile time validated. If they are incorrect you can
         define the correct types by overloading these type defines.
         define the correct types by overloading these type defines.
 
 
+    NK_ZERO_COMMAND_MEMORY
+        Defining this will zero out memory for each drawing command added to a
+        drawing queue (inside nk_command_buffer_push). This can be used to
+        implement fast check (using memcmp) that command buffers are equal and
+        avoid drawing frames when nothing on screen has changed since previous
+        frame.
+
 CREDITS:
 CREDITS:
     Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
     Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
 
 
@@ -5847,6 +5854,10 @@ nk_command_buffer_push(struct nk_command_buffer* b,
     memory = NK_ALIGN_PTR(unaligned, align);
     memory = NK_ALIGN_PTR(unaligned, align);
     alignment = (nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
     alignment = (nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
 
 
+#ifdef NK_ZERO_COMMAND_MEMORY
+    NK_MEMSET(cmd, 0, size + alignment);
+#endif
+
     cmd->type = t;
     cmd->type = t;
     cmd->next = b->base->allocated + alignment;
     cmd->next = b->base->allocated + alignment;
 #ifdef NK_INCLUDE_COMMAND_USERDATA
 #ifdef NK_INCLUDE_COMMAND_USERDATA