You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.8 KiB
109 lines
2.8 KiB
/*
|
|
* Copyright (c) Hisilicon Technologies Co., Ltd.. 2019-2020. All rights reserved.
|
|
* Description: overlay create win/queue buffer by VO
|
|
* Author: Original Media Software Group
|
|
* Create: 2019-07-15
|
|
*/
|
|
#include "OverlayAdapter.h"
|
|
|
|
#include "securec.h"
|
|
#include "UnifiedWindowImpl.h"
|
|
|
|
using namespace android;
|
|
/**
|
|
* main purpose:
|
|
* 1.open/close overlay channel according buffer usage
|
|
*/
|
|
int OverlayAdapter::PrepareOverlayLayer(const LayerInfo &info)
|
|
{
|
|
int ret;
|
|
displayId = info.displayId;
|
|
if ((ret = impl->CreateWindow(info)) != 0) {
|
|
ALOGE("impl->CreateWindow failed :0x%x", ret);
|
|
return ret;
|
|
}
|
|
if (info.visible == 0) {
|
|
return impl->ResetWindow();
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int OverlayAdapter::QueueBuffer(buffer_handle_t handle, int &releaseFence, const int &dataSpace)
|
|
{
|
|
Frame frame;
|
|
frame.hnd = static_cast<const private_handle_t *>(handle);
|
|
if (frame.hnd == nullptr) {
|
|
ALOGE("surface is not visible, or window is destroy!");
|
|
return -1;
|
|
}
|
|
frame.frameBufFd = frame.hnd->fd;
|
|
frame.frameBufAddr = frame.hnd->addr;
|
|
frame.metadataBufFd = frame.hnd->attr_fd;
|
|
frame.metadataBufAddr = frame.hnd->attr_addr;
|
|
frame.isSec =
|
|
static_cast<bool>((frame.hnd->producer_usage | frame.hnd->consumer_usage) &
|
|
static_cast<unsigned long long>(GRALLOC_USAGE_PROTECTED)) ? 1 : 0;
|
|
frame.isFastOutput =
|
|
static_cast<bool>((frame.hnd->producer_usage | frame.hnd->consumer_usage) &
|
|
static_cast<unsigned long long>(GRALLOC_USAGE_PRI_FASTOUTPUT)) ? 1 : 0;
|
|
|
|
return impl->DisplayFrame(frame, releaseFence, dataSpace);
|
|
}
|
|
|
|
int OverlayAdapter::SetCrop(const OverlayRect &sourceCrop) const
|
|
{
|
|
int ret;
|
|
if ((ret = impl->SetWindowCrop(sourceCrop)) != 0) {
|
|
ALOGE("impl->SetWindowCrop failed :0x%x", ret);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int OverlayAdapter::SetPosition(const OverlayRect &displayFrame) const
|
|
{
|
|
int ret;
|
|
if ((ret = impl->SetWindowPosition(displayFrame)) != 0) {
|
|
ALOGE("impl->SetWindowPosition failed :0x%x", ret);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int OverlayAdapter::SetTransform(uint32_t transform) const
|
|
{
|
|
int ret;
|
|
if ((ret = impl->SetWindowTransform(transform)) != 0) {
|
|
ALOGE("impl->SetWindowTransform failed :0x%x", ret);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int OverlayAdapter::SetZorder(int32_t zorder) const
|
|
{
|
|
int ret;
|
|
if ((ret = impl->SetWindowZorder(zorder)) != 0) {
|
|
ALOGE("impl->SetWindowZorder failed :0x%x", ret);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
int OverlayAdapter::GetDisplayID() const
|
|
{
|
|
return displayId;
|
|
}
|
|
|
|
OverlayAdapter::~OverlayAdapter()
|
|
{
|
|
ALOGD("IN %s:%d ", __func__, __LINE__);
|
|
int ret;
|
|
if ((ret = impl->DestroyWindow()) != 0) {
|
|
ALOGE("impl->DestroyWindow failed :0x%x", ret);
|
|
}
|
|
}
|
|
|
|
OverlayAdapter::OverlayAdapter()
|
|
:displayId(-1),
|
|
impl(new UnifiedWindowImpl())
|
|
{
|
|
ALOGD("IN %s:%d ", __func__, __LINE__);
|
|
}
|