mirror of
https://gitee.com/openharmony/graphic_graphic_2d
synced 2024-11-23 15:11:51 +00:00
修复Hello_Composer,添加setLayerColor测试
Signed-off-by: 刘瓒 <liuzan9@huawei.com>
This commit is contained in:
parent
3b65cbce41
commit
7d66465d40
@ -55,7 +55,8 @@ using GraphicCompositionType = enum {
|
||||
GRAPHIC_COMPOSITION_DEVICE_CLEAR, /**< Device clear composition type, the device will clear the target region. */
|
||||
GRAPHIC_COMPOSITION_CLIENT_CLEAR, /**< Client clear composition type, the service will clear the target region. */
|
||||
GRAPHIC_COMPOSITION_TUNNEL, /**< Tunnel composition type, used for tunnel. */
|
||||
GRAPHIC_COMPOSITION_BUTT
|
||||
GRAPHIC_COMPOSITION_BUTT,
|
||||
GRAPHIC_COMPOSITION_SOLID_COLOR /**< used for SetLayerColor. */
|
||||
};
|
||||
|
||||
using GraphicLayerAlpha = struct {
|
||||
|
@ -50,6 +50,7 @@ static const std::map<GraphicCompositionType, std::string> CompositionTypeStrs =
|
||||
{GRAPHIC_COMPOSITION_CLIENT_CLEAR, "5 <client clear composistion>"},
|
||||
{GRAPHIC_COMPOSITION_TUNNEL, "6 <tunnel composistion>"},
|
||||
{GRAPHIC_COMPOSITION_BUTT, "7 <uninitialized>"},
|
||||
{GRAPHIC_COMPOSITION_SOLID_COLOR, "8 <layercolor composition>"},
|
||||
};
|
||||
|
||||
static const std::map<GraphicBlendType, std::string> BlendTypeStrs = {
|
||||
|
@ -55,6 +55,7 @@ ohos_executable("hello_composer") {
|
||||
]
|
||||
|
||||
external_deps = [
|
||||
"c_utils:utils",
|
||||
"eventhandler:libeventhandler",
|
||||
"hilog:libhilog",
|
||||
]
|
||||
|
@ -74,7 +74,7 @@ void HelloComposer::Run(const std::vector<std::string> &runArgs)
|
||||
sleep(1);
|
||||
std::shared_ptr<OHOS::AppExecFwk::EventRunner> runner = OHOS::AppExecFwk::EventRunner::Create(false);
|
||||
mainThreadHandler_ = std::make_shared<OHOS::AppExecFwk::EventHandler>(runner);
|
||||
g_receiver = new VSyncReceiver(vsyncConnection, mainThreadHandler_);
|
||||
g_receiver = new VSyncReceiver(vsyncConnection, nullptr, mainThreadHandler_);
|
||||
g_receiver->Init();
|
||||
mainThreadHandler_->PostTask(std::bind(&HelloComposer::RequestSync, this));
|
||||
runner->Run();
|
||||
@ -91,6 +91,8 @@ void HelloComposer::ParseArgs(const std::vector<std::string> &runArgs)
|
||||
testLayerRotate_ = true;
|
||||
} else if (arg == "--YUV") {
|
||||
YUVFormat_ = true;
|
||||
} else if (arg == "--testLayerColor") {
|
||||
testLayerColor_ = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -219,6 +221,10 @@ void HelloComposer::Sync(int64_t, void *data)
|
||||
void HelloComposer::SetRunArgs(const std::unique_ptr<LayerContext> &drawLayer) const
|
||||
{
|
||||
LayerType type = drawLayer->GetLayerType();
|
||||
if (testLayerColor_) {
|
||||
drawLayer->SetTestLayerColor(true);
|
||||
}
|
||||
|
||||
if (type < LayerType::LAYER_EXTRA) {
|
||||
return;
|
||||
}
|
||||
@ -248,6 +254,7 @@ void HelloComposer::Draw()
|
||||
}
|
||||
|
||||
for (auto &drawLayer : drawLayers) { // consumer
|
||||
drawLayer->FillHDIBuffer();
|
||||
drawLayer->FillHDILayer();
|
||||
layerVec.emplace_back(drawLayer->GetHdiLayer());
|
||||
}
|
||||
@ -464,13 +471,11 @@ void HelloComposer::DoPrepareCompleted(sptr<Surface> surface, const struct Prepa
|
||||
sptr<SyncFence> tempFence = new SyncFence(releaseFence);
|
||||
tempFence->Wait(100); // 100 ms
|
||||
|
||||
uint32_t clientCount = 0;
|
||||
bool hasClient = false;
|
||||
const std::vector<LayerInfoPtr> &layers = param.layers;
|
||||
for (const LayerInfoPtr &layer : layers) {
|
||||
if (layer->GetCompositionType() == GraphicCompositionType::GRAPHIC_COMPOSITION_CLIENT) {
|
||||
hasClient = true;
|
||||
clientCount++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,6 +47,7 @@ private:
|
||||
bool postHotPlugEvent_ = false;
|
||||
bool testClient_ = false;
|
||||
bool testLayerRotate_ = false;
|
||||
bool testLayerColor_ = false;
|
||||
HdiBackend* backend_ = nullptr;
|
||||
std::vector<std::unique_ptr<HdiScreen>> screens_;
|
||||
std::shared_ptr<HdiOutput> curOutput_;
|
||||
|
@ -72,6 +72,11 @@ void LayerContext::SetTestYUVStatus(bool status)
|
||||
testYUV_ = status;
|
||||
}
|
||||
|
||||
void LayerContext::SetTestLayerColor(bool status)
|
||||
{
|
||||
testLayerColor_ = status;
|
||||
}
|
||||
|
||||
OHOS::Rosen::LayerType LayerContext::GetLayerType() const
|
||||
{
|
||||
return layerType_;
|
||||
@ -132,23 +137,9 @@ SurfaceError LayerContext::DrawBufferColor()
|
||||
return ret;
|
||||
}
|
||||
|
||||
SurfaceError LayerContext::FillHDILayer()
|
||||
void LayerContext::FillHDILayer()
|
||||
{
|
||||
OHOS::sptr<SurfaceBuffer> buffer = nullptr;
|
||||
int32_t acquireFence = -1;
|
||||
int64_t timestamp;
|
||||
Rect damage;
|
||||
SurfaceError ret = cSurface_->AcquireBuffer(buffer, acquireFence, timestamp, damage);
|
||||
sptr<SyncFence> acquireSyncFence = new SyncFence(acquireFence);
|
||||
if (ret != SURFACE_ERROR_OK) {
|
||||
LOGE("Acquire buffer failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
GraphicLayerAlpha alpha = { .enPixelAlpha = true };
|
||||
|
||||
hdiLayer_->SetSurface(cSurface_);
|
||||
hdiLayer_->SetBuffer(buffer, acquireSyncFence);
|
||||
hdiLayer_->SetZorder(static_cast<int32_t>(zorder_));
|
||||
hdiLayer_->SetAlpha(alpha);
|
||||
if (layerType_ >= LayerType::LAYER_EXTRA) {
|
||||
@ -163,9 +154,52 @@ SurfaceError LayerContext::FillHDILayer()
|
||||
dirtyRegions.emplace_back(src_);
|
||||
hdiLayer_->SetDirtyRegions(dirtyRegions);
|
||||
hdiLayer_->SetLayerSize(dst_);
|
||||
|
||||
if (testLayerColor_) {
|
||||
hdiLayer_->SetBlendType(GraphicBlendType::GRAPHIC_BLEND_SRC);
|
||||
} else {
|
||||
hdiLayer_->SetBlendType(GraphicBlendType::GRAPHIC_BLEND_SRCOVER);
|
||||
}
|
||||
|
||||
hdiLayer_->SetPreMulti(true);
|
||||
hdiLayer_->SetCropRect(src_);
|
||||
hdiLayer_->SetPreMulti(false);
|
||||
}
|
||||
|
||||
SurfaceError LayerContext::FillHDIBuffer()
|
||||
{
|
||||
OHOS::sptr<SurfaceBuffer> buffer = nullptr;
|
||||
int32_t acquireFence = -1;
|
||||
int64_t timestamp;
|
||||
Rect damage;
|
||||
SurfaceError ret = cSurface_->AcquireBuffer(buffer, acquireFence, timestamp, damage);
|
||||
sptr<SyncFence> acquireSyncFence = new SyncFence(acquireFence);
|
||||
if (ret != SURFACE_ERROR_OK) {
|
||||
LOGE("Acquire buffer failed");
|
||||
return ret;
|
||||
}
|
||||
|
||||
hdiLayer_->SetSurface(cSurface_);
|
||||
|
||||
if (testLayerColor_) {
|
||||
if (layerType_ != LayerType::LAYER_LAUNCHER) {
|
||||
hdiLayer_->SetBuffer(buffer, acquireSyncFence);
|
||||
} else {
|
||||
const uint32_t COLOR_R = 255; // 255 is red color
|
||||
const uint32_t COLOR_G = 255; // 255 is green color
|
||||
const uint32_t COLOR_B = 255; // 255 is blue color
|
||||
const uint32_t COLOR_A = 255; // 255 is alpha
|
||||
GraphicLayerColor color = {
|
||||
.r = COLOR_R,
|
||||
.g = COLOR_G,
|
||||
.b = COLOR_B,
|
||||
.a = COLOR_A
|
||||
};
|
||||
|
||||
hdiLayer_->SetLayerColor(color);
|
||||
}
|
||||
} else {
|
||||
hdiLayer_->SetBuffer(buffer, acquireSyncFence);
|
||||
}
|
||||
|
||||
prevBuffer_ = buffer;
|
||||
prevFence_ = acquireSyncFence;
|
||||
@ -201,6 +235,8 @@ void LayerContext::SetLayerCompositionType()
|
||||
{
|
||||
if (layerType_ >= LayerType::LAYER_EXTRA && testClient_) {
|
||||
hdiLayer_->SetCompositionType(GraphicCompositionType::GRAPHIC_COMPOSITION_CLIENT);
|
||||
} else if (layerType_ == LayerType::LAYER_LAUNCHER && testLayerColor_) {
|
||||
hdiLayer_->SetCompositionType(GraphicCompositionType::GRAPHIC_COMPOSITION_SOLID_COLOR);
|
||||
} else {
|
||||
hdiLayer_->SetCompositionType(GraphicCompositionType::GRAPHIC_COMPOSITION_DEVICE);
|
||||
}
|
||||
|
@ -48,11 +48,13 @@ public:
|
||||
|
||||
void OnBufferAvailable() override;
|
||||
SurfaceError DrawBufferColor();
|
||||
SurfaceError FillHDILayer();
|
||||
void FillHDILayer();
|
||||
SurfaceError FillHDIBuffer();
|
||||
const std::shared_ptr<HdiLayerInfo> GetHdiLayer();
|
||||
void SetTestClientStatus(bool status);
|
||||
void SetTestRotateStatus(bool status);
|
||||
void SetTestYUVStatus(bool status);
|
||||
void SetTestLayerColor(bool status);
|
||||
LayerType GetLayerType() const;
|
||||
sptr<SurfaceBuffer> GetPreBuffer() const
|
||||
{
|
||||
@ -80,6 +82,7 @@ private:
|
||||
bool testClient_ = false;
|
||||
bool testRotate_ = false;
|
||||
bool testYUV_ = false;
|
||||
bool testLayerColor_ = false;
|
||||
|
||||
void DrawColor(void *image, int width, int height);
|
||||
void DrawExtraColor(void *image, uint32_t width, uint32_t height);
|
||||
|
Loading…
Reference in New Issue
Block a user