• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef OHOS_HDI_DISPLAY_V1_3_DISPLAY_CMD_REQUESTER_H
17 #define OHOS_HDI_DISPLAY_V1_3_DISPLAY_CMD_REQUESTER_H
18 
19 #include "v1_2/display_command/display_cmd_requester.h"
20 #include "v1_3/display_command/display_cmd_utils.h"
21 #include "v1_3/display_composer_type.h"
22 #include "v1_3/idisplay_composer.h"
23 
24 namespace OHOS {
25 namespace HDI {
26 namespace Display {
27 namespace Composer {
28 namespace V1_3 {
29 using namespace OHOS::HDI::Base;
30 
31 template <typename Transfer, typename CompHdi>
32 class DisplayCmdRequester : public V1_2::DisplayCmdRequester<Transfer, CompHdi> {
33 public:
DisplayCmdRequester(sptr<CompHdi> hdi)34     DisplayCmdRequester(sptr<CompHdi> hdi) : BaseType1_2(hdi), hdi_1_3_(hdi) {}
35 
Create(sptr<CompHdi> hdi)36     static std::unique_ptr<DisplayCmdRequester> Create(sptr<CompHdi> hdi)
37     {
38         DISPLAY_CHK_RETURN(hdi == nullptr, nullptr, HDF_LOGE("%{public}s: hdi is nullptr", __func__));
39         auto requester = std::make_unique<DisplayCmdRequester>(hdi);
40         DISPLAY_CHK_RETURN(requester == nullptr, nullptr,
41             HDF_LOGE("%{public}s: CmdRequester is nullptr", __func__));
42         auto ret = requester->Init(CmdUtils::INIT_ELEMENT_COUNT);
43         if (ret != HDF_SUCCESS) {
44             HDF_LOGE("DisplayCmdRequester init failed");
45             return nullptr;
46         }
47         return requester;
48     }
49 
50 protected:
51     sptr<CompHdi> hdi_1_3_;
52 private:
53     using BaseType1_2 = V1_2::DisplayCmdRequester<Transfer, CompHdi>;
54 };
55 using HdiDisplayCmdRequester = V1_3::DisplayCmdRequester<SharedMemQueue<int32_t>, V1_3::IDisplayComposer>;
56 } // namespace V1_3
57 } // namespace Composer
58 } // namespace Display
59 } // namespace HDI
60 } // namespace OHOS
61 #endif // OHOS_HDI_DISPLAY_V1_3_DISPLAY_CMD_REQUESTER_H
62