blob: bc8cf2ea0ed00fe084a0289fd7ef13406acdcc27 [file] [log] [blame]
Sean Paul98e73c82015-06-24 14:38:49 -07001/*
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_DISPLAY_COMPOSITION_H_
18#define ANDROID_DRM_DISPLAY_COMPOSITION_H_
19
20#include "drm_hwcomposer.h"
21#include "drmplane.h"
22#include "importer.h"
23
24#include <vector>
25
26#include <hardware/hardware.h>
27#include <hardware/hwcomposer.h>
28
29namespace android {
30
Sean Paulacb2a442015-06-24 18:43:01 -070031enum DrmCompositionType {
32 DRM_COMPOSITION_TYPE_EMPTY,
33 DRM_COMPOSITION_TYPE_FRAME,
34};
35
Sean Paul98e73c82015-06-24 14:38:49 -070036typedef struct DrmCompositionLayer {
37 DrmCompositionLayer();
38 ~DrmCompositionLayer();
39
40 hwc_layer_1_t layer;
41 hwc_drm_bo_t bo;
42 DrmCrtc *crtc;
43 DrmPlane *plane;
44} DrmCompositionLayer_t;
45typedef std::vector<DrmCompositionLayer_t> DrmCompositionLayerVector_t;
46
47class DrmDisplayComposition {
48 public:
49 DrmDisplayComposition();
50 ~DrmDisplayComposition();
51
52 int Init(DrmResources *drm, Importer *importer);
53
Sean Paulacb2a442015-06-24 18:43:01 -070054 DrmCompositionType type() const;
55
Sean Paul98e73c82015-06-24 14:38:49 -070056 int AddLayer(hwc_layer_1_t *layer, hwc_drm_bo_t *bo, DrmCrtc *crtc,
57 DrmPlane *plane);
58
59 int FinishComposition();
60
61 DrmCompositionLayerVector_t *GetCompositionLayers();
62
63 private:
64 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
65
Sean Paulacb2a442015-06-24 18:43:01 -070066 bool validate_composition_type(DrmCompositionType desired);
67
Sean Paul98e73c82015-06-24 14:38:49 -070068 DrmResources *drm_;
69 Importer *importer_;
70
Sean Paulacb2a442015-06-24 18:43:01 -070071 DrmCompositionType type_;
72
Sean Paul98e73c82015-06-24 14:38:49 -070073 int timeline_fd_;
74 int timeline_;
75
76 DrmCompositionLayerVector_t layers_;
77};
78}
79
80#endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_