1 /* 2 * Copyright 2018 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #pragma once 18 19 #include <TimeStats/TimeStats.h> 20 #include <utils/Timers.h> 21 22 #include <memory> 23 24 namespace android { 25 26 class HWComposer; 27 28 namespace renderengine { 29 class RenderEngine; 30 } // namespace renderengine 31 32 namespace compositionengine { 33 34 class Display; 35 36 struct CompositionRefreshArgs; 37 struct DisplayCreationArgs; 38 struct LayerCreationArgs; 39 struct LayerFECompositionState; 40 41 /** 42 * Encapsulates all the interfaces and implementation details for performing 43 * display output composition. 44 */ 45 class CompositionEngine { 46 public: 47 virtual ~CompositionEngine(); 48 49 // Create a composition Display 50 virtual std::shared_ptr<Display> createDisplay(const DisplayCreationArgs&) = 0; 51 virtual std::unique_ptr<compositionengine::LayerFECompositionState> 52 createLayerFECompositionState() = 0; 53 54 virtual HWComposer& getHwComposer() const = 0; 55 virtual void setHwComposer(std::unique_ptr<HWComposer>) = 0; 56 57 virtual renderengine::RenderEngine& getRenderEngine() const = 0; 58 virtual void setRenderEngine(std::unique_ptr<renderengine::RenderEngine>) = 0; 59 60 virtual TimeStats& getTimeStats() const = 0; 61 virtual void setTimeStats(const std::shared_ptr<TimeStats>&) = 0; 62 63 virtual bool needsAnotherUpdate() const = 0; 64 virtual nsecs_t getLastFrameRefreshTimestamp() const = 0; 65 66 // Presents the indicated outputs 67 virtual void present(CompositionRefreshArgs&) = 0; 68 69 // Updates the cursor position for the indicated outputs. 70 virtual void updateCursorAsync(CompositionRefreshArgs&) = 0; 71 72 // TODO(b/121291683): These will become private/internal 73 virtual void preComposition(CompositionRefreshArgs&) = 0; 74 75 // Debugging 76 virtual void dump(std::string&) const = 0; 77 }; 78 79 } // namespace compositionengine 80 } // namespace android 81