blob: 7e8c96d9686029e054bf510116b22eb7c5688f3e [file] [log] [blame]
John Reck3b202512014-06-23 13:13:08 -07001/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
John Reck1bcacfd2017-11-03 10:12:19 -070016#include "renderstate/RenderState.h"
John Reck3b202512014-06-23 13:13:08 -070017
Derek Sollenberger28a4d992018-09-20 13:37:24 -040018#include "renderthread/RenderThread.h"
Romain Guycaaaa662017-03-27 00:40:21 -070019
John Reck3b202512014-06-23 13:13:08 -070020namespace android {
21namespace uirenderer {
22
Derek Sollenberger28a4d992018-09-20 13:37:24 -040023RenderState::RenderState(renderthread::RenderThread& thread) : mRenderThread(thread) {
John Reck0e89e2b2014-10-31 14:49:06 -070024 mThreadId = pthread_self();
John Reck3b202512014-06-23 13:13:08 -070025}
26
Stan Iliev564ca3e2018-09-04 22:00:00 +000027void RenderState::onContextDestroyed() {
Derek Sollenberger5a5a6482018-09-19 13:52:13 -040028 for(auto callback : mContextCallbacks) {
29 callback->onContextDestroyed();
30 }
Greg Daniel45ec62b2017-01-04 14:27:00 -050031}
32
John Reck0e89e2b2014-10-31 14:49:06 -070033void RenderState::postDecStrong(VirtualLightRefBase* object) {
John Recka55b5d62016-01-14 15:09:10 -080034 if (pthread_equal(mThreadId, pthread_self())) {
35 object->decStrong(nullptr);
36 } else {
John Reckf8441e62017-10-23 13:10:41 -070037 mRenderThread.queue().post([object]() { object->decStrong(nullptr); });
John Recka55b5d62016-01-14 15:09:10 -080038 }
John Reck0e89e2b2014-10-31 14:49:06 -070039}
40
Chris Craik6c15ffa2015-02-02 13:50:55 -080041///////////////////////////////////////////////////////////////////////////////
42// Render
43///////////////////////////////////////////////////////////////////////////////
44
John Reck3b202512014-06-23 13:13:08 -070045} /* namespace uirenderer */
46} /* namespace android */