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 | 9a17da8 | 2016-04-18 11:17:52 -0700 | [diff] [blame] | 43 | namespace SyncResult { |
| 44 | enum { |
| 45 | OK = 0, |
| 46 | UIRedrawRequired = 1 << 0, |
| 47 | LostSurfaceRewardIfFound = 1 << 1, |
| 48 | ContextIsStopped = 1 << 2, |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 49 | }; |
John Reck | 9a17da8 | 2016-04-18 11:17:52 -0700 | [diff] [blame] | 50 | } |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 51 | |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 52 | /* |
| 53 | * 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] | 54 | * and contains state (such as layer updaters & new DisplayLists) that is |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 55 | * tracked across many frames not just a single frame. |
| 56 | * It is the sync-state task, and will kick off the post-sync draw |
| 57 | */ |
| 58 | class DrawFrameTask : public RenderTask { |
| 59 | public: |
| 60 | DrawFrameTask(); |
| 61 | virtual ~DrawFrameTask(); |
| 62 | |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 63 | void setContext(RenderThread* thread, CanvasContext* context, RenderNode* targetNode); |
John Reck | f138b17 | 2017-09-08 11:00:42 -0700 | [diff] [blame] | 64 | void setContentDrawBounds(int left, int top, int right, int bottom) { |
| 65 | mContentDrawBounds.set(left, top, right, bottom); |
| 66 | } |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 67 | |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 68 | void pushLayerUpdate(DeferredLayerUpdater* layer); |
| 69 | void removeLayerUpdate(DeferredLayerUpdater* layer); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 70 | |
John Reck | 2de950d | 2017-01-25 10:58:30 -0800 | [diff] [blame] | 71 | int drawFrame(); |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 72 | |
| 73 | int64_t* frameInfo() { return mFrameInfo; } |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 74 | |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 75 | virtual void run() override; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 76 | |
| 77 | private: |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 78 | void postAndWait(); |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 79 | bool syncFrameState(TreeInfo& info); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 80 | void unblockUiThread(); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 81 | |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 82 | Mutex mLock; |
| 83 | Condition mSignal; |
| 84 | |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 85 | RenderThread* mRenderThread; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 86 | CanvasContext* mContext; |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 87 | RenderNode* mTargetNode = nullptr; |
John Reck | f138b17 | 2017-09-08 11:00:42 -0700 | [diff] [blame] | 88 | Rect mContentDrawBounds; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 89 | |
| 90 | /********************************************* |
| 91 | * Single frame data |
| 92 | *********************************************/ |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 93 | std::vector< sp<DeferredLayerUpdater> > mLayers; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 94 | |
John Reck | f9be779 | 2014-05-02 18:21:16 -0700 | [diff] [blame] | 95 | int mSyncResult; |
John Reck | be3fba0 | 2015-07-06 13:49:58 -0700 | [diff] [blame] | 96 | int64_t mSyncQueued; |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 97 | |
| 98 | int64_t mFrameInfo[UI_THREAD_FRAME_INFO_SIZE]; |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 99 | }; |
| 100 | |
| 101 | } /* namespace renderthread */ |
| 102 | } /* namespace uirenderer */ |
| 103 | } /* namespace android */ |
| 104 | |
| 105 | #endif /* DRAWFRAMETASK_H */ |