blob: acbc02a8635e4c613df7885e3cf577f45dfeacb6 [file] [log] [blame]
John Reck668f0e32014-03-26 15:10:40 -07001/*
2 * Copyright (C) 2014 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#ifndef DRAWFRAMETASK_H
17#define DRAWFRAMETASK_H
18
19#include <utils/Condition.h>
20#include <utils/Mutex.h>
John Reck087bc0c2014-04-04 16:20:08 -070021#include <utils/StrongPointer.h>
John Reck668f0e32014-03-26 15:10:40 -070022#include <utils/Vector.h>
23
24#include "RenderTask.h"
25
26#include "../Rect.h"
John Recka5dda642014-05-22 15:43:54 -070027#include "../TreeInfo.h"
John Reck668f0e32014-03-26 15:10:40 -070028
29namespace android {
30namespace uirenderer {
31
32class DeferredLayerUpdater;
33class DisplayListData;
34class RenderNode;
35
36namespace renderthread {
37
38class CanvasContext;
39class RenderThread;
40
John Reckf9be7792014-05-02 18:21:16 -070041enum SyncResult {
42 kSync_OK = 0,
43 kSync_UIRedrawRequired = 1 << 1,
44};
45
John Reck668f0e32014-03-26 15:10:40 -070046/*
47 * This is a special Super Task. It is re-used multiple times by RenderProxy,
48 * and contains state (such as layer updaters & new DisplayListDatas) that is
49 * tracked across many frames not just a single frame.
50 * It is the sync-state task, and will kick off the post-sync draw
51 */
52class DrawFrameTask : public RenderTask {
53public:
54 DrawFrameTask();
55 virtual ~DrawFrameTask();
56
John Reck18f16e62014-05-02 16:46:41 -070057 void setContext(RenderThread* thread, CanvasContext* context);
John Reck668f0e32014-03-26 15:10:40 -070058
John Reck668f0e32014-03-26 15:10:40 -070059 void addLayer(DeferredLayerUpdater* layer);
60 void removeLayer(DeferredLayerUpdater* layer);
61
John Reck668f0e32014-03-26 15:10:40 -070062 void setDirty(int left, int top, int right, int bottom);
John Reckf9be7792014-05-02 18:21:16 -070063 int drawFrame(nsecs_t frameTimeNanos);
John Reck668f0e32014-03-26 15:10:40 -070064
65 virtual void run();
66
67private:
John Reck18f16e62014-05-02 16:46:41 -070068 void postAndWait();
John Recka5dda642014-05-22 15:43:54 -070069 bool syncFrameState(TreeInfo& info);
John Reck668f0e32014-03-26 15:10:40 -070070 void unblockUiThread();
John Reck668f0e32014-03-26 15:10:40 -070071
John Reck668f0e32014-03-26 15:10:40 -070072 Mutex mLock;
73 Condition mSignal;
74
John Reck18f16e62014-05-02 16:46:41 -070075 RenderThread* mRenderThread;
John Reck668f0e32014-03-26 15:10:40 -070076 CanvasContext* mContext;
77
78 /*********************************************
79 * Single frame data
80 *********************************************/
John Reck668f0e32014-03-26 15:10:40 -070081 Rect mDirty;
John Reck18f16e62014-05-02 16:46:41 -070082 nsecs_t mFrameTimeNanos;
John Reck668f0e32014-03-26 15:10:40 -070083
John Reckf9be7792014-05-02 18:21:16 -070084 int mSyncResult;
85
John Reck668f0e32014-03-26 15:10:40 -070086 /*********************************************
87 * Multi frame data
88 *********************************************/
89 Vector<DeferredLayerUpdater*> mLayers;
90};
91
92} /* namespace renderthread */
93} /* namespace uirenderer */
94} /* namespace android */
95
96#endif /* DRAWFRAMETASK_H */