blob: ea009004a79763118cb8474bd9fbac2cdbc08a24 [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"
27
28namespace android {
29namespace uirenderer {
30
31class DeferredLayerUpdater;
32class DisplayListData;
33class RenderNode;
34
35namespace renderthread {
36
37class CanvasContext;
38class RenderThread;
39
John Reck668f0e32014-03-26 15:10:40 -070040/*
41 * This is a special Super Task. It is re-used multiple times by RenderProxy,
42 * and contains state (such as layer updaters & new DisplayListDatas) that is
43 * tracked across many frames not just a single frame.
44 * It is the sync-state task, and will kick off the post-sync draw
45 */
46class DrawFrameTask : public RenderTask {
47public:
48 DrawFrameTask();
49 virtual ~DrawFrameTask();
50
John Reck18f16e62014-05-02 16:46:41 -070051 void setContext(RenderThread* thread, CanvasContext* context);
John Reck668f0e32014-03-26 15:10:40 -070052
John Reck668f0e32014-03-26 15:10:40 -070053 void addLayer(DeferredLayerUpdater* layer);
54 void removeLayer(DeferredLayerUpdater* layer);
55
John Reck668f0e32014-03-26 15:10:40 -070056 void setDirty(int left, int top, int right, int bottom);
John Reck18f16e62014-05-02 16:46:41 -070057 void drawFrame(nsecs_t frameTimeNanos);
John Reck668f0e32014-03-26 15:10:40 -070058
59 virtual void run();
60
61private:
John Reck18f16e62014-05-02 16:46:41 -070062 void postAndWait();
John Reckf4198b72014-04-09 17:00:04 -070063 bool syncFrameState();
John Reck668f0e32014-03-26 15:10:40 -070064 void unblockUiThread();
John Reck668f0e32014-03-26 15:10:40 -070065
John Reck668f0e32014-03-26 15:10:40 -070066 Mutex mLock;
67 Condition mSignal;
68
John Reck18f16e62014-05-02 16:46:41 -070069 RenderThread* mRenderThread;
John Reck668f0e32014-03-26 15:10:40 -070070 CanvasContext* mContext;
71
72 /*********************************************
73 * Single frame data
74 *********************************************/
John Reck668f0e32014-03-26 15:10:40 -070075 Rect mDirty;
John Reck18f16e62014-05-02 16:46:41 -070076 nsecs_t mFrameTimeNanos;
John Reck668f0e32014-03-26 15:10:40 -070077
78 /*********************************************
79 * Multi frame data
80 *********************************************/
81 Vector<DeferredLayerUpdater*> mLayers;
82};
83
84} /* namespace renderthread */
85} /* namespace uirenderer */
86} /* namespace android */
87
88#endif /* DRAWFRAMETASK_H */