blob: 91ea60298033e95f4998081ee46d8f7f1a70dcd8 [file] [log] [blame]
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08001/*
Mathias Agopian67016af2012-02-02 15:14:13 -08002 * Copyright (C) 2012 The Android Open Source Project
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -08003 *
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>
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080023#include "Barrier.h"
24
25namespace android {
26
27class SurfaceFlinger;
28
29class DisplayHardwareBase
30{
31public:
Mathias Agopian67016af2012-02-02 15:14:13 -080032 DisplayHardwareBase(
33 const sp<SurfaceFlinger>& flinger,
34 uint32_t displayIndex);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080035
Mathias Agopian67016af2012-02-02 15:14:13 -080036 ~DisplayHardwareBase();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080037
Mathias Agopianc7d14e22011-08-01 16:32:21 -070038 // console management
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080039 void releaseScreen() const;
40 void acquireScreen() const;
Mathias Agopian59119e62010-10-11 12:37:43 -070041 bool isScreenAcquired() const;
42
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080043 bool canDraw() const;
Mathias Agopian59119e62010-10-11 12:37:43 -070044
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080045
46private:
Mathias Agopian67016af2012-02-02 15:14:13 -080047 class DisplayEventThread : public Thread {
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080048 wp<SurfaceFlinger> mFlinger;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080049 mutable Barrier mBarrier;
Mathias Agopian67016af2012-02-02 15:14:13 -080050 status_t waitForFbSleep();
51 status_t waitForFbWake();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080052 public:
Mathias Agopian67016af2012-02-02 15:14:13 -080053 DisplayEventThread(const sp<SurfaceFlinger>& flinger);
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080054 virtual ~DisplayEventThread();
Mathias Agopian67016af2012-02-02 15:14:13 -080055 virtual void onFirstRef();
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080056 virtual bool threadLoop();
Mathias Agopian67016af2012-02-02 15:14:13 -080057 status_t releaseScreen() const;
58 status_t initCheck() const;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080059 };
60
Mathias Agopian67016af2012-02-02 15:14:13 -080061 sp<DisplayEventThread> mDisplayEventThread;
62 mutable int mScreenAcquired;
The Android Open Source Projectedbf3b62009-03-03 19:31:44 -080063};
64
65}; // namespace android
66
67#endif // ANDROID_DISPLAY_HARDWARE_BASE_H