Skip to content

Commit

Permalink
Improve performance when repeatedly writing to the hardware buffer on…
Browse files Browse the repository at this point in the history
… the OHOS platform. (#327)
  • Loading branch information
domchen committed Nov 11, 2024
1 parent 619297c commit 279fa22
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/platform/ohos/HardwareBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "utils/PixelFormatUtil.h"

namespace tgfx {
#define BUFFER_USAGE_MEM_MMZ_CACHE (1ULL << 5)

std::shared_ptr<ImageBuffer> ImageBuffer::MakeFrom(HardwareBufferRef hardwareBuffer,
YUVColorSpace colorSpace) {
auto pixelBuffer = PixelBuffer::MakeFrom(hardwareBuffer);
Expand All @@ -43,8 +45,9 @@ HardwareBufferRef HardwareBufferAllocate(int width, int height, bool alphaOnly)
return nullptr;
}
OH_NativeBuffer_Config config = {width, height, NATIVEBUFFER_PIXEL_FMT_RGBA_8888,
NATIVEBUFFER_USAGE_CPU_READ | NATIVEBUFFER_USAGE_CPU_WRITE |
NATIVEBUFFER_USAGE_HW_RENDER | NATIVEBUFFER_USAGE_HW_TEXTURE,
NATIVEBUFFER_USAGE_CPU_READ | BUFFER_USAGE_MEM_MMZ_CACHE |
NATIVEBUFFER_USAGE_CPU_WRITE | NATIVEBUFFER_USAGE_HW_RENDER |
NATIVEBUFFER_USAGE_HW_TEXTURE,
0};
return OH_NativeBuffer_Alloc(&config);
}
Expand Down

0 comments on commit 279fa22

Please sign in to comment.