DrawFrameTask.h revision 8ca3eecc2b7fe507d3482745efc4cd2567ad15a1
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 28namespace android { 29namespace uirenderer { 30 31class DeferredLayerUpdater; 32class DisplayListData; 33class RenderNode; 34 35namespace renderthread { 36 37class CanvasContext; 38class RenderThread; 39 40/* 41 * This is a special Super Task. It is re-used multiple times by RenderProxy, 42 * and contains state (such as layer updaters & new DisplayListDatas) that is 43 * tracked across many frames not just a single frame. 44 * It is the sync-state task, and will kick off the post-sync draw 45 */ 46class DrawFrameTask : public RenderTask { 47public: 48 DrawFrameTask(); 49 virtual ~DrawFrameTask(); 50 51 void setContext(CanvasContext* context); 52 53 void addLayer(DeferredLayerUpdater* layer); 54 void removeLayer(DeferredLayerUpdater* layer); 55 56 void setRenderNode(RenderNode* renderNode); 57 void setDirty(int left, int top, int right, int bottom); 58 void drawFrame(RenderThread* renderThread); 59 60 virtual void run(); 61 62private: 63 void postAndWait(RenderThread* renderThread); 64 bool syncFrameState(); 65 void unblockUiThread(); 66 static void drawRenderNode(CanvasContext* context, RenderNode* renderNode, Rect* dirty); 67 68 Mutex mLock; 69 Condition mSignal; 70 71 CanvasContext* mContext; 72 73 /********************************************* 74 * Single frame data 75 *********************************************/ 76 sp<RenderNode> mRenderNode; 77 Rect mDirty; 78 79 /********************************************* 80 * Multi frame data 81 *********************************************/ 82 Vector<DeferredLayerUpdater*> mLayers; 83}; 84 85} /* namespace renderthread */ 86} /* namespace uirenderer */ 87} /* namespace android */ 88 89#endif /* DRAWFRAMETASK_H */ 90