blob: def805adeeea2ec71fc15bdb5db257ae3b995291 [file] [log] [blame]
John Reckcec24ae2013-11-05 13:27:50 -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 Reckcec24ae2013-11-05 13:27:50 -080017#include "RenderThread.h"
18
John Reck4f02bf42014-01-03 18:09:17 -080019#include "CanvasContext.h"
John Reck56428472018-03-16 17:27:17 -070020#include "DeviceInfo.h"
John Reck3b202512014-06-23 13:13:08 -070021#include "EglManager.h"
Stan Iliev1a025a72018-09-05 16:35:11 -040022#include "Readback.h"
John Reck4f02bf42014-01-03 18:09:17 -080023#include "RenderProxy.h"
Derek Sollenberger0e3cba32016-11-09 11:58:36 -050024#include "VulkanManager.h"
John Reck1bcacfd2017-11-03 10:12:19 -070025#include "hwui/Bitmap.h"
26#include "pipeline/skia/SkiaOpenGLPipeline.h"
John Reck1a4a9812018-04-18 16:13:31 -070027#include "pipeline/skia/SkiaVulkanPipeline.h"
John Reck1bcacfd2017-11-03 10:12:19 -070028#include "renderstate/RenderState.h"
John Reck12efa552016-11-15 10:22:01 -080029#include "utils/FatVector.h"
John Reck56428472018-03-16 17:27:17 -070030#include "utils/TimeUtils.h"
John Reck322b8ab2019-03-14 13:15:28 -070031#include "utils/TraceUtils.h"
John Reckcec24ae2013-11-05 13:27:50 -080032
John Reck1e510712018-04-23 08:15:03 -070033#ifdef HWUI_GLES_WRAP_ENABLED
34#include "debug/GlesDriver.h"
35#endif
36
37#include <GrContextOptions.h>
38#include <gl/GrGLInterface.h>
39
Chris Craik65fe5ee2015-01-26 18:06:29 -080040#include <gui/DisplayEventReceiver.h>
41#include <sys/resource.h>
John Reckcba287b2015-11-10 12:52:44 -080042#include <utils/Condition.h>
Chris Craik65fe5ee2015-01-26 18:06:29 -080043#include <utils/Log.h>
John Reckcba287b2015-11-10 12:52:44 -080044#include <utils/Mutex.h>
Stan Iliev898123b2019-02-14 14:57:44 -050045#include <thread>
Chris Craik65fe5ee2015-01-26 18:06:29 -080046
John Reckcec24ae2013-11-05 13:27:50 -080047namespace android {
John Reckcec24ae2013-11-05 13:27:50 -080048namespace uirenderer {
49namespace renderthread {
50
John Recke45b1fd2014-04-15 09:50:16 -070051// Number of events to read at a time from the DisplayEventReceiver pipe.
52// The value should be large enough that we can quickly drain the pipe
53// using just a few large reads.
54static const size_t EVENT_BUFFER_SIZE = 100;
55
John Reck6b507802015-11-03 10:09:59 -080056static bool gHasRenderThreadInstance = false;
57
Stan Iliev80dbc352019-02-05 15:31:28 -050058static JVMAttachHook gOnStartHook = nullptr;
John Reck259b25a2017-12-01 16:18:53 -080059
John Reck56428472018-03-16 17:27:17 -070060class DisplayEventReceiverWrapper : public VsyncSource {
61public:
62 DisplayEventReceiverWrapper(std::unique_ptr<DisplayEventReceiver>&& receiver)
63 : mDisplayEventReceiver(std::move(receiver)) {}
64
65 virtual void requestNextVsync() override {
66 status_t status = mDisplayEventReceiver->requestNextVsync();
67 LOG_ALWAYS_FATAL_IF(status != NO_ERROR, "requestNextVsync failed with status: %d", status);
68 }
69
70 virtual nsecs_t latestVsyncEvent() override {
71 DisplayEventReceiver::Event buf[EVENT_BUFFER_SIZE];
72 nsecs_t latest = 0;
73 ssize_t n;
74 while ((n = mDisplayEventReceiver->getEvents(buf, EVENT_BUFFER_SIZE)) > 0) {
75 for (ssize_t i = 0; i < n; i++) {
76 const DisplayEventReceiver::Event& ev = buf[i];
77 switch (ev.header.type) {
78 case DisplayEventReceiver::DISPLAY_EVENT_VSYNC:
79 latest = ev.header.timestamp;
80 break;
81 }
82 }
83 }
84 if (n < 0) {
85 ALOGW("Failed to get events from display event receiver, status=%d", status_t(n));
86 }
87 return latest;
88 }
89
90private:
91 std::unique_ptr<DisplayEventReceiver> mDisplayEventReceiver;
92};
93
94class DummyVsyncSource : public VsyncSource {
95public:
96 DummyVsyncSource(RenderThread* renderThread) : mRenderThread(renderThread) {}
97
98 virtual void requestNextVsync() override {
John Reckb90d4cb2018-04-19 17:05:35 -070099 mRenderThread->queue().postDelayed(16_ms,
100 [this]() { mRenderThread->drainDisplayEventQueue(); });
John Reck56428472018-03-16 17:27:17 -0700101 }
102
John Reckb90d4cb2018-04-19 17:05:35 -0700103 virtual nsecs_t latestVsyncEvent() override { return systemTime(CLOCK_MONOTONIC); }
John Reck56428472018-03-16 17:27:17 -0700104
105private:
106 RenderThread* mRenderThread;
107};
108
John Reck6b507802015-11-03 10:09:59 -0800109bool RenderThread::hasInstance() {
110 return gHasRenderThreadInstance;
111}
112
Stan Iliev80dbc352019-02-05 15:31:28 -0500113void RenderThread::setOnStartHook(JVMAttachHook onStartHook) {
John Reck259b25a2017-12-01 16:18:53 -0800114 LOG_ALWAYS_FATAL_IF(hasInstance(), "can't set an onStartHook after we've started...");
115 gOnStartHook = onStartHook;
116}
117
Stan Iliev80dbc352019-02-05 15:31:28 -0500118JVMAttachHook RenderThread::getOnStartHook() {
119 return gOnStartHook;
120}
121
John Reck6b507802015-11-03 10:09:59 -0800122RenderThread& RenderThread::getInstance() {
123 // This is a pointer because otherwise __cxa_finalize
124 // will try to delete it like a Good Citizen but that causes us to crash
125 // because we don't want to delete the RenderThread normally.
126 static RenderThread* sInstance = new RenderThread();
127 gHasRenderThreadInstance = true;
128 return *sInstance;
129}
130
John Reck1bcacfd2017-11-03 10:12:19 -0700131RenderThread::RenderThread()
132 : ThreadBase()
John Reck56428472018-03-16 17:27:17 -0700133 , mVsyncSource(nullptr)
John Recke45b1fd2014-04-15 09:50:16 -0700134 , mVsyncRequested(false)
135 , mFrameCallbackTaskPending(false)
Chris Craikd41c4d82015-01-05 15:51:13 -0800136 , mRenderState(nullptr)
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500137 , mEglManager(nullptr)
John Reck283bb462018-12-13 16:40:14 -0800138 , mFunctorManager(WebViewFunctorManager::instance())
Derek Sollenberger0e3cba32016-11-09 11:58:36 -0500139 , mVkManager(nullptr) {
Chris Craik2507c342015-05-04 14:36:49 -0700140 Properties::load();
John Reckf8441e62017-10-23 13:10:41 -0700141 start("RenderThread");
John Reckcec24ae2013-11-05 13:27:50 -0800142}
143
144RenderThread::~RenderThread() {
John Reck3b202512014-06-23 13:13:08 -0700145 LOG_ALWAYS_FATAL("Can't destroy the render thread");
John Reckcec24ae2013-11-05 13:27:50 -0800146}
147
John Recke45b1fd2014-04-15 09:50:16 -0700148void RenderThread::initializeDisplayEventReceiver() {
John Reck56428472018-03-16 17:27:17 -0700149 LOG_ALWAYS_FATAL_IF(mVsyncSource, "Initializing a second DisplayEventReceiver?");
John Recke45b1fd2014-04-15 09:50:16 -0700150
John Reck56428472018-03-16 17:27:17 -0700151 if (!Properties::isolatedProcess) {
152 auto receiver = std::make_unique<DisplayEventReceiver>();
153 status_t status = receiver->initCheck();
154 LOG_ALWAYS_FATAL_IF(status != NO_ERROR,
John Reckb90d4cb2018-04-19 17:05:35 -0700155 "Initialization of DisplayEventReceiver "
156 "failed with status: %d",
157 status);
John Reck56428472018-03-16 17:27:17 -0700158
159 // Register the FD
160 mLooper->addFd(receiver->getFd(), 0, Looper::EVENT_INPUT,
John Reckb90d4cb2018-04-19 17:05:35 -0700161 RenderThread::displayEventReceiverCallback, this);
John Reck56428472018-03-16 17:27:17 -0700162 mVsyncSource = new DisplayEventReceiverWrapper(std::move(receiver));
163 } else {
164 mVsyncSource = new DummyVsyncSource(this);
165 }
John Recke45b1fd2014-04-15 09:50:16 -0700166}
167
John Reck3b202512014-06-23 13:13:08 -0700168void RenderThread::initThreadLocals() {
Derek Sollenberger17662382018-09-13 14:14:00 -0400169 mDisplayInfo = DeviceInfo::get()->displayInfo();
John Reckb36016c2015-03-11 08:50:53 -0700170 nsecs_t frameIntervalNanos = static_cast<nsecs_t>(1000000000 / mDisplayInfo.fps);
171 mTimeLord.setFrameInterval(frameIntervalNanos);
John Reck3c0f5632019-03-15 16:36:01 -0700172 mDispatchFrameDelay = static_cast<nsecs_t>(frameIntervalNanos * .25f);
John Reck3b202512014-06-23 13:13:08 -0700173 initializeDisplayEventReceiver();
John Reck1e510712018-04-23 08:15:03 -0700174 mEglManager = new EglManager();
John Reck0e89e2b2014-10-31 14:49:06 -0700175 mRenderState = new RenderState(*this);
Stan Iliev981afe72019-02-13 14:24:33 -0500176 mVkManager = new VulkanManager();
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400177 mCacheManager = new CacheManager(mDisplayInfo);
178}
179
John Reck1e510712018-04-23 08:15:03 -0700180void RenderThread::requireGlContext() {
181 if (mEglManager->hasEglContext()) {
182 return;
183 }
184 mEglManager->initialize();
John Reck1e510712018-04-23 08:15:03 -0700185
John Reck1e510712018-04-23 08:15:03 -0700186#ifdef HWUI_GLES_WRAP_ENABLED
John Reckb5fc2092018-04-30 14:43:22 -0700187 debug::GlesDriver* driver = debug::GlesDriver::get();
188 sk_sp<const GrGLInterface> glInterface(driver->getSkiaInterface());
John Reck1e510712018-04-23 08:15:03 -0700189#else
John Reckb5fc2092018-04-30 14:43:22 -0700190 sk_sp<const GrGLInterface> glInterface(GrGLCreateNativeInterface());
John Reck1e510712018-04-23 08:15:03 -0700191#endif
John Reckb5fc2092018-04-30 14:43:22 -0700192 LOG_ALWAYS_FATAL_IF(!glInterface.get());
John Reck1e510712018-04-23 08:15:03 -0700193
John Reckb5fc2092018-04-30 14:43:22 -0700194 GrContextOptions options;
Stan Iliev981afe72019-02-13 14:24:33 -0500195 initGrContextOptions(options);
Yichi Chen9f959552018-03-29 21:21:54 +0800196 auto glesVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION));
197 auto size = glesVersion ? strlen(glesVersion) : -1;
198 cacheManager().configureContext(&options, glesVersion, size);
John Reckb5fc2092018-04-30 14:43:22 -0700199 sk_sp<GrContext> grContext(GrContext::MakeGL(std::move(glInterface), options));
200 LOG_ALWAYS_FATAL_IF(!grContext.get());
201 setGrContext(grContext);
John Reck1e510712018-04-23 08:15:03 -0700202}
203
Stan Iliev981afe72019-02-13 14:24:33 -0500204void RenderThread::requireVkContext() {
205 if (mVkManager->hasVkContext()) {
206 return;
207 }
208 mVkManager->initialize();
209 GrContextOptions options;
210 initGrContextOptions(options);
211 // TODO: get a string describing the SPIR-V compiler version and use it here
212 cacheManager().configureContext(&options, nullptr, 0);
213 sk_sp<GrContext> grContext = mVkManager->createContext(options);
214 LOG_ALWAYS_FATAL_IF(!grContext.get());
215 setGrContext(grContext);
216}
217
218void RenderThread::initGrContextOptions(GrContextOptions& options) {
219 options.fPreferExternalImagesOverES3 = true;
220 options.fDisableDistanceFieldPaths = true;
221}
222
John Reck283bb462018-12-13 16:40:14 -0800223void RenderThread::destroyRenderingContext() {
224 mFunctorManager.onContextDestroyed();
Stan Iliev90276c82019-02-03 18:01:02 -0500225 if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaGL) {
226 if (mEglManager->hasEglContext()) {
227 setGrContext(nullptr);
228 mEglManager->destroy();
229 }
230 } else {
231 if (vulkanManager().hasVkContext()) {
232 setGrContext(nullptr);
233 vulkanManager().destroy();
234 }
John Reck1e510712018-04-23 08:15:03 -0700235 }
236}
237
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400238void RenderThread::dumpGraphicsMemory(int fd) {
John Reck34781b22017-07-05 16:39:36 -0700239 globalProfileData()->dump(fd);
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400240
241 String8 cachesOutput;
242 String8 pipeline;
243 auto renderType = Properties::getRenderPipelineType();
244 switch (renderType) {
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400245 case RenderPipelineType::SkiaGL: {
246 mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
247 pipeline.appendFormat("Skia (OpenGL)");
248 break;
249 }
250 case RenderPipelineType::SkiaVulkan: {
251 mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
252 pipeline.appendFormat("Skia (Vulkan)");
253 break;
254 }
255 default:
John Reck1bcacfd2017-11-03 10:12:19 -0700256 LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t)renderType);
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400257 break;
258 }
259
John Reck47f5c3a2017-11-13 11:32:39 -0800260 dprintf(fd, "\n%s\n", cachesOutput.string());
261 dprintf(fd, "\nPipeline=%s\n", pipeline.string());
John Reck3b202512014-06-23 13:13:08 -0700262}
263
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -0500264Readback& RenderThread::readback() {
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -0500265 if (!mReadback) {
Stan Iliev1a025a72018-09-05 16:35:11 -0400266 mReadback = new Readback(*this);
Derek Sollenbergerc4fbada2016-11-07 16:05:41 -0500267 }
268
269 return *mReadback;
270}
271
Greg Daniel660d6ec2017-12-08 11:44:27 -0500272void RenderThread::setGrContext(sk_sp<GrContext> context) {
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400273 mCacheManager->reset(context);
Greg Daniel660d6ec2017-12-08 11:44:27 -0500274 if (mGrContext) {
Derek Sollenberger5a5a6482018-09-19 13:52:13 -0400275 mRenderState->onContextDestroyed();
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400276 mGrContext->releaseResourcesAndAbandonContext();
277 }
Greg Daniel660d6ec2017-12-08 11:44:27 -0500278 mGrContext = std::move(context);
Derek Sollenberger17662382018-09-13 14:14:00 -0400279 if (mGrContext) {
Derek Sollenberger5a5a6482018-09-19 13:52:13 -0400280 mRenderState->onContextCreated();
Derek Sollenberger17662382018-09-13 14:14:00 -0400281 DeviceInfo::setMaxTextureSize(mGrContext->maxRenderTargetSize());
282 }
Derek Sollenbergerf9e45d12017-06-01 13:07:39 -0400283}
284
John Recke45b1fd2014-04-15 09:50:16 -0700285int RenderThread::displayEventReceiverCallback(int fd, int events, void* data) {
286 if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) {
287 ALOGE("Display event receiver pipe was closed or an error occurred. "
John Reck1bcacfd2017-11-03 10:12:19 -0700288 "events=0x%x",
289 events);
290 return 0; // remove the callback
John Recke45b1fd2014-04-15 09:50:16 -0700291 }
292
293 if (!(events & Looper::EVENT_INPUT)) {
294 ALOGW("Received spurious callback for unhandled poll event. "
John Reck1bcacfd2017-11-03 10:12:19 -0700295 "events=0x%x",
296 events);
297 return 1; // keep the callback
John Recke45b1fd2014-04-15 09:50:16 -0700298 }
299
300 reinterpret_cast<RenderThread*>(data)->drainDisplayEventQueue();
301
John Reck1bcacfd2017-11-03 10:12:19 -0700302 return 1; // keep the callback
John Recke45b1fd2014-04-15 09:50:16 -0700303}
304
John Recka733f892014-12-19 11:37:21 -0800305void RenderThread::drainDisplayEventQueue() {
John Recka5dda642014-05-22 15:43:54 -0700306 ATRACE_CALL();
John Reck56428472018-03-16 17:27:17 -0700307 nsecs_t vsyncEvent = mVsyncSource->latestVsyncEvent();
John Recke45b1fd2014-04-15 09:50:16 -0700308 if (vsyncEvent > 0) {
309 mVsyncRequested = false;
John Recka733f892014-12-19 11:37:21 -0800310 if (mTimeLord.vsyncReceived(vsyncEvent) && !mFrameCallbackTaskPending) {
John Recka5dda642014-05-22 15:43:54 -0700311 ATRACE_NAME("queue mFrameCallbackTask");
John Recke45b1fd2014-04-15 09:50:16 -0700312 mFrameCallbackTaskPending = true;
John Reck3c0f5632019-03-15 16:36:01 -0700313 nsecs_t runAt = (vsyncEvent + mDispatchFrameDelay);
John Reck1bcacfd2017-11-03 10:12:19 -0700314 queue().postAt(runAt, [this]() { dispatchFrameCallbacks(); });
John Recke45b1fd2014-04-15 09:50:16 -0700315 }
316 }
317}
318
319void RenderThread::dispatchFrameCallbacks() {
John Recka5dda642014-05-22 15:43:54 -0700320 ATRACE_CALL();
John Recke45b1fd2014-04-15 09:50:16 -0700321 mFrameCallbackTaskPending = false;
322
323 std::set<IFrameCallback*> callbacks;
324 mFrameCallbacks.swap(callbacks);
325
John Recka733f892014-12-19 11:37:21 -0800326 if (callbacks.size()) {
327 // Assume one of them will probably animate again so preemptively
328 // request the next vsync in case it occurs mid-frame
329 requestVsync();
John Reck1bcacfd2017-11-03 10:12:19 -0700330 for (std::set<IFrameCallback*>::iterator it = callbacks.begin(); it != callbacks.end();
331 it++) {
John Recka733f892014-12-19 11:37:21 -0800332 (*it)->doFrame();
333 }
John Recke45b1fd2014-04-15 09:50:16 -0700334 }
335}
336
John Recka5dda642014-05-22 15:43:54 -0700337void RenderThread::requestVsync() {
338 if (!mVsyncRequested) {
339 mVsyncRequested = true;
John Reck56428472018-03-16 17:27:17 -0700340 mVsyncSource->requestNextVsync();
John Recka5dda642014-05-22 15:43:54 -0700341 }
342}
343
John Reckcec24ae2013-11-05 13:27:50 -0800344bool RenderThread::threadLoop() {
John Reck21be43e2014-08-14 10:25:16 -0700345 setpriority(PRIO_PROCESS, 0, PRIORITY_DISPLAY);
John Reck700079e2019-02-19 10:38:50 -0800346 Looper::setForThread(mLooper);
John Reck259b25a2017-12-01 16:18:53 -0800347 if (gOnStartHook) {
Stan Iliev978d5322019-02-06 12:02:28 -0500348 gOnStartHook("RenderThread");
John Reck259b25a2017-12-01 16:18:53 -0800349 }
John Reck3b202512014-06-23 13:13:08 -0700350 initThreadLocals();
John Recke45b1fd2014-04-15 09:50:16 -0700351
John Reckf8441e62017-10-23 13:10:41 -0700352 while (true) {
353 waitForWork();
354 processQueue();
John Recka5dda642014-05-22 15:43:54 -0700355
356 if (mPendingRegistrationFrameCallbacks.size() && !mFrameCallbackTaskPending) {
John Recka733f892014-12-19 11:37:21 -0800357 drainDisplayEventQueue();
John Reck1bcacfd2017-11-03 10:12:19 -0700358 mFrameCallbacks.insert(mPendingRegistrationFrameCallbacks.begin(),
359 mPendingRegistrationFrameCallbacks.end());
John Recka5dda642014-05-22 15:43:54 -0700360 mPendingRegistrationFrameCallbacks.clear();
361 requestVsync();
362 }
John Recka22c9b22015-01-14 10:40:15 -0800363
364 if (!mFrameCallbackTaskPending && !mVsyncRequested && mFrameCallbacks.size()) {
365 // TODO: Clean this up. This is working around an issue where a combination
366 // of bad timing and slow drawing can result in dropping a stale vsync
367 // on the floor (correct!) but fails to schedule to listen for the
368 // next vsync (oops), so none of the callbacks are run.
369 requestVsync();
370 }
John Reckcec24ae2013-11-05 13:27:50 -0800371 }
372
373 return false;
374}
375
John Recke45b1fd2014-04-15 09:50:16 -0700376void RenderThread::postFrameCallback(IFrameCallback* callback) {
John Recka5dda642014-05-22 15:43:54 -0700377 mPendingRegistrationFrameCallbacks.insert(callback);
John Recke45b1fd2014-04-15 09:50:16 -0700378}
379
John Reck01a5ea32014-12-03 13:01:07 -0800380bool RenderThread::removeFrameCallback(IFrameCallback* callback) {
381 size_t erased;
382 erased = mFrameCallbacks.erase(callback);
383 erased |= mPendingRegistrationFrameCallbacks.erase(callback);
384 return erased;
John Recka5dda642014-05-22 15:43:54 -0700385}
386
387void RenderThread::pushBackFrameCallback(IFrameCallback* callback) {
388 if (mFrameCallbacks.erase(callback)) {
389 mPendingRegistrationFrameCallbacks.insert(callback);
390 }
John Recke45b1fd2014-04-15 09:50:16 -0700391}
392
Stan Iliev7bc3bc62017-05-24 13:28:36 -0400393sk_sp<Bitmap> RenderThread::allocateHardwareBitmap(SkBitmap& skBitmap) {
394 auto renderType = Properties::getRenderPipelineType();
395 switch (renderType) {
Stan Iliev7bc3bc62017-05-24 13:28:36 -0400396 case RenderPipelineType::SkiaVulkan:
397 return skiapipeline::SkiaVulkanPipeline::allocateHardwareBitmap(*this, skBitmap);
398 default:
John Reck1bcacfd2017-11-03 10:12:19 -0700399 LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t)renderType);
Stan Iliev7bc3bc62017-05-24 13:28:36 -0400400 break;
401 }
402 return nullptr;
403}
404
Stan Iliev6b894d72017-08-23 12:41:41 -0400405bool RenderThread::isCurrent() {
406 return gettid() == getInstance().getTid();
407}
408
Stan Iliev898123b2019-02-14 14:57:44 -0500409void RenderThread::preload() {
410 std::thread eglInitThread([]() {
411 //TODO: don't load EGL drivers for Vulkan, when HW bitmap uploader is refactored.
412 eglGetDisplay(EGL_DEFAULT_DISPLAY);
413 });
414 eglInitThread.detach();
415 if (Properties::getRenderPipelineType() == RenderPipelineType::SkiaVulkan) {
416 requireVkContext();
417 }
418}
419
John Reckcec24ae2013-11-05 13:27:50 -0800420} /* namespace renderthread */
421} /* namespace uirenderer */
422} /* namespace android */