John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 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 | |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 19 | #include <vector> |
| 20 | |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 21 | #include <utils/Condition.h> |
| 22 | #include <utils/Mutex.h> |
John Reck | 087bc0c | 2014-04-04 16:20:08 -0700 | [diff] [blame] | 23 | #include <utils/StrongPointer.h> |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 24 | |
| 25 | #include "RenderTask.h" |
| 26 | |
| 27 | #include "../Rect.h" |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 28 | #include "../FrameInfo.h" |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 29 | #include "../TreeInfo.h" |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 30 | |
| 31 | namespace android { |
| 32 | namespace uirenderer { |
| 33 | |
| 34 | class DeferredLayerUpdater; |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 35 | class DisplayList; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 36 | class RenderNode; |
| 37 | |
| 38 | namespace renderthread { |
| 39 | |
| 40 | class CanvasContext; |
| 41 | class RenderThread; |
| 42 | |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 43 | enum SyncResult { |
| 44 | kSync_OK = 0, |
John Reck | cd028f3 | 2014-06-24 08:44:29 -0700 | [diff] [blame] | 45 | kSync_UIRedrawRequired = 1 << 0, |
John Reck | aa95a88 | 2014-11-07 11:02:07 -0800 | [diff] [blame] | 46 | kSync_LostSurfaceRewardIfFound = 1 << 1, |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 47 | }; |
| 48 | |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 49 | /* |
| 50 | * This is a special Super Task. It is re-used multiple times by RenderProxy, |
Chris Craik | 003cc3d | 2015-10-16 10:24:55 -0700 | [diff] [blame] | 51 | * and contains state (such as layer updaters & new DisplayLists) that is |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 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 | */ |
| 55 | class DrawFrameTask : public RenderTask { |
| 56 | public: |
| 57 | DrawFrameTask(); |
| 58 | virtual ~DrawFrameTask(); |
| 59 | |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 60 | void setContext(RenderThread* thread, CanvasContext* context, RenderNode* targetNode); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 61 | |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 62 | void pushLayerUpdate(DeferredLayerUpdater* layer); |
| 63 | void removeLayerUpdate(DeferredLayerUpdater* layer); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 64 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 65 | int drawFrame(); |
| 66 | |
| 67 | int64_t* frameInfo() { return mFrameInfo; } |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 68 | |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 69 | virtual void run() override; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 70 | |
| 71 | private: |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 72 | void postAndWait(); |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 73 | bool syncFrameState(TreeInfo& info); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 74 | void unblockUiThread(); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 75 | |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 76 | Mutex mLock; |
| 77 | Condition mSignal; |
| 78 | |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 79 | RenderThread* mRenderThread; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 80 | CanvasContext* mContext; |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 81 | RenderNode* mTargetNode = nullptr; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 82 | |
| 83 | /********************************************* |
| 84 | * Single frame data |
| 85 | *********************************************/ |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 86 | std::vector< sp<DeferredLayerUpdater> > mLayers; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 87 | |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 88 | int mSyncResult; |
John Reck | be3fba0 | 2015-07-06 13:49:58 -0700 | [diff] [blame] | 89 | int64_t mSyncQueued; |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 90 | |
| 91 | int64_t mFrameInfo[UI_THREAD_FRAME_INFO_SIZE]; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 92 | }; |
| 93 | |
| 94 | } /* namespace renderthread */ |
| 95 | } /* namespace uirenderer */ |
| 96 | } /* namespace android */ |
| 97 | |
| 98 | #endif /* DRAWFRAMETASK_H */ |