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 | |
| 17 | #define LOG_TAG "RenderProxy" |
| 18 | |
| 19 | #include "RenderProxy.h" |
| 20 | |
| 21 | #include "CanvasContext.h" |
| 22 | #include "RenderTask.h" |
| 23 | #include "RenderThread.h" |
| 24 | |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 25 | #include "../DeferredLayerUpdater.h" |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 26 | #include "../DisplayList.h" |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 27 | #include "../LayerRenderer.h" |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 28 | #include "../Rect.h" |
| 29 | |
| 30 | namespace android { |
| 31 | namespace uirenderer { |
| 32 | namespace renderthread { |
| 33 | |
| 34 | #define ARGS(method) method ## Args |
| 35 | |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 36 | #define CREATE_BRIDGE0(name) CREATE_BRIDGE(name,,,,,,,,) |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 37 | #define CREATE_BRIDGE1(name, a1) CREATE_BRIDGE(name, a1,,,,,,,) |
| 38 | #define CREATE_BRIDGE2(name, a1, a2) CREATE_BRIDGE(name, a1,a2,,,,,,) |
| 39 | #define CREATE_BRIDGE3(name, a1, a2, a3) CREATE_BRIDGE(name, a1,a2,a3,,,,,) |
| 40 | #define CREATE_BRIDGE4(name, a1, a2, a3, a4) CREATE_BRIDGE(name, a1,a2,a3,a4,,,,) |
Chris Craik | 797b95b2 | 2014-05-20 18:10:25 -0700 | [diff] [blame] | 41 | #define CREATE_BRIDGE5(name, a1, a2, a3, a4, a5) CREATE_BRIDGE(name, a1,a2,a3,a4,a5,,,) |
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 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 55 | CREATE_BRIDGE2(createContext, bool translucent, RenderNode* rootRenderNode) { |
| 56 | return new CanvasContext(args->translucent, args->rootRenderNode); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 57 | } |
| 58 | |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 59 | RenderProxy::RenderProxy(bool translucent, RenderNode* rootRenderNode) |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 60 | : mRenderThread(RenderThread::getInstance()) |
| 61 | , mContext(0) { |
| 62 | SETUP_TASK(createContext); |
| 63 | args->translucent = translucent; |
John Reck | e45b1fd | 2014-04-15 09:50:16 -0700 | [diff] [blame] | 64 | args->rootRenderNode = rootRenderNode; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 65 | mContext = (CanvasContext*) postAndWait(task); |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 66 | mDrawFrameTask.setContext(&mRenderThread, mContext); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | RenderProxy::~RenderProxy() { |
| 70 | destroyContext(); |
| 71 | } |
| 72 | |
| 73 | CREATE_BRIDGE1(destroyContext, CanvasContext* context) { |
| 74 | delete args->context; |
| 75 | return NULL; |
| 76 | } |
| 77 | |
| 78 | void RenderProxy::destroyContext() { |
| 79 | if (mContext) { |
| 80 | SETUP_TASK(destroyContext); |
| 81 | args->context = mContext; |
| 82 | mContext = 0; |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 83 | mDrawFrameTask.setContext(NULL, NULL); |
John Reck | 668f0e3 | 2014-03-26 15:10:40 -0700 | [diff] [blame] | 84 | // This is also a fence as we need to be certain that there are no |
| 85 | // outstanding mDrawFrame tasks posted before it is destroyed |
| 86 | postAndWait(task); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 87 | } |
| 88 | } |
| 89 | |
John Reck | 18f16e6 | 2014-05-02 16:46:41 -0700 | [diff] [blame] | 90 | CREATE_BRIDGE2(setFrameInterval, RenderThread* thread, nsecs_t frameIntervalNanos) { |
| 91 | args->thread->timeLord().setFrameInterval(args->frameIntervalNanos); |
| 92 | return NULL; |
| 93 | } |
| 94 | |
| 95 | void RenderProxy::setFrameInterval(nsecs_t frameIntervalNanos) { |
| 96 | SETUP_TASK(setFrameInterval); |
| 97 | args->thread = &mRenderThread; |
| 98 | args->frameIntervalNanos = frameIntervalNanos; |
| 99 | post(task); |
| 100 | } |
| 101 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 102 | CREATE_BRIDGE1(loadSystemProperties, CanvasContext* context) { |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 103 | bool needsRedraw = false; |
| 104 | if (Caches::hasInstance()) { |
| 105 | needsRedraw = Caches::getInstance().initProperties(); |
| 106 | } |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 107 | if (args->context->profiler().loadSystemProperties()) { |
| 108 | needsRedraw = true; |
| 109 | } |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 110 | return (void*) needsRedraw; |
| 111 | } |
| 112 | |
| 113 | bool RenderProxy::loadSystemProperties() { |
| 114 | SETUP_TASK(loadSystemProperties); |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 115 | args->context = mContext; |
John Reck | e4280ba | 2014-05-05 16:39:37 -0700 | [diff] [blame] | 116 | return (bool) postAndWait(task); |
| 117 | } |
| 118 | |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 119 | CREATE_BRIDGE2(initialize, CanvasContext* context, ANativeWindow* window) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 120 | return (void*) args->context->initialize(args->window); |
| 121 | } |
| 122 | |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 123 | bool RenderProxy::initialize(const sp<ANativeWindow>& window) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 124 | SETUP_TASK(initialize); |
| 125 | args->context = mContext; |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 126 | args->window = window.get(); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 127 | return (bool) postAndWait(task); |
| 128 | } |
| 129 | |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 130 | CREATE_BRIDGE2(updateSurface, CanvasContext* context, ANativeWindow* window) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 131 | args->context->updateSurface(args->window); |
| 132 | return NULL; |
| 133 | } |
| 134 | |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 135 | void RenderProxy::updateSurface(const sp<ANativeWindow>& window) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 136 | SETUP_TASK(updateSurface); |
| 137 | args->context = mContext; |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 138 | args->window = window.get(); |
| 139 | postAndWait(task); |
| 140 | } |
| 141 | |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 142 | CREATE_BRIDGE2(pauseSurface, CanvasContext* context, ANativeWindow* window) { |
John Reck | f7d9c1d | 2014-04-09 10:01:03 -0700 | [diff] [blame] | 143 | args->context->pauseSurface(args->window); |
| 144 | return NULL; |
| 145 | } |
| 146 | |
| 147 | void RenderProxy::pauseSurface(const sp<ANativeWindow>& window) { |
| 148 | SETUP_TASK(pauseSurface); |
| 149 | args->context = mContext; |
| 150 | args->window = window.get(); |
| 151 | postAndWait(task); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 152 | } |
| 153 | |
Chris Craik | 797b95b2 | 2014-05-20 18:10:25 -0700 | [diff] [blame] | 154 | CREATE_BRIDGE5(setup, CanvasContext* context, int width, int height, |
| 155 | Vector3 lightCenter, int lightRadius) { |
| 156 | args->context->setup(args->width, args->height, args->lightCenter, args->lightRadius); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 157 | return NULL; |
| 158 | } |
| 159 | |
Chris Craik | 797b95b2 | 2014-05-20 18:10:25 -0700 | [diff] [blame] | 160 | void RenderProxy::setup(int width, int height, const Vector3& lightCenter, float lightRadius) { |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 161 | SETUP_TASK(setup); |
| 162 | args->context = mContext; |
| 163 | args->width = width; |
| 164 | args->height = height; |
Chris Craik | 797b95b2 | 2014-05-20 18:10:25 -0700 | [diff] [blame] | 165 | args->lightCenter = lightCenter; |
| 166 | args->lightRadius = lightRadius; |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 167 | post(task); |
| 168 | } |
| 169 | |
John Reck | 63a0667 | 2014-05-07 13:45:54 -0700 | [diff] [blame] | 170 | CREATE_BRIDGE2(setOpaque, CanvasContext* context, bool opaque) { |
| 171 | args->context->setOpaque(args->opaque); |
| 172 | return NULL; |
| 173 | } |
| 174 | |
| 175 | void RenderProxy::setOpaque(bool opaque) { |
| 176 | SETUP_TASK(setOpaque); |
| 177 | args->context = mContext; |
| 178 | args->opaque = opaque; |
| 179 | post(task); |
| 180 | } |
| 181 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 182 | int RenderProxy::syncAndDrawFrame(nsecs_t frameTimeNanos, nsecs_t recordDurationNanos, |
John Reck | e4267ea | 2014-06-03 15:53:15 -0700 | [diff] [blame] | 183 | float density) { |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 184 | mDrawFrameTask.setDensity(density); |
| 185 | return mDrawFrameTask.drawFrame(frameTimeNanos, recordDurationNanos); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 186 | } |
| 187 | |
John Reck | fae904d | 2014-04-14 11:01:57 -0700 | [diff] [blame] | 188 | CREATE_BRIDGE1(destroyCanvasAndSurface, CanvasContext* context) { |
| 189 | args->context->destroyCanvasAndSurface(); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 190 | return NULL; |
| 191 | } |
| 192 | |
John Reck | fae904d | 2014-04-14 11:01:57 -0700 | [diff] [blame] | 193 | void RenderProxy::destroyCanvasAndSurface() { |
| 194 | SETUP_TASK(destroyCanvasAndSurface); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 195 | args->context = mContext; |
John Reck | fae904d | 2014-04-14 11:01:57 -0700 | [diff] [blame] | 196 | // destroyCanvasAndSurface() needs a fence as when it returns the |
| 197 | // underlying BufferQueue is going to be released from under |
| 198 | // the render thread. |
| 199 | postAndWait(task); |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 200 | } |
| 201 | |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 202 | CREATE_BRIDGE2(invokeFunctor, CanvasContext* context, Functor* functor) { |
| 203 | args->context->invokeFunctor(args->functor); |
| 204 | return NULL; |
| 205 | } |
| 206 | |
| 207 | void RenderProxy::invokeFunctor(Functor* functor, bool waitForCompletion) { |
John Reck | d3d8daf | 2014-04-10 15:00:13 -0700 | [diff] [blame] | 208 | ATRACE_CALL(); |
John Reck | 0d1f634 | 2014-03-28 20:30:27 -0700 | [diff] [blame] | 209 | SETUP_TASK(invokeFunctor); |
| 210 | args->context = mContext; |
| 211 | args->functor = functor; |
| 212 | if (waitForCompletion) { |
| 213 | postAndWait(task); |
| 214 | } else { |
| 215 | post(task); |
| 216 | } |
| 217 | } |
| 218 | |
John Reck | fc53ef27 | 2014-02-11 10:40:25 -0800 | [diff] [blame] | 219 | CREATE_BRIDGE2(runWithGlContext, CanvasContext* context, RenderTask* task) { |
| 220 | args->context->runWithGlContext(args->task); |
| 221 | return NULL; |
| 222 | } |
| 223 | |
| 224 | void RenderProxy::runWithGlContext(RenderTask* gltask) { |
| 225 | SETUP_TASK(runWithGlContext); |
| 226 | args->context = mContext; |
| 227 | args->task = gltask; |
| 228 | postAndWait(task); |
| 229 | } |
| 230 | |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 231 | CREATE_BRIDGE1(destroyLayer, Layer* layer) { |
| 232 | LayerRenderer::destroyLayer(args->layer); |
| 233 | return NULL; |
| 234 | } |
| 235 | |
| 236 | static void enqueueDestroyLayer(Layer* layer) { |
| 237 | SETUP_TASK(destroyLayer); |
| 238 | args->layer = layer; |
| 239 | RenderThread::getInstance().queue(task); |
| 240 | } |
| 241 | |
John Reck | 1949e79 | 2014-04-08 15:18:56 -0700 | [diff] [blame] | 242 | CREATE_BRIDGE3(createDisplayListLayer, CanvasContext* context, int width, int height) { |
| 243 | Layer* layer = args->context->createRenderLayer(args->width, args->height); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 244 | if (!layer) return 0; |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 245 | return new DeferredLayerUpdater(layer, enqueueDestroyLayer); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 246 | } |
| 247 | |
| 248 | DeferredLayerUpdater* RenderProxy::createDisplayListLayer(int width, int height) { |
| 249 | SETUP_TASK(createDisplayListLayer); |
| 250 | args->width = width; |
| 251 | args->height = height; |
John Reck | 1949e79 | 2014-04-08 15:18:56 -0700 | [diff] [blame] | 252 | args->context = mContext; |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 253 | void* retval = postAndWait(task); |
| 254 | DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(retval); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 255 | return layer; |
| 256 | } |
| 257 | |
John Reck | 1949e79 | 2014-04-08 15:18:56 -0700 | [diff] [blame] | 258 | CREATE_BRIDGE1(createTextureLayer, CanvasContext* context) { |
| 259 | Layer* layer = args->context->createTextureLayer(); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 260 | if (!layer) return 0; |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 261 | return new DeferredLayerUpdater(layer, enqueueDestroyLayer); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | DeferredLayerUpdater* RenderProxy::createTextureLayer() { |
| 265 | SETUP_TASK(createTextureLayer); |
John Reck | 1949e79 | 2014-04-08 15:18:56 -0700 | [diff] [blame] | 266 | args->context = mContext; |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 267 | void* retval = postAndWait(task); |
| 268 | DeferredLayerUpdater* layer = reinterpret_cast<DeferredLayerUpdater*>(retval); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 269 | return layer; |
| 270 | } |
| 271 | |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 272 | CREATE_BRIDGE3(copyLayerInto, CanvasContext* context, DeferredLayerUpdater* layer, |
| 273 | SkBitmap* bitmap) { |
| 274 | bool success = args->context->copyLayerInto(args->layer, args->bitmap); |
| 275 | return (void*) success; |
| 276 | } |
| 277 | |
| 278 | bool RenderProxy::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap* bitmap) { |
| 279 | SETUP_TASK(copyLayerInto); |
| 280 | args->context = mContext; |
| 281 | args->layer = layer; |
| 282 | args->bitmap = bitmap; |
| 283 | return (bool) postAndWait(task); |
| 284 | } |
| 285 | |
John Reck | d72e0a3 | 2014-05-29 18:56:11 -0700 | [diff] [blame] | 286 | void RenderProxy::pushLayerUpdate(DeferredLayerUpdater* layer) { |
| 287 | mDrawFrameTask.pushLayerUpdate(layer); |
| 288 | } |
| 289 | |
| 290 | void RenderProxy::cancelLayerUpdate(DeferredLayerUpdater* layer) { |
| 291 | mDrawFrameTask.removeLayerUpdate(layer); |
John Reck | 19b6bcf | 2014-02-14 20:03:38 -0800 | [diff] [blame] | 292 | } |
| 293 | |
John Reck | e1628b7 | 2014-05-23 15:11:19 -0700 | [diff] [blame] | 294 | CREATE_BRIDGE2(flushCaches, CanvasContext* context, Caches::FlushMode flushMode) { |
| 295 | args->context->flushCaches(args->flushMode); |
| 296 | return NULL; |
| 297 | } |
| 298 | |
| 299 | void RenderProxy::flushCaches(Caches::FlushMode flushMode) { |
| 300 | SETUP_TASK(flushCaches); |
| 301 | args->context = mContext; |
| 302 | args->flushMode = flushMode; |
| 303 | post(task); |
| 304 | } |
| 305 | |
John Reck | 28ad7b5 | 2014-04-07 16:59:25 -0700 | [diff] [blame] | 306 | CREATE_BRIDGE0(fence) { |
| 307 | // Intentionally empty |
| 308 | return NULL; |
| 309 | } |
| 310 | |
| 311 | void RenderProxy::fence() { |
| 312 | SETUP_TASK(fence); |
| 313 | postAndWait(task); |
| 314 | } |
| 315 | |
John Reck | a5dda64 | 2014-05-22 15:43:54 -0700 | [diff] [blame] | 316 | CREATE_BRIDGE1(notifyFramePending, CanvasContext* context) { |
| 317 | args->context->notifyFramePending(); |
| 318 | return NULL; |
| 319 | } |
| 320 | |
| 321 | void RenderProxy::notifyFramePending() { |
| 322 | SETUP_TASK(notifyFramePending); |
| 323 | args->context = mContext; |
| 324 | mRenderThread.queueAtFront(task); |
| 325 | } |
| 326 | |
John Reck | fe5e7b7 | 2014-05-23 17:42:28 -0700 | [diff] [blame] | 327 | CREATE_BRIDGE2(dumpProfileInfo, CanvasContext* context, int fd) { |
| 328 | args->context->profiler().dumpData(args->fd); |
| 329 | return NULL; |
| 330 | } |
| 331 | |
| 332 | void RenderProxy::dumpProfileInfo(int fd) { |
| 333 | SETUP_TASK(dumpProfileInfo); |
| 334 | args->context = mContext; |
| 335 | args->fd = fd; |
| 336 | postAndWait(task); |
| 337 | } |
| 338 | |
John Reck | 4f02bf4 | 2014-01-03 18:09:17 -0800 | [diff] [blame] | 339 | void RenderProxy::post(RenderTask* task) { |
| 340 | mRenderThread.queue(task); |
| 341 | } |
| 342 | |
| 343 | void* RenderProxy::postAndWait(MethodInvokeRenderTask* task) { |
| 344 | void* retval; |
| 345 | task->setReturnPtr(&retval); |
| 346 | SignalingRenderTask syncTask(task, &mSyncMutex, &mSyncCondition); |
| 347 | AutoMutex _lock(mSyncMutex); |
| 348 | mRenderThread.queue(&syncTask); |
| 349 | mSyncCondition.wait(mSyncMutex); |
| 350 | return retval; |
| 351 | } |
| 352 | |
| 353 | } /* namespace renderthread */ |
| 354 | } /* namespace uirenderer */ |
| 355 | } /* namespace android */ |