黄蓝不一致问题修复 Signed-off-by: m00472246 <majingtao1@huawei.com>

Signed-off-by: m00472246 <majingtao1@huawei.com>
This commit is contained in:
m00472246 2024-09-02 20:57:53 +08:00
parent 1253e46f6c
commit 40456e741d
2 changed files with 6 additions and 11 deletions

View File

@ -218,7 +218,7 @@ int64_t SurfaceImage::GetTimeStamp()
SurfaceError SurfaceImage::GetTransformMatrix(float matrix[16])
{
std::lock_guard<std::mutex> lockGuard(opMutex_);
auto ret = memcpy_s(matrix, sizeof(float) * 16, // 16 is the length of array,
auto ret = memcpy_s(matrix, sizeof(float) * 16, // 16 is the length of array
currentTransformMatrix_, sizeof(currentTransformMatrix_));
if (ret != EOK) {
BLOGE("GetTransformMatrix: currentTransformMatrix_ memcpy_s failed");
@ -417,7 +417,7 @@ SurfaceError SurfaceImage::AcquireNativeWindowBuffer(OHNativeWindowBuffer** nati
Rect damage;
SurfaceError ret = AcquireBuffer(buffer, acquireFence, timestamp, damage);
if (ret != SURFACE_ERROR_OK) {
BLOGE("AcquireBuffer failed: %{public}d", ret);
BLOGE("AcquireBuffer failed: %d", ret);
return ret;
}
currentSurfaceBuffer_ = buffer;
@ -429,10 +429,7 @@ SurfaceError SurfaceImage::AcquireNativeWindowBuffer(OHNativeWindowBuffer** nati
currentSurfaceBuffer_, currentTransformType_, currentCrop_);
*fenceFd = acquireFence->Dup();
OHNativeWindowBuffer *nwBuffer = new(std::nothrow) OHNativeWindowBuffer();
if (nwBuffer == nullptr) {
return SURFACE_ERROR_NOMEM;
}
OHNativeWindowBuffer *nwBuffer = new OHNativeWindowBuffer();
nwBuffer->sfbuffer = buffer;
NativeObjectReference(nwBuffer);
*nativeWindowBuffer = nwBuffer;
@ -446,7 +443,7 @@ SurfaceError SurfaceImage::ReleaseNativeWindowBuffer(OHNativeWindowBuffer* nativ
// There is no need to close this fd, because in function ReleaseBuffer it will be closed.
SurfaceError ret = ReleaseBuffer(nativeWindowBuffer->sfbuffer, fenceFd);
if (ret != SURFACE_ERROR_OK) {
BLOGE("ReleaseBuffer failed: %{public}d", ret);
BLOGE("ReleaseBuffer failed: %d", ret);
return ret;
}
NativeObjectUnreference(nativeWindowBuffer);

View File

@ -224,11 +224,9 @@ int32_t OH_NativeImage_GetTransformMatrixV2(OH_NativeImage* image, float matrix[
* @brief Acquire an <b>OHNativeWindowBuffer</b> through an <b>OH_NativeImage</b> instance for content consumer.\n
* This method can not be used at the same time with <b>OH_NativeImage_UpdateSurfaceImage</b>.\n
* This method will create an <b>OHNativeWindowBuffer</b>.\n
* If there is a situation when <b>OHNativeWindowBuffer</b> is still used after calling
* <b>OH_NativeImage_ReleaseNativeWindowBuffer</b>, you must pay attention to the following two points.\n
* 1) When using <b>OHNativeWindowBuffer</b>, need to increase its reference count
* When using <b>OHNativeWindowBuffer</b>, need to increase its reference count
* by <b>OH_NativeWindow_NativeObjectReference</b>.\n
* 2) When the <b>OHNativeWindowBuffer</b> is used up, its reference count needs to be decremented
* When the <b>OHNativeWindowBuffer</b> is used up, its reference count needs to be decremented
* by <b>OH_NativeWindow_NativeObjectUnreference</b>.\n
* This interface needs to be used in conjunction with <b>OH_NativeImage_ReleaseNativeWindowBuffer<\b>,
* otherwise memory leaks will occur.\n