John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2013 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 | |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 17 | #include "RenderProxy.h" |
| 18 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 19 | #include "DeferredLayerUpdater.h" |
| 20 | #include "DisplayList.h" |
| 21 | #include "LayerRenderer.h" |
| 22 | #include "Rect.h" |
| 23 | #include "renderthread/CanvasContext.h" |
| 24 | #include "renderthread/RenderTask.h" |
| 25 | #include "renderthread/RenderThread.h" |
| 26 | #include "utils/Macros.h" |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 27 | |
| 28 | namespace android { |
| 29 | namespace uirenderer { |
| 30 | namespace renderthread { |
| 31 | |
| 32 | #define ARGS(method) method ## Args |
| 33 | |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 34 | #define CREATE_BRIDGE0(name) CREATE_BRIDGE(name,,,,,,,,) |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 35 | #define CREATE_BRIDGE1(name, a1) CREATE_BRIDGE(name, a1,,,,,,,) |
| 36 | #define CREATE_BRIDGE2(name, a1, a2) CREATE_BRIDGE(name, a1,a2,,,,,,) |
| 37 | #define CREATE_BRIDGE3(name, a1, a2, a3) CREATE_BRIDGE(name, a1,a2,a3,,,,,) |
| 38 | #define CREATE_BRIDGE4(name, a1, a2, a3, a4) CREATE_BRIDGE(name, a1,a2,a3,a4,,,,) |
Chris Craik | 797b95b | 2014-05-20 18:10:25 -0700 | [diff] [blame] | 39 | #define CREATE_BRIDGE5(name, a1, a2, a3, a4, a5) CREATE_BRIDGE(name, a1,a2,a3,a4,a5,,,) |
Chris Craik | 058fc64 | 2014-07-23 18:19:28 -0700 | [diff] [blame] | 40 | #define CREATE_BRIDGE6(name, a1, a2, a3, a4, a5, a6) CREATE_BRIDGE(name, a1,a2,a3,a4,a5,a6,,) |
| 41 | #define CREATE_BRIDGE7(name, a1, a2, a3, a4, a5, a6, a7) CREATE_BRIDGE(name, a1,a2,a3,a4,a5,a6,a7,) |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 42 | #define CREATE_BRIDGE(name, a1, a2, a3, a4, a5, a6, a7, a8) \ |
| 43 | typedef struct { \ |
| 44 | a1; a2; a3; a4; a5; a6; a7; a8; \ |
| 45 | } ARGS(name); \ |
| 46 | static void* Bridge_ ## name(ARGS(name)* args) |
| 47 | |
| 48 | #define SETUP_TASK(method) \ |
| 49 | LOG_ALWAYS_FATAL_IF( METHOD_INVOKE_PAYLOAD_SIZE < sizeof(ARGS(method)), \ |
Mark Salyzyn | 546f353 | 2014-06-10 12:29:14 -0700 | [diff] [blame] | 50 | "METHOD_INVOKE_PAYLOAD_SIZE %zu is smaller than sizeof(" #method "Args) %zu", \ |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 51 | METHOD_INVOKE_PAYLOAD_SIZE, sizeof(ARGS(method))); \ |
John Reck | e2c4552 | 2014-04-07 17:31:44 -0700 | [diff] [blame] | 52 | MethodInvokeRenderTask* task = new MethodInvokeRenderTask((RunnableMethod) Bridge_ ## method); \ |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 53 | ARGS(method) *args = (ARGS(method) *) task->payload() |
| 54 | |
Chris Craik | 53e51e4 | 2015-06-01 10:35:35 -0700 | [diff] [blame] | 55 | namespace DumpFlags { |
| 56 | enum { |
| 57 | FrameStats = 1 << 0, |
| 58 | Reset = 1 << 1, |
John Reck | 6601080 | 2016-03-30 14:19:44 -0700 | [diff] [blame] | 59 | JankStats = 1 << 2, |
Chris Craik | 53e51e4 | 2015-06-01 10:35:35 -0700 | [diff] [blame] | 60 | }; |
John Reck | c87be99 | 2015-02-20 10:57:22 -0800 | [diff] [blame] | 61 | }; |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 62 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 63 | CREATE_BRIDGE4(createContext, RenderThread* thread, bool translucent, |
| 64 | RenderNode* rootRenderNode, IContextFactory* contextFactory) { |
| 65 | return new CanvasContext(*args->thread, args->translucent, |
| 66 | args->rootRenderNode, args->contextFactory); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 67 | } |
| 68 | |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 69 | RenderProxy::RenderProxy(bool translucent, RenderNode* rootRenderNode, IContextFactory* contextFactory) |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 70 | : mRenderThread(RenderThread::getInstance()) |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 71 | , mContext(nullptr) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 72 | SETUP_TASK(createContext); |
| 73 | args->translucent = translucent; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 74 | args->rootRenderNode = rootRenderNode; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 75 | args->thread = &mRenderThread; |
John Reck | 119907c | 2014-08-14 09:02:01 -0700 | [diff] [blame] | 76 | args->contextFactory = contextFactory; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 77 | mContext = (CanvasContext*) postAndWait(task); |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 78 | mDrawFrameTask.setContext(&mRenderThread, mContext, rootRenderNode); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 79 | } |
| 80 | |
| 81 | RenderProxy::~RenderProxy() { |
| 82 | destroyContext(); |
| 83 | } |
| 84 | |
| 85 | CREATE_BRIDGE1(destroyContext, CanvasContext* context) { |
| 86 | delete args->context; |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 87 | return nullptr; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 88 | } |
| 89 | |
| 90 | void RenderProxy::destroyContext() { |
| 91 | if (mContext) { |
| 92 | SETUP_TASK(destroyContext); |
| 93 | args->context = mContext; |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 94 | mContext = nullptr; |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 95 | mDrawFrameTask.setContext(nullptr, nullptr, nullptr); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 96 | // This is also a fence as we need to be certain that there are no |
| 97 | // outstanding mDrawFrame tasks posted before it is destroyed |
| 98 | postAndWait(task); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 99 | } |
| 100 | } |
| 101 | |
John Reck | 1125d1f | 2014-10-23 11:02:19 -0700 | [diff] [blame] | 102 | CREATE_BRIDGE2(setSwapBehavior, CanvasContext* context, SwapBehavior swapBehavior) { |
| 103 | args->context->setSwapBehavior(args->swapBehavior); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 104 | return nullptr; |
John Reck | 1125d1f | 2014-10-23 11:02:19 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | void RenderProxy::setSwapBehavior(SwapBehavior swapBehavior) { |
| 108 | SETUP_TASK(setSwapBehavior); |
| 109 | args->context = mContext; |
| 110 | args->swapBehavior = swapBehavior; |
| 111 | post(task); |
| 112 | } |
| 113 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 114 | CREATE_BRIDGE1(loadSystemProperties, CanvasContext* context) { |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 115 | bool needsRedraw = false; |
| 116 | if (Caches::hasInstance()) { |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 117 | needsRedraw = Properties::load(); |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 118 | } |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 119 | if (args->context->profiler().consumeProperties()) { |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 120 | needsRedraw = true; |
| 121 | } |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 122 | return (void*) needsRedraw; |
| 123 | } |
| 124 | |
| 125 | bool RenderProxy::loadSystemProperties() { |
| 126 | SETUP_TASK(loadSystemProperties); |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 127 | args->context = mContext; |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 128 | return (bool) postAndWait(task); |
| 129 | } |
| 130 | |
John Reck | b36016c | 2015-03-11 08:50:53 -0700 | [diff] [blame] | 131 | CREATE_BRIDGE2(setName, CanvasContext* context, const char* name) { |
| 132 | args->context->setName(std::string(args->name)); |
| 133 | return nullptr; |
| 134 | } |
| 135 | |
| 136 | void RenderProxy::setName(const char* name) { |
| 137 | SETUP_TASK(setName); |
| 138 | args->context = mContext; |
| 139 | args->name = name; |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 140 | postAndWait(task); // block since name/value pointers owned by caller |
John Reck | b36016c | 2015-03-11 08:50:53 -0700 | [diff] [blame] | 141 | } |
| 142 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 143 | CREATE_BRIDGE2(initialize, CanvasContext* context, Surface* surface) { |
| 144 | args->context->initialize(args->surface); |
Thomas Buhot | 0bcd0cb | 2015-12-04 12:18:03 +0100 | [diff] [blame] | 145 | return nullptr; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 146 | } |
| 147 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 148 | void RenderProxy::initialize(const sp<Surface>& surface) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 149 | SETUP_TASK(initialize); |
| 150 | args->context = mContext; |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 151 | args->surface = surface.get(); |
Thomas Buhot | 0bcd0cb | 2015-12-04 12:18:03 +0100 | [diff] [blame] | 152 | post(task); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 153 | } |
| 154 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 155 | CREATE_BRIDGE2(updateSurface, CanvasContext* context, Surface* surface) { |
| 156 | args->context->updateSurface(args->surface); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 157 | return nullptr; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 158 | } |
| 159 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 160 | void RenderProxy::updateSurface(const sp<Surface>& surface) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 161 | SETUP_TASK(updateSurface); |
| 162 | args->context = mContext; |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 163 | args->surface = surface.get(); |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 164 | postAndWait(task); |
| 165 | } |
| 166 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 167 | CREATE_BRIDGE2(pauseSurface, CanvasContext* context, Surface* surface) { |
| 168 | return (void*) args->context->pauseSurface(args->surface); |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 169 | } |
| 170 | |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 171 | bool RenderProxy::pauseSurface(const sp<Surface>& surface) { |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 172 | SETUP_TASK(pauseSurface); |
| 173 | args->context = mContext; |
John Reck | f648108 | 2016-02-02 15:18:23 -0800 | [diff] [blame] | 174 | args->surface = surface.get(); |
John Reck | 01a5ea3 | 2014-12-03 13:01:07 -0800 | [diff] [blame] | 175 | return (bool) postAndWait(task); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 176 | } |
| 177 | |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 178 | CREATE_BRIDGE6(setup, CanvasContext* context, int width, int height, |
| 179 | float lightRadius, uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) { |
| 180 | args->context->setup(args->width, args->height, args->lightRadius, |
Chris Craik | 058fc64 | 2014-07-23 18:19:28 -0700 | [diff] [blame] | 181 | args->ambientShadowAlpha, args->spotShadowAlpha); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 182 | return nullptr; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 183 | } |
| 184 | |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 185 | void RenderProxy::setup(int width, int height, float lightRadius, |
John Reck | b36016c | 2015-03-11 08:50:53 -0700 | [diff] [blame] | 186 | uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 187 | SETUP_TASK(setup); |
| 188 | args->context = mContext; |
| 189 | args->width = width; |
| 190 | args->height = height; |
Chris Craik | 797b95b | 2014-05-20 18:10:25 -0700 | [diff] [blame] | 191 | args->lightRadius = lightRadius; |
Chris Craik | 058fc64 | 2014-07-23 18:19:28 -0700 | [diff] [blame] | 192 | args->ambientShadowAlpha = ambientShadowAlpha; |
| 193 | args->spotShadowAlpha = spotShadowAlpha; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 194 | post(task); |
| 195 | } |
| 196 | |
Alan Viverette | 50210d9 | 2015-05-14 18:05:36 -0700 | [diff] [blame] | 197 | CREATE_BRIDGE2(setLightCenter, CanvasContext* context, Vector3 lightCenter) { |
| 198 | args->context->setLightCenter(args->lightCenter); |
| 199 | return nullptr; |
| 200 | } |
| 201 | |
| 202 | void RenderProxy::setLightCenter(const Vector3& lightCenter) { |
| 203 | SETUP_TASK(setLightCenter); |
| 204 | args->context = mContext; |
| 205 | args->lightCenter = lightCenter; |
| 206 | post(task); |
| 207 | } |
| 208 | |
John Reck | 63a0667 | 2014-05-07 13:45:54 -0700 | [diff] [blame] | 209 | CREATE_BRIDGE2(setOpaque, CanvasContext* context, bool opaque) { |
| 210 | args->context->setOpaque(args->opaque); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 211 | return nullptr; |
John Reck | 63a0667 | 2014-05-07 13:45:54 -0700 | [diff] [blame] | 212 | } |
| 213 | |
| 214 | void RenderProxy::setOpaque(bool opaque) { |
| 215 | SETUP_TASK(setOpaque); |
| 216 | args->context = mContext; |
| 217 | args->opaque = opaque; |
| 218 | post(task); |
| 219 | } |
| 220 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 221 | int64_t* RenderProxy::frameInfo() { |
| 222 | return mDrawFrameTask.frameInfo(); |
| 223 | } |
| 224 | |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 225 | int RenderProxy::syncAndDrawFrame(TreeObserver* observer) { |
| 226 | return mDrawFrameTask.drawFrame(observer); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 227 | } |
| 228 | |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 229 | CREATE_BRIDGE2(destroy, CanvasContext* context, TreeObserver* observer) { |
| 230 | args->context->destroy(args->observer); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 231 | return nullptr; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 232 | } |
| 233 | |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 234 | void RenderProxy::destroy(TreeObserver* observer) { |
John Reck | 17035b0 | 2014-09-03 07:39:53 -0700 | [diff] [blame] | 235 | SETUP_TASK(destroy); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 236 | args->context = mContext; |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 237 | args->observer = observer; |
John Reck | fae904d | 2014-04-14 11:01:57 -0700 | [diff] [blame] | 238 | // destroyCanvasAndSurface() needs a fence as when it returns the |
| 239 | // underlying BufferQueue is going to be released from under |
| 240 | // the render thread. |
| 241 | postAndWait(task); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 242 | } |
| 243 | |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 244 | CREATE_BRIDGE2(invokeFunctor, RenderThread* thread, Functor* functor) { |
| 245 | CanvasContext::invokeFunctor(*args->thread, args->functor); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 246 | return nullptr; |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 247 | } |
| 248 | |
| 249 | void RenderProxy::invokeFunctor(Functor* functor, bool waitForCompletion) { |
John Reck | d3d8daf | 2014-04-10 15:00:13 -0700 | [diff] [blame] | 250 | ATRACE_CALL(); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 251 | RenderThread& thread = RenderThread::getInstance(); |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 252 | SETUP_TASK(invokeFunctor); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 253 | args->thread = &thread; |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 254 | args->functor = functor; |
| 255 | if (waitForCompletion) { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 256 | // waitForCompletion = true is expected to be fairly rare and only |
| 257 | // happen in destruction. Thus it should be fine to temporarily |
| 258 | // create a Mutex |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 259 | staticPostAndWait(task); |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 260 | } else { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 261 | thread.queue(task); |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 262 | } |
| 263 | } |
| 264 | |
John Reck | fc53ef27 | 2014-02-11 10:40:25 -0800 | [diff] [blame] | 265 | CREATE_BRIDGE2(runWithGlContext, CanvasContext* context, RenderTask* task) { |
| 266 | args->context->runWithGlContext(args->task); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 267 | return nullptr; |
John Reck | fc53ef27 | 2014-02-11 10:40:25 -0800 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | void RenderProxy::runWithGlContext(RenderTask* gltask) { |
| 271 | SETUP_TASK(runWithGlContext); |
| 272 | args->context = mContext; |
| 273 | args->task = gltask; |
| 274 | postAndWait(task); |
| 275 | } |
| 276 | |
John Reck | c36df95 | 2015-07-29 10:09:36 -0700 | [diff] [blame] | 277 | CREATE_BRIDGE1(createTextureLayer, CanvasContext* context) { |
John Reck | 1949e79 | 2014-04-08 15:18:56 -0700 | [diff] [blame] | 278 | Layer* layer = args->context->createTextureLayer(); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 279 | if (!layer) return nullptr; |
John Reck | c36df95 | 2015-07-29 10:09:36 -0700 | [diff] [blame] | 280 | return new DeferredLayerUpdater(layer); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 281 | } |
| 282 | |
| 283 | DeferredLayerUpdater* RenderProxy::createTextureLayer() { |
| 284 | SETUP_TASK(createTextureLayer); |
John Reck | 1949e79 | 2014-04-08 15:18:56 -0700 | [diff] [blame] | 285 | args->context = mContext; |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 286 | void* retval = postAndWait(task); |
| 287 | DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(retval); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 288 | return layer; |
| 289 | } |
| 290 | |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 291 | CREATE_BRIDGE3(buildLayer, CanvasContext* context, RenderNode* node, TreeObserver* observer) { |
| 292 | args->context->buildLayer(args->node, args->observer); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 293 | return nullptr; |
John Reck | 3e82495 | 2014-08-20 10:08:39 -0700 | [diff] [blame] | 294 | } |
| 295 | |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 296 | void RenderProxy::buildLayer(RenderNode* node, TreeObserver* observer) { |
John Reck | 3e82495 | 2014-08-20 10:08:39 -0700 | [diff] [blame] | 297 | SETUP_TASK(buildLayer); |
| 298 | args->context = mContext; |
| 299 | args->node = node; |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 300 | args->observer = observer; |
John Reck | 3e82495 | 2014-08-20 10:08:39 -0700 | [diff] [blame] | 301 | postAndWait(task); |
| 302 | } |
| 303 | |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 304 | CREATE_BRIDGE3(copyLayerInto, CanvasContext* context, DeferredLayerUpdater* layer, |
| 305 | SkBitmap* bitmap) { |
| 306 | bool success = args->context->copyLayerInto(args->layer, args->bitmap); |
| 307 | return (void*) success; |
| 308 | } |
| 309 | |
John Reck | 3731dc2 | 2015-04-13 15:20:29 -0700 | [diff] [blame] | 310 | bool RenderProxy::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap& bitmap) { |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 311 | SETUP_TASK(copyLayerInto); |
| 312 | args->context = mContext; |
| 313 | args->layer = layer; |
John Reck | 3731dc2 | 2015-04-13 15:20:29 -0700 | [diff] [blame] | 314 | args->bitmap = &bitmap; |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 315 | return (bool) postAndWait(task); |
| 316 | } |
| 317 | |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 318 | void RenderProxy::pushLayerUpdate(DeferredLayerUpdater* layer) { |
| 319 | mDrawFrameTask.pushLayerUpdate(layer); |
| 320 | } |
| 321 | |
| 322 | void RenderProxy::cancelLayerUpdate(DeferredLayerUpdater* layer) { |
| 323 | mDrawFrameTask.removeLayerUpdate(layer); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 324 | } |
| 325 | |
John Reck | 918ad52 | 2014-06-27 14:45:25 -0700 | [diff] [blame] | 326 | CREATE_BRIDGE1(detachSurfaceTexture, DeferredLayerUpdater* layer) { |
| 327 | args->layer->detachSurfaceTexture(); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 328 | return nullptr; |
John Reck | 918ad52 | 2014-06-27 14:45:25 -0700 | [diff] [blame] | 329 | } |
| 330 | |
| 331 | void RenderProxy::detachSurfaceTexture(DeferredLayerUpdater* layer) { |
| 332 | SETUP_TASK(detachSurfaceTexture); |
| 333 | args->layer = layer; |
| 334 | postAndWait(task); |
| 335 | } |
| 336 | |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 337 | CREATE_BRIDGE2(destroyHardwareResources, CanvasContext* context, TreeObserver* observer) { |
| 338 | args->context->destroyHardwareResources(args->observer); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 339 | return nullptr; |
John Reck | e1628b7 | 2014-05-23 15:11:19 -0700 | [diff] [blame] | 340 | } |
| 341 | |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 342 | void RenderProxy::destroyHardwareResources(TreeObserver* observer) { |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 343 | SETUP_TASK(destroyHardwareResources); |
John Reck | e1628b7 | 2014-05-23 15:11:19 -0700 | [diff] [blame] | 344 | args->context = mContext; |
John Reck | 51f2d60 | 2016-04-06 07:50:47 -0700 | [diff] [blame^] | 345 | args->observer = observer; |
| 346 | postAndWait(task); |
John Reck | e1628b7 | 2014-05-23 15:11:19 -0700 | [diff] [blame] | 347 | } |
| 348 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 349 | CREATE_BRIDGE2(trimMemory, RenderThread* thread, int level) { |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 350 | CanvasContext::trimMemory(*args->thread, args->level); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 351 | return nullptr; |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 352 | } |
| 353 | |
| 354 | void RenderProxy::trimMemory(int level) { |
John Reck | cd3a22c | 2014-08-06 13:33:59 -0700 | [diff] [blame] | 355 | // Avoid creating a RenderThread to do a trimMemory. |
| 356 | if (RenderThread::hasInstance()) { |
| 357 | RenderThread& thread = RenderThread::getInstance(); |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 358 | SETUP_TASK(trimMemory); |
John Reck | cd3a22c | 2014-08-06 13:33:59 -0700 | [diff] [blame] | 359 | args->thread = &thread; |
| 360 | args->level = level; |
| 361 | thread.queue(task); |
| 362 | } |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 363 | } |
| 364 | |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 365 | CREATE_BRIDGE2(overrideProperty, const char* name, const char* value) { |
| 366 | Properties::overrideProperty(args->name, args->value); |
| 367 | return nullptr; |
| 368 | } |
| 369 | |
| 370 | void RenderProxy::overrideProperty(const char* name, const char* value) { |
Chris Craik | 2507c34 | 2015-05-04 14:36:49 -0700 | [diff] [blame] | 371 | SETUP_TASK(overrideProperty); |
| 372 | args->name = name; |
| 373 | args->value = value; |
| 374 | staticPostAndWait(task); // expensive, but block here since name/value pointers owned by caller |
| 375 | } |
| 376 | |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 377 | CREATE_BRIDGE0(fence) { |
| 378 | // Intentionally empty |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 379 | return nullptr; |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 380 | } |
| 381 | |
Andreas Gampe | 64bb413 | 2014-11-22 00:35:09 +0000 | [diff] [blame] | 382 | template <typename T> |
| 383 | void UNUSED(T t) {} |
| 384 | |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 385 | void RenderProxy::fence() { |
| 386 | SETUP_TASK(fence); |
Andreas Gampe | 1e19674 | 2014-11-10 15:23:43 -0800 | [diff] [blame] | 387 | UNUSED(args); |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 388 | postAndWait(task); |
| 389 | } |
| 390 | |
Thomas Buhot | c0a0e1a | 2016-01-18 10:31:58 +0100 | [diff] [blame] | 391 | void RenderProxy::staticFence() { |
| 392 | SETUP_TASK(fence); |
| 393 | UNUSED(args); |
| 394 | staticPostAndWait(task); |
| 395 | } |
| 396 | |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 397 | CREATE_BRIDGE1(stopDrawing, CanvasContext* context) { |
| 398 | args->context->stopDrawing(); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 399 | return nullptr; |
John Reck | f47a594 | 2014-06-30 16:20:04 -0700 | [diff] [blame] | 400 | } |
| 401 | |
| 402 | void RenderProxy::stopDrawing() { |
| 403 | SETUP_TASK(stopDrawing); |
| 404 | args->context = mContext; |
| 405 | postAndWait(task); |
| 406 | } |
| 407 | |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 408 | CREATE_BRIDGE1(notifyFramePending, CanvasContext* context) { |
| 409 | args->context->notifyFramePending(); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 410 | return nullptr; |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 411 | } |
| 412 | |
| 413 | void RenderProxy::notifyFramePending() { |
| 414 | SETUP_TASK(notifyFramePending); |
| 415 | args->context = mContext; |
| 416 | mRenderThread.queueAtFront(task); |
| 417 | } |
| 418 | |
John Reck | 7f2e5e3 | 2015-05-05 11:00:53 -0700 | [diff] [blame] | 419 | CREATE_BRIDGE4(dumpProfileInfo, CanvasContext* context, RenderThread* thread, |
| 420 | int fd, int dumpFlags) { |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 421 | args->context->profiler().dumpData(args->fd); |
Chris Craik | 53e51e4 | 2015-06-01 10:35:35 -0700 | [diff] [blame] | 422 | if (args->dumpFlags & DumpFlags::FrameStats) { |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 423 | args->context->dumpFrames(args->fd); |
| 424 | } |
Chris Craik | 53e51e4 | 2015-06-01 10:35:35 -0700 | [diff] [blame] | 425 | if (args->dumpFlags & DumpFlags::Reset) { |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 426 | args->context->resetFrameStats(); |
| 427 | } |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 428 | return nullptr; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 429 | } |
| 430 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 431 | void RenderProxy::dumpProfileInfo(int fd, int dumpFlags) { |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 432 | SETUP_TASK(dumpProfileInfo); |
| 433 | args->context = mContext; |
John Reck | 7f2e5e3 | 2015-05-05 11:00:53 -0700 | [diff] [blame] | 434 | args->thread = &mRenderThread; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 435 | args->fd = fd; |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 436 | args->dumpFlags = dumpFlags; |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 437 | postAndWait(task); |
| 438 | } |
| 439 | |
John Reck | 7f2e5e3 | 2015-05-05 11:00:53 -0700 | [diff] [blame] | 440 | CREATE_BRIDGE1(resetProfileInfo, CanvasContext* context) { |
| 441 | args->context->resetFrameStats(); |
| 442 | return nullptr; |
| 443 | } |
| 444 | |
| 445 | void RenderProxy::resetProfileInfo() { |
| 446 | SETUP_TASK(resetProfileInfo); |
| 447 | args->context = mContext; |
| 448 | postAndWait(task); |
| 449 | } |
| 450 | |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 451 | CREATE_BRIDGE2(dumpGraphicsMemory, int fd, RenderThread* thread) { |
| 452 | args->thread->jankTracker().dump(args->fd); |
| 453 | |
Chris Craik | 2ae0733 | 2015-01-21 14:22:39 -0800 | [diff] [blame] | 454 | FILE *file = fdopen(args->fd, "a"); |
| 455 | if (Caches::hasInstance()) { |
| 456 | String8 cachesLog; |
| 457 | Caches::getInstance().dumpMemoryUsage(cachesLog); |
| 458 | fprintf(file, "\nCaches:\n%s\n", cachesLog.string()); |
| 459 | } else { |
| 460 | fprintf(file, "\nNo caches instance.\n"); |
| 461 | } |
Chris Craik | ff3edce | 2016-01-14 10:04:08 -0800 | [diff] [blame] | 462 | #if HWUI_NEW_OPS |
| 463 | fprintf(file, "\nPipeline=FrameBuilder\n"); |
| 464 | #else |
| 465 | fprintf(file, "\nPipeline=OpenGLRenderer\n"); |
| 466 | #endif |
Chris Craik | 2ae0733 | 2015-01-21 14:22:39 -0800 | [diff] [blame] | 467 | fflush(file); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 468 | return nullptr; |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 469 | } |
| 470 | |
Chris Craik | 2ae0733 | 2015-01-21 14:22:39 -0800 | [diff] [blame] | 471 | void RenderProxy::dumpGraphicsMemory(int fd) { |
youngmin0822.lee | c80c9ad | 2015-03-20 21:22:32 +0900 | [diff] [blame] | 472 | if (!RenderThread::hasInstance()) return; |
Chris Craik | 2ae0733 | 2015-01-21 14:22:39 -0800 | [diff] [blame] | 473 | SETUP_TASK(dumpGraphicsMemory); |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 474 | args->fd = fd; |
John Reck | ba6adf6 | 2015-02-19 14:36:50 -0800 | [diff] [blame] | 475 | args->thread = &RenderThread::getInstance(); |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 476 | staticPostAndWait(task); |
| 477 | } |
| 478 | |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 479 | CREATE_BRIDGE4(setTextureAtlas, RenderThread* thread, GraphicBuffer* buffer, int64_t* map, |
| 480 | size_t size) { |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 481 | CanvasContext::setTextureAtlas(*args->thread, args->buffer, args->map, args->size); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 482 | args->buffer->decStrong(nullptr); |
| 483 | return nullptr; |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | void RenderProxy::setTextureAtlas(const sp<GraphicBuffer>& buffer, int64_t* map, size_t size) { |
| 487 | SETUP_TASK(setTextureAtlas); |
| 488 | args->thread = &mRenderThread; |
| 489 | args->buffer = buffer.get(); |
Chris Craik | d41c4d8 | 2015-01-05 15:51:13 -0800 | [diff] [blame] | 490 | args->buffer->incStrong(nullptr); |
John Reck | 3b20251 | 2014-06-23 13:13:08 -0700 | [diff] [blame] | 491 | args->map = map; |
| 492 | args->size = size; |
| 493 | post(task); |
| 494 | } |
| 495 | |
John Reck | edc524c | 2015-03-18 15:24:33 -0700 | [diff] [blame] | 496 | CREATE_BRIDGE2(setProcessStatsBuffer, RenderThread* thread, int fd) { |
| 497 | args->thread->jankTracker().switchStorageToAshmem(args->fd); |
| 498 | close(args->fd); |
| 499 | return nullptr; |
| 500 | } |
| 501 | |
| 502 | void RenderProxy::setProcessStatsBuffer(int fd) { |
| 503 | SETUP_TASK(setProcessStatsBuffer); |
| 504 | args->thread = &mRenderThread; |
| 505 | args->fd = dup(fd); |
| 506 | post(task); |
| 507 | } |
| 508 | |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 509 | CREATE_BRIDGE3(addRenderNode, CanvasContext* context, RenderNode* node, bool placeFront) { |
| 510 | args->context->addRenderNode(args->node, args->placeFront); |
| 511 | return nullptr; |
| 512 | } |
| 513 | |
| 514 | void RenderProxy::addRenderNode(RenderNode* node, bool placeFront) { |
| 515 | SETUP_TASK(addRenderNode); |
| 516 | args->context = mContext; |
| 517 | args->node = node; |
| 518 | args->placeFront = placeFront; |
| 519 | post(task); |
| 520 | } |
| 521 | |
| 522 | CREATE_BRIDGE2(removeRenderNode, CanvasContext* context, RenderNode* node) { |
| 523 | args->context->removeRenderNode(args->node); |
| 524 | return nullptr; |
| 525 | } |
| 526 | |
| 527 | void RenderProxy::removeRenderNode(RenderNode* node) { |
| 528 | SETUP_TASK(removeRenderNode); |
| 529 | args->context = mContext; |
| 530 | args->node = node; |
| 531 | post(task); |
| 532 | } |
| 533 | |
| 534 | CREATE_BRIDGE2(drawRenderNode, CanvasContext* context, RenderNode* node) { |
| 535 | args->context->prepareAndDraw(args->node); |
| 536 | return nullptr; |
| 537 | } |
| 538 | |
| 539 | void RenderProxy::drawRenderNode(RenderNode* node) { |
| 540 | SETUP_TASK(drawRenderNode); |
| 541 | args->context = mContext; |
| 542 | args->node = node; |
| 543 | // Be pseudo-thread-safe and don't use any member variables |
| 544 | staticPostAndWait(task); |
| 545 | } |
| 546 | |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 547 | CREATE_BRIDGE5(setContentDrawBounds, CanvasContext* context, int left, int top, |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 548 | int right, int bottom) { |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 549 | args->context->setContentDrawBounds(args->left, args->top, args->right, args->bottom); |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 550 | return nullptr; |
| 551 | } |
| 552 | |
Skuhne | b816087 | 2015-09-22 09:51:39 -0700 | [diff] [blame] | 553 | void RenderProxy::setContentDrawBounds(int left, int top, int right, int bottom) { |
| 554 | SETUP_TASK(setContentDrawBounds); |
Skuhne | ea7a7fb | 2015-08-28 07:10:31 -0700 | [diff] [blame] | 555 | args->context = mContext; |
| 556 | args->left = left; |
| 557 | args->top = top; |
| 558 | args->right = right; |
| 559 | args->bottom = bottom; |
| 560 | staticPostAndWait(task); |
| 561 | } |
| 562 | |
John Reck | e248bd1 | 2015-08-05 13:53:53 -0700 | [diff] [blame] | 563 | CREATE_BRIDGE1(serializeDisplayListTree, CanvasContext* context) { |
| 564 | args->context->serializeDisplayListTree(); |
| 565 | return nullptr; |
| 566 | } |
| 567 | |
| 568 | void RenderProxy::serializeDisplayListTree() { |
| 569 | SETUP_TASK(serializeDisplayListTree); |
| 570 | args->context = mContext; |
| 571 | post(task); |
| 572 | } |
| 573 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 574 | CREATE_BRIDGE2(addFrameMetricsObserver, CanvasContext* context, |
| 575 | FrameMetricsObserver* frameStatsObserver) { |
| 576 | args->context->addFrameMetricsObserver(args->frameStatsObserver); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 577 | if (args->frameStatsObserver != nullptr) { |
| 578 | args->frameStatsObserver->decStrong(args->context); |
| 579 | } |
| 580 | return nullptr; |
| 581 | } |
| 582 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 583 | void RenderProxy::addFrameMetricsObserver(FrameMetricsObserver* observer) { |
| 584 | SETUP_TASK(addFrameMetricsObserver); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 585 | args->context = mContext; |
| 586 | args->frameStatsObserver = observer; |
| 587 | if (observer != nullptr) { |
| 588 | observer->incStrong(mContext); |
| 589 | } |
| 590 | post(task); |
| 591 | } |
| 592 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 593 | CREATE_BRIDGE2(removeFrameMetricsObserver, CanvasContext* context, |
| 594 | FrameMetricsObserver* frameStatsObserver) { |
| 595 | args->context->removeFrameMetricsObserver(args->frameStatsObserver); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 596 | if (args->frameStatsObserver != nullptr) { |
| 597 | args->frameStatsObserver->decStrong(args->context); |
| 598 | } |
| 599 | return nullptr; |
| 600 | } |
| 601 | |
Andres Morales | 910beb8 | 2016-02-02 16:19:40 -0800 | [diff] [blame] | 602 | void RenderProxy::removeFrameMetricsObserver(FrameMetricsObserver* observer) { |
| 603 | SETUP_TASK(removeFrameMetricsObserver); |
Andres Morales | 06f5bc7 | 2015-12-15 15:21:31 -0800 | [diff] [blame] | 604 | args->context = mContext; |
| 605 | args->frameStatsObserver = observer; |
| 606 | if (observer != nullptr) { |
| 607 | observer->incStrong(mContext); |
| 608 | } |
| 609 | post(task); |
| 610 | } |
| 611 | |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 612 | void RenderProxy::post(RenderTask* task) { |
| 613 | mRenderThread.queue(task); |
| 614 | } |
| 615 | |
| 616 | void* RenderProxy::postAndWait(MethodInvokeRenderTask* task) { |
| 617 | void* retval; |
| 618 | task->setReturnPtr(&retval); |
John Reck | cba287b | 2015-11-10 12:52:44 -0800 | [diff] [blame] | 619 | SignalingRenderTask syncTask(task, &mSyncMutex, &mSyncCondition); |
| 620 | AutoMutex _lock(mSyncMutex); |
| 621 | mRenderThread.queue(&syncTask); |
| 622 | mSyncCondition.wait(mSyncMutex); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 623 | return retval; |
| 624 | } |
| 625 | |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 626 | void* RenderProxy::staticPostAndWait(MethodInvokeRenderTask* task) { |
| 627 | RenderThread& thread = RenderThread::getInstance(); |
| 628 | void* retval; |
| 629 | task->setReturnPtr(&retval); |
Chris Craik | 0a24b14 | 2015-10-19 17:10:19 -0700 | [diff] [blame] | 630 | thread.queueAndWait(task); |
John Reck | 0e89e2b | 2014-10-31 14:49:06 -0700 | [diff] [blame] | 631 | return retval; |
| 632 | } |
| 633 | |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 634 | } /* namespace renderthread */ |
| 635 | } /* namespace uirenderer */ |
| 636 | } /* namespace android */ |