summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/RenderThread.cpp
diff options
context:
space:
mode:
authorDerek Sollenberger <djsollen@google.com>2017-06-01 13:07:39 -0400
committerStan Iliev <stani@google.com>2017-06-06 14:19:37 -0400
commitf9e45d1d818ae0956ba77ed598b7040cfecca553 (patch)
treead24203eaa17f2dedd3bab03d5536e746aa668b7 /libs/hwui/renderthread/RenderThread.cpp
parentf74752293d1d25633aebc42c600717d0296a0820 (diff)
Implement CacheManager for the Skia pipelines.
The core of the implementation is complete and provides heuristic cache sizing based on the size of the surface being used. This CL will also be used to add the following features in the future... 1) Support Vulkan pipeline reporting on the size of the surface. 2) Complete the VectorDrawableAtlas stub code 3) Automatic purging of stale resources for low memory devices. Test: hwui_unit_tests (new test added) and CtsUiRendering Bug: 62260637 Change-Id: Ib85159cca28b646fe249f2190b07f1b7e0f50d8f
Diffstat (limited to 'libs/hwui/renderthread/RenderThread.cpp')
-rw-r--r--libs/hwui/renderthread/RenderThread.cpp47
1 files changed, 47 insertions, 0 deletions
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index 055458397023..13af2c4d15e8 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -202,6 +202,45 @@ void RenderThread::initThreadLocals() {
mRenderState = new RenderState(*this);
mJankTracker = new JankTracker(mDisplayInfo);
mVkManager = new VulkanManager(*this);
+ mCacheManager = new CacheManager(mDisplayInfo);
+}
+
+void RenderThread::dumpGraphicsMemory(int fd) {
+ jankTracker().dump(fd);
+
+ String8 cachesOutput;
+ String8 pipeline;
+ auto renderType = Properties::getRenderPipelineType();
+ switch (renderType) {
+ case RenderPipelineType::OpenGL: {
+ if (Caches::hasInstance()) {
+ cachesOutput.appendFormat("Caches:\n");
+ Caches::getInstance().dumpMemoryUsage(cachesOutput);
+ } else {
+ cachesOutput.appendFormat("No caches instance.");
+ }
+ pipeline.appendFormat("FrameBuilder");
+ break;
+ }
+ case RenderPipelineType::SkiaGL: {
+ mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
+ pipeline.appendFormat("Skia (OpenGL)");
+ break;
+ }
+ case RenderPipelineType::SkiaVulkan: {
+ mCacheManager->dumpMemoryUsage(cachesOutput, mRenderState);
+ pipeline.appendFormat("Skia (Vulkan)");
+ break;
+ }
+ default:
+ LOG_ALWAYS_FATAL("canvas context type %d not supported", (int32_t) renderType);
+ break;
+ }
+
+ FILE *file = fdopen(fd, "a");
+ fprintf(file, "\n%s\n", cachesOutput.string());
+ fprintf(file, "\nPipeline=%s\n", pipeline.string());
+ fflush(file);
}
Readback& RenderThread::readback() {
@@ -228,6 +267,14 @@ Readback& RenderThread::readback() {
return *mReadback;
}
+void RenderThread::setGrContext(GrContext* context) {
+ mCacheManager->reset(context);
+ if (mGrContext.get()) {
+ mGrContext->releaseResourcesAndAbandonContext();
+ }
+ mGrContext.reset(context);
+}
+
int RenderThread::displayEventReceiverCallback(int fd, int events, void* data) {
if (events & (Looper::EVENT_ERROR | Looper::EVENT_HANGUP)) {
ALOGE("Display event receiver pipe was closed or an error occurred. "