blob: 5450dd57133eafaf52b1ad9634df16cc0396983e [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>
21#include <utils/Vector.h>
22
23#include "RenderTask.h"
24
25#include "../Rect.h"
26
27namespace android {
28namespace uirenderer {
29
30class DeferredLayerUpdater;
31class DisplayListData;
32class RenderNode;
33
34namespace renderthread {
35
36class CanvasContext;
37class RenderThread;
38
39struct SetDisplayListData {
40 RenderNode* targetNode;
41 DisplayListData* newData;
42};
43
44/*
45 * This is a special Super Task. It is re-used multiple times by RenderProxy,
46 * and contains state (such as layer updaters & new DisplayListDatas) that is
47 * tracked across many frames not just a single frame.
48 * It is the sync-state task, and will kick off the post-sync draw
49 */
50class DrawFrameTask : public RenderTask {
51public:
52 DrawFrameTask();
53 virtual ~DrawFrameTask();
54
55 void setContext(CanvasContext* context);
56
57 void setDisplayListData(RenderNode* renderNode, DisplayListData* newData);
58 void addLayer(DeferredLayerUpdater* layer);
59 void removeLayer(DeferredLayerUpdater* layer);
60
61 void setRenderNode(RenderNode* renderNode);
62 void setDirty(int left, int top, int right, int bottom);
63 void drawFrame(RenderThread* renderThread);
64
65 virtual void run();
66
67private:
68 void syncFrameState();
69 void unblockUiThread();
70 static void drawRenderNode(CanvasContext* context, RenderNode* renderNode, Rect* dirty);
71
72 // This checks to see if there are any drawGlFunctors which would require
73 // a synchronous drawRenderNode()
74 static bool requiresSynchronousDraw(RenderNode* renderNode);
75
76 Mutex mLock;
77 Condition mSignal;
78
79 CanvasContext* mContext;
80
81 /*********************************************
82 * Single frame data
83 *********************************************/
84 RenderNode* mRenderNode;
85 Rect mDirty;
86 Vector<SetDisplayListData> mDisplayListDataUpdates;
87
88 /*********************************************
89 * Multi frame data
90 *********************************************/
91 Vector<DeferredLayerUpdater*> mLayers;
92};
93
94} /* namespace renderthread */
95} /* namespace uirenderer */
96} /* namespace android */
97
98#endif /* DRAWFRAMETASK_H */