blob: 4872c2b82360d9a2a10736f2b221e65a7e10b6bc [file] [log] [blame]
Mathias Agopiand0566bc2011-11-17 17:49:17 -08001/*
2 * Copyright (C) 2011 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_SURFACE_FLINGER_EVENT_THREAD_H
18#define ANDROID_SURFACE_FLINGER_EVENT_THREAD_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <gui/IDisplayEventConnection.h>
24
25#include <utils/Errors.h>
26#include <utils/threads.h>
27#include <utils/SortedVector.h>
28
29#include "DisplayEventConnection.h"
30
31// ---------------------------------------------------------------------------
32
33namespace android {
34
35// ---------------------------------------------------------------------------
36
37class SurfaceFlinger;
38class DisplayHardware;
39
40// ---------------------------------------------------------------------------
41
42class EventThread : public Thread {
43 friend class DisplayEventConnection;
44
45public:
46 EventThread(const sp<SurfaceFlinger>& flinger);
47
48 status_t registerDisplayEventConnection(
49 const sp<DisplayEventConnection>& connection);
50
51 status_t unregisterDisplayEventConnection(
52 const wp<DisplayEventConnection>& connection);
53
54 void dump(String8& result, char* buffer, size_t SIZE) const;
55
56private:
57 virtual bool threadLoop();
58 virtual status_t readyToRun();
59 virtual void onFirstRef();
60
Mathias Agopian23748662011-12-05 14:33:34 -080061 status_t removeDisplayEventConnection(
62 const wp<DisplayEventConnection>& connection);
63
Mathias Agopiand0566bc2011-11-17 17:49:17 -080064 // constants
65 sp<SurfaceFlinger> mFlinger;
66 const DisplayHardware& mHw;
67
68 mutable Mutex mLock;
69 mutable Condition mCondition;
70
71 // protected by mLock
72 SortedVector<wp<DisplayEventConnection> > mDisplayEventConnections;
73 size_t mDeliveredEvents;
74};
75
76// ---------------------------------------------------------------------------
77
78}; // namespace android
79
80// ---------------------------------------------------------------------------
81
82#endif /* ANDROID_SURFACE_FLINGER_EVENT_THREAD_H */