OSDN Git Service

drm_hwcomposer: Use hw planes + drm atomic interface
[android-x86/external-drm_hwcomposer.git] / drmcompositor.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_COMPOSITOR_H_
18 #define ANDROID_DRM_COMPOSITOR_H_
19
20 #include "compositor.h"
21 #include "drm_hwcomposer.h"
22 #include "drmcomposition.h"
23 #include "drmcompositorworker.h"
24 #include "drmplane.h"
25 #include "importer.h"
26
27 #include <pthread.h>
28 #include <queue>
29
30 #include <hardware/hardware.h>
31 #include <hardware/hwcomposer.h>
32
33 namespace android {
34
35 class Drm;
36
37 class DrmCompositor : public Compositor {
38  public:
39   DrmCompositor(DrmResources *drm);
40   ~DrmCompositor();
41
42   virtual int Init();
43
44   virtual Targeting *targeting() {
45     return NULL;
46   }
47
48   virtual Composition *CreateComposition(Importer *importer);
49
50   virtual int QueueComposition(Composition *composition);
51   virtual int Composite();
52
53   bool HaveQueuedComposites() const;
54
55  private:
56   DrmCompositor(const DrmCompositor &);
57
58   int CompositeDisplay(DrmCompositionLayerMap_t::iterator begin,
59                        DrmCompositionLayerMap_t::iterator end);
60   int PerformModeset(DrmCompositionLayerMap_t::iterator begin,
61                      DrmCompositionLayerMap_t::iterator end);
62
63   DrmResources *drm_;
64
65   DrmCompositorWorker worker_;
66
67   std::queue<DrmComposition *> composite_queue_;
68   DrmComposition *active_composition_;
69
70   uint64_t frame_no_;
71
72   bool initialized_;
73
74   // mutable since we need to acquire in HaveQueuedComposites
75   mutable pthread_mutex_t lock_;
76 };
77 }
78
79 #endif  // ANDROID_DRM_COMPOSITOR_H_