blob: 44b60f566af40d355eb4af0b45b40a393e0767dc [file] [log] [blame]
Sahil Dhanjuc1ba5c42016-06-07 20:09:20 -07001/*
2 * Copyright 2016 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_SURFACEREPLAYER_EVENT_H
18#define ANDROID_SURFACEREPLAYER_EVENT_H
19
20#include <frameworks/native/cmds/surfacereplayer/proto/src/trace.pb.h>
21
22#include <condition_variable>
23#include <mutex>
24
25namespace android {
26
27class Event {
28 public:
29 Event(Increment::IncrementCase);
30
31 enum class EventState {
32 SettingUp, // Completing as much time-independent work as possible
33 Waiting, // Waiting for signal from main thread to finish execution
34 Signaled, // Signaled by main thread, about to immediately switch to Running
35 Running // Finishing execution of rest of work
36 };
37
38 void readyToExecute();
39 void complete();
40
41 Increment::IncrementCase getIncrementType();
42
43 private:
44 void waitUntil(EventState state);
45 void changeState(EventState state);
46
47 std::mutex mLock;
48 std::condition_variable mCond;
49
50 EventState mState = EventState::SettingUp;
51
52 Increment::IncrementCase mIncrementType;
53};
54}
55#endif