Skip to content

Commit

Permalink
Merge pull request cocos#14 from minggo/merge_v3.3
Browse files Browse the repository at this point in the history
Merge v3.3
  • Loading branch information
minggo authored May 25, 2021
2 parents 5655b83 + 25bd903 commit 67b9223
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 32 deletions.
8 changes: 6 additions & 2 deletions cocos/2d/renderer/draw-batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* @hidden
*/

import { JSB } from 'internal:constants';
import { MeshBuffer } from './mesh-buffer';
import { Material } from '../../core/assets/material';
import { Texture, Sampler } from '../../core/gfx';
Expand Down Expand Up @@ -130,8 +131,11 @@ export class DrawBatch2D {
this._passes[i] = new Pass(legacyCC.director.root);
// @ts-expect-error hack for UI use pass object
this._passes[i]._handle = PassPool.alloc();
// @ts-expect-error hack for UI use pass object
this._passes[i]._nativeObj = new ns.Pass();

if (JSB) {
// @ts-expect-error hack for UI use pass object
this._passes[i]._nativeObj = new ns.Pass();
}
}
const mtlPass = passes[i];
const passInUse = this._passes[i];
Expand Down
20 changes: 6 additions & 14 deletions cocos/core/renderer/scene/submodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,9 @@ export class SubModel {
}

private _createDescriptorSet (descInfo: DescriptorSetInfo) {
if (JSB) {
const dsHandle = DSPool.alloc(this._device!, descInfo);
SubModelPool.set(this._handle, SubModelView.DESCRIPTOR_SET, dsHandle);
this._descriptorSet = DSPool.get(dsHandle);
return;
}
this._descriptorSet = this._device!.createDescriptorSet(descInfo);
const dsHandle = DSPool.alloc(this._device!, descInfo);
SubModelPool.set(this._handle, SubModelView.DESCRIPTOR_SET, dsHandle);
this._descriptorSet = DSPool.get(dsHandle);
}

private _setPassCount (val: number) {
Expand Down Expand Up @@ -152,13 +148,9 @@ export class SubModel {
}

private _setInputAssembler (iaInfo: InputAssemblerInfo) {
if (JSB) {
const iaHandle = IAPool.alloc(this._device!, iaInfo);
SubModelPool.set(this._handle, SubModelView.INPUT_ASSEMBLER, iaHandle);
this._inputAssembler = IAPool.get(iaHandle);
return;
}
this._inputAssembler = this._device!.createInputAssembler(iaInfo);
const iaHandle = IAPool.alloc(this._device!, iaInfo);
SubModelPool.set(this._handle, SubModelView.INPUT_ASSEMBLER, iaHandle);
this._inputAssembler = IAPool.get(iaHandle);
}

private _setSubMesh (subMesh: RenderingSubMesh) {
Expand Down
6 changes: 3 additions & 3 deletions cocos/dragon-bones/CCSlot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { BoneType, BinaryOffset, Slot } from '@cocos/dragonbones-js';
import { Color, ImageAsset, mat4, Mat4, Texture2D } from '../core';
import { Color, Mat4, Texture2D } from '../core';
import { ccclass } from '../core/data/class-decorator';
import { CCTextureData } from './CCTextureData';

Expand Down Expand Up @@ -38,8 +38,8 @@ export class CCSlot extends Slot {
getTexture () {
if (this._textureData) {
const sp = (this._textureData as any).spriteFrame;
const tex = sp.texture instanceof ImageAsset ? sp.texture._texture : sp.texture;
return tex as Texture2D;
const tex = sp.texture as Texture2D;
return tex;
}
return null;
}
Expand Down
7 changes: 3 additions & 4 deletions cocos/spine/skeleton-texture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
* @module spine
*/

import { ImageAsset, Material, Texture2D } from '../core';
import { Material, Texture2D } from '../core';
import { Filter, WrapMode } from '../core/assets/asset-enum';
import spine from './lib/spine-core.js';

export class SkeletonTexture extends spine.Texture {
name = 'sp.SkeletonTexture';
_texture: Texture2D|ImageAsset | null = null;
_texture: Texture2D | null = null;
_material: Material | null = null;

constructor (opt:ImageBitmap|HTMLImageElement) {
Expand All @@ -22,8 +22,7 @@ export class SkeletonTexture extends spine.Texture {
}

getRealTexture (): Texture2D|null {
if (!this._texture) { return null; }
return this._texture instanceof ImageAsset ? this._texture._texture as Texture2D : this._texture;
return this._texture;
}

setFilters (minFilter: spine.TextureFilter, magFilter: spine.TextureFilter) {
Expand Down
2 changes: 1 addition & 1 deletion platforms/native/engine/jsb-dragonbones.js
Original file line number Diff line number Diff line change
Expand Up @@ -794,7 +794,7 @@ const cacheManager = require('./jsb-cache-manager');
middleware.resetIndicesStart = false;
}

ui.commitComp(this, realTexture._texture, this._assembler, null);
ui.commitComp(this, realTexture, this._assembler, null);
this.material = mat;
}
}
Expand Down
19 changes: 11 additions & 8 deletions platforms/native/engine/jsb-spine-skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ const cacheManager = require('./jsb-cache-manager');
return;
}

let skeletonCache = spine.retainSkeletonData(uuid);
if (skeletonCache) {
this._skeletonCache = skeletonCache;
this.width = this._skeletonCache.getWidth();
this.height = this._skeletonCache.getHeight();
return;
}
// gfxTexture may not exist if this._skeletonCache == null
// let skeletonCache = spine.retainSkeletonData(uuid);
// if (skeletonCache) {
// this._skeletonCache = skeletonCache;
// this.width = this._skeletonCache.getWidth();
// this.height = this._skeletonCache.getHeight();
// return;
// }

let atlasText = this.atlasText;
if (!atlasText) {
Expand All @@ -117,6 +118,8 @@ const cacheManager = require('./jsb-cache-manager');
return;
}

_gTextureIdx = 1;
_textureKeyMap = {};
let jsbTextures = {};
for (let i = 0; i < textures.length; ++i) {
let texture = textures[i];
Expand Down Expand Up @@ -894,7 +897,7 @@ const cacheManager = require('./jsb-cache-manager');
middleware.resetIndicesStart = false;
}

ui.commitComp(this, realTexture._texture, this._assembler, null);
ui.commitComp(this, realTexture, this._assembler, null);
this.material = mat;
}
}
Expand Down

0 comments on commit 67b9223

Please sign in to comment.