OSDN Git Service

drm_hwcomposer: Allow layer transforms
[android-x86/external-drm_hwcomposer.git] / drmcomposition.h
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 "drm_hwcomposer.h"
21 #include "drmdisplaycomposition.h"
22 #include "drmplane.h"
23 #include "importer.h"
24
25 #include <deque>
26 #include <map>
27 #include <vector>
28
29 #include <hardware/hardware.h>
30 #include <hardware/hwcomposer.h>
31
32 namespace android {
33
34 struct DrmCompositionDisplayLayersMap {
35   int display;
36   size_t num_layers;
37   hwc_layer_1_t *layers;
38   size_t *layer_indices;
39 };
40
41 class DrmComposition {
42  public:
43   DrmComposition(DrmResources *drm, Importer *importer);
44
45   int Init();
46
47   int SetLayers(size_t num_displays,
48                 const DrmCompositionDisplayLayersMap *maps);
49   int SetDpmsMode(int display, uint32_t dpms_mode);
50
51   std::unique_ptr<DrmDisplayComposition> TakeDisplayComposition(int display);
52   DrmDisplayComposition *GetDisplayComposition(int display);
53   int DisableUnusedPlanes();
54
55  private:
56   DrmComposition(const DrmComposition &) = delete;
57
58   DrmResources *drm_;
59   Importer *importer_;
60
61   std::vector<DrmPlane *> primary_planes_;
62   std::vector<DrmPlane *> overlay_planes_;
63
64   /*
65    * This _must_ be read-only after it's passed to QueueComposition. Otherwise
66    * locking is required to maintain consistency across the compositor threads.
67    */
68   std::map<int, std::unique_ptr<DrmDisplayComposition>> composition_map_;
69 };
70 }
71
72 #endif  // ANDROID_DRM_COMPOSITION_H_