/* * Copyright 2019 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 #include #include #include #include #include #include #include #include #include #include "DisplayHardware/HWComposer.h" #include "DisplayHardware/PowerAdvisor.h" namespace android::compositionengine { class CompositionEngine; namespace impl { // The implementation class contains the common implementation, but does not // actually contain the final display state. class Display : public compositionengine::impl::Output, public virtual compositionengine::Display { public: virtual ~Display(); // compositionengine::Output overrides std::optional getDisplayId() const override; bool isValid() const override; void dump(std::string&) const override; using compositionengine::impl::Output::setReleasedLayers; void setReleasedLayers(const CompositionRefreshArgs&) override; void setColorTransform(const CompositionRefreshArgs&) override; void setColorProfile(const ColorProfile&) override; void beginFrame() override; using DeviceRequestedChanges = android::HWComposer::DeviceRequestedChanges; bool chooseCompositionStrategy( std::optional*) override; void applyCompositionStrategy(const std::optional&) override; bool getSkipColorTransform() const override; compositionengine::Output::FrameFences presentFrame() override; void executeCommands() override; void setExpensiveRenderingExpected(bool) override; void finishFrame(GpuCompositionResult&&) override; bool supportsOffloadPresent() const override; // compositionengine::Display overrides DisplayId getId() const override; bool isSecure() const override; bool isVirtual() const override; void disconnect() override; void createDisplayColorProfile( const compositionengine::DisplayColorProfileCreationArgs&) override; void createRenderSurface(const compositionengine::RenderSurfaceCreationArgs&) override; void createClientCompositionCache(uint32_t cacheSize) override; void applyDisplayBrightness(bool applyImmediately) override; void setSecure(bool secure) override; // Internal helpers used by chooseCompositionStrategy() using ChangedTypes = android::HWComposer::DeviceRequestedChanges::ChangedTypes; using DisplayRequests = android::HWComposer::DeviceRequestedChanges::DisplayRequests; using LayerRequests = android::HWComposer::DeviceRequestedChanges::LayerRequests; using ClientTargetProperty = android::HWComposer::DeviceRequestedChanges::ClientTargetProperty; virtual bool allLayersRequireClientComposition() const; virtual void applyChangedTypesToLayers(const ChangedTypes&); virtual void applyDisplayRequests(const DisplayRequests&); virtual void applyLayerRequestsToLayers(const LayerRequests&); virtual void applyClientTargetRequests(const ClientTargetProperty&); // Internal virtual void setConfiguration(const compositionengine::DisplayCreationArgs&); std::unique_ptr createOutputLayer(const sp&) const; private: bool isPowerHintSessionEnabled() override; bool isPowerHintSessionGpuReportingEnabled() override; void setHintSessionGpuStart(TimePoint startTime) override; void setHintSessionGpuFence(std::unique_ptr&& gpuFence) override; void setHintSessionRequiresRenderEngine(bool requiresRenderEngine) override; DisplayId mId; bool mIsDisconnected = false; Hwc2::PowerAdvisor* mPowerAdvisor = nullptr; }; // This template factory function standardizes the implementation details of the // final class using the types actually required by the implementation. This is // not possible to do in the base class as those types may not even be visible // to the base code. template std::shared_ptr createDisplayTemplated( const CompositionEngine& compositionEngine, const compositionengine::DisplayCreationArgs& args) { auto display = createOutputTemplated(compositionEngine); display->setConfiguration(args); return display; } std::shared_ptr createDisplay(const compositionengine::CompositionEngine&, const compositionengine::DisplayCreationArgs&); } // namespace impl } // namespace android::compositionengine