2013-07-23 02:17:51 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2013 Zynga Inc.
|
2018-01-29 16:25:32 +08:00
|
|
|
Copyright (c) 2013-2016 Chukong Technologies Inc.
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-11-27 11:06:51 +08:00
|
|
|
Copyright (c) 2021 Bytedance Inc.
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
https://axys1.github.io/
|
2013-07-23 02:17:51 +08:00
|
|
|
|
|
|
|
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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-07-27 07:04:21 +08:00
|
|
|
#ifndef _COCOS2D_CCLABEL_H_
|
|
|
|
#define _COCOS2D_CCLABEL_H_
|
2013-07-23 02:17:51 +08:00
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
#include "2d/CCNode.h"
|
2014-04-30 08:37:36 +08:00
|
|
|
#include "renderer/CCCustomCommand.h"
|
2015-08-04 21:49:14 +08:00
|
|
|
#include "renderer/CCQuadCommand.h"
|
2014-05-01 10:09:13 +08:00
|
|
|
#include "2d/CCFontAtlas.h"
|
2015-04-10 14:18:16 +08:00
|
|
|
#include "base/ccTypes.h"
|
2013-07-23 02:17:51 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_BEGIN
|
2013-07-23 02:17:51 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
2015-03-24 14:12:58 +08:00
|
|
|
* @addtogroup _2d
|
|
|
|
* @{
|
|
|
|
*/
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#define AX_DEFAULT_FONT_LABEL_SIZE 12
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* @struct TTFConfig
|
2015-03-25 10:59:04 +08:00
|
|
|
* @see `GlyphCollection`
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2014-01-11 22:33:07 +08:00
|
|
|
typedef struct _ttfConfig
|
|
|
|
{
|
|
|
|
std::string fontFilePath;
|
2015-09-28 21:15:51 +08:00
|
|
|
float fontSize;
|
2015-03-25 10:59:04 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
GlyphCollection glyphs;
|
2021-11-26 17:53:24 +08:00
|
|
|
std::string customGlyphs;
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2014-01-15 17:21:08 +08:00
|
|
|
bool distanceFieldEnabled;
|
2014-03-05 15:54:40 +08:00
|
|
|
int outlineSize;
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2016-01-20 12:41:31 +08:00
|
|
|
bool italics;
|
|
|
|
bool bold;
|
|
|
|
bool underline;
|
|
|
|
bool strikethrough;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
_ttfConfig(std::string_view filePath = {},
|
2022-07-15 19:17:01 +08:00
|
|
|
float size = AX_DEFAULT_FONT_LABEL_SIZE,
|
2021-11-27 11:06:51 +08:00
|
|
|
const GlyphCollection& glyphCollection = GlyphCollection::DYNAMIC,
|
2022-01-01 21:21:34 +08:00
|
|
|
const char* customGlyphCollection = nullptr, /* nullable */
|
2021-11-27 11:06:51 +08:00
|
|
|
bool useDistanceField = false,
|
|
|
|
int outline = 0,
|
|
|
|
bool useItalics = false,
|
|
|
|
bool useBold = false,
|
|
|
|
bool useUnderline = false,
|
|
|
|
bool useStrikethrough = false)
|
2015-12-03 09:23:23 +08:00
|
|
|
: fontFilePath(filePath)
|
|
|
|
, fontSize(size)
|
|
|
|
, glyphs(glyphCollection)
|
2022-01-01 21:21:34 +08:00
|
|
|
, customGlyphs(customGlyphCollection ? customGlyphCollection : "")
|
2015-12-03 09:23:23 +08:00
|
|
|
, distanceFieldEnabled(useDistanceField)
|
|
|
|
, outlineSize(outline)
|
2016-01-20 12:41:31 +08:00
|
|
|
, italics(useItalics)
|
|
|
|
, bold(useBold)
|
|
|
|
, underline(useUnderline)
|
|
|
|
, strikethrough(useStrikethrough)
|
2014-03-05 15:54:40 +08:00
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
if (outline > 0)
|
2014-03-05 15:54:40 +08:00
|
|
|
{
|
|
|
|
distanceFieldEnabled = false;
|
|
|
|
}
|
|
|
|
}
|
2015-12-03 09:23:23 +08:00
|
|
|
} TTFConfig;
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
class Sprite;
|
|
|
|
class SpriteBatchNode;
|
2015-07-24 18:38:45 +08:00
|
|
|
class DrawNode;
|
|
|
|
class EventListenerCustom;
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
class TextureAtlas;
|
2015-07-07 14:20:23 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
2015-07-08 15:30:34 +08:00
|
|
|
* @brief Label is a subclass of Node that knows how to render text labels.
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
2015-03-19 10:38:12 +08:00
|
|
|
* Label can be created with:
|
|
|
|
* - A true type font file.
|
|
|
|
* - A bitmap font file.
|
|
|
|
* - A char map file.
|
|
|
|
* - The built in system font.
|
|
|
|
*
|
|
|
|
* Bitmap Font supported editors:
|
|
|
|
* - http://glyphdesigner.71squared.com/ (Commercial, Mac OS X)
|
|
|
|
* - http://www.n4te.com/hiero/hiero.jnlp (Free, Java)
|
|
|
|
* - http://slick.cokeandcode.com/demos/hiero.jnlp (Free, Java)
|
|
|
|
* - http://www.angelcode.com/products/bmfont/ (Free, Windows only)
|
2015-03-28 14:28:16 +08:00
|
|
|
* @js NA
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
class AX_DLL Label : public Node, public LabelProtocol, public BlendProtocol
|
2013-07-23 02:17:51 +08:00
|
|
|
{
|
|
|
|
public:
|
2015-11-19 16:06:13 +08:00
|
|
|
enum class Overflow
|
|
|
|
{
|
2021-12-25 10:04:45 +08:00
|
|
|
// In NONE mode, the dimensions is (0,0) and the content size will change dynamically to fit the label.
|
2016-01-04 21:43:37 +08:00
|
|
|
NONE,
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
*In CLAMP mode, when label content goes out of the bounding box, it will be clipped.
|
|
|
|
*/
|
|
|
|
CLAMP,
|
2016-01-04 21:43:37 +08:00
|
|
|
/**
|
|
|
|
* In SHRINK mode, the font size will change dynamically to adapt the content size.
|
|
|
|
*/
|
2016-01-05 10:20:05 +08:00
|
|
|
SHRINK,
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
*In RESIZE_HEIGHT mode, you can only change the width of label and the height is changed automatically.
|
|
|
|
*/
|
|
|
|
RESIZE_HEIGHT
|
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
enum class LabelType
|
|
|
|
{
|
2018-09-29 14:26:58 +08:00
|
|
|
TTF,
|
|
|
|
BMFONT,
|
|
|
|
CHARMAP,
|
|
|
|
STRING_TEXTURE
|
|
|
|
};
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/// @name Creators
|
|
|
|
/// @{
|
|
|
|
|
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Allocates and initializes a Label, with default settings.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2014-01-11 22:33:07 +08:00
|
|
|
static Label* create();
|
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Allocates and initializes a Label, base on platform-dependent API.
|
|
|
|
*
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param font A font file or a font family name.
|
|
|
|
* @param fontSize The font size. This value must be > 0.
|
2015-04-10 14:18:16 +08:00
|
|
|
* @param dimensions
|
2015-03-19 10:38:12 +08:00
|
|
|
* @param hAlignment The text horizontal alignment.
|
|
|
|
* @param vAlignment The text vertical alignment.
|
|
|
|
*
|
|
|
|
* @warning It will generate texture by the platform-dependent code.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
2014-03-10 19:42:43 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static Label* createWithSystemFont(std::string_view text,
|
|
|
|
std::string_view font,
|
2021-12-25 10:04:45 +08:00
|
|
|
float fontSize,
|
|
|
|
const Vec2& dimensions = Vec2::ZERO,
|
|
|
|
TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, base on FreeType2.
|
|
|
|
*
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param fontFilePath A font file.
|
|
|
|
* @param fontSize The font size. This value must be > 0.
|
|
|
|
* @param dimensions
|
|
|
|
* @param hAlignment The text horizontal alignment.
|
|
|
|
* @param vAlignment The text vertical alignment.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static Label* createWithTTF(std::string_view text,
|
|
|
|
std::string_view fontFilePath,
|
2021-12-25 10:04:45 +08:00
|
|
|
float fontSize,
|
|
|
|
const Vec2& dimensions = Vec2::ZERO,
|
|
|
|
TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, base on FreeType2.
|
|
|
|
*
|
|
|
|
* @param ttfConfig A pointer to a TTFConfig object.
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param hAlignment The text horizontal alignment.
|
|
|
|
* @param maxLineWidth The max line width.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
* @see TTFConfig setTTFConfig setMaxLineWidth
|
|
|
|
*/
|
|
|
|
static Label* createWithTTF(const TTFConfig& ttfConfig,
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view text,
|
2021-12-25 10:04:45 +08:00
|
|
|
TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
int maxLineWidth = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with a bitmap font file.
|
|
|
|
*
|
|
|
|
* @param bmfontPath A bitmap font file, it's a FNT format.
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param hAlignment Text horizontal alignment.
|
|
|
|
* @param maxLineWidth The max line width.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
* @see setBMFontFilePath setMaxLineWidth
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static Label* createWithBMFont(std::string_view bmfontPath,
|
|
|
|
std::string_view text,
|
2021-12-25 10:04:45 +08:00
|
|
|
const TextHAlignment& hAlignment = TextHAlignment::LEFT,
|
|
|
|
int maxLineWidth = 0);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with a bitmap font file.
|
|
|
|
*
|
|
|
|
* @param bmfontPath A bitmap font file, it's a FNT format.
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param hAlignment Text horizontal alignment.
|
|
|
|
* @param maxLineWidth The max line width.
|
|
|
|
* @param imageRect
|
|
|
|
* @param imageRotated
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
* @see setBMFontFilePath setMaxLineWidth
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static Label* createWithBMFont(std::string_view bmfontPath,
|
|
|
|
std::string_view text,
|
2021-12-25 10:04:45 +08:00
|
|
|
const TextHAlignment& hAlignment,
|
|
|
|
int maxLineWidth,
|
|
|
|
const Rect& imageRect,
|
|
|
|
bool imageRotated);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with a bitmap font file.
|
|
|
|
*
|
|
|
|
* @param bmfontPath A bitmap font file, it's a FNT format.
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param hAlignment Text horizontal alignment.
|
|
|
|
* @param maxLineWidth The max line width.
|
|
|
|
* @param subTextureKey Name of entry in PLIST texture atlas/sprite sheet
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
* @see setBMFontFilePath setMaxLineWidth
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static Label* createWithBMFont(std::string_view bmfontPath,
|
|
|
|
std::string_view text,
|
2021-12-25 10:04:45 +08:00
|
|
|
const TextHAlignment& hAlignment,
|
|
|
|
int maxLineWidth,
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view subTextureKey);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with a bitmap font file.
|
|
|
|
*
|
|
|
|
* @param bmfontPath A bitmap font file, it's a FNT format.
|
|
|
|
* @param text The initial text.
|
|
|
|
* @param hAlignment Text horizontal alignment.
|
|
|
|
* @param maxLineWidth The max line width.
|
|
|
|
* @param imageOffset Offset into larger texture
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
* @see setBMFontFilePath setMaxLineWidth
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE static Label* createWithBMFont(std::string_view bmfontPath,
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view text,
|
2021-12-25 10:04:45 +08:00
|
|
|
const TextHAlignment& hAlignment,
|
|
|
|
int maxLineWidth,
|
|
|
|
const Vec2& imageOffset);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with char map configuration.
|
|
|
|
*
|
|
|
|
* @param charMapFile A char map file, it's a PNG format.
|
|
|
|
* @param itemWidth The width in points of each element.
|
|
|
|
* @param itemHeight The height in points of each element.
|
|
|
|
* @param startCharMap The starting char of the char map.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static Label* createWithCharMap(std::string_view charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with char map configuration.
|
|
|
|
*
|
|
|
|
* @param texture A pointer to an existing Texture2D object.
|
|
|
|
* @param itemWidth The width in points of each element.
|
|
|
|
* @param itemHeight The height in points of each element.
|
|
|
|
* @param startCharMap The starting char of the char map.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
|
|
|
static Label* createWithCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Allocates and initializes a Label, with char map configuration.
|
|
|
|
*
|
|
|
|
* @param plistFile A configuration file of char map.
|
|
|
|
*
|
|
|
|
* @return An automatically released Label object.
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
static Label* createWithCharMap(std::string_view plistFile);
|
2014-01-16 16:37:29 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
// end of creators group
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
/// @{
|
|
|
|
/// @name Font methods
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a new TTF configuration to Label.
|
|
|
|
* @see `TTFConfig`
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setTTFConfig(const TTFConfig& ttfConfig);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the TTF configuration object used by the Label.
|
|
|
|
* @see `TTFConfig`
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual const TTFConfig& getTTFConfig() const { return _fontConfig; }
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets a new bitmap font to Label */
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual bool setBMFontFilePath(std::string_view bmfontFilePath, float fontSize = 0);
|
2020-01-06 09:35:52 +08:00
|
|
|
|
|
|
|
/** Sets a new bitmap font to Label */
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual bool setBMFontFilePath(std::string_view bmfontFilePath,
|
2021-12-25 10:04:45 +08:00
|
|
|
const Rect& imageRect,
|
|
|
|
bool imageRotated,
|
|
|
|
float fontSize = 0);
|
2020-01-06 09:35:52 +08:00
|
|
|
|
|
|
|
/** Sets a new bitmap font to Label */
|
2021-12-28 11:00:34 +08:00
|
|
|
virtual bool setBMFontFilePath(std::string_view bmfontFilePath, std::string_view subTextureKey, float fontSize = 0);
|
2020-01-06 09:35:52 +08:00
|
|
|
|
|
|
|
/** Sets a new bitmap font to Label */
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DEPRECATED_ATTRIBUTE virtual bool setBMFontFilePath(std::string_view bmfontFilePath,
|
2021-12-25 10:04:45 +08:00
|
|
|
const Vec2& imageOffset,
|
|
|
|
float fontSize = 0);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the bitmap font used by the Label.*/
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view getBMFontFilePath() const { return _bmFontPath; }
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Sets a new char map configuration to Label.
|
|
|
|
*
|
2021-12-26 23:26:34 +08:00
|
|
|
* @see `createWithCharMap(std::string_view,int,int,int)`
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual bool setCharMap(std::string_view charMapFile, int itemWidth, int itemHeight, int startCharMap);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets a new char map configuration to Label.
|
|
|
|
*
|
|
|
|
* @see `createWithCharMap(Texture2D*,int,int,int)`
|
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual bool setCharMap(Texture2D* texture, int itemWidth, int itemHeight, int startCharMap);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/**
|
2015-04-10 14:18:16 +08:00
|
|
|
* Sets a new char map configuration to Label.
|
2015-03-19 10:38:12 +08:00
|
|
|
*
|
2021-12-26 23:26:34 +08:00
|
|
|
* @see `createWithCharMap(std::string_view)`
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual bool setCharMap(std::string_view plistFile);
|
2014-01-16 16:37:29 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Sets a new system font to Label.
|
|
|
|
*
|
|
|
|
* @param font A font file or a font family name.
|
|
|
|
* @warning
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual void setSystemFontName(std::string_view font);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the system font used by the Label.*/
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual std::string_view getSystemFontName() const { return _systemFont; }
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/* Sets the system font size of Label.*/
|
2014-04-09 23:31:05 +08:00
|
|
|
virtual void setSystemFontSize(float fontSize);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the bitmap font path used by the Label.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual float getSystemFontSize() const { return _systemFontSize; }
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* @warning This method is not recommended for game developers.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void requestSystemFontRefresh() { _systemFontDirty = true; }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
// end of font methods
|
|
|
|
/// @}
|
|
|
|
|
|
|
|
/** Sets the text that this Label is to display.*/
|
2021-12-01 03:35:34 +08:00
|
|
|
virtual void setString(std::string_view text) override;
|
2014-01-11 22:33:07 +08:00
|
|
|
|
2016-01-22 09:05:43 +08:00
|
|
|
/** Return the text the Label is currently displaying.*/
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual std::string_view getString() const override { return _utf8Text; }
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
/**
|
|
|
|
* Return the number of lines of text.
|
|
|
|
*/
|
|
|
|
int getStringNumLines();
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
/**
|
|
|
|
* Return length of string.
|
|
|
|
*/
|
|
|
|
int getStringLength();
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Sets the text color of Label.
|
|
|
|
*
|
|
|
|
* The text color is different from the color of Node.
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
|
|
|
* @warning Limiting use to only when the Label created with true type font or system font.
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void setTextColor(const Color4B& color);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the text color of the Label.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
const Color4B& getTextColor() const { return _textColor; }
|
2014-06-12 12:01:15 +08:00
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Enable shadow effect to Label.
|
2014-03-05 15:54:40 +08:00
|
|
|
*
|
2015-03-19 10:38:12 +08:00
|
|
|
* @todo Support blur for shadow effect.
|
2014-03-05 15:54:40 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void enableShadow(const Color4B& shadowColor = Color4B::BLACK,
|
|
|
|
const Vec2& offset = Vec2(2, -2),
|
|
|
|
int blurRadius = 0);
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Enable outline effect to Label.
|
|
|
|
* @warning Limiting use to only when the Label created with true type font or system font.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void enableOutline(const Color4B& outlineColor, int outlineSize = -1);
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Enable glow effect to Label.
|
|
|
|
* @warning Limiting use to only when the Label created with true type font.
|
|
|
|
*/
|
2014-03-20 20:56:10 +08:00
|
|
|
virtual void enableGlow(const Color4B& glowColor);
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2016-01-20 12:41:31 +08:00
|
|
|
/**
|
|
|
|
* Enable italics rendering
|
|
|
|
*/
|
|
|
|
void enableItalics();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable bold rendering
|
|
|
|
*/
|
|
|
|
void enableBold();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enable underline
|
|
|
|
*/
|
|
|
|
void enableUnderline();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Enables strikethrough.
|
|
|
|
* Underline and Strikethrough cannot be enabled at the same time.
|
2016-02-18 15:16:36 +08:00
|
|
|
* Strikethrough is like an underline but at the middle of the glyph
|
2016-01-20 12:41:31 +08:00
|
|
|
*/
|
|
|
|
void enableStrikethrough();
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
2016-01-27 09:42:25 +08:00
|
|
|
* Disable all effect applied to Label.
|
2015-04-17 14:39:52 +08:00
|
|
|
* @warning Please use disableEffect(LabelEffect::ALL) instead of this API.
|
2015-03-19 10:38:12 +08:00
|
|
|
*/
|
2014-03-05 15:54:40 +08:00
|
|
|
virtual void disableEffect();
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-04-07 15:51:57 +08:00
|
|
|
/**
|
|
|
|
* Disable effect to Label.
|
|
|
|
*
|
|
|
|
* @see `LabelEffect`
|
|
|
|
*/
|
|
|
|
virtual void disableEffect(LabelEffect effect);
|
|
|
|
|
2015-12-11 12:04:54 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Return whether the shadow effect is enabled.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
bool isShadowEnabled() const { return _shadowEnabled; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Return shadow effect offset value.
|
|
|
|
*/
|
2021-10-23 23:27:14 +08:00
|
|
|
Vec2 getShadowOffset() const { return _shadowOffset; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Return the shadow effect blur radius.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
float getShadowBlurRadius() const { return _shadowBlurRadius; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Return the shadow effect color value.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
Color4F getShadowColor() const { return _shadowColor4F; }
|
|
|
|
|
2015-12-11 12:04:54 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Return the outline effect size value.
|
|
|
|
*/
|
2017-01-04 12:01:07 +08:00
|
|
|
float getOutlineSize() const { return _outlineSize; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Return current effect type.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
LabelEffect getLabelEffectType() const { return _currLabelEffect; }
|
2015-12-11 12:04:54 +08:00
|
|
|
|
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* Return current effect color value.
|
|
|
|
*/
|
2015-12-10 13:17:31 +08:00
|
|
|
Color4F getEffectColor() const { return _effectColorF; }
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text horizontal alignment.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void setAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment, _vAlignment); }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the Label's text horizontal alignment.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
TextHAlignment getTextAlignment() const { return _hAlignment; }
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text alignment.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void setAlignment(TextHAlignment hAlignment, TextVAlignment vAlignment);
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text horizontal alignment.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void setHorizontalAlignment(TextHAlignment hAlignment) { setAlignment(hAlignment, _vAlignment); }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the Label's text horizontal alignment.*/
|
2014-03-07 14:58:44 +08:00
|
|
|
TextHAlignment getHorizontalAlignment() const { return _hAlignment; }
|
2014-03-07 15:58:49 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the Label's text vertical alignment.*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void setVerticalAlignment(TextVAlignment vAlignment) { setAlignment(_hAlignment, vAlignment); }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
|
|
|
/** Returns the Label's text vertical alignment.*/
|
2014-03-07 14:58:44 +08:00
|
|
|
TextVAlignment getVerticalAlignment() const { return _vAlignment; }
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Specify what happens when a line is too long for Label.
|
2015-04-10 14:18:16 +08:00
|
|
|
*
|
2015-03-19 10:38:12 +08:00
|
|
|
* @param breakWithoutSpace Lines are automatically broken between words if this value is false.
|
|
|
|
*/
|
2014-03-11 14:32:07 +08:00
|
|
|
void setLineBreakWithoutSpace(bool breakWithoutSpace);
|
2013-08-13 07:16:34 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Makes the Label at most this line untransformed width.
|
|
|
|
* The Label's max line width be used for force line breaks if the value not equal zero.
|
2014-03-07 14:58:44 +08:00
|
|
|
*/
|
2015-01-20 11:46:43 +08:00
|
|
|
void setMaxLineWidth(float maxLineWidth);
|
|
|
|
float getMaxLineWidth() { return _maxLineWidth; }
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
* Change font size of label type BMFONT
|
|
|
|
* Note: This function only scale the BMFONT letter to mimic the font size change effect.
|
|
|
|
*
|
|
|
|
* @param fontSize The desired font size in float.
|
|
|
|
*/
|
|
|
|
void setBMFontSize(float fontSize);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the user define BMFont size.
|
|
|
|
*
|
|
|
|
* @return The BMFont size in float value.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
float getBMFontSize() const;
|
2015-11-19 16:06:13 +08:00
|
|
|
|
|
|
|
/**
|
2015-11-20 10:54:05 +08:00
|
|
|
* Toggle wrap option of the label.
|
2015-11-19 16:06:13 +08:00
|
|
|
* Note: System font doesn't support manually toggle wrap.
|
|
|
|
*
|
|
|
|
* @param enable Set true to enable wrap and false to disable wrap.
|
|
|
|
*/
|
|
|
|
void enableWrap(bool enable);
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-11-19 16:06:13 +08:00
|
|
|
/**
|
|
|
|
* Query the wrap is enabled or not.
|
|
|
|
* Note: System font will always return true.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
bool isWrapEnabled() const;
|
2015-11-19 16:06:13 +08:00
|
|
|
|
|
|
|
/**
|
2015-11-20 10:54:05 +08:00
|
|
|
* Change the label's Overflow type, currently only TTF and BMFont support all the valid Overflow type.
|
|
|
|
* Char Map font supports all the Overflow type except for SHRINK, because we can't measure it's font size.
|
|
|
|
* System font only support Overflow::Normal and Overflow::RESIZE_HEIGHT.
|
2015-11-19 16:06:13 +08:00
|
|
|
*
|
|
|
|
* @param overflow see `Overflow`
|
|
|
|
*/
|
|
|
|
void setOverflow(Overflow overflow);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Query the label's Overflow type.
|
|
|
|
*
|
|
|
|
* @return see `Overflow`
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
Overflow getOverflow() const;
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Makes the Label exactly this untransformed width.
|
|
|
|
*
|
|
|
|
* The Label's width be used for text align if the value not equal zero.
|
2021-12-25 10:04:45 +08:00
|
|
|
*/
|
|
|
|
void setWidth(float width) { setDimensions(width, _labelHeight); }
|
2015-01-20 11:46:43 +08:00
|
|
|
float getWidth() const { return _labelWidth; }
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
|
|
|
* Makes the Label exactly this untransformed height.
|
|
|
|
*
|
|
|
|
* The Label's height be used for text align if the value not equal zero.
|
2016-01-27 09:42:25 +08:00
|
|
|
* The text will display incomplete if the size of Label is not large enough to display all text.
|
2014-03-07 14:58:44 +08:00
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
void setHeight(float height) { setDimensions(_labelWidth, height); }
|
2015-01-20 11:46:43 +08:00
|
|
|
float getHeight() const { return _labelHeight; }
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the untransformed size of the Label in a more efficient way. */
|
2015-01-20 11:46:43 +08:00
|
|
|
void setDimensions(float width, float height);
|
2021-12-25 10:04:45 +08:00
|
|
|
const Vec2& getDimensions() const { return _labelDimensions; }
|
2014-03-11 14:32:07 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Update content immediately.*/
|
2014-03-10 19:42:43 +08:00
|
|
|
virtual void updateContent();
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/**
|
2016-01-27 09:42:25 +08:00
|
|
|
* Provides a way to treat each character like a Sprite.
|
2015-03-19 10:38:12 +08:00
|
|
|
* @warning No support system font.
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual Sprite* getLetter(int lettetIndex);
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2016-01-27 09:42:25 +08:00
|
|
|
/** Clips upper and lower margin to reduce height of Label.*/
|
2014-03-24 14:16:27 +08:00
|
|
|
void setClipMarginEnabled(bool clipEnabled) { _clipEnabled = clipEnabled; }
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2014-03-25 16:37:34 +08:00
|
|
|
bool isClipMarginEnabled() const { return _clipEnabled; }
|
2014-06-12 12:01:15 +08:00
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
/** Sets the line height of the Label.
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
void setLineHeight(float height);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Returns the line height of this Label.
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
float getLineHeight() const;
|
|
|
|
|
2015-09-29 00:02:17 +08:00
|
|
|
void setLineSpacing(float height);
|
|
|
|
float getLineSpacing() const;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2018-09-29 14:26:58 +08:00
|
|
|
/**
|
|
|
|
Returns type of label
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2018-09-29 14:26:58 +08:00
|
|
|
@warning Not support system font.
|
|
|
|
@return the type of label
|
|
|
|
@since v3.18.0
|
|
|
|
*/
|
|
|
|
LabelType getLabelType() const { return _currentLabelType; }
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2018-09-29 14:26:58 +08:00
|
|
|
/**
|
|
|
|
Returns font size
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
float getRenderingFontSize() const;
|
2015-09-29 00:02:17 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Sets the additional kerning of the Label.
|
|
|
|
*
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
void setAdditionalKerning(float space);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2015-04-10 14:18:16 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Returns the additional kerning of the Label.
|
|
|
|
*
|
|
|
|
* @warning Not support system font.
|
|
|
|
* @since v3.2.0
|
2014-06-12 12:01:15 +08:00
|
|
|
*/
|
|
|
|
float getAdditionalKerning() const;
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool setProgramState(backend::ProgramState* programState, bool needsRetain = true) override;
|
2019-03-26 13:45:03 +08:00
|
|
|
|
2014-04-02 14:57:00 +08:00
|
|
|
FontAtlas* getFontAtlas() { return _fontAtlas; }
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-07-08 15:30:34 +08:00
|
|
|
virtual const BlendFunc& getBlendFunc() const override { return _blendFunc; }
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void setBlendFunc(const BlendFunc& blendFunc) override;
|
2014-04-02 14:57:00 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
virtual bool isOpacityModifyRGB() const override { return _isOpacityModifyRGB; }
|
2014-04-02 14:57:00 +08:00
|
|
|
virtual void setOpacityModifyRGB(bool isOpacityModifyRGB) override;
|
|
|
|
virtual void updateDisplayedColor(const Color3B& parentColor) override;
|
2019-06-05 17:58:33 +08:00
|
|
|
virtual void updateDisplayedOpacity(uint8_t parentOpacity) override;
|
2013-12-13 06:30:22 +08:00
|
|
|
|
2014-03-07 14:58:44 +08:00
|
|
|
virtual std::string getDescription() const override;
|
2014-01-22 14:57:11 +08:00
|
|
|
|
2021-10-23 23:27:14 +08:00
|
|
|
virtual const Vec2& getContentSize() const override;
|
2014-03-28 15:58:28 +08:00
|
|
|
virtual Rect getBoundingBox() const override;
|
2014-03-28 11:03:39 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
virtual void visit(Renderer* renderer, const Mat4& parentTransform, uint32_t parentFlags) override;
|
|
|
|
virtual void draw(Renderer* renderer, const Mat4& transform, uint32_t flags) override;
|
2014-04-02 14:57:00 +08:00
|
|
|
|
2015-03-16 17:11:17 +08:00
|
|
|
virtual void setCameraMask(unsigned short mask, bool applyChildren = true) override;
|
2015-03-16 15:31:29 +08:00
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
virtual void removeAllChildrenWithCleanup(bool cleanup) override;
|
|
|
|
virtual void removeChild(Node* child, bool cleanup = true) override;
|
2015-08-19 10:22:48 +08:00
|
|
|
virtual void setGlobalZOrder(float globalZOrder) override;
|
2015-07-07 14:20:23 +08:00
|
|
|
|
2022-03-18 21:46:07 +08:00
|
|
|
/**
|
|
|
|
* Constructor of Label.
|
|
|
|
* @js NA
|
|
|
|
*/
|
|
|
|
Label(TextHAlignment hAlignment = TextHAlignment::LEFT, TextVAlignment vAlignment = TextVAlignment::TOP);
|
2015-03-19 10:38:12 +08:00
|
|
|
|
2014-08-21 15:11:33 +08:00
|
|
|
/**
|
2015-03-19 10:38:12 +08:00
|
|
|
* Destructor of Label.
|
2014-08-21 15:11:33 +08:00
|
|
|
* @js NA
|
|
|
|
* @lua NA
|
|
|
|
*/
|
|
|
|
virtual ~Label();
|
|
|
|
|
2021-12-26 23:26:34 +08:00
|
|
|
bool initWithTTF(std::string_view text,
|
|
|
|
std::string_view fontFilePath,
|
2021-12-25 10:04:45 +08:00
|
|
|
float fontSize,
|
|
|
|
const Vec2& dimensions = Vec2::ZERO,
|
|
|
|
TextHAlignment hAlignment = TextHAlignment::LEFT,
|
2015-12-03 09:23:23 +08:00
|
|
|
TextVAlignment vAlignment = TextVAlignment::TOP);
|
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
bool initWithTTF(const TTFConfig& ttfConfig,
|
2021-12-26 23:26:34 +08:00
|
|
|
std::string_view text,
|
2021-12-25 10:04:45 +08:00
|
|
|
TextHAlignment hAlignment = TextHAlignment::LEFT,
|
|
|
|
int maxLineWidth = 0);
|
2015-12-03 09:23:23 +08:00
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
protected:
|
2014-02-19 20:26:14 +08:00
|
|
|
struct LetterInfo
|
|
|
|
{
|
2017-02-06 16:41:52 +08:00
|
|
|
char32_t utf32Char;
|
2015-07-24 18:38:45 +08:00
|
|
|
bool valid;
|
|
|
|
float positionX;
|
|
|
|
float positionY;
|
|
|
|
int atlasIndex;
|
|
|
|
int lineIndex;
|
2014-02-19 20:26:14 +08:00
|
|
|
};
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
struct BatchCommand
|
|
|
|
{
|
2019-04-02 14:56:29 +08:00
|
|
|
BatchCommand();
|
2020-09-17 11:41:14 +08:00
|
|
|
BatchCommand(const BatchCommand& rhs) = delete;
|
2021-12-25 10:04:45 +08:00
|
|
|
BatchCommand(BatchCommand&& rhs) = default;
|
2019-04-02 14:56:29 +08:00
|
|
|
~BatchCommand();
|
|
|
|
|
2020-09-17 11:41:14 +08:00
|
|
|
BatchCommand& operator=(const BatchCommand& rhs) = delete;
|
|
|
|
BatchCommand& operator=(BatchCommand&& rhs) = default;
|
|
|
|
|
2020-08-19 11:46:13 +08:00
|
|
|
void setProgramState(backend::ProgramState* state);
|
|
|
|
|
|
|
|
std::array<CustomCommand*, 3> getCommandArray();
|
|
|
|
|
2019-04-02 14:56:29 +08:00
|
|
|
CustomCommand textCommand;
|
|
|
|
CustomCommand outLineCommand;
|
|
|
|
CustomCommand shadowCommand;
|
|
|
|
};
|
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
virtual void setFontAtlas(FontAtlas* atlas, bool distanceFieldEnabled = false, bool useA8Shader = false);
|
2018-03-13 09:40:24 +08:00
|
|
|
bool getFontLetterDef(char32_t character, FontLetterDefinition& letterDef) const;
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
void computeStringNumLines();
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-07-17 17:45:11 +08:00
|
|
|
void drawSelf(bool visibleByCamera, Renderer* renderer, uint32_t flags);
|
2015-04-10 14:18:16 +08:00
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
bool multilineTextWrapByChar();
|
|
|
|
bool multilineTextWrapByWord();
|
2017-02-06 16:41:52 +08:00
|
|
|
bool multilineTextWrap(const std::function<int(const std::u32string&, int, int)>& lambda);
|
2016-07-22 18:37:43 +08:00
|
|
|
void shrinkLabelToContentSize(const std::function<bool(void)>& lambda);
|
2015-11-19 16:06:13 +08:00
|
|
|
bool isHorizontalClamp();
|
|
|
|
bool isVerticalClamp();
|
2015-11-20 16:39:48 +08:00
|
|
|
void rescaleWithOriginalFontSize();
|
2015-07-24 18:38:45 +08:00
|
|
|
|
2015-08-13 10:29:58 +08:00
|
|
|
void updateLabelLetters();
|
2015-11-19 16:06:13 +08:00
|
|
|
virtual bool alignText();
|
2015-07-24 18:38:45 +08:00
|
|
|
void computeAlignmentOffset();
|
2017-02-06 16:41:52 +08:00
|
|
|
bool computeHorizontalKernings(const std::u32string& stringToRender);
|
2015-07-24 18:38:45 +08:00
|
|
|
|
2022-08-08 18:02:17 +08:00
|
|
|
void recordLetterInfo(const ax::Vec2& point, char32_t utf32Char, int letterIndex, int lineIndex);
|
2017-02-06 16:41:52 +08:00
|
|
|
void recordPlaceholderInfo(int letterIndex, char32_t utf16Char);
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-11-19 16:06:13 +08:00
|
|
|
bool updateQuads();
|
2013-12-11 16:38:47 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
void createSpriteForSystemFont(const FontDefinition& fontDef);
|
|
|
|
void createShadowSpriteForSystemFont(const FontDefinition& fontDef);
|
2013-12-11 16:38:47 +08:00
|
|
|
|
2014-03-13 21:00:36 +08:00
|
|
|
virtual void updateShaderProgram();
|
2020-08-04 12:11:36 +08:00
|
|
|
virtual void updateBMFontScale();
|
2022-01-03 13:55:52 +08:00
|
|
|
void scaleFontSize(float fontSize);
|
2015-11-19 16:06:13 +08:00
|
|
|
bool setTTFConfigInternal(const TTFConfig& ttfConfig);
|
|
|
|
void setBMFontSizeInternal(float fontSize);
|
2017-01-11 21:34:57 +08:00
|
|
|
bool isHorizontalClamped(float letterPositionX, int lineIndex);
|
2015-11-19 16:06:13 +08:00
|
|
|
void restoreFontSize();
|
2015-11-20 16:39:48 +08:00
|
|
|
void updateLetterSpriteScale(Sprite* sprite);
|
2018-03-13 09:40:24 +08:00
|
|
|
int getFirstCharLen(const std::u32string& utf32Text, int startIndex, int textLen) const;
|
|
|
|
int getFirstWordLen(const std::u32string& utf32Text, int startIndex, int textLen) const;
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2014-03-13 18:46:35 +08:00
|
|
|
void reset();
|
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
FontDefinition _getFontDefinition() const;
|
2015-07-07 14:20:23 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
virtual void updateColor() override;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2019-03-26 13:45:03 +08:00
|
|
|
void updateUniformLocations();
|
2020-08-19 11:46:13 +08:00
|
|
|
void setVertexLayout();
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
void updateBlendState();
|
2021-12-25 10:04:45 +08:00
|
|
|
void updateEffectUniforms(BatchCommand& batch,
|
|
|
|
TextureAtlas* textureAtlas,
|
|
|
|
Renderer* renderer,
|
|
|
|
const Mat4& transform);
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
void updateBuffer(TextureAtlas* textureAtlas, CustomCommand& customCommand);
|
2014-03-17 18:33:15 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
void updateBatchCommand(BatchCommand& batch);
|
2019-04-02 14:56:29 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
LabelType _currentLabelType;
|
2014-03-10 19:42:43 +08:00
|
|
|
bool _contentDirty;
|
2017-02-06 16:41:52 +08:00
|
|
|
std::u32string _utf32Text;
|
2015-07-24 18:38:45 +08:00
|
|
|
std::string _utf8Text;
|
|
|
|
int _numberOfLines;
|
2015-07-14 11:30:56 +08:00
|
|
|
|
|
|
|
std::string _bmFontPath;
|
2020-01-06 09:35:52 +08:00
|
|
|
std::string _bmSubTextureKey;
|
|
|
|
Rect _bmRect;
|
|
|
|
bool _bmRotated;
|
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
TTFConfig _fontConfig;
|
|
|
|
float _outlineSize;
|
2014-04-09 23:31:05 +08:00
|
|
|
|
2014-05-08 21:30:12 +08:00
|
|
|
bool _systemFontDirty;
|
2014-04-09 23:31:05 +08:00
|
|
|
std::string _systemFont;
|
2015-07-14 11:30:56 +08:00
|
|
|
float _systemFontSize;
|
|
|
|
Sprite* _textSprite;
|
|
|
|
Sprite* _shadowNode;
|
2014-03-07 14:58:44 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
FontAtlas* _fontAtlas;
|
2015-07-07 14:20:23 +08:00
|
|
|
Vector<SpriteBatchNode*> _batchNodes;
|
2015-07-14 11:30:56 +08:00
|
|
|
std::vector<LetterInfo> _lettersInfo;
|
2014-03-10 19:42:43 +08:00
|
|
|
|
2013-10-29 20:25:03 +08:00
|
|
|
//! used for optimization
|
2021-12-25 10:04:45 +08:00
|
|
|
Sprite* _reusedLetter;
|
2014-02-19 20:26:14 +08:00
|
|
|
Rect _reusedRect;
|
2015-07-24 18:38:45 +08:00
|
|
|
int _lengthOfString;
|
2014-01-15 17:21:08 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
// layout relevant properties.
|
2015-07-24 18:38:45 +08:00
|
|
|
float _lineHeight;
|
2015-09-29 00:02:17 +08:00
|
|
|
float _lineSpacing;
|
2015-07-24 18:38:45 +08:00
|
|
|
float _additionalKerning;
|
2015-07-14 11:30:56 +08:00
|
|
|
int* _horizontalKernings;
|
|
|
|
bool _lineBreakWithoutSpaces;
|
2015-01-20 11:46:43 +08:00
|
|
|
float _maxLineWidth;
|
2021-10-23 23:27:14 +08:00
|
|
|
Vec2 _labelDimensions;
|
2015-01-20 11:46:43 +08:00
|
|
|
float _labelWidth;
|
|
|
|
float _labelHeight;
|
2014-03-07 14:58:44 +08:00
|
|
|
TextHAlignment _hAlignment;
|
|
|
|
TextVAlignment _vAlignment;
|
|
|
|
|
2015-07-24 18:38:45 +08:00
|
|
|
float _textDesiredHeight;
|
|
|
|
std::vector<float> _linesWidth;
|
|
|
|
std::vector<float> _linesOffsetX;
|
|
|
|
float _letterOffsetY;
|
|
|
|
float _tailoredTopY;
|
|
|
|
float _tailoredBottomY;
|
|
|
|
|
2014-01-17 13:35:58 +08:00
|
|
|
LabelEffect _currLabelEffect;
|
2014-03-20 20:56:10 +08:00
|
|
|
Color4F _effectColorF;
|
2015-07-14 11:30:56 +08:00
|
|
|
Color4B _textColor;
|
|
|
|
Color4F _textColorF;
|
2013-12-13 12:42:15 +08:00
|
|
|
|
2015-08-04 21:49:14 +08:00
|
|
|
QuadCommand _quadCommand;
|
2019-04-02 14:56:29 +08:00
|
|
|
|
|
|
|
std::vector<BatchCommand> _batchCommands;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
|
|
|
Mat4 _shadowTransform;
|
|
|
|
int _uniformEffectColor;
|
|
|
|
int _uniformEffectType; // 0: None, 1: Outline, 2: Shadow; Only used when outline is enabled.
|
|
|
|
int _uniformTextColor;
|
2015-07-14 11:30:56 +08:00
|
|
|
bool _useDistanceField;
|
|
|
|
bool _useA8Shader;
|
2014-02-19 20:26:14 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
bool _shadowDirty;
|
|
|
|
bool _shadowEnabled;
|
2021-10-23 23:27:14 +08:00
|
|
|
Vec2 _shadowOffset;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2015-04-07 11:17:01 +08:00
|
|
|
Color4F _shadowColor4F;
|
|
|
|
Color3B _shadowColor3B;
|
2019-06-05 17:58:33 +08:00
|
|
|
uint8_t _shadowOpacity;
|
2015-07-14 11:30:56 +08:00
|
|
|
float _shadowBlurRadius;
|
2014-03-05 15:54:40 +08:00
|
|
|
|
2014-03-24 14:16:27 +08:00
|
|
|
bool _clipEnabled;
|
2014-03-31 15:45:06 +08:00
|
|
|
bool _blendFuncDirty;
|
2015-07-07 14:20:23 +08:00
|
|
|
BlendFunc _blendFunc;
|
2015-07-14 11:30:56 +08:00
|
|
|
|
|
|
|
/// whether or not the label was inside bounds the previous frame
|
2015-03-19 10:38:12 +08:00
|
|
|
bool _insideBounds;
|
2014-03-24 14:16:27 +08:00
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
bool _isOpacityModifyRGB;
|
|
|
|
|
2015-07-07 14:20:23 +08:00
|
|
|
std::unordered_map<int, Sprite*> _letters;
|
|
|
|
|
2015-07-14 11:30:56 +08:00
|
|
|
EventListenerCustom* _purgeTextureListener;
|
|
|
|
EventListenerCustom* _resetTextureListener;
|
|
|
|
|
2022-07-15 19:17:01 +08:00
|
|
|
#if AX_LABEL_DEBUG_DRAW
|
2015-07-24 18:38:45 +08:00
|
|
|
DrawNode* _debugDrawNode;
|
|
|
|
#endif
|
2015-11-19 16:06:13 +08:00
|
|
|
|
|
|
|
bool _enableWrap;
|
|
|
|
float _bmFontSize;
|
|
|
|
float _bmfontScale;
|
|
|
|
Overflow _overflow;
|
|
|
|
float _originalFontSize;
|
2016-01-20 12:41:31 +08:00
|
|
|
|
|
|
|
bool _boldEnabled;
|
|
|
|
DrawNode* _underlineNode;
|
|
|
|
bool _strikethroughEnabled;
|
2021-12-25 10:04:45 +08:00
|
|
|
|
metal support for cocos2d-x (#19305)
* remove deprecated files
* remove some deprecated codes
* remove more deprecated codes
* remove ui deprecated codes
* remove more deprecated codes
* remove deprecated codes in ccmenuitem
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes in ui
* remove more deprecated codes
* remove more deprecated codes
* remove more deprecated codes
* remove vr related codes and ignore some modules
* remove allocator
* remove some config
* 【Feature】add back-end project file
* [Feature] add back-end file
* add pipeline descriptor and shader cache
* [Feature] support sprite for backend
* [Feature] remove unneeded code
* [Feature] according to es2.0 spec, you must use clamp-to-edge as texture wrap mode, and no mipmapping for non-power-of-two texture
* [Feature] set texture wrap mode to clamp-to-edge, and no mipmapping for non-power-of-two texture
* [Feature] remove macro define to .cpp file
* [Feature] add log info
* [Feature] add PipelineDescriptor for TriangleCommand
* [Feature] add PipelineDescriptor object as member of TriangleCommand
* [Feature] add getPipelineDescriptor method
* add renderbackend
* complete pipeline descriptor
* [Feature] add viewport in RenderCommand
* set viewport when rendrering
* [Feature] occur error when using RendererBackend, to be fixed.
* a workaround to fix black screen on macOS 10.14 (#19090)
* add rendererbackend init function
* fix typo
* [Feature] modify testFile
* [BugFix] modify shader path
* [Feature] set default viewport
* fix projection
* [Feature] modify log info
* [BugFix] change viewport data type to int
* [BugFix] add BindGroup to PipelienDescriptor
* [BugFix] change a_position to vec3 in sprite.vert
* [BugFix] set vertexLayout according to V3F_C4B_T2F structure
* [Feature] revert a_position to vec4
* [Feature] renderer should not use gl codes directly
* [Feature] it's better not use default value parameter
* fix depth test setting
* rendererbackend -> renderer
* clear color and depth at begin
* add metal backend
* metal support normalized attribute
* simplify codes
* update external
* add render pass desctriptor in pipeline descriptor
* fix warnings
* fix crash and memeory leak
* refactor Texture2D
* put pipeline descriptor into render command
* simplify codes
* [Feature] update Sprite
* fix crash when closing app
* [Feature] update SpriteBatchNode and TextureAtlas
* support render texture(not finish)
* [Feature] remove unused code
* make tests work on mac
* fix download-deps path error
* make tests work on iOS
* [Feature] support ttf under normal label effect
* refactor triangle command processing
* let renderer handle more common commands
* refactor backend
* make render texture work
* [Feature] refactor backend for GL
* [Feature]Renaming to make it easy to understand
* [Feature] change warp mode to CLAMP_TO_EDGE
* fix ghost
* simplify visit render queue logic
* support progress timer without rial mode
* support partcile system
* Feature/update label (#149)
* [BugFix] fix compile error
* [Feature] support outline effect in ios
* [Feature] add shader file
* [BugFix] fix begin and end RenderPass
* [Feature] update CustomCommand
* [Feature] revert project.pbxproj
* [Feature] simplify codes
* [BugFix] pack AI88 to RGBA8888 only when outline enable
* [Feature] support shadow effect in Label
* [Feature] support BMFont
* [Feature] support glow effect
* [Feature] simplify shader files
* LabelAtlas work
* handle blend function correctly
* support tile map
* don't share buffer in metal
* alloc buffer size as needed
* support more tilemap
* Merge branch 'minggo/metal-support' into feature/updateLabel
* minggo/metal-support:
support tile map
handle blend function correctly
LabelAtlas work
Feature/update label (#149)
support partcile system
# Conflicts:
# cocos/2d/CCLabel.cpp
# cocos/2d/CCSprite.cpp
# cocos/2d/CCSpriteBatchNode.cpp
# cocos/renderer/CCQuadCommand.cpp
# cocos/renderer/CCQuadCommand.h
* render texture work without saving file
* use global viewport
* grid3d works
* remove grabber
* tiled3d works
* [BugFix] fix label bug
* [Feature] add updateSubData for buffer
* [Feature] remove setVertexCount
* support depth test
* add callback command
* [Feature] add UITest
* [Feature] update UITest
* [Feature] remove unneeded codes
* fix custom command issue
* fix layer color blend issue
* [BugFix] fix iOS compile error
* [Feature] remove unneeded codes
* [Feature] fix updateVertexBuffer
* layerradial works
* add draw test back
* fix batch issue
* fix compiling error
* [BugFix] support ETC1
* [BugFix] get the correct pipelineDescriptor
* [BugFix] skip draw when backendTexture nullptr
* clipping node support
* [Feature] add shader files
* fix stencil issue in metal
* [Feature] update UILayoutTest
* [BugFix] skip drawing when vertexCount is zero
* refactor renderer
* add set global z order for stencil manager commands
* fix warnings caused by type
* remove viewport in render command
* [Feature] fix warnings caused by type
* [BugFix] clear vertexCount and indexCount for CustomComand when needed
* [Feature] update clear for CustomCommand
* ios use metal
* fix viewport issue
* fix LayerColorGradient crash
* [cmake] transport to android and windows (#160)
* save point 1
* compile on windows
* run on android
* revert useless change
* android set CC_ENABLE_CACHE_TEXTURE_DATA to 1
* add initGlew
* fix android crash
* add TODO new-renderer
* review update
* revert onGLFWWindowPosCallback
* fix android compiling error
* Impl progress radial (#162)
* progresstimer add radial impl
* default drawType to element
* dec invoke times of createVertexBuffer (#163)
* support depth/stencil format for gl backend
* simplify progress timer codes
* support motionstreak, effect is wrong
* fix motionstreak issue
* [Feature] update Scissor Test (#161)
* [Feature] update Scissor Test
* [Feature] update ScissorTest
* [Feature] rename function
* [Feature] get constant reference if needed
* [Feature] show render status (#164)
* improve performance
* fix depth state
* fill error that triangle vertex/index number bigger than buffer
* fix compiline error in release mode
* fix buffer conflict between CPU and GPU on iOS/macOS
* Renderer refactor (#165)
* use one vertes/index buffer with opengl
* fix error on windows
* custom command support index format config
* CCLayer: compact vertex data structure
* update comment
* fix doc
* support fast tilemap
* pass index format instead
* fix some wrong effect
* fix render texture error
* fix texture per-element size
* fix texture format error
* BlendFunc type refactor, GLenum -> backend::BlendFactor (#167)
* BlendFunc use backend::BlendFactor as inner field
* update comments
* use int to replace GLenum
* update xcode project fiel
* rename to GLBlendConst
* add ccConstants.h
* update xcode project file
* update copyright
* remove primitive command
* remove CCPrimitive.cpp/.h
* remove deprecated files
* remove unneeded files
* remove multiple view support
* remove multiple view support
* remove the usage of frame buffer in camera
* director don't use frame buffer
* remove FrameBuffer
* remove BatchCommand
* add some api reference
* add physics2d back
* fix crash when close app on mac
* improve render texture
* fix rendertexture issue
* fix rendertexture issue
* simplify codes
* CMake support for mac & ios (#169)
* update cmake
* fix compile error
* update 3rd libs version
* remove CCThread.h/.cpp
* remove ccthread
* use audio engine to implement simple audio engine
* remove unneeded codes
* remove deprecated codes
* remove winrt macro
* remove CC_USE_WIC
* set partcile blend function in more elegant way
* remove unneeded codes
* remove unneeded codes
* cmake works on windows
* update project setting
* improve performance
* GLFloat -> float
* sync v3 cmake improvements into metal-support (#172)
* pick: modern cmake, compile definitions improvement (#19139)
* modern cmake, use target_compile_definitions partly
* simplify macro define, remove USE_*
* modern cmake, macro define
* add physics 2d macro define into ccConfig.h
* remove USE_CHIPMUNK macro in build.gradle
* remove CocosSelectModule.cmake
* shrink useless define
* simplify compile options config, re-add if necessary
* update external for tmp CI test
* un-quote target_compile_options value
* add "-g" parameter only when debug mode
* keep single build type when generator Xcode & VS projecy
* update external for tmp CI tes
* add static_cast<char>(-1), fix -Wc++11-narrowing
* simplify win32 compile define
* not modify code, only improve compile options
# Conflicts:
# .gitignore
# cmake/Modules/CocosConfigDepend.cmake
# cocos/CMakeLists.txt
# external/config.json
# tests/cpp-tests/CMakeLists.txt
* modern cmake, improve cmake_compiler_flags (#19145)
* cmake_compiler_flags
* Fix typo
* Fix typo2
* Remove chanages from Android.mk
* correct lua template cmake build (#19149)
* don't add -Wno-deprecated into jsb target
* correct lua template cmake build
* fix win32 lua template compile error
* prevent cmake in-source-build friendly (#19151)
* pick: Copy resources to "Resources/" on win32 like in linux configuration
* add "/Z7" for cpp-tests on windows
* [cmake] fix iOS xcode property setting failed (#19208)
* fix iOS xcode property setting failed
* use search_depend_libs_recursive at dlls collect
* fix typo
* [cmake] add find_host_library into iOS toolchain file (#19230)
* pick: [lua android] use luajit & template cmake update (#19239)
* increase cmake stability , remove tests/CMakeLists.txt (#19261)
* cmake win32 Precompiled header (#19273)
* Precompiled header
* Fix
* Precompiled header for cocos
* Precompiled header jscocos2d
* Fix for COCOS2D_DEBUG is always 1 on Android (#19291)
Related #19289
* little build fix, tests cpp-tests works on mac
* sync v3 build related codes into metal-support (#173)
* strict initialization for std::array
* remove proj.win32 project configs
* modern cmake, cmake_cleanup_remove_unused_variables (#19146)
* Switch travis CI to xenial (#19207)
* Switch travis CI to xenial
* Remove language: android
* Set language: cpp
* Fix java problem
* Update sdkmanager
* Fix sdkmanger
* next sdkmanager fix
* Remove xenial from android
* revert to sdk-tools-{system}-3859397
* Remove linux cmake install
* Update before-install.sh
* Update .travis.yml
* Simplify install-deps-linux.sh, tested on Ubuntu 16.04 (#19212)
* Simplify install-deps-linux.sh
* Cleanup
* pick: install ninja
* update cocos2d-console submodule
* for metal-support alpha release, we only test cpp
* add HelloCpp into project(Cocos2d-x) for tmp test
* update extenal metal-support-4
* update uniform setting
* [Feature] update BindGroup
* [Feature] empty-test
* [Feature] cpp-test
* [Feature] fix GL compiler error
* [Feature] fix GL crash
* [Feature] empty-test
* [Feature] cpp-tests
* [feature] improve frameRate
* [feature] fix opengl compile error
* [feature] fix opengl compile error
* [BugFix] fix compute maxLocation error
* [Feature] update setting unifrom
* [Feature] fix namespace
* [Feature] remove unneeded code
* [Bugfix] fix project file
* [Feature] update review
* [texture2d] impl texture format support (#175)
* texture update
* update
* update texture
* commit
* compile on windows
* ddd
* rename
* rename methods
* no crash
* save gl
* save
* save
* rename
* move out pixel format convert functions
* metal crash
* update
* update android
* support gles compressed texture format
* support more compress format
* add more conversion methods
* ss
* save
* update conversion methods
* add PVRTC format support
* reformat
* add marco linux
* fix GL marcro
* pvrtc supported only by ios 8.0+
* remove unused cmake
* revert change
* refactor Texture2D::initWithData
* fix conversion log
* refactor Texture2D::initWithData
* remove some OpenGL constants for PVRTC
* add todo
* fix typo
* AutoTest works on mac/iOS by disable part cases, sync v3 bug fix (#174)
* review cpp-tests, and fix part issues on start auto test
* sync png format fix: Node:Particle3D abnormal texture effects #19204
* fix cpp-tests SpritePolygon crash, wrong png format (#19170)
* fix wrong png convert format from sRGB to Gray
* erase plist index if all frames was erased
* test_A8.png have I8 format, fix it
* [CCSpriteCache] allow re-add plist & add testcase (#19175)
* allow re-add plist & add testcase
* remove comments/rename method/update testcase
* fix isSpriteFramesWithFileLoaded & add testcase
* remove used variable
* remove unused variable
* fix double free issues when js/lua-tests exit on iOS (#19236)
* disable part cases, AutoTest works without crash on mac
* update cocos2dx files json, to test cocos new next
* fix spritecache plist parsing issue (#19269)
* [linux] Fix FileUtils::getContents with folder (#19157)
* fix FileUtils::getContents on linux/mac
* use stat.st_mode
* simplify
* [CCFileUtils] win32 getFileSize (#19176)
* win32 getFileSize
* fix stat
* [cpp test-Android]20:FileUtils/2 change title (#19197)
* sync #19200
* sync #19231
* [android lua] improve performance of lua loader (#19234)
* [lua] improve performance of lua loader
* remove cache fix
* Revert "fix spritecache plist parsing issue (#19269)"
This reverts commit f3a85ece4307a7b90816c34489d1ed2c8fd11baf.
* remove win32 project files ref in template.json
* add metal framework lnk ref into cpp template
* test on iOS, and disable part cases
* alBufferData instead of alBufferDataStatic for small audio file on Apple (#19227)
* changes AudioCache to use alBufferData instead of alBufferDataStatic
(also makes test 19 faster to trigger openal bugs faster)
The original problem: CrashIfClientProvidedBogusAudioBufferList
https://github.com/cocos2d/cocos2d-x/issues/18948
is not happening anymore, but there's still a not very frequent issue
that makes OpenAL crash with a call stack like this.
AudioCache::readDataTask > alBufferData > CleanUpDeadBufferList
It happes more frequently when the device is "cold", which means after
half an hour of not using the device (locked).
I could not find the actual source code for iOS OpenAL, so I used the
macOS versions:
https://opensource.apple.com/source/OpenAL/OpenAL-48.7/Source/OpenAL/oalImp.cpp.auto.html
They seem to use CAGuard.h to make sure the dead buffer list
has no threading issues. I'm worried because the CAGuard code I found
has macos and win32 define but no iOS, so I'm not sure. I guess the
iOS version is different and has the guard.
I could not find a place in the code that's unprotected by the locks
except the InitializeBufferMap() which should not be called more than
once from cocos, and there's a workaround in AudioEngine-impl for it.
I reduced the occurence of the CleanUpDeadBufferList crash by moving
the guard in ~AudioCache to cover the alDeleteBuffers call.
* remove hack method "setTimeout" on audio
* AutoTest works on iOS
* support set ios deployment target for root project
* enable all texture2d cases, since Jiang have fixed
* add CCTextureUtils to xcode project file (#176)
* add leak cases for SpriteFrameCache (#177)
* re-add SpriteFrameCache cases
* update template file json
* Update SpriteFrameCacheTest.cpp
* fix compiling error
2019-01-18 15:08:25 +08:00
|
|
|
backend::UniformLocation _mvpMatrixLocation;
|
|
|
|
backend::UniformLocation _textureLocation;
|
|
|
|
backend::UniformLocation _textColorLocation;
|
|
|
|
backend::UniformLocation _effectColorLocation;
|
|
|
|
backend::UniformLocation _effectTypeLocation;
|
2016-01-20 12:41:31 +08:00
|
|
|
|
2014-03-05 15:54:40 +08:00
|
|
|
private:
|
2022-07-15 19:17:01 +08:00
|
|
|
AX_DISALLOW_COPY_AND_ASSIGN(Label);
|
2013-07-23 02:17:51 +08:00
|
|
|
};
|
|
|
|
|
2015-03-19 10:38:12 +08:00
|
|
|
// end group
|
|
|
|
/// @}
|
2013-08-08 07:36:04 +08:00
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
NS_AX_END
|
2013-07-23 02:17:51 +08:00
|
|
|
|
|
|
|
#endif /*__COCOS2D_CCLABEL_H */
|