blob: 020761110ef0f501b62b954f3ee75fbe6e0d8d20 [file] [log] [blame]
John Reck4f02bf42014-01-03 18:09:17 -08001/*
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 Reck4f02bf42014-01-03 18:09:17 -080017#include "RenderProxy.h"
18
John Reckba6adf62015-02-19 14:36:50 -080019#include "DeferredLayerUpdater.h"
20#include "DisplayList.h"
John Recka8963062017-06-14 10:47:50 -070021#include "Properties.h"
John Reck10dd0582016-03-31 16:36:16 -070022#include "Readback.h"
John Reckba6adf62015-02-19 14:36:50 -080023#include "Rect.h"
Stan Iliev3310fb12017-03-23 16:56:51 -040024#include "pipeline/skia/VectorDrawableAtlas.h"
John Reck1bcacfd2017-11-03 10:12:19 -070025#include "renderstate/RenderState.h"
John Reckba6adf62015-02-19 14:36:50 -080026#include "renderthread/CanvasContext.h"
John Reck43871902016-08-01 14:39:24 -070027#include "renderthread/EglManager.h"
John Reckba6adf62015-02-19 14:36:50 -080028#include "renderthread/RenderTask.h"
29#include "renderthread/RenderThread.h"
30#include "utils/Macros.h"
John Reck43871902016-08-01 14:39:24 -070031#include "utils/TimeUtils.h"
John Reck4f02bf42014-01-03 18:09:17 -080032
sergeyv59eecb522016-11-17 17:54:57 -080033#include <ui/GraphicBuffer.h>
34
John Reck4f02bf42014-01-03 18:09:17 -080035namespace android {
36namespace uirenderer {
37namespace renderthread {
38
John Reck1bcacfd2017-11-03 10:12:19 -070039RenderProxy::RenderProxy(bool translucent, RenderNode* rootRenderNode,
40 IContextFactory* contextFactory)
41 : mRenderThread(RenderThread::getInstance()), mContext(nullptr) {
John Reckf8441e62017-10-23 13:10:41 -070042 mContext = mRenderThread.queue().runSync([&]() -> CanvasContext* {
43 return CanvasContext::create(mRenderThread, translucent, rootRenderNode, contextFactory);
44 });
Skuhneea7a7fb2015-08-28 07:10:31 -070045 mDrawFrameTask.setContext(&mRenderThread, mContext, rootRenderNode);
John Reck4f02bf42014-01-03 18:09:17 -080046}
47
48RenderProxy::~RenderProxy() {
49 destroyContext();
50}
51
John Reck4f02bf42014-01-03 18:09:17 -080052void RenderProxy::destroyContext() {
53 if (mContext) {
Skuhneea7a7fb2015-08-28 07:10:31 -070054 mDrawFrameTask.setContext(nullptr, nullptr, nullptr);
John Reck668f0e32014-03-26 15:10:40 -070055 // This is also a fence as we need to be certain that there are no
56 // outstanding mDrawFrame tasks posted before it is destroyed
John Reck1bcacfd2017-11-03 10:12:19 -070057 mRenderThread.queue().runSync([this]() { delete mContext; });
John Reckf8441e62017-10-23 13:10:41 -070058 mContext = nullptr;
John Reck4f02bf42014-01-03 18:09:17 -080059 }
60}
61
John Reck1125d1f2014-10-23 11:02:19 -070062void RenderProxy::setSwapBehavior(SwapBehavior swapBehavior) {
John Reck1bcacfd2017-11-03 10:12:19 -070063 mRenderThread.queue().post([this, swapBehavior]() { mContext->setSwapBehavior(swapBehavior); });
John Recke4280ba2014-05-05 16:39:37 -070064}
65
66bool RenderProxy::loadSystemProperties() {
John Reckf8441e62017-10-23 13:10:41 -070067 return mRenderThread.queue().runSync([this]() -> bool {
68 bool needsRedraw = false;
69 if (Caches::hasInstance()) {
70 needsRedraw = Properties::load();
71 }
72 if (mContext->profiler().consumeProperties()) {
73 needsRedraw = true;
74 }
75 return needsRedraw;
76 });
John Reckb36016c2015-03-11 08:50:53 -070077}
78
79void RenderProxy::setName(const char* name) {
John Reckf8441e62017-10-23 13:10:41 -070080 // block since name/value pointers owned by caller
81 // TODO: Support move arguments
John Reck1bcacfd2017-11-03 10:12:19 -070082 mRenderThread.queue().runSync([this, name]() { mContext->setName(std::string(name)); });
John Reck4f02bf42014-01-03 18:09:17 -080083}
84
John Reckf6481082016-02-02 15:18:23 -080085void RenderProxy::initialize(const sp<Surface>& surface) {
John Reck1bcacfd2017-11-03 10:12:19 -070086 mRenderThread.queue().post(
87 [ this, surf = surface ]() mutable { mContext->setSurface(std::move(surf)); });
John Reck4f02bf42014-01-03 18:09:17 -080088}
89
Jorim Jaggi7823ee72018-07-17 15:24:16 +020090void RenderProxy::allocateBuffers(const sp<Surface>& surface) {
91 mRenderThread.queue().post(
92 [ surf = surface ]() mutable { surf->allocateBuffers(); });
93}
94
John Reckf6481082016-02-02 15:18:23 -080095void RenderProxy::updateSurface(const sp<Surface>& surface) {
John Reck1bcacfd2017-11-03 10:12:19 -070096 mRenderThread.queue().post(
97 [ this, surf = surface ]() mutable { mContext->setSurface(std::move(surf)); });
John Reckf7d9c1d2014-04-09 10:01:03 -070098}
99
John Reckf6481082016-02-02 15:18:23 -0800100bool RenderProxy::pauseSurface(const sp<Surface>& surface) {
John Reck1bcacfd2017-11-03 10:12:19 -0700101 return mRenderThread.queue().runSync([this]() -> bool { return mContext->pauseSurface(); });
John Reck8afcc762016-04-13 10:24:06 -0700102}
103
104void RenderProxy::setStopped(bool stopped) {
John Reck1bcacfd2017-11-03 10:12:19 -0700105 mRenderThread.queue().runSync([this, stopped]() { mContext->setStopped(stopped); });
John Reck8afcc762016-04-13 10:24:06 -0700106}
107
John Reckf8441e62017-10-23 13:10:41 -0700108void RenderProxy::setup(float lightRadius, uint8_t ambientShadowAlpha, uint8_t spotShadowAlpha) {
John Reck1bcacfd2017-11-03 10:12:19 -0700109 mRenderThread.queue().post(
110 [=]() { mContext->setup(lightRadius, ambientShadowAlpha, spotShadowAlpha); });
Alan Viverette50210d92015-05-14 18:05:36 -0700111}
112
113void RenderProxy::setLightCenter(const Vector3& lightCenter) {
John Reck1bcacfd2017-11-03 10:12:19 -0700114 mRenderThread.queue().post([=]() { mContext->setLightCenter(lightCenter); });
John Reck63a06672014-05-07 13:45:54 -0700115}
116
117void RenderProxy::setOpaque(bool opaque) {
John Reck1bcacfd2017-11-03 10:12:19 -0700118 mRenderThread.queue().post([=]() { mContext->setOpaque(opaque); });
Romain Guy26a2b972017-04-17 09:39:51 -0700119}
120
121void RenderProxy::setWideGamut(bool wideGamut) {
John Reck1bcacfd2017-11-03 10:12:19 -0700122 mRenderThread.queue().post([=]() { mContext->setWideGamut(wideGamut); });
Romain Guy26a2b972017-04-17 09:39:51 -0700123}
124
John Reckba6adf62015-02-19 14:36:50 -0800125int64_t* RenderProxy::frameInfo() {
126 return mDrawFrameTask.frameInfo();
127}
128
John Reck2de950d2017-01-25 10:58:30 -0800129int RenderProxy::syncAndDrawFrame() {
130 return mDrawFrameTask.drawFrame();
John Reck4f02bf42014-01-03 18:09:17 -0800131}
132
John Reck2de950d2017-01-25 10:58:30 -0800133void RenderProxy::destroy() {
John Reckfae904d2014-04-14 11:01:57 -0700134 // destroyCanvasAndSurface() needs a fence as when it returns the
135 // underlying BufferQueue is going to be released from under
136 // the render thread.
John Reck1bcacfd2017-11-03 10:12:19 -0700137 mRenderThread.queue().runSync([=]() { mContext->destroy(); });
John Reck0d1f6342014-03-28 20:30:27 -0700138}
139
140void RenderProxy::invokeFunctor(Functor* functor, bool waitForCompletion) {
John Reckd3d8daf2014-04-10 15:00:13 -0700141 ATRACE_CALL();
John Reck3b202512014-06-23 13:13:08 -0700142 RenderThread& thread = RenderThread::getInstance();
John Reckf8441e62017-10-23 13:10:41 -0700143 auto invoke = [&thread, functor]() { CanvasContext::invokeFunctor(thread, functor); };
John Reck0d1f6342014-03-28 20:30:27 -0700144 if (waitForCompletion) {
John Reck3b202512014-06-23 13:13:08 -0700145 // waitForCompletion = true is expected to be fairly rare and only
146 // happen in destruction. Thus it should be fine to temporarily
147 // create a Mutex
John Reckf8441e62017-10-23 13:10:41 -0700148 thread.queue().runSync(std::move(invoke));
John Reck0d1f6342014-03-28 20:30:27 -0700149 } else {
John Reckf8441e62017-10-23 13:10:41 -0700150 thread.queue().post(std::move(invoke));
John Reck0d1f6342014-03-28 20:30:27 -0700151 }
152}
153
John Reck19b6bcf2014-02-14 20:03:38 -0800154DeferredLayerUpdater* RenderProxy::createTextureLayer() {
John Reckf8441e62017-10-23 13:10:41 -0700155 return mRenderThread.queue().runSync([this]() -> auto {
156 return mContext->createTextureLayer();
157 });
John Reck3e824952014-08-20 10:08:39 -0700158}
159
John Reck2de950d2017-01-25 10:58:30 -0800160void RenderProxy::buildLayer(RenderNode* node) {
John Reck1bcacfd2017-11-03 10:12:19 -0700161 mRenderThread.queue().runSync([&]() { mContext->buildLayer(node); });
John Reck19b6bcf2014-02-14 20:03:38 -0800162}
163
John Reck3731dc22015-04-13 15:20:29 -0700164bool RenderProxy::copyLayerInto(DeferredLayerUpdater* layer, SkBitmap& bitmap) {
John Reck1bcacfd2017-11-03 10:12:19 -0700165 return mRenderThread.queue().runSync(
166 [&]() -> bool { return mContext->copyLayerInto(layer, &bitmap); });
John Reck19b6bcf2014-02-14 20:03:38 -0800167}
168
John Reckd72e0a32014-05-29 18:56:11 -0700169void RenderProxy::pushLayerUpdate(DeferredLayerUpdater* layer) {
170 mDrawFrameTask.pushLayerUpdate(layer);
171}
172
173void RenderProxy::cancelLayerUpdate(DeferredLayerUpdater* layer) {
174 mDrawFrameTask.removeLayerUpdate(layer);
John Reck19b6bcf2014-02-14 20:03:38 -0800175}
176
John Reck918ad522014-06-27 14:45:25 -0700177void RenderProxy::detachSurfaceTexture(DeferredLayerUpdater* layer) {
John Reck1bcacfd2017-11-03 10:12:19 -0700178 return mRenderThread.queue().runSync([&]() { layer->detachSurfaceTexture(); });
John Recke1628b72014-05-23 15:11:19 -0700179}
180
John Reck2de950d2017-01-25 10:58:30 -0800181void RenderProxy::destroyHardwareResources() {
John Reck1bcacfd2017-11-03 10:12:19 -0700182 return mRenderThread.queue().runSync([&]() { mContext->destroyHardwareResources(); });
John Reckf47a5942014-06-30 16:20:04 -0700183}
184
185void RenderProxy::trimMemory(int level) {
John Reckcd3a22c2014-08-06 13:33:59 -0700186 // Avoid creating a RenderThread to do a trimMemory.
187 if (RenderThread::hasInstance()) {
188 RenderThread& thread = RenderThread::getInstance();
John Reck1bcacfd2017-11-03 10:12:19 -0700189 thread.queue().post([&thread, level]() { CanvasContext::trimMemory(thread, level); });
John Reckcd3a22c2014-08-06 13:33:59 -0700190 }
John Reckf47a5942014-06-30 16:20:04 -0700191}
192
Chris Craik2507c342015-05-04 14:36:49 -0700193void RenderProxy::overrideProperty(const char* name, const char* value) {
John Reckf8441e62017-10-23 13:10:41 -0700194 // expensive, but block here since name/value pointers owned by caller
John Reck1bcacfd2017-11-03 10:12:19 -0700195 RenderThread::getInstance().queue().runSync(
196 [&]() { Properties::overrideProperty(name, value); });
Chris Craik2507c342015-05-04 14:36:49 -0700197}
198
John Reck28ad7b52014-04-07 16:59:25 -0700199void RenderProxy::fence() {
John Reck1bcacfd2017-11-03 10:12:19 -0700200 mRenderThread.queue().runSync([]() {});
John Reck28ad7b52014-04-07 16:59:25 -0700201}
202
Thomas Buhotc0a0e1a2016-01-18 10:31:58 +0100203void RenderProxy::staticFence() {
John Reck1bcacfd2017-11-03 10:12:19 -0700204 RenderThread::getInstance().queue().runSync([]() {});
John Reckf47a5942014-06-30 16:20:04 -0700205}
206
207void RenderProxy::stopDrawing() {
John Reck1bcacfd2017-11-03 10:12:19 -0700208 mRenderThread.queue().runSync([this]() { mContext->stopDrawing(); });
John Recka5dda642014-05-22 15:43:54 -0700209}
210
211void RenderProxy::notifyFramePending() {
John Reck1bcacfd2017-11-03 10:12:19 -0700212 mRenderThread.queue().post([this]() { mContext->notifyFramePending(); });
John Reckfe5e7b72014-05-23 17:42:28 -0700213}
214
John Reckba6adf62015-02-19 14:36:50 -0800215void RenderProxy::dumpProfileInfo(int fd, int dumpFlags) {
John Reckf8441e62017-10-23 13:10:41 -0700216 mRenderThread.queue().runSync([&]() {
217 mContext->profiler().dumpData(fd);
218 if (dumpFlags & DumpFlags::FrameStats) {
219 mContext->dumpFrames(fd);
220 }
221 if (dumpFlags & DumpFlags::JankStats) {
222 mRenderThread.globalProfileData()->dump(fd);
223 }
224 if (dumpFlags & DumpFlags::Reset) {
225 mContext->resetFrameStats();
226 }
227 });
John Reck7f2e5e32015-05-05 11:00:53 -0700228}
229
230void RenderProxy::resetProfileInfo() {
John Reck1bcacfd2017-11-03 10:12:19 -0700231 mRenderThread.queue().runSync([=]() { mContext->resetFrameStats(); });
John Reck7f2e5e32015-05-05 11:00:53 -0700232}
233
John Reckf8441e62017-10-23 13:10:41 -0700234uint32_t RenderProxy::frameTimePercentile(int percentile) {
235 return mRenderThread.queue().runSync([&]() -> auto {
236 return mRenderThread.globalProfileData()->findPercentile(percentile);
237 });
John Reck0e89e2b2014-10-31 14:49:06 -0700238}
239
Chris Craik2ae07332015-01-21 14:22:39 -0800240void RenderProxy::dumpGraphicsMemory(int fd) {
John Reckf8441e62017-10-23 13:10:41 -0700241 auto& thread = RenderThread::getInstance();
John Reck1bcacfd2017-11-03 10:12:19 -0700242 thread.queue().runSync([&]() { thread.dumpGraphicsMemory(fd); });
John Reckedc524c2015-03-18 15:24:33 -0700243}
244
245void RenderProxy::setProcessStatsBuffer(int fd) {
John Reckdf1742e2017-01-19 15:56:21 -0800246 auto& rt = RenderThread::getInstance();
John Reck1bcacfd2017-11-03 10:12:19 -0700247 rt.queue().post([&rt, fd = dup(fd) ]() {
John Reckf8441e62017-10-23 13:10:41 -0700248 rt.globalProfileData().switchStorageToAshmem(fd);
249 close(fd);
250 });
John Reckdf1742e2017-01-19 15:56:21 -0800251}
252
253void RenderProxy::rotateProcessStatsBuffer() {
John Reckdf1742e2017-01-19 15:56:21 -0800254 auto& rt = RenderThread::getInstance();
John Reck1bcacfd2017-11-03 10:12:19 -0700255 rt.queue().post([&rt]() { rt.globalProfileData().rotateStorage(); });
John Reckedc524c2015-03-18 15:24:33 -0700256}
257
Tim Murray33eb07f2016-06-10 10:03:20 -0700258int RenderProxy::getRenderThreadTid() {
259 return mRenderThread.getTid();
260}
261
Skuhneea7a7fb2015-08-28 07:10:31 -0700262void RenderProxy::addRenderNode(RenderNode* node, bool placeFront) {
John Reck1bcacfd2017-11-03 10:12:19 -0700263 mRenderThread.queue().post([=]() { mContext->addRenderNode(node, placeFront); });
Skuhneea7a7fb2015-08-28 07:10:31 -0700264}
265
266void RenderProxy::removeRenderNode(RenderNode* node) {
John Reck1bcacfd2017-11-03 10:12:19 -0700267 mRenderThread.queue().post([=]() { mContext->removeRenderNode(node); });
Skuhneea7a7fb2015-08-28 07:10:31 -0700268}
269
270void RenderProxy::drawRenderNode(RenderNode* node) {
John Reck1bcacfd2017-11-03 10:12:19 -0700271 mRenderThread.queue().runSync([=]() { mContext->prepareAndDraw(node); });
Skuhneea7a7fb2015-08-28 07:10:31 -0700272}
273
Skuhneb8160872015-09-22 09:51:39 -0700274void RenderProxy::setContentDrawBounds(int left, int top, int right, int bottom) {
John Reckf138b172017-09-08 11:00:42 -0700275 mDrawFrameTask.setContentDrawBounds(left, top, right, bottom);
Skuhneea7a7fb2015-08-28 07:10:31 -0700276}
277
Mihai Popa95688002018-02-23 16:10:11 +0000278void RenderProxy::setFrameCallback(std::function<void(int64_t)>&& callback) {
279 mDrawFrameTask.setFrameCallback(std::move(callback));
280}
281
John Reck5b02c622018-05-17 10:44:00 -0700282void RenderProxy::setFrameCompleteCallback(std::function<void(int64_t)>&& callback) {
283 mDrawFrameTask.setFrameCompleteCallback(std::move(callback));
284}
285
John Recke248bd12015-08-05 13:53:53 -0700286void RenderProxy::serializeDisplayListTree() {
John Reck1bcacfd2017-11-03 10:12:19 -0700287 mRenderThread.queue().post([=]() { mContext->serializeDisplayListTree(); });
John Recke248bd12015-08-05 13:53:53 -0700288}
289
John Reckf8441e62017-10-23 13:10:41 -0700290void RenderProxy::addFrameMetricsObserver(FrameMetricsObserver* observerPtr) {
John Reck1bcacfd2017-11-03 10:12:19 -0700291 mRenderThread.queue().post([ this, observer = sp{observerPtr} ]() {
John Reckf8441e62017-10-23 13:10:41 -0700292 mContext->addFrameMetricsObserver(observer.get());
293 });
Andres Morales06f5bc72015-12-15 15:21:31 -0800294}
295
John Reckf8441e62017-10-23 13:10:41 -0700296void RenderProxy::removeFrameMetricsObserver(FrameMetricsObserver* observerPtr) {
John Reck1bcacfd2017-11-03 10:12:19 -0700297 mRenderThread.queue().post([ this, observer = sp{observerPtr} ]() {
John Reckf8441e62017-10-23 13:10:41 -0700298 mContext->removeFrameMetricsObserver(observer.get());
299 });
John Reck10dd0582016-03-31 16:36:16 -0700300}
301
John Reck1bcacfd2017-11-03 10:12:19 -0700302int RenderProxy::copySurfaceInto(sp<Surface>& surface, int left, int top, int right, int bottom,
303 SkBitmap* bitmap) {
John Reckf8441e62017-10-23 13:10:41 -0700304 auto& thread = RenderThread::getInstance();
305 return static_cast<int>(thread.queue().runSync([&]() -> auto {
306 return thread.readback().copySurfaceInto(*surface, Rect(left, top, right, bottom), bitmap);
307 }));
John Reck43871902016-08-01 14:39:24 -0700308}
309
sergeyvec4a4b12016-10-20 18:39:04 -0700310void RenderProxy::prepareToDraw(Bitmap& bitmap) {
John Reck43871902016-08-01 14:39:24 -0700311 // If we haven't spun up a hardware accelerated window yet, there's no
312 // point in precaching these bitmaps as it can't impact jank.
313 // We also don't know if we even will spin up a hardware-accelerated
314 // window or not.
315 if (!RenderThread::hasInstance()) return;
316 RenderThread* renderThread = &RenderThread::getInstance();
sergeyvec4a4b12016-10-20 18:39:04 -0700317 bitmap.ref();
John Reckf8441e62017-10-23 13:10:41 -0700318 auto task = [renderThread, &bitmap]() {
319 CanvasContext::prepareToDraw(*renderThread, &bitmap);
320 bitmap.unref();
321 };
John Reck43871902016-08-01 14:39:24 -0700322 nsecs_t lastVsync = renderThread->timeLord().latestVsync();
323 nsecs_t estimatedNextVsync = lastVsync + renderThread->timeLord().frameIntervalNanos();
324 nsecs_t timeToNextVsync = estimatedNextVsync - systemTime(CLOCK_MONOTONIC);
325 // We expect the UI thread to take 4ms and for RT to be active from VSYNC+4ms to
326 // VSYNC+12ms or so, so aim for the gap during which RT is expected to
327 // be idle
328 // TODO: Make this concept a first-class supported thing? RT could use
329 // knowledge of pending draws to better schedule this task
330 if (timeToNextVsync > -6_ms && timeToNextVsync < 1_ms) {
John Reckf8441e62017-10-23 13:10:41 -0700331 renderThread->queue().postAt(estimatedNextVsync + 8_ms, task);
John Reck43871902016-08-01 14:39:24 -0700332 } else {
John Reckf8441e62017-10-23 13:10:41 -0700333 renderThread->queue().post(task);
John Reck43871902016-08-01 14:39:24 -0700334 }
335}
336
sergeyv694d4992016-10-27 10:23:13 -0700337sk_sp<Bitmap> RenderProxy::allocateHardwareBitmap(SkBitmap& bitmap) {
John Reckf8441e62017-10-23 13:10:41 -0700338 auto& thread = RenderThread::getInstance();
John Reck1bcacfd2017-11-03 10:12:19 -0700339 return thread.queue().runSync([&]() -> auto { return thread.allocateHardwareBitmap(bitmap); });
sergeyv59eecb522016-11-17 17:54:57 -0800340}
341
342int RenderProxy::copyGraphicBufferInto(GraphicBuffer* buffer, SkBitmap* bitmap) {
Stan Iliev6983bc42017-02-02 14:11:53 -0500343 RenderThread& thread = RenderThread::getInstance();
344 if (Properties::isSkiaEnabled() && gettid() == thread.getTid()) {
John Reck1bcacfd2017-11-03 10:12:19 -0700345 // TODO: fix everything that hits this. We should never be triggering a readback ourselves.
346 return (int)thread.readback().copyGraphicBufferInto(buffer, bitmap);
Stan Iliev6983bc42017-02-02 14:11:53 -0500347 } else {
John Reckf8441e62017-10-23 13:10:41 -0700348 return thread.queue().runSync([&]() -> int {
John Reck1bcacfd2017-11-03 10:12:19 -0700349 return (int)thread.readback().copyGraphicBufferInto(buffer, bitmap);
John Reckf8441e62017-10-23 13:10:41 -0700350 });
Stan Iliev6983bc42017-02-02 14:11:53 -0500351 }
sergeyv59eecb522016-11-17 17:54:57 -0800352}
353
John Reck9a814872017-05-22 15:04:21 -0700354void RenderProxy::onBitmapDestroyed(uint32_t pixelRefId) {
355 if (!RenderThread::hasInstance()) return;
John Reck9a814872017-05-22 15:04:21 -0700356 RenderThread& thread = RenderThread::getInstance();
John Reck1bcacfd2017-11-03 10:12:19 -0700357 thread.queue().post(
358 [&thread, pixelRefId]() { thread.renderState().onBitmapDestroyed(pixelRefId); });
John Reck9a814872017-05-22 15:04:21 -0700359}
360
John Recka8963062017-06-14 10:47:50 -0700361void RenderProxy::disableVsync() {
362 Properties::disableVsync = true;
363}
364
Stan Iliev3310fb12017-03-23 16:56:51 -0400365void RenderProxy::repackVectorDrawableAtlas() {
366 RenderThread& thread = RenderThread::getInstance();
John Reckf8441e62017-10-23 13:10:41 -0700367 thread.queue().post([&thread]() {
Stan Iliev6c4b6e82018-03-01 15:51:17 -0500368 // The context may be null if trimMemory executed, but then the atlas was deleted too.
369 if (thread.getGrContext() != nullptr) {
370 thread.cacheManager().acquireVectorDrawableAtlas()->repackIfNeeded(
371 thread.getGrContext());
372 }
John Reckf8441e62017-10-23 13:10:41 -0700373 });
Stan Iliev6b894d72017-08-23 12:41:41 -0400374}
375
376void RenderProxy::releaseVDAtlasEntries() {
377 RenderThread& thread = RenderThread::getInstance();
John Reckf8441e62017-10-23 13:10:41 -0700378 thread.queue().post([&thread]() {
Stan Iliev6c4b6e82018-03-01 15:51:17 -0500379 // The context may be null if trimMemory executed, but then the atlas was deleted too.
380 if (thread.getGrContext() != nullptr) {
381 thread.cacheManager().acquireVectorDrawableAtlas()->delayedReleaseEntries();
382 }
John Reckf8441e62017-10-23 13:10:41 -0700383 });
John Reck0e89e2b2014-10-31 14:49:06 -0700384}
385
John Reck4f02bf42014-01-03 18:09:17 -0800386} /* namespace renderthread */
387} /* namespace uirenderer */
388} /* namespace android */