diff --git a/Android.bp b/Android.bp index c2649aa..1fe690e 100644 --- a/Android.bp +++ b/Android.bp @@ -95,6 +95,7 @@ filegroup { "backend/GenericCompositionPlanner.cpp", "backend/ClientCompositionPlanner.cpp", "backend/BackendManager.cpp", + "backend/GenericPipelineCreator.cpp", "hwc/HwcDisplay.cpp", "hwc/HwcDisplayConfigs.cpp", diff --git a/backend/GenericCompositionPlanner.cpp b/backend/GenericCompositionPlanner.cpp index ec5c814..1a5e7dd 100644 --- a/backend/GenericCompositionPlanner.cpp +++ b/backend/GenericCompositionPlanner.cpp @@ -266,22 +266,4 @@ std::tuple GenericCompositionPlanner::GetExtraClientRange( return std::make_tuple(client_start, client_size); } -class GenericBackendPipelineCreator : public BackendManager::PipelineCreator { - public: - GenericBackendPipelineCreator() : BackendManager::PipelineCreator("generic") { - } - std::unique_ptr CreatePipeline( - DrmConnector& connector) override { - auto pipeline = DrmDisplayPipeline::CreatePipeline(connector); - if (pipeline) { - pipeline->backend = std::make_unique(); - } - return pipeline; - } -}; - -// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables, -// cert-err58-cpp) -static GenericBackendPipelineCreator generic_backend; - } // namespace android::drm_hwcomposer diff --git a/backend/GenericPipelineCreator.cpp b/backend/GenericPipelineCreator.cpp new file mode 100644 index 0000000..35260ed --- /dev/null +++ b/backend/GenericPipelineCreator.cpp @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * 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. + */ + +#include "backend/GenericPipelineCreator.h" + +#include "backend/GenericCompositionPlanner.h" +#include "drm/DrmDisplayPipeline.h" + +namespace android::drm_hwcomposer { + +GenericPipelineCreator::GenericPipelineCreator() + : BackendManager::PipelineCreator("generic") { +} + +std::unique_ptr GenericPipelineCreator::CreatePipeline( + DrmConnector& connector) { + auto pipeline = DrmDisplayPipeline::CreatePipeline(connector); + if (pipeline) { + pipeline->backend = std::make_unique(); + } + return pipeline; +} + +// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables) +static GenericPipelineCreator generic_pipeline_creator; + +} // namespace android::drm_hwcomposer diff --git a/backend/GenericPipelineCreator.h b/backend/GenericPipelineCreator.h new file mode 100644 index 0000000..2e57c22 --- /dev/null +++ b/backend/GenericPipelineCreator.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2025 The Android Open Source Project + * + * 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. + */ + +#pragma once + +#include "backend/BackendManager.h" + +namespace android::drm_hwcomposer { + +// Implement the PipelineCreator interface by creating a DrmDisplayPipeline +// using generic heuristics on top of upstream drm uAPI. +class GenericPipelineCreator : public BackendManager::PipelineCreator { + public: + GenericPipelineCreator(); + std::unique_ptr CreatePipeline( + DrmConnector& connector) override; +}; + +} // namespace android::drm_hwcomposer diff --git a/meson.build b/meson.build index 87191fa..4994893 100644 --- a/meson.build +++ b/meson.build @@ -15,6 +15,7 @@ src_common = files( 'backend/BackendManager.cpp', 'backend/GenericCompositionPlanner.cpp', 'backend/ClientCompositionPlanner.cpp', + 'backend/GenericPipelineCreator.cpp', 'hwc/HwcDisplayConfigs.cpp', 'hwc/HwcDisplay.cpp', 'hwc/HwcLayer.cpp',