Skip to content

Commit

Permalink
Merge branch 'v3.8.1' into develop-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
star-e committed Jul 19, 2023
2 parents fc488eb + 839a086 commit fabb7fe
Show file tree
Hide file tree
Showing 156 changed files with 7,347 additions and 5,690 deletions.
7 changes: 4 additions & 3 deletions .eslintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ extends:
- plugin:@typescript-eslint/recommended
- plugin:@typescript-eslint/recommended-requiring-type-checking

plugins:
- '@typescript-eslint'
plugins: ["@typescript-eslint"]

settings:
import/resolver:
Expand Down Expand Up @@ -146,4 +145,6 @@ rules:

# Prefer the interface style.
'@typescript-eslint/consistent-type-definitions': [error, interface]
'@typescript-eslint/explicit-function-return-type': [error]
'@typescript-eslint/explicit-function-return-type': [error, {
allowIIFEs: true, # IIFEs are widely used, writing their signature twice is painful
}]
4 changes: 2 additions & 2 deletions .github/workflows/web-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ jobs:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 12
node-version: '16.x'

- name: Download external
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
- run: npm ci
- run: npx npm@6 ci

- name: Run ESLint
shell: pwsh
Expand Down
4 changes: 4 additions & 0 deletions EngineErrorMap.md
Original file line number Diff line number Diff line change
Expand Up @@ -2911,6 +2911,10 @@ Spine: Animation not found: %s

Spine: Animation not found: %s

### 7511

Spine: Invalid input!

### 7600

The context of RenderTexture is invalid.
Expand Down
4 changes: 2 additions & 2 deletions cocos/3d/reflection-probe/reflection-probe-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export class ReflectionProbe extends Component {
* @zh 设置探针类型,环境反射或者平面反射
*/
@type(Enum(ProbeType))
set probeType (value: number) {
set probeType (value: ProbeType) {
this.probe.probeType = value;
if (value !== this._probeType) {
const lastSize = this._size.clone();
Expand Down Expand Up @@ -163,7 +163,7 @@ export class ReflectionProbe extends Component {
this.size = this._size;
}
}
get probeType (): number {
get probeType (): ProbeType {
return this._probeType;
}

Expand Down
74 changes: 48 additions & 26 deletions cocos/audio/audio-source.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
THE SOFTWARE.
*/

import { AudioPlayer } from 'pal/audio';
import { AudioPlayer, OneShotAudio } from 'pal/audio';
import { ccclass, help, menu, tooltip, type, range, serializable } from 'cc.decorator';
import { AudioPCMDataView, AudioState } from '../../pal/audio/type';
import { Component } from '../scene-graph/component';
Expand Down Expand Up @@ -59,6 +59,7 @@ export class AudioSource extends Component {
@type(AudioClip)
protected _clip: AudioClip | null = null;
protected _player: AudioPlayer | null = null;
private _hasRegisterListener: boolean = false;

@serializable
protected _loop = false;
Expand All @@ -78,9 +79,7 @@ export class AudioSource extends Component {
private _resetPlayer (): void {
if (this._player) {
audioManager.removePlaying(this._player);
this._player.offEnded();
this._player.offInterruptionBegin();
this._player.offInterruptionEnd();
this._unregisterListener();
this._player.destroy();
this._player = null;
}
Expand Down Expand Up @@ -137,6 +136,14 @@ export class AudioSource extends Component {
// clear old player
this._resetPlayer();
this._player = player;
this._syncStates();
this.node?.emit(_LOADED_EVENT);
}).catch((e) => {});
}

private _registerListener (): void {
if (!this._hasRegisterListener && this._player) {
const player = this._player;
player.onEnded(() => {
audioManager.removePlaying(player);
this.node?.emit(AudioSourceEventType.ENDED, this);
Expand All @@ -145,11 +152,21 @@ export class AudioSource extends Component {
audioManager.removePlaying(player);
});
player.onInterruptionEnd(() => {
audioManager.addPlaying(player);
if (this._player === player) {
audioManager.addPlaying(player);
}
});
this._syncStates();
this.node?.emit(_LOADED_EVENT);
}).catch((e) => {});
this._hasRegisterListener = true;
}
}

private _unregisterListener (): void {
if (this._player && this._hasRegisterListener) {
this._player.offEnded();
this._player.offInterruptionBegin();
this._player.offInterruptionEnd();
this._hasRegisterListener = false;
}
}

/**
Expand Down Expand Up @@ -233,8 +250,7 @@ export class AudioSource extends Component {

public onDestroy (): void {
this.stop();
this._player?.destroy();
this._player = null;
this.clip = null;// It will trigger _syncPlayer then call resetPlayer
}
/**
* @en
Expand Down Expand Up @@ -334,16 +350,21 @@ export class AudioSource extends Component {
this._operationsBeforeLoading.push('play');
return;
}
this._registerListener();
audioManager.discardOnePlayingIfNeeded();
// Replay if the audio is playing
if (this.state === AudioState.PLAYING) {
this._player?.stop().catch((e) => {});
}
const player = this._player;
this._player?.play().then(() => {
audioManager.addPlaying(player!);
this.node?.emit(AudioSourceEventType.STARTED, this);
}).catch((e) => {});
if (player) {
player.play().then(() => {
this.node?.emit(AudioSourceEventType.STARTED, this);
}).catch((e) => {
audioManager.removePlaying(player);
});
audioManager.addPlaying(player);
}
}

/**
Expand All @@ -357,10 +378,7 @@ export class AudioSource extends Component {
this._operationsBeforeLoading.push('pause');
return;
}
const player = this._player;
this._player?.pause().then(() => {
audioManager.removePlaying(player!);
}).catch((e) => {});
this._player?.pause().catch((e) => {});
}

/**
Expand All @@ -374,10 +392,10 @@ export class AudioSource extends Component {
this._operationsBeforeLoading.push('stop');
return;
}
const player = this._player;
this._player?.stop().then(() => {
audioManager.removePlaying(player!);
}).catch((e) => {});
if (this._player) {
this._player.stop().catch((e) => {});
audioManager.removePlaying(this._player);
}
}

/**
Expand All @@ -393,18 +411,22 @@ export class AudioSource extends Component {
error('Invalid audio clip');
return;
}
let player: OneShotAudio;
AudioPlayer.loadOneShotAudio(clip._nativeAsset.url, this._volume * volumeScale, {
audioLoadMode: clip.loadMode,
}).then((oneShotAudio) => {
player = oneShotAudio;
audioManager.discardOnePlayingIfNeeded();
oneShotAudio.onPlay = (): void => {
audioManager.addPlaying(oneShotAudio);
};
oneShotAudio.onEnd = (): void => {
audioManager.removePlaying(oneShotAudio);
};
oneShotAudio.play();
}).catch((e): void => {});
audioManager.addPlaying(oneShotAudio);
}).catch((e): void => {
if (player) {
audioManager.removePlaying(player);
}
});
}

protected _syncStates (): void {
Expand Down
32 changes: 23 additions & 9 deletions cocos/gfx/base/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* eslint-disable no-empty-function */

import { Queue } from './queue';
import { Buffer } from './buffer';
Expand Down Expand Up @@ -129,6 +130,7 @@ export enum Feature {
SUBPASS_COLOR_INPUT,
SUBPASS_DEPTH_STENCIL_INPUT,
RASTERIZATION_ORDER_COHERENT,
MULTI_SAMPLE_RESOLVE_DEPTH_STENCIL,
COUNT,
}

Expand Down Expand Up @@ -406,6 +408,7 @@ export enum TextureFlagBit {
EXTERNAL_OES = 0x4, // External oes texture
EXTERNAL_NORMAL = 0x8, // External normal texture
MUTABLE_STORAGE = 0x10, // Texture is mutable or not, default is immutable(only for webgl2)
LAZILY_ALLOCATED = 0x20, // Try lazily allocated mode.
}

export enum FormatFeatureBit {
Expand All @@ -418,10 +421,13 @@ export enum FormatFeatureBit {
}

export enum SampleCount {
ONE, // Single sample
MULTIPLE_PERFORMANCE, // Multiple samples prioritizing performance over quality
MULTIPLE_BALANCE, // Multiple samples leveraging both quality and performance
MULTIPLE_QUALITY, // Multiple samples prioritizing quality over performance
X1 = 0x01,
X2 = 0x02,
X4 = 0x04,
X8 = 0x08,
X16 = 0x10,
X32 = 0x20,
X64 = 0x40
}

export enum VsyncMode {
Expand Down Expand Up @@ -1172,7 +1178,7 @@ export class TextureInfo {
public flags: TextureFlags = TextureFlagBit.NONE,
public layerCount: number = 1,
public levelCount: number = 1,
public samples: SampleCount = SampleCount.ONE,
public samples: SampleCount = SampleCount.X1,
public depth: number = 1,
public externalRes: number = 0,
) {}
Expand Down Expand Up @@ -1512,7 +1518,7 @@ export class ColorAttachment {

constructor (
public format: Format = Format.UNKNOWN,
public sampleCount: SampleCount = SampleCount.ONE,
public sampleCount: SampleCount = SampleCount.X1,
public loadOp: LoadOp = LoadOp.CLEAR,
public storeOp: StoreOp = StoreOp.STORE,
public barrier: GeneralBarrier = null!,
Expand All @@ -1533,7 +1539,7 @@ export class DepthStencilAttachment {

constructor (
public format: Format = Format.UNKNOWN,
public sampleCount: SampleCount = SampleCount.ONE,
public sampleCount: SampleCount = SampleCount.X1,
public depthLoadOp: LoadOp = LoadOp.CLEAR,
public depthStoreOp: StoreOp = StoreOp.STORE,
public stencilLoadOp: LoadOp = LoadOp.CLEAR,
Expand Down Expand Up @@ -1607,13 +1613,15 @@ export class RenderPassInfo {
constructor (
public colorAttachments: ColorAttachment[] = [],
public depthStencilAttachment: DepthStencilAttachment = new DepthStencilAttachment(),
public depthStencilResolveAttachment: DepthStencilAttachment = new DepthStencilAttachment(),
public subpasses: SubpassInfo[] = [],
public dependencies: SubpassDependency[] = [],
) {}

public copy (info: Readonly<RenderPassInfo>): RenderPassInfo {
deepCopy(this.colorAttachments, info.colorAttachments, ColorAttachment);
this.depthStencilAttachment.copy(info.depthStencilAttachment);
this.depthStencilResolveAttachment.copy(info.depthStencilResolveAttachment);
deepCopy(this.subpasses, info.subpasses, SubpassInfo);
deepCopy(this.dependencies, info.dependencies, SubpassDependency);
return this;
Expand Down Expand Up @@ -1702,12 +1710,14 @@ export class FramebufferInfo {
public renderPass: RenderPass = null!,
public colorTextures: Texture[] = [],
public depthStencilTexture: Texture | null = null,
public depthStencilResolveTexture: Texture | null = null,
) {}

public copy (info: Readonly<FramebufferInfo>): FramebufferInfo {
this.renderPass = info.renderPass;
this.colorTextures = info.colorTextures.slice();
this.depthStencilTexture = info.depthStencilTexture;
this.depthStencilResolveTexture = info.depthStencilResolveTexture;
return this;
}
}
Expand Down Expand Up @@ -2244,8 +2254,11 @@ export function FormatSize (format: Format, width: number, height: number, depth
* @param mips The target mip levels.
*/
export function FormatSurfaceSize (
format: Format, width: number, height: number,
depth: number, mips: number,
format: Format,
width: number,
height: number,
depth: number,
mips: number,
): number {
let size = 0;

Expand Down Expand Up @@ -2431,3 +2444,4 @@ export function formatAlignment (format: Format): FormatAlignment {
export function alignTo (size: number, alignment: number): number {
return Math.ceil(size / alignment) * alignment;
}

Check failure on line 2447 in cocos/gfx/base/define.ts

View workflow job for this annotation

GitHub Actions / Run ESLint

Too many blank lines at the end of file. Max of 0 allowed
Loading

0 comments on commit fabb7fe

Please sign in to comment.