Stan Iliev e0fae2356b Add memory tracing in HWUI
Add ATRACE memory counters to track memory usage at the end
of each frame in HWUI.
There are 3 catagories: CPU, GPU and Texture memory.
There are 3 more counters for memory that can be purged.
This CL deletes GpuMemoryTracker class, which implemented
similar function for Android O HWUI renderer.

Test: Collected systrace with gmail and setting.
Test: memory tracing adds ~0.1ms per frame when ATRACE is enabled
Bug: 146580770
Change-Id: Icbcc0478bc426dff578e83726fe7c95df171ed93
2020-01-10 16:14:39 +00:00

47 lines
1.4 KiB
C++

/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "renderstate/RenderState.h"
#include "renderthread/RenderThread.h"
namespace android {
namespace uirenderer {
RenderState::RenderState(renderthread::RenderThread& thread) : mRenderThread(thread) {
mThreadId = pthread_self();
}
void RenderState::onContextDestroyed() {
for(auto callback : mContextCallbacks) {
callback->onContextDestroyed();
}
}
void RenderState::postDecStrong(VirtualLightRefBase* object) {
if (pthread_equal(mThreadId, pthread_self())) {
object->decStrong(nullptr);
} else {
mRenderThread.queue().post([object]() { object->decStrong(nullptr); });
}
}
///////////////////////////////////////////////////////////////////////////////
// Render
///////////////////////////////////////////////////////////////////////////////
} /* namespace uirenderer */
} /* namespace android */