/* * Copyright (c) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #ifndef HDI_DRM_COMPOSITION_H #define HDI_DRM_COMPOSITION_H #include #include #include #include #include "drm_device.h" #include "hdi_composer.h" #include "hdi_device_common.h" #include "hdi_drm_layer.h" namespace OHOS { namespace HDI { namespace DISPLAY { class AtomicReqPtr { public: explicit AtomicReqPtr(drmModeAtomicReqPtr ptr) : mPtr(ptr) {} virtual ~AtomicReqPtr() { if (mPtr != nullptr) drmModeAtomicFree(mPtr); } drmModeAtomicReqPtr Get() const { return mPtr; } private: drmModeAtomicReqPtr mPtr; }; class HdiDrmComposition : public HdiComposition { public: HdiDrmComposition(const std::shared_ptr &connector, const std::shared_ptr &crtc, const std::shared_ptr &drmDevice); ~HdiDrmComposition() override {} int32_t Init() override; int32_t SetLayers(std::vector &layers, HdiLayer &clientLayer) override; int32_t Apply(bool modeSet) override; int32_t UpdateMode(std::unique_ptr &modeBlock); private: int32_t ApplyPlane(HdiDrmLayer &layer, HdiLayer &hlayer, DrmPlane &drmPlane, drmModeAtomicReqPtr pset); int32_t SetSrcProperty(DrmPlane &drmPlane, drmModeAtomicReqPtr pset, int32_t bufferW, int32_t bufferH); int32_t SetCrtcProperty(DrmPlane &drmPlane, drmModeAtomicReqPtr pset, int32_t bufferW, int32_t bufferH); int32_t RemoveUnusePlane(drmModeAtomicReqPtr pset); int32_t FindPlaneAndApply(drmModeAtomicReqPtr pset); std::shared_ptr mDrmDevice; std::shared_ptr mConnector; std::shared_ptr mCrtc; std::vector> mPrimPlanes; std::vector> mOverlayPlanes; std::vector> mPlanes; }; } // OHOS } // HDI } // DISPLAY #endif // HDI_DRM_COMPOSITION_H