Skip to content

Commit

Permalink
Merge branch 'v3.8.2' of https://github.com/cocos/cocos-engine into p…
Browse files Browse the repository at this point in the history
…article
  • Loading branch information
SantyWang committed Oct 16, 2023
2 parents 2355983 + 590ef33 commit 08ae061
Show file tree
Hide file tree
Showing 325 changed files with 23,215 additions and 10,229 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/generate-android-ndk-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: <Native> Generate Android NDK Cache

on:
workflow_dispatch:
inputs:
android_ndk_sdk_version:
description: 'Android NDK Version'
type: string
default: 'r21e'
required: true

jobs:
generate_android_ndk_cache:
name: "Generate Android NDK Cache"
runs-on: ubuntu-latest
steps:
- name: Setup Android NDK
uses: nttld/setup-ndk@v1
id: setup-ndk
with:
ndk-version: ${{ github.event.inputs.android_ndk_sdk_version }}
local-cache: true

- name: Verify
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
run: |
cd ${ANDROID_NDK_HOME}
cat source.properties
platform=$(uname -s | tr '[:upper:]' '[:lower:]')
./toolchains/llvm/prebuilt/${platform}-x86_64/bin/clang -v
26 changes: 26 additions & 0 deletions .github/workflows/generate-emsdk-cache.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: <Native> Generate Emsdk Cache

on:
workflow_dispatch:
inputs:
emsdk_version:
description: 'Emsdk version'
type: string
default: '3.1.45'
required: true

jobs:
generate_emsdk_cache:
name: "Generate Emsdk cache"
runs-on: ubuntu-latest
steps:
- name: Setup emsdk
uses: dumganhar/setup-emsdk@997d2cde2deabda085a11f98e86e842915b0e846
with:
version: ${{ github.event.inputs.emsdk_version }}
actions-cache-folder: 'emsdk-cache'

- name: Verify
run: |
which emcc
emcc -v
1 change: 1 addition & 0 deletions .github/workflows/native-bindings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
with:
ndk-version: r21e
add-to-path: false
local-cache: true
- name: Generate decorators
env:
ANDROID_NDK_HOME: ${{ steps.setup-ndk.outputs.ndk-path }}
Expand Down
38 changes: 5 additions & 33 deletions .github/workflows/native-compile-platforms.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ jobs:
with:
ndk-version: r21e
add-to-path: false
local-cache: true
- uses: actions/setup-java@v3
id: setup-jdk
with:
Expand Down Expand Up @@ -163,6 +164,7 @@ jobs:
with:
ndk-version: r21e
add-to-path: false
local-cache: true
- uses: actions/setup-java@v3
id: setup-jdk
with:
Expand Down Expand Up @@ -331,6 +333,8 @@ jobs:
echo "set(CMAKE_CXX_STANDARD_REQUIRED ON)" >> build-oh/proj/cfg.cmake
echo "set(COCOS_X_PATH $NATIVE_ROOT)" >> build-oh/proj/cfg.cmake
echo "set(CC_EXECUTABLE_NAME \"\")" >> build-oh/proj/cfg.cmake
echo "set(USE_SE_V8 OFF)" >> build-oh/proj/cfg.cmake
echo "set(USE_SE_NAPI ON)" >> build-oh/proj/cfg.cmake
echo "=============== cat build-oh/proj/cfg.cmake ==============="
cat build-oh/proj/cfg.cmake
Expand Down Expand Up @@ -364,9 +368,7 @@ jobs:
echo "{\"hvigorVersion\":\"3.0.2\",\"dependencies\":{\"@ohos/hvigor-ohos-plugin\":\"3.0.2\"}}" > ./hvigor/hvigor-config.json5
echo "=============== Do not import game.ts for cocos_worker.ts ==============="
sed -i "s@import . launchEngine .@const window = globalThis;//@g" ./entry/src/main/ets/workers/cocos_worker.ts
sed -i 's@launchEngine().then@/*@g' ./entry/src/main/ets/workers/cocos_worker.ts
sed -i '[email protected]@*/window.oh.postMessage@g' ./entry/src/main/ets/workers/cocos_worker.ts
sed -i '/<% if(!useV8) { %>/,/<% } %>/d' ./entry/src/main/ets/workers/cocos_worker.ts
echo "=============== EXECUTE hvigorw ==============="
./hvigorw clean -i
Expand Down Expand Up @@ -529,33 +531,3 @@ jobs:
cmake --build . --config Debug -- -jobs $NUM_OF_CORES CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO
fi
echo "Compile iOS Done!"
compile_wgpu_mac:
name: "Emscripten"
runs-on: macos-latest
if: contains( github.event.pull_request.title, 'WGPU_CI_ON' )
steps:
- uses: actions/checkout@v2
- name: Download external libraries
shell: bash
run: |
EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
- name: Setup Emscripten
run: |
NATIVE_ROOT=$GITHUB_WORKSPACE/native
git clone https://github.com/emscripten-core/emsdk.git NATIVE_ROOT/../../emsdk
cd NATIVE_ROOT/../../emsdk
./emsdk install 3.1.17
./emsdk activate 3.1.17
source ./emsdk_env.sh
emcc -v
- name: Compile
env:
COCOS_ENGINE_DEV: 1
run: |
NATIVE_ROOT=$GITHUB_WORKSPACE/native
cd $NATIVE_ROOT/cocos/renderer/gfx-wgpu
$NATIVE_ROOT/../../emsdk/upstream/emscripten/emcmake cmake .
$NATIVE_ROOT/../../emsdk/upstream/emscripten/emmake make
echo "Compile WGPU by ems on MacOS Done!"
66 changes: 66 additions & 0 deletions .github/workflows/native-compile-webgpu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: <Native> Compile WebGPU

on:
pull_request:
paths:
- 'native/external-config.json'
- 'native/cocos/base/**'
- 'native/cocos/renderer/gfx-base/**'
- 'native/cocos/renderer/gfx-wgpu/**'
- 'native/cocos/renderer/gfx-validator/**'
- 'native/cocos/renderer/gfx-empty/**'
- '.github/workflows/native-compile-webgpu.yml'

# github.head_ref is only defined on pull_request events
concurrency:
group: ${{ github.workflow }}-${{ github.actor }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
compile_wgpu:
if:
(! contains(github.event.pull_request.body, '[X] does not change any runtime related code or build configuration'))
name: "Emscripten"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Download external libraries
shell: bash
run: |
EXT_VERSION=`node ./.github/workflows/get-native-external-version.js`
git clone --branch $EXT_VERSION --depth 1 https://github.com/cocos/cocos-engine-external native/external
- name: Setup emsdk
uses: dumganhar/setup-emsdk@997d2cde2deabda085a11f98e86e842915b0e846
with:
version: 3.1.45
actions-cache-folder: 'emsdk-cache'

- name: Verify
run: |
which emcc
emcc -v
- name: Install ninja
run: |
if ! command -v ninja &> /dev/null; then
echo "Ninja not found, installing..."
# sudo apt update
sudo apt install ninja-build
else
echo "Ninja is already installed."
fi
which ninja
- name: Compile
# env:
# COCOS_ENGINE_DEV: 1
run: |
NATIVE_ROOT=$GITHUB_WORKSPACE/native
cd $NATIVE_ROOT/cocos/renderer/gfx-wgpu
mkdir build
cd build
cmake .. -GNinja -DCMAKE_TOOLCHAIN_FILE=${EMSDK}/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_BUILD_TYPE=Debug
ninja
echo "============== Compile WGPU by ems on Ubuntu Done! =============="
1 change: 1 addition & 0 deletions .github/workflows/native-linter-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
with:
ndk-version: r21e
add-to-path: false
local-cache: true
- name: Get changed files
uses: PatriceJiang/paths-filter@master
id: listchanged
Expand Down
6 changes: 6 additions & 0 deletions @types/jsb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ declare namespace jsb {
id: number;
axisInfoList: AxisInfo[],
buttonInfoList: ButtonInfo[],
touchInfoList: TouchInfo[],
}

export interface AxisInfo {
Expand All @@ -92,6 +93,11 @@ declare namespace jsb {
isPressed: boolean,
}

export interface TouchInfo {
code: number,
value: number,
}

export let onControllerInput: (infoList: ControllerInfo[]) => void | undefined;
export let onHandleInput: (infoList: ControllerInfo[]) => void | undefined;
export let onControllerChange: (controllerIds: number[]) => void | undefined;
Expand Down
14 changes: 7 additions & 7 deletions cocos/2d/assembler/label/letter-font.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import { js } from '../../../core';
import { Label, LabelOutline } from '../../components';
import { bmfontUtils } from './bmfontUtils';
import { shareLabelInfo, LetterAtlas, computeHash } from './font-utils';
import { shareLabelInfo, LetterAtlas, computeHash, LetterRenderTexture } from './font-utils';

const _atlasWidth = 1024;
const _atlasHeight = 1024;
Expand All @@ -39,20 +39,20 @@ export const letterFont = js.mixin(bmfontUtils, {
_shareAtlas = new LetterAtlas(_atlasWidth, _atlasHeight);
}

return _shareAtlas.getTexture();
return _shareAtlas.getTexture() as LetterRenderTexture | null;
},

_updateFontFamily (comp) {
shareLabelInfo.fontAtlas = _shareAtlas;
shareLabelInfo.fontFamily = this._getFontFamily(comp);

// outline
const outline = comp.getComponent(LabelOutline);
if (outline && outline.enabled) {
const isOutlined = comp.enableOutline && comp.outlineWidth > 0;
if (isOutlined) {
shareLabelInfo.isOutlined = true;
shareLabelInfo.margin = outline.width;
shareLabelInfo.out = outline.color.clone();
shareLabelInfo.out.a = outline.color.a * comp.color.a / 255.0;
shareLabelInfo.margin = comp.outlineWidth;
shareLabelInfo.out = comp.outlineColor.clone();
shareLabelInfo.out.a = comp.outlineColor.color.a * comp.color.a / 255.0;
} else {
shareLabelInfo.isOutlined = false;
shareLabelInfo.margin = 0;
Expand Down
48 changes: 31 additions & 17 deletions cocos/2d/assembler/label/ttfUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
import { Label, LabelOutline, LabelShadow } from '../../components';
import { Label } from '../../components';
import { ISharedLabelData } from './font-utils';
import { UITransform } from '../../framework/ui-transform';
import { dynamicAtlasManager } from '../../utils/dynamic-atlas/atlas-manager';
Expand All @@ -30,13 +30,20 @@ import { TextOutputLayoutData, TextOutputRenderData } from './text-output-data';
import { TextStyle } from './text-style';
import { TextLayout } from './text-layout';
import { view } from '../../../ui/view';
import { approx } from '../../../core';

const Overflow = Label.Overflow;

export const ttfUtils = {

updateProcessingData (style: TextStyle, layout: TextLayout,
outputLayoutData: TextOutputLayoutData, outputRenderData: TextOutputRenderData, comp: Label, trans: UITransform): void {
updateProcessingData (
style: TextStyle,
layout: TextLayout,
outputLayoutData: TextOutputLayoutData,
outputRenderData: TextOutputRenderData,
comp: Label,
trans: UITransform,
): void {
// font info // both
style.isSystemFontUsed = comp.useSystemFont;
style.fontSize = comp.fontSize;
Expand All @@ -62,25 +69,23 @@ export const ttfUtils = {
style.underlineHeight = comp.underlineHeight;

// outline// both
let outlineComp = LabelOutline && comp.getComponent(LabelOutline);
outlineComp = (outlineComp && outlineComp.enabled && outlineComp.width > 0) ? outlineComp : null;
if (outlineComp) {
const isOutlined = comp.enableOutline && comp.outlineWidth > 0;
if (isOutlined) {
style.isOutlined = true;
style.outlineColor.set(outlineComp.color);
style.outlineWidth = outlineComp.width;
style.outlineColor.set(comp.outlineColor);
style.outlineWidth = comp.outlineWidth;
} else {
style.isOutlined = false;
}

// shadow// both
let shadowComp = LabelShadow && comp.getComponent(LabelShadow);
shadowComp = (shadowComp && shadowComp.enabled) ? shadowComp : null;
if (shadowComp) {
const isShadow = comp.enableShadow && (comp.shadowBlur > 0 || !approx(comp.shadowOffset.x, 0) || !approx(comp.shadowOffset.y, 0));
if (isShadow) {
style.hasShadow = true;
style.shadowColor.set(shadowComp.color);
style.shadowBlur = shadowComp.blur;
style.shadowOffsetX = shadowComp.offset.x;
style.shadowOffsetY = shadowComp.offset.y;
style.shadowColor.set(comp.shadowColor);
style.shadowBlur = comp.shadowBlur;
style.shadowOffsetX = comp.shadowOffset.x;
style.shadowOffsetY = comp.shadowOffset.y;
} else {
style.hasShadow = false;
}
Expand Down Expand Up @@ -126,8 +131,15 @@ export const ttfUtils = {

// TextProcessing
processing.processingString(false, style, layout, outputLayoutData, comp.string);
processing.generateRenderInfo(false, style, layout, outputLayoutData, outputRenderData,
comp.string, this.generateVertexData);
processing.generateRenderInfo(
false,
style,
layout,
outputLayoutData,
outputRenderData,
comp.string,
this.generateVertexData,
);

const renderData = comp.renderData;
renderData.textureDirty = true;
Expand Down Expand Up @@ -173,9 +185,11 @@ export const ttfUtils = {
},

updateVertexData (comp: Label): void {
// no needs to update vertex data
},

updateUVs (comp: Label): void {
// no needs to update uv data
},

_updateFontFamily (comp: Label): string {
Expand Down
Loading

0 comments on commit 08ae061

Please sign in to comment.