2 * Copyright (C) 2015 The Android Open Source Project
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef ANDROID_DRM_DISPLAY_COMPOSITION_H_
18 #define ANDROID_DRM_DISPLAY_COMPOSITION_H_
20 #include "drm_hwcomposer.h"
28 #include <hardware/gralloc.h>
29 #include <hardware/hardware.h>
30 #include <hardware/hwcomposer.h>
34 enum DrmCompositionType {
35 DRM_COMPOSITION_TYPE_EMPTY,
36 DRM_COMPOSITION_TYPE_FRAME,
37 DRM_COMPOSITION_TYPE_DPMS,
40 typedef struct DrmCompositionLayer {
41 DrmCompositionLayer();
47 native_handle_t *handle;
48 } DrmCompositionLayer_t;
49 typedef std::vector<DrmCompositionLayer_t> DrmCompositionLayerVector_t;
51 class DrmDisplayComposition {
53 DrmDisplayComposition();
54 ~DrmDisplayComposition();
56 int Init(DrmResources *drm, DrmCrtc *crtc, Importer *importer,
59 DrmCompositionType type() const;
61 int SetLayers(hwc_layer_1_t *layers, size_t num_layers, size_t *layer_indices,
62 std::vector<DrmPlane *> *primary_planes,
63 std::vector<DrmPlane *> *overlay_planes);
64 int AddPlaneDisable(DrmPlane *plane);
65 int SetDpmsMode(uint32_t dpms_mode);
67 void RemoveNoPlaneLayers();
68 int SignalPreCompositionDone();
69 int FinishComposition();
71 DrmCompositionLayerVector_t *GetCompositionLayers();
72 int pre_composition_layer_index() const;
73 uint32_t dpms_mode() const;
75 uint64_t frame_no() const;
77 Importer *importer() const;
80 DrmDisplayComposition(const DrmDisplayComposition &) = delete;
82 bool validate_composition_type(DrmCompositionType desired);
84 int CreateNextTimelineFence();
85 int IncreaseTimelineToPoint(int point);
90 const gralloc_module_t *gralloc_;
91 EGLDisplay egl_display_;
93 DrmCompositionType type_;
97 int timeline_current_;
98 int timeline_pre_comp_done_;
100 DrmCompositionLayerVector_t layers_;
101 int pre_composition_layer_index_;
108 #endif // ANDROID_DRM_DISPLAY_COMPOSITION_H_