• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2022 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 #ifndef ANDROID_HWC_CLIENTCOMPOSER_H
18 #define ANDROID_HWC_CLIENTCOMPOSER_H
19 
20 #include <unordered_map>
21 
22 #include "Common.h"
23 #include "Composer.h"
24 #include "Display.h"
25 #include "DrmPresenter.h"
26 #include "Layer.h"
27 
28 namespace android {
29 
30 class ClientComposer : public Composer {
31  public:
32   ClientComposer(DrmPresenter* drmPresenter);
33 
34   ClientComposer(const ClientComposer&) = delete;
35   ClientComposer& operator=(const ClientComposer&) = delete;
36 
37   ClientComposer(ClientComposer&&) = delete;
38   ClientComposer& operator=(ClientComposer&&) = delete;
39 
40   HWC2::Error init() override;
41 
42   HWC2::Error onDisplayCreate(Display*) override;
43 
44   HWC2::Error onDisplayDestroy(Display*) override;
45 
46   HWC2::Error onDisplayClientTargetSet(Display*) override;
47 
48   HWC2::Error onActiveConfigChange(Display*) override;
49 
50   // Determines if this composer can compose the given layers on the given
51   // display and requests changes for layers that can't not be composed.
52   HWC2::Error validateDisplay(
53       Display* display, std::unordered_map<hwc2_layer_t, HWC2::Composition>*
54                             outLayerCompositionChanges) override;
55 
56   // Performs the actual composition of layers and presents the composed result
57   // to the display.
58   std::tuple<HWC2::Error, base::unique_fd> presentDisplay(
59       Display* display) override;
60 
61  private:
62   struct DisplayInfo {
63     std::unique_ptr<DrmBuffer> clientTargetDrmBuffer;
64   };
65 
66   std::unordered_map<int64_t, DisplayInfo> mDisplayInfos;
67 
68   DrmPresenter* mDrmPresenter = nullptr;
69 };
70 
71 }  // namespace android
72 
73 #endif