blob: 96f0add4c08c426eaa6e9855d30e8307d049b412 [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
John Reckd72e0a32014-05-29 18:56:11 -070019#include <vector>
20
John Reck668f0e32014-03-26 15:10:40 -070021#include <utils/Condition.h>
22#include <utils/Mutex.h>
John Reck087bc0c2014-04-04 16:20:08 -070023#include <utils/StrongPointer.h>
John Reck668f0e32014-03-26 15:10:40 -070024
25#include "RenderTask.h"
26
27#include "../Rect.h"
John Recka5dda642014-05-22 15:43:54 -070028#include "../TreeInfo.h"
John Reck668f0e32014-03-26 15:10:40 -070029
30namespace android {
31namespace uirenderer {
32
33class DeferredLayerUpdater;
34class DisplayListData;
35class RenderNode;
36
37namespace renderthread {
38
39class CanvasContext;
40class RenderThread;
41
John Reckf9be7792014-05-02 18:21:16 -070042enum SyncResult {
43 kSync_OK = 0,
44 kSync_UIRedrawRequired = 1 << 1,
45};
46
John Reck668f0e32014-03-26 15:10:40 -070047/*
48 * This is a special Super Task. It is re-used multiple times by RenderProxy,
49 * and contains state (such as layer updaters & new DisplayListDatas) that is
50 * tracked across many frames not just a single frame.
51 * It is the sync-state task, and will kick off the post-sync draw
52 */
53class DrawFrameTask : public RenderTask {
54public:
55 DrawFrameTask();
56 virtual ~DrawFrameTask();
57
John Reck18f16e62014-05-02 16:46:41 -070058 void setContext(RenderThread* thread, CanvasContext* context);
John Reck668f0e32014-03-26 15:10:40 -070059
John Reckd72e0a32014-05-29 18:56:11 -070060 void pushLayerUpdate(DeferredLayerUpdater* layer);
61 void removeLayerUpdate(DeferredLayerUpdater* layer);
John Reck668f0e32014-03-26 15:10:40 -070062
John Reckfe5e7b72014-05-23 17:42:28 -070063 void setDensity(float density) { mDensity = density; }
64 int drawFrame(nsecs_t frameTimeNanos, nsecs_t recordDurationNanos);
John Reck668f0e32014-03-26 15:10:40 -070065
66 virtual void run();
67
68private:
John Reck18f16e62014-05-02 16:46:41 -070069 void postAndWait();
John Recka5dda642014-05-22 15:43:54 -070070 bool syncFrameState(TreeInfo& info);
John Reck668f0e32014-03-26 15:10:40 -070071 void unblockUiThread();
John Reck668f0e32014-03-26 15:10:40 -070072
John Reck668f0e32014-03-26 15:10:40 -070073 Mutex mLock;
74 Condition mSignal;
75
John Reck18f16e62014-05-02 16:46:41 -070076 RenderThread* mRenderThread;
John Reck668f0e32014-03-26 15:10:40 -070077 CanvasContext* mContext;
78
79 /*********************************************
80 * Single frame data
81 *********************************************/
John Reck18f16e62014-05-02 16:46:41 -070082 nsecs_t mFrameTimeNanos;
John Reckfe5e7b72014-05-23 17:42:28 -070083 nsecs_t mRecordDurationNanos;
84 float mDensity;
John Reckd72e0a32014-05-29 18:56:11 -070085 std::vector< sp<DeferredLayerUpdater> > mLayers;
John Reck668f0e32014-03-26 15:10:40 -070086
John Reckf9be7792014-05-02 18:21:16 -070087 int mSyncResult;
John Reck668f0e32014-03-26 15:10:40 -070088};
89
90} /* namespace renderthread */
91} /* namespace uirenderer */
92} /* namespace android */
93
94#endif /* DRAWFRAMETASK_H */