DrawFrameTask.h revision a5dda645da738da7b4ae15e28fa7d93d3b04b94f
1/* 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/StrongPointer.h> 22#include <utils/Vector.h> 23 24#include "RenderTask.h" 25 26#include "../Rect.h" 27#include "../TreeInfo.h" 28 29namespace android { 30namespace uirenderer { 31 32class DeferredLayerUpdater; 33class DisplayListData; 34class RenderNode; 35 36namespace renderthread { 37 38class CanvasContext; 39class RenderThread; 40 41enum SyncResult { 42 kSync_OK = 0, 43 kSync_UIRedrawRequired = 1 << 1, 44}; 45 46/* 47 * This is a special Super Task. It is re-used multiple times by RenderProxy, 48 * and contains state (such as layer updaters & new DisplayListDatas) that is 49 * tracked across many frames not just a single frame. 50 * It is the sync-state task, and will kick off the post-sync draw 51 */ 52class DrawFrameTask : public RenderTask { 53public: 54 DrawFrameTask(); 55 virtual ~DrawFrameTask(); 56 57 void setContext(RenderThread* thread, CanvasContext* context); 58 59 void addLayer(DeferredLayerUpdater* layer); 60 void removeLayer(DeferredLayerUpdater* layer); 61 62 void setDirty(int left, int top, int right, int bottom); 63 int drawFrame(nsecs_t frameTimeNanos); 64 65 virtual void run(); 66 67private: 68 void postAndWait(); 69 bool syncFrameState(TreeInfo& info); 70 void unblockUiThread(); 71 72 Mutex mLock; 73 Condition mSignal; 74 75 RenderThread* mRenderThread; 76 CanvasContext* mContext; 77 78 /********************************************* 79 * Single frame data 80 *********************************************/ 81 Rect mDirty; 82 nsecs_t mFrameTimeNanos; 83 84 int mSyncResult; 85 86 /********************************************* 87 * Multi frame data 88 *********************************************/ 89 Vector<DeferredLayerUpdater*> mLayers; 90}; 91 92} /* namespace renderthread */ 93} /* namespace uirenderer */ 94} /* namespace android */ 95 96#endif /* DRAWFRAMETASK_H */ 97