Browse Source

don't reset resources for EMSCRIPTEN
oxyresbuild improved: dont add dublicated frames into atlass

dmuratshin 9 years ago
parent
commit
f6c9213342
2 changed files with 23 additions and 2 deletions
  1. 3 1
      oxygine/src/core/oxygine.cpp
  2. 20 1
      tools/resbuild/process_atlas.py

+ 3 - 1
oxygine/src/core/oxygine.cpp

@@ -67,7 +67,9 @@ extern "C"
 #endif
 #endif
 
 
 
 
-#if !SDL_VIDEO_OPENGL
+#if EMSCRIPTEN
+#define HANDLE_FOCUS_LOST 0
+#elif !SDL_VIDEO_OPENGL
 #define HANDLE_FOCUS_LOST 1
 #define HANDLE_FOCUS_LOST 1
 #else
 #else
 #define HANDLE_FOCUS_LOST 0
 #define HANDLE_FOCUS_LOST 0

+ 20 - 1
tools/resbuild/process_atlas.py

@@ -4,8 +4,10 @@ from __future__ import unicode_literals, print_function
 
 
 try:
 try:
     import Image
     import Image
+    import ImageChops
 except ImportError:
 except ImportError:
     from PIL import Image
     from PIL import Image
+    from PIL import ImageChops
 
 
 import os
 import os
 import struct
 import struct
@@ -15,6 +17,9 @@ from . import atlas
 from . import process
 from . import process
 
 
 
 
+def isImagesIdentical(im1, im2):
+    return ImageChops.difference(im1, im2).getbbox() is None
+
 def as_int(attr, df=0):
 def as_int(attr, df=0):
     if not attr:
     if not attr:
         return df
         return df
@@ -87,6 +92,7 @@ class frame(object):
         self.resanim = rs
         self.resanim = rs
         self.border_top = self.border_left = 2
         self.border_top = self.border_left = 2
         self.border_right = self.border_bottom = 1
         self.border_right = self.border_bottom = 1
+        self.identicalWith = None
 
 
         if not bbox:
         if not bbox:
             bbox = (0, 0, 1, 1)
             bbox = (0, 0, 1, 1)
@@ -214,6 +220,8 @@ def pack(st, frames, sw, sh):
 
 
     not_packed = []
     not_packed = []
     for fr in frames:
     for fr in frames:
+        if fr.identicalWith:
+            continue
         ns = st.get_size(fr)
         ns = st.get_size(fr)
         node = atl.add(ns[0], ns[1], fr)
         node = atl.add(ns[0], ns[1], fr)
         if not node:
         if not node:
@@ -466,6 +474,14 @@ def processRS(context, walker):
             if not extend:
             if not extend:
                 fr.border_left = fr.border_right = fr.border_top = fr.border_bottom = 0
                 fr.border_left = fr.border_right = fr.border_top = fr.border_bottom = 0
 
 
+            for f in resAnim.frames:
+                if isImagesIdentical(f.image, fr.image):                    
+                    fr.identicalWith = f
+                    
+                    if f.identicalWith:
+                        fr.identicalWith = f.identicalWith
+                        
+
             resAnim.frames.append(fr)
             resAnim.frames.append(fr)
 
 
     return resAnim
     return resAnim
@@ -691,7 +707,10 @@ class atlas_Processor(process.Process):
                 image_frames_el.setAttribute("debug_image", anim.name)
                 image_frames_el.setAttribute("debug_image", anim.name)
 
 
             data = ""
             data = ""
-            for fr in anim.frames:
+            for item in anim.frames:
+                fr = item
+                if item.identicalWith:
+                    fr = item.identicalWith
                 data += "%d,%d,%d,%d,%d,%d,%d;" % (fr.atlas_id,
                 data += "%d,%d,%d,%d,%d,%d,%d;" % (fr.atlas_id,
                                                    fr.node.rect.x + fr.border_left, fr.node.rect.y + fr.border_top,
                                                    fr.node.rect.x + fr.border_left, fr.node.rect.y + fr.border_top,
                                                    fr.bbox[0], fr.bbox[1],
                                                    fr.bbox[0], fr.bbox[1],