mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 15:11:51 +00:00
!9672 修复bufferhandle与hdi不一致的问题&&新增transformhint接口
Merge pull request !9672 from 马靖涛/20240328
This commit is contained in:
commit
2461225b31
@ -82,6 +82,9 @@ public:
|
||||
GSError GetTransform(GraphicTransformType &transform) override;
|
||||
GSError AttachBufferToQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
GSError DetachBufferFromQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
|
||||
GSError GetTransformHint(GraphicTransformType &transformHint) override;
|
||||
GSError SetTransformHint(GraphicTransformType transformHint) override;
|
||||
private:
|
||||
static inline BrokerDelegator<BufferClientProducer> delegator_;
|
||||
std::string name_ = "not init";
|
||||
|
@ -31,7 +31,6 @@ typedef struct {
|
||||
int32_t format; /**< the format of memory */
|
||||
uint64_t usage; /**< the usage of memory */
|
||||
void *virAddr; /**< Virtual address of memory */
|
||||
int32_t key; /**< Shared memory key */
|
||||
uint64_t phyAddr; /**< Physical address */
|
||||
uint32_t reserveFds; /**< the number of reserved fd value */
|
||||
uint32_t reserveInts; /**< the number of reserved integer value */
|
||||
|
@ -154,6 +154,9 @@ public:
|
||||
GSError AttachBufferToQueue(sptr<SurfaceBuffer> &buffer, InvokerType invokerType);
|
||||
GSError DetachBufferFromQueue(sptr<SurfaceBuffer> &buffer, InvokerType invokerType);
|
||||
|
||||
GSError SetTransformHint(GraphicTransformType transformHint);
|
||||
GraphicTransformType GetTransformHint() const;
|
||||
|
||||
private:
|
||||
GSError AllocBuffer(sptr<SurfaceBuffer>& buffer, const BufferRequestConfig &config);
|
||||
void DeleteBufferInCache(uint32_t sequence);
|
||||
@ -213,6 +216,7 @@ private:
|
||||
sptr<SyncFence> lastFlusedFence_;
|
||||
wptr<ConsumerSurfaceDelegator> wpCSurfaceDelegator_;
|
||||
bool isCpuAccessable_ = false;
|
||||
GraphicTransformType transformHint_ = GraphicTransformType::GRAPHIC_ROTATE_NONE;
|
||||
};
|
||||
}; // namespace OHOS
|
||||
|
||||
|
@ -95,6 +95,9 @@ public:
|
||||
GSError AttachBufferToQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
GSError DetachBufferFromQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
|
||||
GSError SetTransformHint(GraphicTransformType transformHint) override;
|
||||
GSError GetTransformHint(GraphicTransformType &transformHint) override;
|
||||
|
||||
private:
|
||||
GSError CheckConnectLocked();
|
||||
GSError SetTunnelHandle(const sptr<SurfaceTunnelHandle> &handle);
|
||||
@ -130,6 +133,8 @@ private:
|
||||
int32_t GetTransformRemote(MessageParcel &arguments, MessageParcel &reply, MessageOption &option);
|
||||
int32_t AttachBufferToQueueRemote(MessageParcel &arguments, MessageParcel &reply, MessageOption &option);
|
||||
int32_t DetachBufferFromQueueRemote(MessageParcel &arguments, MessageParcel &reply, MessageOption &option);
|
||||
int32_t SetTransformHintRemote(MessageParcel &arguments, MessageParcel &reply, MessageOption &option);
|
||||
int32_t GetTransformHintRemote(MessageParcel &arguments, MessageParcel &reply, MessageOption &option);
|
||||
|
||||
using BufferQueueProducerFunc = int32_t (BufferQueueProducer::*)(MessageParcel &arguments,
|
||||
MessageParcel &reply, MessageOption &option);
|
||||
|
@ -129,6 +129,8 @@ public:
|
||||
void ConsumerRequestCpuAccess(bool on) override;
|
||||
GSError AttachBufferToQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
GSError DetachBufferFromQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
GraphicTransformType GetTransformHint() const override;
|
||||
GSError SetTransformHint(GraphicTransformType transformHint) override;
|
||||
|
||||
private:
|
||||
std::map<std::string, std::string> userData_;
|
||||
|
@ -131,6 +131,8 @@ public:
|
||||
GSError ClearUserDataChangeListener() override;
|
||||
GSError AttachBufferToQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
GSError DetachBufferFromQueue(sptr<SurfaceBuffer>& buffer) override;
|
||||
GraphicTransformType GetTransformHint() const override;
|
||||
GSError SetTransformHint(GraphicTransformType transformHint) override;
|
||||
private:
|
||||
bool IsRemote();
|
||||
void CleanAllLocked();
|
||||
|
@ -587,4 +587,34 @@ GSError BufferClientProducer::GetTransform(GraphicTransformType &transform)
|
||||
transform = static_cast<GraphicTransformType>(reply.ReadUint32());
|
||||
return GSERROR_OK;
|
||||
}
|
||||
|
||||
GSError BufferClientProducer::GetTransformHint(GraphicTransformType &transformHint)
|
||||
{
|
||||
DEFINE_MESSAGE_VARIABLES(arguments, reply, option, BLOGE);
|
||||
SEND_REQUEST(BUFFER_PRODUCER_GET_TRANSFORMHINT, arguments, reply, option);
|
||||
|
||||
auto ret = static_cast<GSError>(reply.ReadInt32());
|
||||
if (ret != GSERROR_OK) {
|
||||
BLOGN_FAILURE("Remote return %{public}d", static_cast<int>(ret));
|
||||
return ret;
|
||||
}
|
||||
transformHint = static_cast<GraphicTransformType>(reply.ReadUint32());
|
||||
return GSERROR_OK;
|
||||
}
|
||||
|
||||
GSError BufferClientProducer::SetTransformHint(GraphicTransformType transformHint)
|
||||
{
|
||||
DEFINE_MESSAGE_VARIABLES(arguments, reply, option, BLOGE);
|
||||
|
||||
arguments.WriteUint32(static_cast<uint32_t>(transformHint));
|
||||
|
||||
SEND_REQUEST(BUFFER_PRODUCER_SET_TRANSFORMHINT, arguments, reply, option);
|
||||
int32_t ret = reply.ReadInt32();
|
||||
if (ret != GSERROR_OK) {
|
||||
BLOGN_FAILURE("Remote return %{public}d", ret);
|
||||
return (GSError)ret;
|
||||
}
|
||||
|
||||
return GSERROR_OK;
|
||||
}
|
||||
}; // namespace OHOS
|
||||
|
@ -1237,6 +1237,17 @@ GraphicTransformType BufferQueue::GetTransform() const
|
||||
return transform_;
|
||||
}
|
||||
|
||||
GSError BufferQueue::SetTransformHint(GraphicTransformType transformHint)
|
||||
{
|
||||
transformHint_ = transformHint;
|
||||
return GSERROR_OK;
|
||||
}
|
||||
|
||||
GraphicTransformType BufferQueue::GetTransformHint() const
|
||||
{
|
||||
return transformHint_;
|
||||
}
|
||||
|
||||
GSError BufferQueue::IsSupportedAlloc(const std::vector<BufferVerifyAllocInfo> &infos,
|
||||
std::vector<bool> &supporteds) const
|
||||
{
|
||||
|
@ -70,6 +70,8 @@ BufferQueueProducer::BufferQueueProducer(sptr<BufferQueue> bufferQueue)
|
||||
memberFuncMap_[BUFFER_PRODUCER_ATTACH_BUFFER_TO_QUEUE] = &BufferQueueProducer::AttachBufferToQueueRemote;
|
||||
memberFuncMap_[BUFFER_PRODUCER_DETACH_BUFFER_FROM_QUEUE] = &BufferQueueProducer::DetachBufferFromQueueRemote;
|
||||
memberFuncMap_[BUFFER_PRODUCER_SET_DEFAULT_USAGE] = &BufferQueueProducer::SetDefaultUsageRemote;
|
||||
memberFuncMap_[BUFFER_PRODUCER_GET_TRANSFORMHINT] = &BufferQueueProducer::GetTransformHintRemote;
|
||||
memberFuncMap_[BUFFER_PRODUCER_SET_TRANSFORMHINT] = &BufferQueueProducer::SetTransformHintRemote;
|
||||
}
|
||||
|
||||
BufferQueueProducer::~BufferQueueProducer()
|
||||
@ -507,6 +509,31 @@ int32_t BufferQueueProducer::GetTransformRemote(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t BufferQueueProducer::SetTransformHintRemote(MessageParcel &arguments,
|
||||
MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
GraphicTransformType transformHint = static_cast<GraphicTransformType>(arguments.ReadUint32());
|
||||
GSError sret = SetTransformHint(transformHint);
|
||||
reply.WriteInt32(sret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int32_t BufferQueueProducer::GetTransformHintRemote(
|
||||
MessageParcel &arguments, MessageParcel &reply, MessageOption &option)
|
||||
{
|
||||
GraphicTransformType transformHint = GraphicTransformType::GRAPHIC_ROTATE_BUTT;
|
||||
auto ret = GetTransformHint(transformHint);
|
||||
if (ret != GSERROR_OK) {
|
||||
reply.WriteInt32(static_cast<int32_t>(ret));
|
||||
return -1;
|
||||
}
|
||||
|
||||
reply.WriteInt32(GSERROR_OK);
|
||||
reply.WriteUint32(static_cast<uint32_t>(transformHint));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
GSError BufferQueueProducer::RequestBuffer(const BufferRequestConfig &config, sptr<BufferExtraData> &bedata,
|
||||
RequestBufferReturnValue &retval)
|
||||
{
|
||||
@ -724,6 +751,25 @@ GSError BufferQueueProducer::GetTransform(GraphicTransformType &transform)
|
||||
return GSERROR_OK;
|
||||
}
|
||||
|
||||
GSError BufferQueueProducer::SetTransformHint(GraphicTransformType transformHint)
|
||||
{
|
||||
if (bufferQueue_ == nullptr) {
|
||||
return GSERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return bufferQueue_->SetTransformHint(transformHint);
|
||||
}
|
||||
|
||||
GSError BufferQueueProducer::GetTransformHint(GraphicTransformType &transformHint)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
if (bufferQueue_ == nullptr) {
|
||||
transformHint = GraphicTransformType::GRAPHIC_ROTATE_BUTT;
|
||||
return GSERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
transformHint = bufferQueue_->GetTransformHint();
|
||||
return GSERROR_OK;
|
||||
}
|
||||
|
||||
GSError BufferQueueProducer::IsSupportedAlloc(const std::vector<BufferVerifyAllocInfo> &infos,
|
||||
std::vector<bool> &supporteds)
|
||||
{
|
||||
|
@ -532,4 +532,19 @@ void ConsumerSurface::ConsumerRequestCpuAccess(bool on)
|
||||
{
|
||||
consumer_->ConsumerRequestCpuAccess(on);
|
||||
}
|
||||
|
||||
GraphicTransformType ConsumerSurface::GetTransformHint() const
|
||||
{
|
||||
GraphicTransformType transformHint = GraphicTransformType::GRAPHIC_ROTATE_BUTT;
|
||||
if (producer_->GetTransformHint(transformHint) != GSERROR_OK) {
|
||||
BLOGNE("Warning ProducerSurface GetTransformHint failed.");
|
||||
return GraphicTransformType::GRAPHIC_ROTATE_BUTT;
|
||||
}
|
||||
return transformHint;
|
||||
}
|
||||
|
||||
GSError ConsumerSurface::SetTransformHint(GraphicTransformType transformHint)
|
||||
{
|
||||
return producer_->SetTransformHint(transformHint);
|
||||
}
|
||||
} // namespace OHOS
|
||||
|
@ -523,6 +523,36 @@ int32_t CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **win
|
||||
return OHOS::GSERROR_OK;
|
||||
}
|
||||
|
||||
int32_t NativeWindowGetTransformHint(OHNativeWindow *window, GraphicTransformType *transform)
|
||||
{
|
||||
if (window == nullptr || window->surface == nullptr || transform == nullptr) {
|
||||
BLOGE("parameter error, please check input parameter");
|
||||
return OHOS::GSERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
*transform = window->surface->GetTransformHint();
|
||||
return OHOS::GSERROR_OK;
|
||||
}
|
||||
|
||||
int32_t NativeWindowSetTransformHint(OHNativeWindow *window, GraphicTransformType transform)
|
||||
{
|
||||
if (window == nullptr || window->surface == nullptr) {
|
||||
BLOGE("parameter error, please check input parameter");
|
||||
return OHOS::GSERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
return window->surface->SetTransformHint(transform);
|
||||
}
|
||||
|
||||
int32_t NativeWindowGetDefaultWidthAndHeight(OHNativeWindow *window, int32_t *width, int32_t *height)
|
||||
{
|
||||
if (window == nullptr || window->surface == nullptr || width == nullptr || height == nullptr) {
|
||||
BLOGE("parameter error, please check input parameter");
|
||||
return OHOS::GSERROR_INVALID_ARGUMENTS;
|
||||
}
|
||||
*width = window->surface->GetDefaultWidth();
|
||||
*height = window->surface->GetDefaultHeight();
|
||||
return OHOS::GSERROR_OK;
|
||||
}
|
||||
|
||||
NativeWindow::NativeWindow() : NativeWindowMagic(NATIVE_OBJECT_MAGIC_WINDOW), surface(nullptr)
|
||||
{
|
||||
}
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "buffer_producer_listener.h"
|
||||
#include "sync_fence.h"
|
||||
#include "native_window.h"
|
||||
#include "surface_utils.h"
|
||||
|
||||
namespace OHOS {
|
||||
namespace {
|
||||
@ -360,6 +361,21 @@ int32_t ProducerSurface::GetDefaultHeight()
|
||||
return producer_->GetDefaultHeight();
|
||||
}
|
||||
|
||||
GraphicTransformType ProducerSurface::GetTransformHint() const
|
||||
{
|
||||
GraphicTransformType transformHint = GraphicTransformType::GRAPHIC_ROTATE_BUTT;
|
||||
if (producer_->GetTransformHint(transformHint) != GSERROR_OK) {
|
||||
BLOGNE("Warning ProducerSurface GetTransformHint failed.");
|
||||
return GraphicTransformType::GRAPHIC_ROTATE_BUTT;
|
||||
}
|
||||
return transformHint;
|
||||
}
|
||||
|
||||
GSError ProducerSurface::SetTransformHint(GraphicTransformType transformHint)
|
||||
{
|
||||
return producer_->SetTransformHint(transformHint);
|
||||
}
|
||||
|
||||
GSError ProducerSurface::SetDefaultUsage(uint64_t usage)
|
||||
{
|
||||
return producer_->SetDefaultUsage(usage);
|
||||
|
@ -71,7 +71,7 @@ SurfaceError SurfaceUtils::Remove(uint64_t uniqueId)
|
||||
{
|
||||
std::lock_guard<std::mutex> lockGuard(mutex_);
|
||||
if (surfaceCache_.count(uniqueId) == 0) {
|
||||
BLOGW("Delete failed without surface by uniqueId %" PRIu64, uniqueId);
|
||||
BLOGD("Delete failed without surface by uniqueId %" PRIu64, uniqueId);
|
||||
return GSERROR_INVALID_OPERATING;
|
||||
}
|
||||
surfaceCache_.erase(uniqueId);
|
||||
|
@ -1311,4 +1311,42 @@ HWTEST_F(NativeWindowTest, SetTunnelHandle004, Function | MediumTest | Level1)
|
||||
ASSERT_EQ(OH_NativeWindow_NativeWindowSetTunnelHandle(nativeWindow, handle), OHOS::GSERROR_NO_ENTRY);
|
||||
FreeOHExtDataHandle(handle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: NativeWindowGetTransformHint
|
||||
* Type: Function
|
||||
* Rank: Important(1)
|
||||
* EnvConditions: N/A
|
||||
* CaseDescription: 1. call NativeWindowGetTransformHint with normal parameters and check ret
|
||||
* @tc.require: issueI5GMZN issueI5IWHW
|
||||
*/
|
||||
HWTEST_F(NativeWindowTest, NativeWindowGetTransformHint001, Function | MediumTest | Level1)
|
||||
{
|
||||
GraphicTransformType transform = GraphicTransformType::GRAPHIC_ROTATE_180;
|
||||
ASSERT_EQ(NativeWindowGetTransformHint(nullptr, &transform), OHOS::GSERROR_INVALID_ARGUMENTS);
|
||||
ASSERT_EQ(NativeWindowSetTransformHint(nullptr, transform), OHOS::GSERROR_INVALID_ARGUMENTS);
|
||||
ASSERT_EQ(NativeWindowSetTransformHint(nativeWindow, transform), OHOS::GSERROR_OK);
|
||||
transform = GraphicTransformType::GRAPHIC_ROTATE_NONE;
|
||||
ASSERT_EQ(NativeWindowGetTransformHint(nativeWindow, &transform), OHOS::GSERROR_OK);
|
||||
ASSERT_EQ(transform, GraphicTransformType::GRAPHIC_ROTATE_180);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function: NativeWindowGetDefaultWidthAndHeight
|
||||
* Type: Function
|
||||
* Rank: Important(1)
|
||||
* EnvConditions: N/A
|
||||
* CaseDescription: 1. call NativeWindowGetDefaultWidthAndHeight with normal parameters and check ret
|
||||
* @tc.require: issueI5GMZN issueI5IWHW
|
||||
*/
|
||||
HWTEST_F(NativeWindowTest, NativeWindowGetDefaultWidthAndHeight001, Function | MediumTest | Level1)
|
||||
{
|
||||
ASSERT_EQ(NativeWindowGetDefaultWidthAndHeight(nullptr, nullptr, nullptr), OHOS::GSERROR_INVALID_ARGUMENTS);
|
||||
cSurface->SetDefaultWidthAndHeight(300, 400);
|
||||
int32_t width;
|
||||
int32_t height;
|
||||
ASSERT_EQ(NativeWindowGetDefaultWidthAndHeight(nativeWindow, &width, &height), OHOS::GSERROR_OK);
|
||||
ASSERT_EQ(width, 300);
|
||||
ASSERT_EQ(height, 400);
|
||||
}
|
||||
}
|
||||
|
@ -97,6 +97,8 @@ public:
|
||||
|
||||
virtual GSError AttachBufferToQueue(sptr<SurfaceBuffer>& buffer) = 0;
|
||||
virtual GSError DetachBufferFromQueue(sptr<SurfaceBuffer>& buffer) = 0;
|
||||
virtual GSError GetTransformHint(GraphicTransformType &transformHint) = 0;
|
||||
virtual GSError SetTransformHint(GraphicTransformType transformHint) = 0;
|
||||
DECLARE_INTERFACE_DESCRIPTOR(u"surf.IBufferProducer");
|
||||
|
||||
protected:
|
||||
@ -132,6 +134,8 @@ protected:
|
||||
BUFFER_PRODUCER_ATTACH_BUFFER_TO_QUEUE = 28,
|
||||
BUFFER_PRODUCER_DETACH_BUFFER_FROM_QUEUE = 29,
|
||||
BUFFER_PRODUCER_SET_DEFAULT_USAGE = 30,
|
||||
BUFFER_PRODUCER_GET_TRANSFORMHINT = 31,
|
||||
BUFFER_PRODUCER_SET_TRANSFORMHINT = 32,
|
||||
};
|
||||
};
|
||||
} // namespace OHOS
|
||||
|
@ -132,6 +132,9 @@ public:
|
||||
virtual GSError AttachBufferToQueue(sptr<SurfaceBuffer>& buffer) = 0;
|
||||
virtual GSError DetachBufferFromQueue(sptr<SurfaceBuffer>& buffer) = 0;
|
||||
|
||||
virtual GraphicTransformType GetTransformHint() const = 0;
|
||||
virtual GSError SetTransformHint(GraphicTransformType transformHint) = 0;
|
||||
|
||||
protected:
|
||||
Surface() = default;
|
||||
};
|
||||
|
@ -17,6 +17,7 @@
|
||||
#define NDK_INCLUDE_NATIVE_WINDOW_H_
|
||||
|
||||
#include "external_window.h"
|
||||
#include "surface_type.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -66,6 +67,9 @@ int32_t GetSurfaceId(OHNativeWindow *window, uint64_t *surfaceId);
|
||||
int32_t CreateNativeWindowFromSurfaceId(uint64_t surfaceId, OHNativeWindow **window);
|
||||
int32_t NativeWindowAttachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
|
||||
int32_t NativeWindowDetachBuffer(OHNativeWindow *window, OHNativeWindowBuffer *buffer);
|
||||
int32_t NativeWindowGetTransformHint(OHNativeWindow *window, OHOS::GraphicTransformType *transform);
|
||||
int32_t NativeWindowSetTransformHint(OHNativeWindow *window, OHOS::GraphicTransformType transform);
|
||||
int32_t NativeWindowGetDefaultWidthAndHeight(OHNativeWindow *window, int32_t *width, int32_t *height);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user