blob: 8039643623b653ab9fe0b6db94aaaa5ac0d21ff6 [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;
35class DisplayListData;
36class RenderNode;
37
38namespace renderthread {
39
40class CanvasContext;
41class RenderThread;
42
John Reckf9be7792014-05-02 18:21:16 -070043enum SyncResult {
44 kSync_OK = 0,
John Reckcd028f32014-06-24 08:44:29 -070045 kSync_UIRedrawRequired = 1 << 0,
John Reckaa95a882014-11-07 11:02:07 -080046 kSync_LostSurfaceRewardIfFound = 1 << 1,
John Reckf9be7792014-05-02 18:21:16 -070047};
48
John Reck668f0e32014-03-26 15:10:40 -070049/*
50 * This is a special Super Task. It is re-used multiple times by RenderProxy,
51 * and contains state (such as layer updaters & new DisplayListDatas) that is
52 * tracked across many frames not just a single frame.
53 * It is the sync-state task, and will kick off the post-sync draw
54 */
55class DrawFrameTask : public RenderTask {
56public:
57 DrawFrameTask();
58 virtual ~DrawFrameTask();
59
John Reck18f16e62014-05-02 16:46:41 -070060 void setContext(RenderThread* thread, CanvasContext* context);
John Reck668f0e32014-03-26 15:10:40 -070061
John Reckd72e0a32014-05-29 18:56:11 -070062 void pushLayerUpdate(DeferredLayerUpdater* layer);
63 void removeLayerUpdate(DeferredLayerUpdater* layer);
John Reck668f0e32014-03-26 15:10:40 -070064
John Reckba6adf62015-02-19 14:36:50 -080065 int drawFrame();
66
67 int64_t* frameInfo() { return mFrameInfo; }
John Reck668f0e32014-03-26 15:10:40 -070068
Chris Craikd41c4d82015-01-05 15:51:13 -080069 virtual void run() override;
John Reck668f0e32014-03-26 15:10:40 -070070
71private:
John Reck18f16e62014-05-02 16:46:41 -070072 void postAndWait();
John Recka5dda642014-05-22 15:43:54 -070073 bool syncFrameState(TreeInfo& info);
John Reck668f0e32014-03-26 15:10:40 -070074 void unblockUiThread();
John Reck668f0e32014-03-26 15:10:40 -070075
John Reck668f0e32014-03-26 15:10:40 -070076 Mutex mLock;
77 Condition mSignal;
78
John Reck18f16e62014-05-02 16:46:41 -070079 RenderThread* mRenderThread;
John Reck668f0e32014-03-26 15:10:40 -070080 CanvasContext* mContext;
81
82 /*********************************************
83 * Single frame data
84 *********************************************/
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 Reckba6adf62015-02-19 14:36:50 -080088
89 int64_t mFrameInfo[UI_THREAD_FRAME_INFO_SIZE];
John Reck668f0e32014-03-26 15:10:40 -070090};
91
92} /* namespace renderthread */
93} /* namespace uirenderer */
94} /* namespace android */
95
96#endif /* DRAWFRAMETASK_H */