blob: fb480626d421429d432ded414724518eb9bfd43f [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 Reckba6adf62015-02-19 14:36:50 -080028#include "../FrameInfo.h"
John Recka5dda642014-05-22 15:43:54 -070029#include "../TreeInfo.h"
John Reck668f0e32014-03-26 15:10:40 -070030
31namespace android {
32namespace uirenderer {
33
34class DeferredLayerUpdater;
Chris Craik003cc3d2015-10-16 10:24:55 -070035class DisplayList;
John Reck668f0e32014-03-26 15:10:40 -070036class RenderNode;
37
38namespace renderthread {
39
40class CanvasContext;
41class RenderThread;
42
John Reck9a17da82016-04-18 11:17:52 -070043namespace SyncResult {
44enum {
45 OK = 0,
46 UIRedrawRequired = 1 << 0,
47 LostSurfaceRewardIfFound = 1 << 1,
48 ContextIsStopped = 1 << 2,
John Reckf9be7792014-05-02 18:21:16 -070049};
John Reck9a17da82016-04-18 11:17:52 -070050}
John Reckf9be7792014-05-02 18:21:16 -070051
John Reck668f0e32014-03-26 15:10:40 -070052/*
53 * This is a special Super Task. It is re-used multiple times by RenderProxy,
Chris Craik003cc3d2015-10-16 10:24:55 -070054 * and contains state (such as layer updaters & new DisplayLists) that is
John Reck668f0e32014-03-26 15:10:40 -070055 * tracked across many frames not just a single frame.
56 * It is the sync-state task, and will kick off the post-sync draw
57 */
58class DrawFrameTask : public RenderTask {
59public:
60 DrawFrameTask();
61 virtual ~DrawFrameTask();
62
Skuhneea7a7fb2015-08-28 07:10:31 -070063 void setContext(RenderThread* thread, CanvasContext* context, RenderNode* targetNode);
John Reck668f0e32014-03-26 15:10:40 -070064
John Reckd72e0a32014-05-29 18:56:11 -070065 void pushLayerUpdate(DeferredLayerUpdater* layer);
66 void removeLayerUpdate(DeferredLayerUpdater* layer);
John Reck668f0e32014-03-26 15:10:40 -070067
John Reck2de950d2017-01-25 10:58:30 -080068 int drawFrame();
John Reckba6adf62015-02-19 14:36:50 -080069
70 int64_t* frameInfo() { return mFrameInfo; }
John Reck668f0e32014-03-26 15:10:40 -070071
Chris Craikd41c4d82015-01-05 15:51:13 -080072 virtual void run() override;
John Reck668f0e32014-03-26 15:10:40 -070073
74private:
John Reck18f16e62014-05-02 16:46:41 -070075 void postAndWait();
John Recka5dda642014-05-22 15:43:54 -070076 bool syncFrameState(TreeInfo& info);
John Reck668f0e32014-03-26 15:10:40 -070077 void unblockUiThread();
John Reck668f0e32014-03-26 15:10:40 -070078
John Reck668f0e32014-03-26 15:10:40 -070079 Mutex mLock;
80 Condition mSignal;
81
John Reck18f16e62014-05-02 16:46:41 -070082 RenderThread* mRenderThread;
John Reck668f0e32014-03-26 15:10:40 -070083 CanvasContext* mContext;
Skuhneea7a7fb2015-08-28 07:10:31 -070084 RenderNode* mTargetNode = nullptr;
John Reck668f0e32014-03-26 15:10:40 -070085
86 /*********************************************
87 * Single frame data
88 *********************************************/
John Reckd72e0a32014-05-29 18:56:11 -070089 std::vector< sp<DeferredLayerUpdater> > mLayers;
John Reck668f0e32014-03-26 15:10:40 -070090
John Reckf9be7792014-05-02 18:21:16 -070091 int mSyncResult;
John Reckbe3fba02015-07-06 13:49:58 -070092 int64_t mSyncQueued;
John Reckba6adf62015-02-19 14:36:50 -080093
94 int64_t mFrameInfo[UI_THREAD_FRAME_INFO_SIZE];
John Reck668f0e32014-03-26 15:10:40 -070095};
96
97} /* namespace renderthread */
98} /* namespace uirenderer */
99} /* namespace android */
100
101#endif /* DRAWFRAMETASK_H */