Fix the parameter of TextureCube::setImage, support to pass nullptr to it, keep the same logic as which in web (#12062)

This commit is contained in:
James Chen
2022-07-20 11:09:24 +08:00
committed by GitHub
parent a2aecfe243
commit 131fb74b32
6 changed files with 19 additions and 10 deletions
+4
View File
@@ -27,6 +27,7 @@ import { legacyCC } from '../global-exports';
import { Filter, PixelFormat, WrapMode } from './asset-enum';
import { js } from '../utils/js';
import './simple-texture';
import { EDITOR, TEST } from 'internal:constants';
const textureCubeProto: any = jsb.TextureCube.prototype;
interface ITextureCubeSerializeData {
@@ -67,6 +68,9 @@ enum MipmapMode {
}
textureCubeProto.createNode = null!;
declare const jsb: any;
// @ts-expect-error jsb.TextureCube is exported from cpp
export type TextureCube = jsb.TextureCube;
export const TextureCube: any = jsb.TextureCube;
@@ -24,6 +24,7 @@
****************************************************************************/
#include "bindings/auto/jsb_assets_auto.h"
#include "core/data/JSBNativeDataHolder.h"
#include "core/event/EventTypesToJS.h"
#include "jsb_scene_manual.h"
+7 -3
View File
@@ -168,10 +168,14 @@ void TextureCube::setMipmapAtlasForJS(const TextureCubeMipmapAtlasInfo &value) {
_mipmapAtlas = value;
}
void TextureCube::setImage(const ITextureCubeMipmap &value) {
_mipmaps.clear();
_mipmaps.emplace_back(value);
void TextureCube::setImage(const ITextureCubeMipmap *value) {
if (value != nullptr) {
setMipmaps({*value});
} else {
setMipmaps({});
}
}
void TextureCube::reset(const ITextureCubeCreateInfo &info) {
_width = info.width;
_height = info.height;
+5 -5
View File
@@ -203,7 +203,7 @@ public:
return _mipmaps.empty() ? nullptr : &_mipmaps[0];
}
void setImage(const ITextureCubeMipmap &value);
void setImage(const ITextureCubeMipmap *value);
/**
* @en Reset the current texture with given size, pixel format and mipmap images.
@@ -248,19 +248,19 @@ public:
bool validate() const override;
//
/*@serializable*/
MipmapMode _mipmapMode{MipmapMode::NONE};
/*@serializable*/
bool isRGBE{false};
private:
/*@serializable*/
ccstd::vector<ITextureCubeMipmap> _mipmaps;
/*@serializable*/
MipmapMode _mipmapMode{MipmapMode::NONE};
/*@serializable*/
TextureCubeMipmapAtlasInfo _mipmapAtlas;
private:
CC_DISALLOW_COPY_MOVE_ASSIGN(TextureCube);
};
+1 -1
View File
@@ -239,7 +239,7 @@ void BuiltinResMgr::initTextureCubeWithUuid(const ccstd::string &uuid, const uin
mipmap.bottom = ccnew ImageAsset();
mipmap.bottom->setNativeAsset(imageSource);
texture->setImage(mipmap);
texture->setImage(&mipmap);
texture->initialize();
_resources.emplace(texture->getUuid(), texture);
+1 -1
View File
@@ -30,7 +30,7 @@ headers = %(cocosdir)s/cocos/renderer/pipeline/custom/RenderInterfaceTypes.h
hpp_headers =
cpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_scene_auto.h cocos/renderer/pipeline/custom/LayoutGraphJsb.h cocos/renderer/pipeline/custom/RenderCommonJsb.h cocos/renderer/pipeline/custom/RenderGraphJsb.h
cpp_headers = cocos/bindings/auto/jsb_gfx_auto.h cocos/bindings/auto/jsb_scene_auto.h cocos/renderer/pipeline/custom/LayoutGraphJsb.h cocos/renderer/pipeline/custom/RenderCommonJsb.h cocos/renderer/pipeline/custom/RenderGraphJsb.h cocos/renderer/pipeline/GeometryRenderer.h cocos/renderer/pipeline/GlobalDescriptorSetManager.h
replace_headers =