mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 15:11:51 +00:00
!14727 ICSL Codecheck
Merge pull request !14727 from ustc-tianyu/cherry-pick-1725450279
This commit is contained in:
commit
3ba98ba4f7
@ -127,6 +127,7 @@ JsBrush::JsBrush(const Brush& brush)
|
||||
JsBrush::~JsBrush()
|
||||
{
|
||||
delete brush_;
|
||||
brush_ = nullptr;
|
||||
}
|
||||
|
||||
napi_value JsBrush::SetColor(napi_env env, napi_callback_info info)
|
||||
|
@ -143,6 +143,7 @@ JsPen::JsPen(const Pen& pen)
|
||||
JsPen::~JsPen()
|
||||
{
|
||||
delete pen_;
|
||||
pen_ = nullptr;
|
||||
}
|
||||
|
||||
napi_value JsPen::SetColor(napi_env env, napi_callback_info info)
|
||||
|
@ -77,9 +77,7 @@ napi_value JsRegion::Constructor(napi_env env, napi_callback_info info)
|
||||
status = napi_wrap(env, jsThis, jsRegion,
|
||||
JsRegion::Destructor, nullptr, nullptr);
|
||||
if (status != napi_ok) {
|
||||
if (jsRegion != nullptr) {
|
||||
delete jsRegion;
|
||||
}
|
||||
delete jsRegion;
|
||||
ROSEN_LOGE("JsRegion::Constructor Failed to wrap native instance");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -96,7 +96,10 @@ public:
|
||||
template<typename T>
|
||||
T* GetImpl() const
|
||||
{
|
||||
return fontMgrImpl_->DowncastingTo<T>();
|
||||
if (fontMgrImpl_) {
|
||||
return fontMgrImpl_->DowncastingTo<T>();
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -87,6 +87,7 @@ std::shared_ptr<Surface> SkiaStaticFactory::MakeFromBackendTexture(GPUContext* g
|
||||
return SkiaSurface::MakeFromBackendTexture(gpuContext, info, origin, sampleCnt, colorType,
|
||||
colorSpace, deleteVkImage, cleanHelper);
|
||||
}
|
||||
|
||||
std::shared_ptr<Surface> SkiaStaticFactory::MakeRenderTarget(GPUContext* gpuContext,
|
||||
bool budgeted, const ImageInfo& imageInfo)
|
||||
{
|
||||
|
@ -614,7 +614,10 @@ void DrawPathOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
OpDataHandle pathHandle;
|
||||
if (path_) {
|
||||
pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(pathHandle, paintHandle);
|
||||
}
|
||||
|
||||
@ -680,7 +683,10 @@ std::shared_ptr<DrawOpItem> DrawShadowStyleOpItem::Unmarshalling(const DrawCmdLi
|
||||
|
||||
void DrawShadowStyleOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
auto pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
OpDataHandle pathHandle;
|
||||
if (path_) {
|
||||
pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(
|
||||
pathHandle, planeParams_, devLightPos_, lightRadius_, ambientColor_, spotColor_, flag_, isLimitElevation_);
|
||||
}
|
||||
@ -713,7 +719,10 @@ std::shared_ptr<DrawOpItem> DrawShadowOpItem::Unmarshalling(const DrawCmdList& c
|
||||
|
||||
void DrawShadowOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
auto pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
OpDataHandle pathHandle;
|
||||
if (path_) {
|
||||
pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(
|
||||
pathHandle, planeParams_, devLightPos_, lightRadius_, ambientColor_, spotColor_, flag_);
|
||||
}
|
||||
@ -746,7 +755,10 @@ void DrawRegionOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto regionHandle = CmdListHelper::AddRegionToCmdList(cmdList, *region_);
|
||||
OpDataHandle regionHandle;
|
||||
if (region_) {
|
||||
regionHandle = CmdListHelper::AddRegionToCmdList(cmdList, *region_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(regionHandle, paintHandle);
|
||||
}
|
||||
|
||||
@ -778,7 +790,10 @@ void DrawVerticesOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto opDataHandle = CmdListHelper::AddVerticesToCmdList(cmdList, *vertices_);
|
||||
OpDataHandle opDataHandle;
|
||||
if (vertices_) {
|
||||
opDataHandle = CmdListHelper::AddVerticesToCmdList(cmdList, *vertices_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(opDataHandle, mode_, paintHandle);
|
||||
}
|
||||
|
||||
@ -836,7 +851,10 @@ std::shared_ptr<DrawOpItem> DrawImageNineOpItem::Unmarshalling(const DrawCmdList
|
||||
|
||||
void DrawImageNineOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
auto imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
OpDataHandle imageHandle;
|
||||
if (image_) {
|
||||
imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
}
|
||||
BrushHandle brushHandle;
|
||||
if (hasBrush_) {
|
||||
BrushToBrushHandle(brush_, cmdList, brushHandle);
|
||||
@ -880,7 +898,10 @@ void DrawImageLatticeOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
OpDataHandle imageHandle;
|
||||
if (image_) {
|
||||
imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
}
|
||||
auto latticeHandle = CmdListHelper::AddLatticeToCmdList(cmdList, lattice_);
|
||||
cmdList.AddOp<ConstructorHandle>(imageHandle, latticeHandle, dst_, filter_, paintHandle);
|
||||
}
|
||||
@ -920,7 +941,10 @@ void DrawAtlasOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *atlas_);
|
||||
OpDataHandle imageHandle;
|
||||
if (atlas_) {
|
||||
imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *atlas_);
|
||||
}
|
||||
auto xformData = CmdListHelper::AddVectorToCmdList<RSXform>(cmdList, xform_);
|
||||
auto texData = CmdListHelper::AddVectorToCmdList<Rect>(cmdList, tex_);
|
||||
auto colorData = CmdListHelper::AddVectorToCmdList<ColorQuad>(cmdList, colors_);
|
||||
@ -958,7 +982,10 @@ void DrawBitmapOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto bitmapHandle = CmdListHelper::AddBitmapToCmdList(cmdList, *bitmap_);
|
||||
ImageHandle bitmapHandle;
|
||||
if (bitmap_) {
|
||||
bitmapHandle = CmdListHelper::AddBitmapToCmdList(cmdList, *bitmap_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(bitmapHandle, px_, py_, paintHandle);
|
||||
}
|
||||
|
||||
@ -994,7 +1021,10 @@ void DrawImageOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
OpDataHandle imageHandle;
|
||||
if (image_) {
|
||||
imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(imageHandle, px_, py_, samplingOptions_, paintHandle);
|
||||
}
|
||||
|
||||
@ -1041,7 +1071,10 @@ void DrawImageRectOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
PaintHandle paintHandle;
|
||||
GenerateHandleFromPaint(cmdList, paint_, paintHandle);
|
||||
auto imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
OpDataHandle imageHandle;
|
||||
if (image_) {
|
||||
imageHandle = CmdListHelper::AddImageToCmdList(cmdList, *image_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(imageHandle, src_, dst_, sampling_, constraint_, paintHandle);
|
||||
}
|
||||
|
||||
@ -1083,7 +1116,10 @@ std::shared_ptr<DrawOpItem> DrawPictureOpItem::Unmarshalling(const DrawCmdList&
|
||||
|
||||
void DrawPictureOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
auto pictureHandle = CmdListHelper::AddPictureToCmdList(cmdList, *picture_);
|
||||
OpDataHandle pictureHandle;
|
||||
if (picture_) {
|
||||
pictureHandle = CmdListHelper::AddPictureToCmdList(cmdList, *picture_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(pictureHandle);
|
||||
}
|
||||
|
||||
@ -1331,6 +1367,9 @@ bool DrawTextBlobOpItem::ConstructorHandle::GenerateCachedOpItem(DrawCmdList& cm
|
||||
}
|
||||
|
||||
Canvas* offscreenCanvas = offscreenSurface->GetCanvas().get();
|
||||
if (!offscreenCanvas) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// align draw op to [0, 0]
|
||||
if (bounds->GetLeft() != 0 || bounds->GetTop() != 0) {
|
||||
@ -1388,6 +1427,9 @@ std::shared_ptr<DrawImageRectOpItem> DrawTextBlobOpItem::GenerateCachedOpItem(Ca
|
||||
}
|
||||
|
||||
Canvas* offscreenCanvas = offscreenSurface->GetCanvas().get();
|
||||
if (!offscreenCanvas) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// align draw op to [0, 0]
|
||||
if (bounds->GetLeft() != 0 || bounds->GetTop() != 0) {
|
||||
@ -1578,7 +1620,10 @@ std::shared_ptr<DrawOpItem> ClipPathOpItem::Unmarshalling(const DrawCmdList& cmd
|
||||
|
||||
void ClipPathOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
auto pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
OpDataHandle pathHandle;
|
||||
if (path_) {
|
||||
pathHandle = CmdListHelper::AddPathToCmdList(cmdList, *path_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(pathHandle, clipOp_, doAntiAlias_);
|
||||
}
|
||||
|
||||
@ -1607,7 +1652,10 @@ std::shared_ptr<DrawOpItem> ClipRegionOpItem::Unmarshalling(const DrawCmdList& c
|
||||
|
||||
void ClipRegionOpItem::Marshalling(DrawCmdList& cmdList)
|
||||
{
|
||||
auto regionHandle = CmdListHelper::AddRegionToCmdList(cmdList, *region_);
|
||||
OpDataHandle regionHandle;
|
||||
if (region_) {
|
||||
regionHandle = CmdListHelper::AddRegionToCmdList(cmdList, *region_);
|
||||
}
|
||||
cmdList.AddOp<ConstructorHandle>(regionHandle, clipOp_);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ bool MemAllocator::Resize(size_t size)
|
||||
if (size > LARGE_MALLOC) {
|
||||
LOGW("MemAllocator::Resize this time malloc large memory, size:%{public}zu", size);
|
||||
}
|
||||
char* newData = new char[size];
|
||||
char* newData = new(std::nothrow) char[size];
|
||||
if (!newData) {
|
||||
return false;
|
||||
}
|
||||
|
@ -117,6 +117,9 @@ void RSExtendImageObject::Playback(Drawing::Canvas& canvas, const Drawing::Rect&
|
||||
const Drawing::SamplingOptions& sampling, bool isBackground)
|
||||
{
|
||||
#if defined(ROSEN_OHOS) && (defined(RS_ENABLE_GL) || defined(RS_ENABLE_VK))
|
||||
if (!rsImage_) {
|
||||
return;
|
||||
}
|
||||
std::shared_ptr<Media::PixelMap> pixelmap = rsImage_->GetPixelMap();
|
||||
if (pixelmap && pixelmap->IsAstc()) {
|
||||
if (auto recordingCanvas = static_cast<ExtendRecordingCanvas*>(canvas.GetRecordingCanvas())) {
|
||||
@ -162,7 +165,7 @@ RSExtendImageObject *RSExtendImageObject::Unmarshalling(Parcel &parcel)
|
||||
void RSExtendImageObject::PreProcessPixelMap(Drawing::Canvas& canvas, const std::shared_ptr<Media::PixelMap>& pixelMap,
|
||||
const Drawing::SamplingOptions& sampling)
|
||||
{
|
||||
if (!pixelMap) {
|
||||
if (!pixelMap || !rsImage_) {
|
||||
return;
|
||||
}
|
||||
if (!pixelMap->IsAstc() && RSPixelMapUtil::IsSupportZeroCopy(pixelMap, sampling)) {
|
||||
@ -315,6 +318,9 @@ bool RSExtendImageObject::MakeFromTextureForVK(Drawing::Canvas& canvas, SurfaceB
|
||||
surfaceBuffer->GetWidth(), surfaceBuffer->GetHeight(), false);
|
||||
if (backendTexture_.IsValid()) {
|
||||
auto vkTextureInfo = backendTexture_.GetTextureInfo().GetVKTextureInfo();
|
||||
if (!vkTextureInfo) {
|
||||
return false;
|
||||
}
|
||||
cleanUpHelper_ = new NativeBufferUtils::VulkanCleanupHelper(RsVulkanContext::GetSingleton(),
|
||||
vkTextureInfo->vkImage, vkTextureInfo->vkAlloc.memory);
|
||||
} else {
|
||||
@ -330,6 +336,9 @@ bool RSExtendImageObject::MakeFromTextureForVK(Drawing::Canvas& canvas, SurfaceB
|
||||
}
|
||||
image_ = std::make_shared<Drawing::Image>();
|
||||
auto vkTextureInfo = backendTexture_.GetTextureInfo().GetVKTextureInfo();
|
||||
if (!vkTextureInfo || !cleanUpHelper_) {
|
||||
return false;
|
||||
}
|
||||
Drawing::ColorType colorType = GetColorTypeFromVKFormat(vkTextureInfo->format);
|
||||
Drawing::BitmapFormat bitmapFormat = { colorType, Drawing::AlphaType::ALPHATYPE_PREMUL };
|
||||
if (!image_->BuildFromTexture(*context, backendTexture_.GetTextureInfo(),
|
||||
|
@ -51,6 +51,7 @@ SurfaceOhosVulkan::~SurfaceOhosVulkan()
|
||||
}
|
||||
if (mVulkanWindow_ != nullptr) {
|
||||
delete mVulkanWindow_;
|
||||
mVulkanWindow_ = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,9 +44,11 @@ DrawingEngineSample::~DrawingEngineSample()
|
||||
{
|
||||
if (benchMark_ != nullptr) {
|
||||
delete benchMark_;
|
||||
benchMark_ = nullptr;
|
||||
}
|
||||
if (drawingProxy != nullptr) {
|
||||
delete drawingProxy;
|
||||
drawingProxy = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user