Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 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> |
Sean Paul | c8dcfe0 | 2015-06-10 17:29:05 -0400 | [diff] [blame^] | 29 | #include <sstream> |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 30 | |
| 31 | #include <hardware/hardware.h> |
| 32 | #include <hardware/hwcomposer.h> |
| 33 | |
| 34 | namespace android { |
| 35 | |
| 36 | class Drm; |
| 37 | |
| 38 | class DrmCompositor : public Compositor { |
| 39 | public: |
| 40 | DrmCompositor(DrmResources *drm); |
| 41 | ~DrmCompositor(); |
| 42 | |
| 43 | virtual int Init(); |
| 44 | |
| 45 | virtual Targeting *targeting() { |
| 46 | return NULL; |
| 47 | } |
| 48 | |
| 49 | virtual Composition *CreateComposition(Importer *importer); |
| 50 | |
| 51 | virtual int QueueComposition(Composition *composition); |
| 52 | virtual int Composite(); |
Sean Paul | c8dcfe0 | 2015-06-10 17:29:05 -0400 | [diff] [blame^] | 53 | virtual void Dump(std::ostringstream *out) const; |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 54 | |
| 55 | bool HaveQueuedComposites() const; |
| 56 | |
| 57 | private: |
| 58 | DrmCompositor(const DrmCompositor &); |
| 59 | |
| 60 | int CompositeDisplay(DrmCompositionLayerMap_t::iterator begin, |
| 61 | DrmCompositionLayerMap_t::iterator end); |
| 62 | int PerformModeset(DrmCompositionLayerMap_t::iterator begin, |
| 63 | DrmCompositionLayerMap_t::iterator end); |
| 64 | |
| 65 | DrmResources *drm_; |
| 66 | |
| 67 | DrmCompositorWorker worker_; |
| 68 | |
| 69 | std::queue<DrmComposition *> composite_queue_; |
| 70 | DrmComposition *active_composition_; |
| 71 | |
| 72 | uint64_t frame_no_; |
| 73 | |
| 74 | bool initialized_; |
| 75 | |
| 76 | // mutable since we need to acquire in HaveQueuedComposites |
| 77 | mutable pthread_mutex_t lock_; |
Sean Paul | c8dcfe0 | 2015-06-10 17:29:05 -0400 | [diff] [blame^] | 78 | |
| 79 | // State tracking progress since our last Dump(). These are mutable since |
| 80 | // we need to reset them on every Dump() call. |
| 81 | mutable uint64_t dump_frames_composited_; |
| 82 | mutable uint64_t dump_last_timestamp_ns_; |
Sean Paul | b386f1b | 2015-05-13 06:33:23 -0700 | [diff] [blame] | 83 | }; |
| 84 | } |
| 85 | |
| 86 | #endif // ANDROID_DRM_COMPOSITOR_H_ |