The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2007 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_DISPLAY_HARDWARE_BASE_H |
| 18 | #define ANDROID_DISPLAY_HARDWARE_BASE_H |
| 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <utils/RefBase.h> |
| 22 | #include <utils/threads.h> |
| 23 | #include <linux/kd.h> |
| 24 | #include <linux/vt.h> |
| 25 | #include "Barrier.h" |
| 26 | |
| 27 | namespace android { |
| 28 | |
| 29 | class SurfaceFlinger; |
| 30 | |
| 31 | class DisplayHardwareBase |
| 32 | { |
| 33 | public: |
| 34 | DisplayHardwareBase( |
| 35 | const sp<SurfaceFlinger>& flinger, |
| 36 | uint32_t displayIndex); |
| 37 | |
| 38 | ~DisplayHardwareBase(); |
| 39 | |
Mathias Agopian | c7d14e2 | 2011-08-01 16:32:21 -0700 | [diff] [blame] | 40 | // console management |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 41 | void releaseScreen() const; |
| 42 | void acquireScreen() const; |
Mathias Agopian | 59119e6 | 2010-10-11 12:37:43 -0700 | [diff] [blame] | 43 | bool isScreenAcquired() const; |
| 44 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 45 | bool canDraw() const; |
Mathias Agopian | 59119e6 | 2010-10-11 12:37:43 -0700 | [diff] [blame] | 46 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 47 | |
| 48 | private: |
| 49 | class DisplayEventThreadBase : public Thread { |
| 50 | protected: |
| 51 | wp<SurfaceFlinger> mFlinger; |
| 52 | public: |
| 53 | DisplayEventThreadBase(const sp<SurfaceFlinger>& flinger); |
| 54 | virtual ~DisplayEventThreadBase(); |
| 55 | virtual void onFirstRef() { |
| 56 | run("DisplayEventThread", PRIORITY_URGENT_DISPLAY); |
| 57 | } |
| 58 | virtual status_t acquireScreen() const { return NO_ERROR; }; |
| 59 | virtual status_t releaseScreen() const { return NO_ERROR; }; |
| 60 | virtual status_t initCheck() const = 0; |
| 61 | }; |
| 62 | |
| 63 | class DisplayEventThread : public DisplayEventThreadBase |
| 64 | { |
| 65 | mutable Barrier mBarrier; |
| 66 | public: |
| 67 | DisplayEventThread(const sp<SurfaceFlinger>& flinger); |
| 68 | virtual ~DisplayEventThread(); |
| 69 | virtual bool threadLoop(); |
| 70 | virtual status_t readyToRun(); |
| 71 | virtual status_t releaseScreen() const; |
| 72 | virtual status_t initCheck() const; |
| 73 | }; |
| 74 | |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 75 | sp<DisplayEventThreadBase> mDisplayEventThread; |
Mathias Agopian | 59119e6 | 2010-10-11 12:37:43 -0700 | [diff] [blame] | 76 | mutable int mScreenAcquired; |
The Android Open Source Project | edbf3b6 | 2009-03-03 19:31:44 -0800 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | }; // namespace android |
| 80 | |
| 81 | #endif // ANDROID_DISPLAY_HARDWARE_BASE_H |