mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-10-09 11:05:24 +00:00
[engine] [cocos2d-x] [jsb-adapter] 适配引擎 v2.4.12 版本
This commit is contained in:
@@ -48,6 +48,7 @@ Configuration::Configuration()
|
||||
, _supportsETC2(false)
|
||||
, _supportsS3TC(false)
|
||||
, _supportsATITC(false)
|
||||
, _supportsASTC(false)
|
||||
, _supportsNPOT(false)
|
||||
, _supportsBGRA8888(false)
|
||||
, _supportsDiscardFramebuffer(false)
|
||||
@@ -153,6 +154,9 @@ void Configuration::gatherGPUInfo()
|
||||
_supportsPVRTC = checkForGLExtension("GL_IMG_texture_compression_pvrtc");
|
||||
_valueDict["gl.supports_PVRTC"] = Value(_supportsPVRTC);
|
||||
|
||||
_supportsASTC = checkForGLExtension("texture_compression_astc");
|
||||
_valueDict["gl.supports_ASTC"] = Value(_supportsASTC);
|
||||
|
||||
_supportsNPOT = true;
|
||||
_valueDict["gl.supports_NPOT"] = Value(_supportsNPOT);
|
||||
|
||||
@@ -282,6 +286,11 @@ bool Configuration::supportsETC2() const
|
||||
return _supportsETC2;
|
||||
}
|
||||
|
||||
bool Configuration::supportsASTC() const
|
||||
{
|
||||
return _supportsASTC;
|
||||
}
|
||||
|
||||
bool Configuration::supportsS3TC() const
|
||||
{
|
||||
#ifdef GL_EXT_texture_compression_s3tc
|
||||
|
@@ -112,6 +112,13 @@ public:
|
||||
*/
|
||||
bool supportsETC2() const;
|
||||
|
||||
/** Whether or not ASTC Texture Compressed is supported.
|
||||
*
|
||||
*
|
||||
* @return Is true if supports ASTC Texture Compressed.
|
||||
*/
|
||||
bool supportsASTC() const;
|
||||
|
||||
/** Whether or not S3TC Texture Compressed is supported.
|
||||
*
|
||||
* @return Is true if supports S3TC Texture Compressed.
|
||||
@@ -264,6 +271,7 @@ protected:
|
||||
bool _supportsPVRTC;
|
||||
bool _supportsETC1;
|
||||
bool _supportsETC2;
|
||||
bool _supportsASTC;
|
||||
bool _supportsS3TC;
|
||||
bool _supportsATITC;
|
||||
bool _supportsNPOT;
|
||||
|
@@ -94,6 +94,10 @@ namespace
|
||||
|
||||
} while (pos < len);
|
||||
fflush(stdout);
|
||||
#elif CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY
|
||||
#include <stdarg.h>
|
||||
#include <hilog/log.h>
|
||||
OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, "HMG_LOG", "%{public}s", buf);
|
||||
#else
|
||||
// Linux, Mac, iOS, etc
|
||||
fprintf(stdout, "%s", buf);
|
||||
|
@@ -473,7 +473,7 @@ void RenderTexture::initFramebuffer()
|
||||
ccActiveOffScreenFramebuffer(_FBO);
|
||||
|
||||
// set up depth buffer and stencil buffer
|
||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
||||
#if(CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY)
|
||||
if(Configuration::getInstance()->supportsOESPackedDepthStencil())
|
||||
{
|
||||
//create and attach depth buffer
|
||||
|
@@ -32,6 +32,9 @@
|
||||
#include <android/log.h>
|
||||
#define LOG_TAG "ThreadPool"
|
||||
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG,__VA_ARGS__)
|
||||
#elif OPENHARMONY
|
||||
#include <hilog/log.h>
|
||||
#define LOGD(...) ((void) OH_LOG_Print(LOG_APP, LOG_DEBUG, LOG_DOMAIN, "HMG_LOG", __VA_ARGS__))
|
||||
#else
|
||||
#define LOGD(...) printf(__VA_ARGS__)
|
||||
#endif
|
||||
|
@@ -38,6 +38,8 @@ THE SOFTWARE.
|
||||
#elif(CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT)
|
||||
// for import ssize_t on win32 platform
|
||||
#include "platform/CCStdC.h"
|
||||
#elif(CC_TARGET_PLATFORM == CC_PLATFORM_OPENHARMONY)
|
||||
#include "platform/openharmony/FileUtils-openharmony.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
|
66
cocos2d-x/cocos/base/astc.cpp
Normal file
66
cocos2d-x/cocos/base/astc.cpp
Normal file
@@ -0,0 +1,66 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "base/astc.h"
|
||||
#include "platform/CCImage.h"
|
||||
|
||||
static const unsigned int MAGIC = 0x5CA1AB13;
|
||||
static const astc_byte ASTC_HEADER_SIZE_X_BEGIN = 7;
|
||||
static const astc_byte ASTC_HEADER_SIZE_Y_BEGIN = 10;
|
||||
static const astc_byte ASTC_HEADER_SIZE_Z_BEGIN = 13;
|
||||
|
||||
bool astcIsValid(const astc_byte* pHeader) {
|
||||
uint32_t magicval = (uint32_t)(pHeader[0]) +
|
||||
(uint32_t)(pHeader[1]) * 256 +
|
||||
(uint32_t)(pHeader[2]) * 65536 +
|
||||
(uint32_t)(pHeader[3]) * 16777216;
|
||||
|
||||
if(magicval != MAGIC) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int xdim = pHeader[ASTC_HEADER_MAGIC];
|
||||
int ydim = pHeader[ASTC_HEADER_MAGIC + 1];
|
||||
int zdim = pHeader[ASTC_HEADER_MAGIC + 2];
|
||||
if ((xdim < 3 || xdim > 6 || ydim < 3 || ydim > 6 || zdim < 3 || zdim > 6) &&
|
||||
(xdim < 4 || xdim == 7 || xdim == 9 || xdim == 11 || xdim > 12 ||
|
||||
ydim < 4 || ydim == 7 || ydim == 9 || ydim == 11 || ydim > 12 || zdim != 1))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int astcGetWidth(const astc_byte* pHeader) {
|
||||
int xsize = pHeader[ASTC_HEADER_SIZE_X_BEGIN] + (pHeader[ASTC_HEADER_SIZE_X_BEGIN + 1] * 256) + (pHeader[ASTC_HEADER_SIZE_X_BEGIN + 2] * 65536);
|
||||
return xsize;
|
||||
}
|
||||
|
||||
int astcGetHeight(const astc_byte* pHeader) {
|
||||
int ysize = pHeader[ASTC_HEADER_SIZE_Y_BEGIN] + (pHeader[ASTC_HEADER_SIZE_Y_BEGIN + 1] * 256) + (pHeader[ASTC_HEADER_SIZE_Y_BEGIN + 2] * 65536);
|
||||
return ysize;
|
||||
}
|
53
cocos2d-x/cocos/base/astc.h
Normal file
53
cocos2d-x/cocos/base/astc.h
Normal file
@@ -0,0 +1,53 @@
|
||||
/****************************************************************************
|
||||
Copyright (c) 2010-2012 cocos2d-x.org
|
||||
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef __ASTC_H__
|
||||
#define __ASTC_H__
|
||||
|
||||
typedef unsigned char astc_byte;
|
||||
typedef unsigned int astc_uint32;
|
||||
|
||||
// Size of a ASTC header
|
||||
|
||||
#define ASTC_HEADER_SIZE 16
|
||||
|
||||
#define ASTC_HEADER_MAGIC 4
|
||||
|
||||
// Check if a ASTC header is correctly formatted
|
||||
|
||||
bool astcIsValid(const astc_byte* pHeader);
|
||||
|
||||
// Read the image width from a ASTC header
|
||||
|
||||
int astcGetWidth(const astc_byte* pHeader);
|
||||
|
||||
// Read the image height from a ASTC header
|
||||
|
||||
int astcGetHeight(const astc_byte* pHeader);
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user