From b51102d2346d035515a41d38a388da12f785f207 Mon Sep 17 00:00:00 2001 From: fape Date: Wed, 6 Feb 2013 14:40:48 +0100 Subject: [PATCH 1/4] marmalade webp fixes --- cocos2dx/platform/marmalade/CCImage.cpp | 5 +++++ cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c | 4 ++-- cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h | 2 +- .../platform/third_party/marmalade/libwebp/dsp/lossless.c | 4 ++-- .../third_party/marmalade/libwebp/enc/backward_references.h | 2 +- .../third_party/marmalade/libwebp/utils/bit_reader.h | 4 ++-- 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cocos2dx/platform/marmalade/CCImage.cpp b/cocos2dx/platform/marmalade/CCImage.cpp index cdb1594c1d..401be9ed92 100644 --- a/cocos2dx/platform/marmalade/CCImage.cpp +++ b/cocos2dx/platform/marmalade/CCImage.cpp @@ -572,6 +572,11 @@ bool CCImage::initWithImageData(void * pData, bRet = _initWithTiffData(pData, nDataLen); break; } + else if (kFmtWebp == eFmt) + { + bRet = _initWithWebpData(pData, nDataLen); + break; + } else if (kFmtRawData == eFmt) { bRet = _initWithRawData(pData, nDataLen, nWidth, nHeight, nBitsPerComponent); diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c index 0228734457..aa8704b8a4 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c +++ b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c @@ -33,7 +33,7 @@ static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) { : "=a"(cpu_info[0]), "=D"(cpu_info[1]), "=c"(cpu_info[2]), "=d"(cpu_info[3]) : "a"(info_type)); } -#elif defined(__i386__) || defined(__x86_64__) +#elif (defined(__i386__) || defined(__x86_64__) ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) { __asm__ volatile ( "cpuid\n" @@ -44,7 +44,7 @@ static WEBP_INLINE void GetCPUInfo(int cpu_info[4], int info_type) { #define GetCPUInfo __cpuid #endif -#if defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2) +#if (defined(__i386__) || defined(__x86_64__) || defined(WEBP_MSC_SSE2)) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) static int x86CPUInfo(CPUFeature feature) { int cpu_info[4]; GetCPUInfo(cpu_info, 1); diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h index 24d0c188c4..3d151fa612 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h +++ b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h @@ -21,7 +21,7 @@ extern "C" { //------------------------------------------------------------------------------ // CPU detection -#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) +#if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) #define WEBP_MSC_SSE2 // Visual C++ SSE2 targets #endif diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c index 62a6b7b15a..fd28beb57a 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c +++ b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c @@ -1066,11 +1066,11 @@ static void CopyOrSwap(const uint32_t* src, int num_pixels, uint8_t* dst, const uint32_t* const src_end = src + num_pixels; while (src < src_end) { uint32_t argb = *src++; -#if !defined(__BIG_ENDIAN__) && (defined(__i386__) || defined(__x86_64__)) +#if (!defined(__BIG_ENDIAN__) && (defined(__i386__) || defined(__x86_64__))) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) __asm__ volatile("bswap %0" : "=r"(argb) : "0"(argb)); *(uint32_t*)dst = argb; dst += sizeof(argb); -#elif !defined(__BIG_ENDIAN__) && defined(_MSC_VER) +#elif (!defined(__BIG_ENDIAN__) && defined(_MSC_VER)) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) argb = _byteswap_ulong(argb); *(uint32_t*)dst = argb; dst += sizeof(argb); diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h b/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h index 91c03361ed..1a36258e36 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h +++ b/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h @@ -37,7 +37,7 @@ extern "C" { static WEBP_INLINE int BitsLog2Floor(uint32_t n) { return n == 0 ? -1 : 31 ^ __builtin_clz(n); } -#elif defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86)) +#elif (defined(_MSC_VER) && (defined(_M_X64) || defined(_M_IX86))) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) #include #pragma intrinsic(_BitScanReverse) diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h b/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h index cc7aeece1e..2aa21cb5e8 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h +++ b/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h @@ -81,10 +81,10 @@ static WEBP_INLINE void VP8LoadNewBytes(VP8BitReader* const br) { br->buf_ += (BITS) >> 3; #if !defined(__BIG_ENDIAN__) #if (BITS == 32) -#if defined(__i386__) || defined(__x86_64__) +#if (defined(__i386__) || defined(__x86_64__) ) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) __asm__ volatile("bswap %k0" : "=r"(in_bits) : "0"(in_bits)); bits = (bit_t)in_bits; // 32b -> 64b zero-extension -#elif defined(_MSC_VER) +#elif defined(_MSC_VER) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) bits = _byteswap_ulong(in_bits); #else bits = (bit_t)(in_bits >> 24) | ((in_bits >> 8) & 0xff00) From 19c266ef47b23fc185d1ab3b4d6993aa0a192026 Mon Sep 17 00:00:00 2001 From: fape Date: Wed, 6 Feb 2013 16:16:40 +0100 Subject: [PATCH 2/4] include missing CCPlatformMacros.h --- cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c | 2 ++ cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h | 2 ++ cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c | 2 ++ .../third_party/marmalade/libwebp/enc/backward_references.h | 2 ++ .../platform/third_party/marmalade/libwebp/utils/bit_reader.h | 2 ++ 5 files changed, 10 insertions(+) diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c index aa8704b8a4..4e7845c7d2 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c +++ b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/cpu.c @@ -9,6 +9,8 @@ // // Author: Christian Duvivier (cduvivier@google.com) +#include "platform/CCPlatformConfig.h" + #include "./dsp.h" #if defined(__ANDROID__) diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h index 3d151fa612..0ae250f52e 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h +++ b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h @@ -12,6 +12,8 @@ #ifndef WEBP_DSP_DSP_H_ #define WEBP_DSP_DSP_H_ +#include "platform/CCPlatformConfig.h" + #include "../webp/types.h" #if defined(__cplusplus) || defined(c_plusplus) diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c index fd28beb57a..a077f6e759 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c +++ b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/lossless.c @@ -11,6 +11,8 @@ // Jyrki Alakuijala (jyrki@google.com) // Urvang Joshi (urvang@google.com) +#include "platform/CCPlatformConfig.h" + #if defined(__cplusplus) || defined(c_plusplus) extern "C" { #endif diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h b/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h index 1a36258e36..2fb1aecc5d 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h +++ b/cocos2dx/platform/third_party/marmalade/libwebp/enc/backward_references.h @@ -11,6 +11,8 @@ #ifndef WEBP_ENC_BACKWARD_REFERENCES_H_ #define WEBP_ENC_BACKWARD_REFERENCES_H_ +#include "platform/CCPlatformConfig.h" + #include #include #include "../webp/types.h" diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h b/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h index 2aa21cb5e8..b0324c951c 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h +++ b/cocos2dx/platform/third_party/marmalade/libwebp/utils/bit_reader.h @@ -13,6 +13,8 @@ #ifndef WEBP_UTILS_BIT_READER_H_ #define WEBP_UTILS_BIT_READER_H_ +#include "platform/CCPlatformConfig.h" + #include #ifdef _MSC_VER #include // _byteswap_ulong From 7e19a5464af0342521132b2c99dfc07dbd7ff08f Mon Sep 17 00:00:00 2001 From: fape Date: Wed, 6 Feb 2013 16:17:47 +0100 Subject: [PATCH 3/4] Include missing header files to libwebp's marmalade project file. --- cocos2dx/platform/third_party/marmalade/libwebp.mkf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/platform/third_party/marmalade/libwebp.mkf b/cocos2dx/platform/third_party/marmalade/libwebp.mkf index 9b6a79df1c..f8a8494c0c 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp.mkf +++ b/cocos2dx/platform/third_party/marmalade/libwebp.mkf @@ -33,5 +33,5 @@ files ["headers"] ("libwebp/webp") - + "*.h" } From 1ed9d643c5b2b70ae9fab0e14cc596adfb81282d Mon Sep 17 00:00:00 2001 From: fape Date: Wed, 6 Feb 2013 17:44:06 +0100 Subject: [PATCH 4/4] prevent WEBP_USE_SSE2 --- cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h index 0ae250f52e..0982451520 100644 --- a/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h +++ b/cocos2dx/platform/third_party/marmalade/libwebp/dsp/dsp.h @@ -27,7 +27,7 @@ extern "C" { #define WEBP_MSC_SSE2 // Visual C++ SSE2 targets #endif -#if defined(__SSE2__) || defined(WEBP_MSC_SSE2) +#if (defined(__SSE2__) || defined(WEBP_MSC_SSE2)) && (CC_TARGET_PLATFORM != CC_PLATFORM_MARMALADE) #define WEBP_USE_SSE2 #endif