• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 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_DRM_COMPOSITION_H_
18 #define ANDROID_DRM_COMPOSITION_H_
19 
20 #include "drmhwcomposer.h"
21 #include "drmdisplaycomposition.h"
22 #include "drmplane.h"
23 #include "platform.h"
24 
25 #include <map>
26 #include <vector>
27 
28 #include <hardware/hardware.h>
29 #include <hardware/hwcomposer.h>
30 
31 namespace android {
32 
33 class DrmDisplayCompositor;
34 
35 struct DrmCompositionDisplayLayersMap {
36   int display;
37   bool geometry_changed = true;
38   std::vector<DrmHwcLayer> layers;
39 
40   DrmCompositionDisplayLayersMap() = default;
41   DrmCompositionDisplayLayersMap(DrmCompositionDisplayLayersMap &&rhs) =
42       default;
43 };
44 
45 class DrmComposition {
46  public:
47   DrmComposition(DrmResources *drm, Importer *importer, Planner *planner);
48 
49   int Init(uint64_t frame_no);
50 
51   int SetLayers(size_t num_displays, DrmCompositionDisplayLayersMap *maps);
52   int SetDpmsMode(int display, uint32_t dpms_mode);
53   int SetDisplayMode(int display, const DrmMode &display_mode);
54 
55   std::unique_ptr<DrmDisplayComposition> TakeDisplayComposition(int display);
56   DrmDisplayComposition *GetDisplayComposition(int display);
57 
58   int Plan(std::map<int, DrmDisplayCompositor> &compositor_map);
59   int DisableUnusedPlanes();
60 
61  private:
62   DrmComposition(const DrmComposition &) = delete;
63 
64   DrmResources *drm_;
65   Importer *importer_;
66   Planner *planner_;
67 
68   std::vector<DrmPlane *> primary_planes_;
69   std::vector<DrmPlane *> overlay_planes_;
70 
71   /*
72    * This _must_ be read-only after it's passed to QueueComposition. Otherwise
73    * locking is required to maintain consistency across the compositor threads.
74    */
75   std::map<int, std::unique_ptr<DrmDisplayComposition>> composition_map_;
76 };
77 }
78 
79 #endif  // ANDROID_DRM_COMPOSITION_H_
80