Skip to content

Commit

Permalink
Allow turn on/off deprecated features, follow axmolengine#2111 (axmol…
Browse files Browse the repository at this point in the history
…engine#2136)

- Add new cmake option: `AX_CORE_PROFILE`
- Remove deprecated stubs from extension: `cocostudio`
- Remove `AX_DEPRECATED_ATTRIBUTE`
  • Loading branch information
halx99 authored and xfbird committed Sep 18, 2024
1 parent c8ec137 commit d6c114a
Show file tree
Hide file tree
Showing 115 changed files with 507 additions and 1,070 deletions.
1 change: 1 addition & 0 deletions CMakeOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
- win32: whether use ANGLE GLES backend
- osx: whether use OpenGL instead Metal backend
- ios/tvos: whether use GLES instead Metal backend
- AX_CORE_PROFILE: whether strip deprecated features, default `FALSE`
- AX_ISA_LEVEL: specifiy SIMD Instructions Acceleration Level: 0~4, 0: disabled, 1: SSE2, 2: SSE4.1/NEON, 3: SSE4.2, 4: AVX2, default: 2
- AX_GLES_PROFILE: specify GLES profile version for GLES backend, valid value `200`, `300`
- AX_WASM_THREADS: specify wasm thread count, valid value: number: `>=0` , string: must be: `auto` or `navigator.hardwareConcurrency`(default),
Expand Down
6 changes: 3 additions & 3 deletions core/2d/FastTMXTiledMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,9 @@ class AX_DLL FastTMXTiledMap : public Node
* animations are not enabled by default
*/
void setTileAnimEnabled(bool enabled);

AX_DEPRECATED_ATTRIBUTE int getLayerNum() const { return getLayerCount(); }

#ifndef AX_CORE_PROFILE
AX_DEPRECATED(2.1) int getLayerNum() const { return getLayerCount(); }
#endif
int getLayerCount() const { return _layerCount; }

std::string_view getResourceFile() const { return _tmxFile; }
Expand Down
7 changes: 4 additions & 3 deletions core/2d/FontAtlasCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ FontAtlas* FontAtlasCache::getFontAtlasFNT(std::string_view fontFileName, const

return nullptr;
}

#ifndef AX_CORE_PROFILE
FontAtlas* FontAtlasCache::getFontAtlasFNT(std::string_view fontFileName, const Vec2& imageOffset)
{
return getFontAtlasFNT(fontFileName, Rect(imageOffset.x, imageOffset.y, 0, 0), false);
}

#endif
FontAtlas* FontAtlasCache::getFontAtlasCharMap(std::string_view plistFile)
{
std::string_view atlasName = plistFile;
Expand Down Expand Up @@ -259,11 +259,12 @@ void FontAtlasCache::reloadFontAtlasFNT(std::string_view fontFileName, const Rec
_atlasMap.emplace(std::move(atlasName), tempAtlas);
}
}

#ifndef AX_CORE_PROFILE
void FontAtlasCache::reloadFontAtlasFNT(std::string_view fontFileName, const Vec2& imageOffset)
{
reloadFontAtlasFNT(fontFileName, Rect(imageOffset.x, imageOffset.y, 0, 0), false);
}
#endif

void FontAtlasCache::unloadFontAtlasTTF(std::string_view fontFileName)
{
Expand Down
11 changes: 6 additions & 5 deletions core/2d/FontAtlasCache.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ class AX_DLL FontAtlasCache
static FontAtlas* getFontAtlasFNT(std::string_view fontFileName);
static FontAtlas* getFontAtlasFNT(std::string_view fontFileName, std::string_view subTextureKey);
static FontAtlas* getFontAtlasFNT(std::string_view fontFileName, const Rect& imageRect, bool imageRotated);
AX_DEPRECATED_ATTRIBUTE static FontAtlas* getFontAtlasFNT(std::string_view fontFileName, const Vec2& imageOffset);

#ifndef AX_CORE_PROFILE
AX_DEPRECATED(2.1) static FontAtlas* getFontAtlasFNT(std::string_view fontFileName, const Vec2& imageOffset);
#endif
static FontAtlas* getFontAtlasCharMap(std::string_view charMapFile,
int itemWidth,
int itemHeight,
Expand All @@ -72,10 +73,10 @@ class AX_DLL FontAtlasCache
otherwise, it will cause program crash!
*/
static void reloadFontAtlasFNT(std::string_view fontFileName, const Rect& imageRect, bool imageRotated);

AX_DEPRECATED_ATTRIBUTE static void reloadFontAtlasFNT(std::string_view fontFileName,
#ifndef AX_CORE_PROFILE
AX_DEPRECATED(2.1) static void reloadFontAtlasFNT(std::string_view fontFileName,
const Vec2& imageOffset = Vec2::ZERO);

#endif
/** Unload all texture atlas texture create by special file name.
CAUTION : All component use this font texture should be reset font name, though the file name is same!
otherwise, it will cause program crash!
Expand Down
4 changes: 2 additions & 2 deletions core/2d/FontFNT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,12 +589,12 @@ FontFNT* FontFNT::create(std::string_view fntFilePath)
tempFont->autorelease();
return tempFont;
}

#ifndef AX_CORE_PROFILE
FontFNT* FontFNT::create(std::string_view fntFilePath, const Vec2& imageOffset)
{
return create(fntFilePath, Rect(imageOffset.x, imageOffset.y, 0, 0), false);
}

#endif
FontFNT::FontFNT(BMFontConfiguration* theContfig, const Rect& imageRect, bool imageRotated)
: _configuration(theContfig), _imageRectInPoints(AX_RECT_PIXELS_TO_POINTS(imageRect)), _imageRotated(imageRotated)
{
Expand Down
6 changes: 3 additions & 3 deletions core/2d/FontFNT.h
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ class AX_DLL FontFNT : public Font
static FontFNT* create(std::string_view fntFilePath, const Rect& imageRect, bool imageRotated);
static FontFNT* create(std::string_view fntFilePath, std::string_view subTextureKey);
static FontFNT* create(std::string_view fntFilePath);

AX_DEPRECATED_ATTRIBUTE static FontFNT* create(std::string_view fntFilePath, const Vec2& imageOffset = Vec2::ZERO);

#ifndef AX_CORE_PROFILE
AX_DEPRECATED(2.1) static FontFNT* create(std::string_view fntFilePath, const Vec2& imageOffset = Vec2::ZERO);
#endif
/** Purges the cached data.
Removes from memory the cached configurations and the atlas name dictionary.
*/
Expand Down
7 changes: 4 additions & 3 deletions core/2d/Label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@ Label* Label::createWithBMFont(std::string_view bmfontPath,
return nullptr;
}

#ifndef AX_CORE_PROFILE
Label* Label::createWithBMFont(std::string_view bmfontPath,
std::string_view text,
const TextHAlignment& hAlignment,
Expand All @@ -368,7 +369,7 @@ Label* Label::createWithBMFont(std::string_view bmfontPath,
return createWithBMFont(bmfontPath, text, hAlignment, maxLineWidth, Rect(imageOffset.x, imageOffset.y, 0, 0),
false);
}

#endif
Label* Label::createWithCharMap(std::string_view plistFile)
{
auto ret = new Label();
Expand Down Expand Up @@ -926,12 +927,12 @@ bool Label::setBMFontFilePath(std::string_view bmfontFilePath, std::string_view

return true;
}

#ifndef AX_CORE_PROFILE
bool Label::setBMFontFilePath(std::string_view bmfontFilePath, const Vec2& imageOffset, float fontSize)
{
return setBMFontFilePath(bmfontFilePath, Rect(imageOffset.x, imageOffset.y, 0, 0), false);
}

#endif
void Label::setString(std::string_view text)
{
if (text.compare(_utf8Text))
Expand Down
15 changes: 9 additions & 6 deletions core/2d/Label.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,13 @@ class AX_DLL Label : public Node, public LabelProtocol, public BlendProtocol
* @return An automatically released Label object.
* @see setBMFontFilePath setMaxLineWidth
*/
AX_DEPRECATED_ATTRIBUTE static Label* createWithBMFont(std::string_view bmfontPath,
#ifndef AX_CORE_PROFILE
AX_DEPRECATED(2.1) static Label* createWithBMFont(std::string_view bmfontPath,
std::string_view text,
const TextHAlignment& hAlignment,
int maxLineWidth,
const Vec2& imageOffset);

#endif
/**
* Allocates and initializes a Label, with char map configuration.
*
Expand Down Expand Up @@ -340,12 +341,12 @@ class AX_DLL Label : public Node, public LabelProtocol, public BlendProtocol

/** Sets a new bitmap font to Label */
virtual bool setBMFontFilePath(std::string_view bmfontFilePath, std::string_view subTextureKey, float fontSize = 0);

#ifndef AX_CORE_PROFILE
/** Sets a new bitmap font to Label */
AX_DEPRECATED_ATTRIBUTE virtual bool setBMFontFilePath(std::string_view bmfontFilePath,
AX_DEPRECATED(2.1) virtual bool setBMFontFilePath(std::string_view bmfontFilePath,
const Vec2& imageOffset,
float fontSize = 0);

#endif
/** Returns the bitmap font used by the Label.*/
std::string_view getBMFontFilePath() const { return _bmFontPath; }

Expand Down Expand Up @@ -793,8 +794,10 @@ class AX_DLL Label : public Node, public LabelProtocol, public BlendProtocol

virtual void updateShaderProgram();
virtual void updateFontScale();
#ifndef AX_CORE_PROFILE
/* DEPRECATED: use updateFontScale instead */
AX_DEPRECATED_ATTRIBUTE virtual void updateBMFontScale() { updateFontScale(); }
AX_DEPRECATED(2.1) virtual void updateBMFontScale() { updateFontScale(); }
#endif
void scaleFontSize(float fontSize);
bool setTTFConfigInternal(const TTFConfig& ttfConfig);
bool updateTTFConfigInternal();
Expand Down
4 changes: 3 additions & 1 deletion core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
# include_guard (GLOBAL)

# The version number
set(_AX_VERSION 2.1)
set(_AX_VERSION 2.2)

if(NOT DEFINED _AX_CORE_LIB)
set(_AX_CORE_LIB axmol CACHE INTERNAL "The axmol core lib name" )
Expand Down Expand Up @@ -114,6 +114,7 @@ cmake_dependent_option(AX_ENABLE_NAVMESH "Build NavMesh support" ON "AX_ENABLE_3

option(AX_UPDATE_BUILD_VERSION "Update build version" ON)
option(AX_DISABLE_GLES2 "Whether disable GLES2 support" OFF)
option(AX_CORE_PROFILE "Whether strip deprecated features" OFF)

# default value for axmol extensions modules to Build
# total supported extensions count: 13
Expand Down Expand Up @@ -319,6 +320,7 @@ ax_config_pred(${_AX_CORE_LIB} AX_ENABLE_NAVMESH)
ax_config_pred(${_AX_CORE_LIB} AX_ENABLE_MEDIA)
ax_config_pred(${_AX_CORE_LIB} AX_ENABLE_AUDIO)
ax_config_pred(${_AX_CORE_LIB} AX_ENABLE_CONSOLE)
ax_config_pred(${_AX_CORE_LIB} AX_CORE_PROFILE)

# use 3rdparty libs
add_subdirectory(${_AX_ROOT}/3rdparty ${ENGINE_BINARY_PATH}/3rdparty)
Expand Down
4 changes: 3 additions & 1 deletion core/axmol.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ THE SOFTWARE.
#include "base/Config.h"

// base
#include "base/AsyncTaskPool.h"
#ifndef AX_CORE_PROFILE
# include "base/AsyncTaskPool.h"
#endif
#include "base/AutoreleasePool.h"
#include "base/Configuration.h"
#include "base/Logging.h"
Expand Down
7 changes: 5 additions & 2 deletions core/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ set(_AX_BASE_HEADER
base/Event.h
base/Types.h
base/Enums.h
base/AsyncTaskPool.h
base/Random.h
base/Object.h
base/Profiling.h
Expand Down Expand Up @@ -85,7 +84,6 @@ set(_AX_BASE_HEADER
)

set(_AX_BASE_SRC
base/AsyncTaskPool.cpp
base/JobSystem.cpp
base/AutoreleasePool.cpp
base/Configuration.cpp
Expand Down Expand Up @@ -141,6 +139,11 @@ set(_AX_BASE_SRC
${_AX_BASE_SPECIFIC_SRC}
)

if(NOT AX_CORE_PROFILE)
set(_AX_BASE_HEADER ${_AX_BASE_HEADER} base/AsyncTaskPool.h)
set(_AX_BASE_SRC ${_AX_BASE_SRC} base/AsyncTaskPool.cpp)
endif()

if(AX_ENABLE_CONSOLE)
set(_AX_BASE_HEADER ${_AX_BASE_HEADER} base/Console.h)
set(_AX_BASE_SRC ${_AX_BASE_SRC} base/Console.cpp)
Expand Down
1 change: 0 additions & 1 deletion core/base/Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
* @addtogroup base
* @js NA
* @lua NA
* @DEPRECATED use axstd::byte_buffer directly
*/
NS_AX_BEGIN

Expand Down
6 changes: 5 additions & 1 deletion core/base/Director.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ THE SOFTWARE.
#include "base/Logging.h"
#include "base/AutoreleasePool.h"
#include "base/Configuration.h"
#include "base/AsyncTaskPool.h"
#ifndef AX_CORE_PROFILE
# include "base/AsyncTaskPool.h"
#endif
#include "base/ObjectFactory.h"
#include "platform/Application.h"
#if defined(AX_ENABLE_AUDIO)
Expand Down Expand Up @@ -1056,7 +1058,9 @@ void Director::reset()
AnimationCache::destroyInstance();
SpriteFrameCache::destroyInstance();
FileUtils::destroyInstance();
#ifndef AX_CORE_PROFILE
AsyncTaskPool::destroyInstance();
#endif
backend::ProgramStateRegistry::destroyInstance();
backend::ProgramManager::destroyInstance();

Expand Down
2 changes: 1 addition & 1 deletion core/base/Logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ AX_DLL void writeLog(LogItem& item, const char* tag)
# endif
#endif
}

#ifndef AX_CORE_PROFILE
AX_API void print(const char* format, ...)
{
va_list args;
Expand Down
5 changes: 5 additions & 0 deletions core/base/Logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,14 @@ inline void printLogT(_FmtType&& fmt, LogItem& item, _Types&&... args)

#define AXLOGT AXLOGV

#ifndef AX_CORE_PROFILE
/**
@brief Output Debug message.
*/
/* AX_DEPRECATED_ATTRIBUTE*/ AX_API void print(const char* format, ...) AX_FORMAT_PRINTF(1, 2); // use AXLOGD instead


/* AX_DEPRECATED(2.1)*/ AX_API void print(const char* format, ...) AX_FORMAT_PRINTF(1, 2); // use AXLOGD instead
#endif
// }
NS_AX_END
11 changes: 6 additions & 5 deletions core/base/Scheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -470,12 +470,12 @@ class AX_DLL Scheduler : public Object
@js NA
*/
void runOnAxmolThread(std::function<void()> action);

AX_DEPRECATED_ATTRIBUTE void performFunctionInCocosThread(std::function<void()> action)
#ifndef AX_CORE_PROFILE
AX_DEPRECATED(2.1) void performFunctionInCocosThread(std::function<void()> action)
{
runOnAxmolThread(std::move(action));
}

#endif
/**
* Remove all pending functions queued to be performed with Scheduler::runOnAxmolThread
* Functions unscheduled in this manner will not be executed
Expand All @@ -484,8 +484,9 @@ class AX_DLL Scheduler : public Object
* @js NA
*/
void removeAllPendingActions();
AX_DEPRECATED_ATTRIBUTE void removeAllFunctionsToBePerformedInCocosThread() { removeAllPendingActions(); }

#ifndef AX_CORE_PROFILE
AX_DEPRECATED(2.1) void removeAllFunctionsToBePerformedInCocosThread() { removeAllPendingActions(); }
#endif
protected:
/** Schedules the 'callback' function for a given target with a given priority.
The 'callback' selector will be called every frame.
Expand Down
6 changes: 3 additions & 3 deletions core/base/ScriptSupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ScriptHandlerEntry::~ScriptHandlerEntry()
if (_handler != 0)
{
ScriptEngineManager::getInstance()->getScriptEngine()->removeScriptHandler(_handler);
LUALOG("[LUA] Remove event handler: %d", _handler);
AXLOGD("[LUA] Remove event handler: %d", _handler);
_handler = 0;
}
}
Expand All @@ -79,14 +79,14 @@ bool SchedulerScriptHandlerEntry::init(float interval, bool paused)
_timer = new TimerScriptHandler();
_timer->initWithScriptHandler(_handler, interval);
_paused = paused;
LUALOG("[LUA] ADD script schedule: %d, entryID: %d", _handler, _entryId);
AXLOGD("[LUA] ADD script schedule: {}, entryID: {}", _handler, _entryId);
return true;
}

SchedulerScriptHandlerEntry::~SchedulerScriptHandlerEntry()
{
_timer->release();
LUALOG("[LUA] DEL script schedule %d, entryID: %d", _handler, _entryId);
AXLOGD("[LUA] DEL script schedule {}, entryID: {}", _handler, _entryId);
}

//
Expand Down
4 changes: 2 additions & 2 deletions core/base/UTF8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ NS_AX_BEGIN

namespace StringUtils
{

//#ifndef AX_CORE_PROFILE
std::string AX_DLL format(const char* format, ...)
{
va_list args;
Expand Down Expand Up @@ -115,7 +115,7 @@ std::string vformat(const char* format, va_list ap)

return buf;
}

//#endif
/*
* @str: the string to search through.
* @c: the character to not look for.
Expand Down
3 changes: 2 additions & 1 deletion core/base/UTF8.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ inline std::string toString(T arg)
{
return fmt::to_string(arg);
}

//#ifndef AX_CORE_PROFILE
// DEPRECATED since axmol-2.1.4, use fmt::format instead
std::string AX_DLL format(const char* format, ...) AX_FORMAT_PRINTF(1, 2);
std::string AX_DLL vformat(const char* format, va_list ap);
//#endif

/**
* @brief Converts from UTF8 string to UTF16 string.
Expand Down
Loading

0 comments on commit d6c114a

Please sign in to comment.