Bläddra i källkod

- fixed vram calculation for TexturesInspector
- fixed "cdecode" linkage

dmuratshin 9 år sedan
förälder
incheckning
eff1869976

+ 2 - 2
oxygine/src/Tween.h

@@ -148,8 +148,8 @@ namespace oxygine
         void update(Actor& actor, const UpdateState& us);
 
         static float calcEase(EASE ease, float v);
-		typedef float (*easeHandler)(EASE ease, float v);
-		static void  setCustomEaseHandler(easeHandler);
+        typedef float (*easeHandler)(EASE ease, float v);
+        static void  setCustomEaseHandler(easeHandler);
 
         /**set callback when tween done. Doesn't allocate memory. faster than addDoneCallback*/
         void setDoneCallback(const EventCallback& cb);

+ 1 - 6
oxygine/src/core/NativeTexture.h

@@ -17,7 +17,7 @@ namespace oxygine
     class NativeTexture: public Texture, public Restorable
     {
     public:
-        NativeTexture(): _vram(0) {}
+        NativeTexture() {}
         virtual void init(nativeTextureHandle, int w, int h, TextureFormat tf) = 0;
         virtual void init(int w, int h, TextureFormat tf, bool renderTarget = false) = 0;
         virtual void init(const ImageData& src, bool sysMemCopy) = 0;
@@ -36,17 +36,12 @@ namespace oxygine
 
         /**returns handle (ptr) to HW texture ID*/
         virtual nativeTextureHandle getHandle() const = 0;
-        unsigned int                getSizeVRAM() const {return _vram;}
-
 
         //debug
         static void dumpCreatedTextures();
         static std::vector<spNativeTexture> getCreatedTextures();
         /**debug counter of created textures*/
         static volatile int created;
-
-    protected:
-        unsigned int _vram;
     };
 
     class NativeTextureNull: public NativeTexture

+ 0 - 1
oxygine/src/core/Texture.h

@@ -36,7 +36,6 @@ namespace oxygine
         virtual int getWidth() const = 0;
         virtual int getHeight() const = 0;
         virtual TextureFormat getFormat() const = 0;
-        virtual unsigned int getSizeVRAM() const = 0;
 
         virtual ImageData lock(lock_flags, const Rect* src) = 0;
         virtual void unlock() = 0;

+ 0 - 2
oxygine/src/core/gl/NativeTextureGLES.cpp

@@ -188,8 +188,6 @@ namespace oxygine
             glTexImage2D(GL_TEXTURE_2D, 0, p.format, src.w, src.h, 0, p.format, p.type, src.data);
         }
 
-        _vram = src.h * src.pitch;
-
         OX_ASSERT(sysMemCopy == false);
 
         init((nativeTextureHandle)id, src.w, src.h, src.format);

+ 23 - 1
oxygine/src/dev_tools/TexturesInspector.cpp

@@ -119,7 +119,29 @@ namespace oxygine
             content->addChild(line);
             ++n;
 
-            mem += t->getSizeVRAM();
+            if (t->getHandle())
+            {
+                TextureFormat fmt = t->getFormat();
+                int ram = t->getWidth() * t->getHeight();
+                if (isCompressedFormat(fmt))
+                {
+                    switch (fmt)
+                    {
+                        case TF_PVRTC_4RGBA:
+                            ram /= 2;
+                            break;
+                        case TF_ETC1:
+                            ram /= 2;
+                            break;
+                        default:
+                            break;
+                    }
+                }
+                else
+                    ram *= getBytesPerPixel(fmt);
+
+                mem += ram;
+            }
         }
 
         char txt[255];

+ 6 - 1
oxygine/src/utils/cdecode.h

@@ -8,6 +8,9 @@ For details, see http://sourceforge.net/projects/libb64
 #ifndef BASE64_CDECODE_H
 #define BASE64_CDECODE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 typedef enum
 {
     step_a, step_b, step_c, step_d
@@ -24,5 +27,7 @@ void base64_init_decodestate(base64_decodestate* state_in);
 int base64_decode_value(char value_in);
 
 int base64_decode_block(const char* code_in, const int length_in, char* plaintext_out, base64_decodestate* state_in);
-
+#ifdef __cplusplus
+}
+#endif
 #endif /* BASE64_CDECODE_H */