diff options
Diffstat (limited to 'libs/hwui/renderthread')
| -rw-r--r-- | libs/hwui/renderthread/CacheManager.cpp | 23 | ||||
| -rw-r--r-- | libs/hwui/renderthread/CacheManager.h | 11 | ||||
| -rw-r--r-- | libs/hwui/renderthread/CanvasContext.cpp | 33 | ||||
| -rw-r--r-- | libs/hwui/renderthread/CanvasContext.h | 3 | ||||
| -rw-r--r-- | libs/hwui/renderthread/EglManager.cpp | 14 | ||||
| -rw-r--r-- | libs/hwui/renderthread/RenderProxy.cpp | 26 | ||||
| -rw-r--r-- | libs/hwui/renderthread/RenderProxy.h | 3 | ||||
| -rw-r--r-- | libs/hwui/renderthread/RenderThread.cpp | 3 | ||||
| -rw-r--r-- | libs/hwui/renderthread/RenderThread.h | 4 | ||||
| -rw-r--r-- | libs/hwui/renderthread/VulkanManager.cpp | 15 |
10 files changed, 55 insertions, 80 deletions
diff --git a/libs/hwui/renderthread/CacheManager.cpp b/libs/hwui/renderthread/CacheManager.cpp index f0d6b3860938..55694d046c2f 100644 --- a/libs/hwui/renderthread/CacheManager.cpp +++ b/libs/hwui/renderthread/CacheManager.cpp @@ -43,7 +43,8 @@ namespace renderthread { CacheManager::CacheManager(const DisplayInfo& display) : mMaxSurfaceArea(display.w * display.h) { - mVectorDrawableAtlas.reset(new VectorDrawableAtlas); + mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas(mMaxSurfaceArea/2, + skiapipeline::VectorDrawableAtlas::StorageMode::allowSharedSurface); } void CacheManager::reset(GrContext* context) { @@ -61,7 +62,7 @@ void CacheManager::reset(GrContext* context) { void CacheManager::destroy() { // cleanup any caches here as the GrContext is about to go away... mGrContext.reset(nullptr); - mVectorDrawableAtlas.reset(new VectorDrawableAtlas); + mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas(mMaxSurfaceArea/2); } void CacheManager::updateContextCacheSizes() { @@ -104,7 +105,7 @@ void CacheManager::trimMemory(TrimMemoryMode mode) { switch (mode) { case TrimMemoryMode::Complete: - mVectorDrawableAtlas.reset(new VectorDrawableAtlas); + mVectorDrawableAtlas = new skiapipeline::VectorDrawableAtlas(mMaxSurfaceArea/2); mGrContext->freeGpuResources(); break; case TrimMemoryMode::UiHidden: @@ -121,24 +122,14 @@ void CacheManager::trimStaleResources() { mGrContext->purgeResourcesNotUsedInMs(std::chrono::seconds(30)); } -VectorDrawableAtlas* CacheManager::acquireVectorDrawableAtlas() { +sp<skiapipeline::VectorDrawableAtlas> CacheManager::acquireVectorDrawableAtlas() { LOG_ALWAYS_FATAL_IF(mVectorDrawableAtlas.get() == nullptr); LOG_ALWAYS_FATAL_IF(mGrContext == nullptr); /** - * TODO LIST: - * 1) compute the atlas based on the surfaceArea surface - * 2) identify a way to reuse cache entries - * 3) add ability to repack the cache? - * 4) define memory conditions where we clear the cache (e.g. surface->reset()) + * TODO: define memory conditions where we clear the cache (e.g. surface->reset()) */ - - return mVectorDrawableAtlas.release(); -} -void CacheManager::releaseVectorDrawableAtlas(VectorDrawableAtlas* atlas) { - LOG_ALWAYS_FATAL_IF(mVectorDrawableAtlas.get() != nullptr); - mVectorDrawableAtlas.reset(atlas); - mVectorDrawableAtlas->isNewAtlas = false; + return mVectorDrawableAtlas; } void CacheManager::dumpMemoryUsage(String8& log, const RenderState* renderState) { diff --git a/libs/hwui/renderthread/CacheManager.h b/libs/hwui/renderthread/CacheManager.h index 43d58f2d58a8..90362f33358d 100644 --- a/libs/hwui/renderthread/CacheManager.h +++ b/libs/hwui/renderthread/CacheManager.h @@ -22,6 +22,7 @@ #include <ui/DisplayInfo.h> #include <utils/String8.h> #include <vector> +#include "pipeline/skia/VectorDrawableAtlas.h" namespace android { @@ -36,11 +37,6 @@ namespace renderthread { class IRenderPipeline; class RenderThread; -struct VectorDrawableAtlas { - sk_sp<SkSurface> surface; - bool isNewAtlas = true; -}; - class CacheManager { public: enum class TrimMemoryMode { @@ -53,8 +49,7 @@ public: void trimStaleResources(); void dumpMemoryUsage(String8& log, const RenderState* renderState = nullptr); - VectorDrawableAtlas* acquireVectorDrawableAtlas(); - void releaseVectorDrawableAtlas(VectorDrawableAtlas*); + sp<skiapipeline::VectorDrawableAtlas> acquireVectorDrawableAtlas(); size_t getCacheSize() const { return mMaxResourceBytes; } size_t getBackgroundCacheSize() const { return mBackgroundResourceBytes; } @@ -81,7 +76,7 @@ private: size_t surfaceArea = 0; }; - std::unique_ptr<VectorDrawableAtlas> mVectorDrawableAtlas; + sp<skiapipeline::VectorDrawableAtlas> mVectorDrawableAtlas; }; } /* namespace renderthread */ diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 779924883016..5d7f5948b0ec 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -142,8 +142,8 @@ CanvasContext::CanvasContext(RenderThread& thread, bool translucent, : mRenderThread(thread) , mOpaque(!translucent) , mAnimationContext(contextFactory->createAnimationContext(mRenderThread.timeLord())) - , mJankTracker(thread.mainDisplayInfo()) - , mProfiler(mFrames) + , mJankTracker(&thread.globalProfileData(), thread.mainDisplayInfo()) + , mProfiler(mJankTracker.frames()) , mContentDrawBounds(0, 0, 0, 0) , mRenderPipeline(std::move(renderPipeline)) { rootRenderNode->makeRoot(); @@ -321,7 +321,7 @@ void CanvasContext::prepareTree(TreeInfo& info, int64_t* uiFrameInfo, // If the previous frame was dropped we don't need to hold onto it, so // just keep using the previous frame's structure instead if (!wasSkipped(mCurrentFrameInfo)) { - mCurrentFrameInfo = &mFrames.next(); + mCurrentFrameInfo = mJankTracker.startFrame(); } mCurrentFrameInfo->importUiThreadInfo(uiFrameInfo); mCurrentFrameInfo->set(FrameInfoIndex::SyncQueued) = syncQueued; @@ -485,8 +485,7 @@ void CanvasContext::draw() { } #endif - mJankTracker.addFrame(*mCurrentFrameInfo); - mRenderThread.jankTracker().addFrame(*mCurrentFrameInfo); + mJankTracker.finishFrame(*mCurrentFrameInfo); if (CC_UNLIKELY(mFrameMetricsReporter.get() != nullptr)) { mFrameMetricsReporter->reportFrameMetrics(mCurrentFrameInfo->data()); } @@ -625,30 +624,12 @@ DeferredLayerUpdater* CanvasContext::createTextureLayer() { } void CanvasContext::dumpFrames(int fd) { - mJankTracker.dump(fd); - FILE* file = fdopen(fd, "a"); - fprintf(file, "\n\n---PROFILEDATA---\n"); - for (size_t i = 0; i < static_cast<size_t>(FrameInfoIndex::NumIndexes); i++) { - fprintf(file, "%s", FrameInfoNames[i].c_str()); - fprintf(file, ","); - } - for (size_t i = 0; i < mFrames.size(); i++) { - FrameInfo& frame = mFrames[i]; - if (frame[FrameInfoIndex::SyncStart] == 0) { - continue; - } - fprintf(file, "\n"); - for (int i = 0; i < static_cast<int>(FrameInfoIndex::NumIndexes); i++) { - fprintf(file, "%" PRId64 ",", frame[i]); - } - } - fprintf(file, "\n---PROFILEDATA---\n\n"); - fflush(file); + mJankTracker.dumpStats(fd); + mJankTracker.dumpFrames(fd); } void CanvasContext::resetFrameStats() { - mFrames.clear(); - mRenderThread.jankTracker().reset(); + mJankTracker.reset(); } void CanvasContext::setName(const std::string&& name) { diff --git a/libs/hwui/renderthread/CanvasContext.h b/libs/hwui/renderthread/CanvasContext.h index b1f405040a59..aa6d2f3513d7 100644 --- a/libs/hwui/renderthread/CanvasContext.h +++ b/libs/hwui/renderthread/CanvasContext.h @@ -29,7 +29,6 @@ #include "RenderNode.h" #include "thread/Task.h" #include "thread/TaskProcessor.h" -#include "utils/RingBuffer.h" #include "renderthread/RenderTask.h" #include "renderthread/RenderThread.h" @@ -253,8 +252,6 @@ private: std::vector< sp<RenderNode> > mRenderNodes; FrameInfo* mCurrentFrameInfo = nullptr; - // Ring buffer large enough for 2 seconds worth of frames - RingBuffer<FrameInfo, 120> mFrames; std::string mName; JankTracker mJankTracker; FrameInfoVisualizer mProfiler; diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp index d6240e7064cf..16d77364942e 100644 --- a/libs/hwui/renderthread/EglManager.cpp +++ b/libs/hwui/renderthread/EglManager.cpp @@ -79,6 +79,7 @@ static struct { bool noConfigContext = false; bool pixelFormatFloat = false; bool glColorSpace = false; + bool scRGB = false; } EglExtensions; EglManager::EglManager(RenderThread& thread) @@ -113,7 +114,7 @@ void EglManager::initialize() { // An Adreno driver bug is causing rendering problems for SkiaGL with // buffer age swap behavior (b/31957043). To temporarily workaround, // we will use preserved swap behavior. - if (Properties::useBufferAge && EglExtensions.bufferAge && !Properties::isSkiaEnabled()) { + if (Properties::useBufferAge && EglExtensions.bufferAge) { mSwapBehavior = SwapBehavior::BufferAge; } else { mSwapBehavior = SwapBehavior::Preserved; @@ -161,6 +162,11 @@ void EglManager::initExtensions() { EglExtensions.glColorSpace = extensions.has("EGL_KHR_gl_colorspace"); EglExtensions.noConfigContext = extensions.has("EGL_KHR_no_config_context"); EglExtensions.pixelFormatFloat = extensions.has("EGL_EXT_pixel_format_float"); +#ifdef ANDROID_ENABLE_LINEAR_BLENDING + EglExtensions.scRGB = extensions.has("EGL_EXT_gl_colorspace_scrgb_linear"); +#else + EglExtensions.scRGB = extensions.has("EGL_EXT_gl_colorspace_scrgb"); +#endif } bool EglManager::hasEglContext() { @@ -249,7 +255,7 @@ void EglManager::createPBufferSurface() { EGLSurface EglManager::createSurface(EGLNativeWindowType window, bool wideColorGamut) { initialize(); - wideColorGamut = wideColorGamut && EglExtensions.glColorSpace + wideColorGamut = wideColorGamut && EglExtensions.glColorSpace && EglExtensions.scRGB && EglExtensions.pixelFormatFloat && EglExtensions.noConfigContext; // The color space we want to use depends on whether linear blending is turned @@ -289,9 +295,7 @@ EGLSurface EglManager::createSurface(EGLNativeWindowType window, bool wideColorG } #else if (wideColorGamut) { - // TODO: this should be using scRGB-nl, not scRGB, we need an extension for this - // TODO: in the meantime SurfaceFlinger just assumes that scRGB is scRGB-nl - attribs[1] = EGL_GL_COLORSPACE_SCRGB_LINEAR_EXT; + attribs[1] = EGL_GL_COLORSPACE_SCRGB_EXT; } else { attribs[1] = EGL_GL_COLORSPACE_LINEAR_KHR; } diff --git a/libs/hwui/renderthread/RenderProxy.cpp b/libs/hwui/renderthread/RenderProxy.cpp index 80c2955400d8..7fe966dde316 100644 --- a/libs/hwui/renderthread/RenderProxy.cpp +++ b/libs/hwui/renderthread/RenderProxy.cpp @@ -21,6 +21,7 @@ #include "Properties.h" #include "Readback.h" #include "Rect.h" +#include "pipeline/skia/VectorDrawableAtlas.h" #include "renderthread/CanvasContext.h" #include "renderthread/EglManager.h" #include "renderthread/RenderTask.h" @@ -427,12 +428,12 @@ CREATE_BRIDGE4(dumpProfileInfo, CanvasContext* context, RenderThread* thread, if (args->dumpFlags & DumpFlags::FrameStats) { args->context->dumpFrames(args->fd); } + if (args->dumpFlags & DumpFlags::JankStats) { + args->thread->globalProfileData()->dump(args->fd); + } if (args->dumpFlags & DumpFlags::Reset) { args->context->resetFrameStats(); } - if (args->dumpFlags & DumpFlags::JankStats) { - args->thread->jankTracker().dump(args->fd); - } return nullptr; } @@ -458,7 +459,7 @@ void RenderProxy::resetProfileInfo() { CREATE_BRIDGE2(frameTimePercentile, RenderThread* thread, int percentile) { return reinterpret_cast<void*>(static_cast<uintptr_t>( - args->thread->jankTracker().findPercentile(args->percentile))); + args->thread->globalProfileData()->findPercentile(args->percentile))); } uint32_t RenderProxy::frameTimePercentile(int p) { @@ -483,7 +484,7 @@ void RenderProxy::dumpGraphicsMemory(int fd) { } CREATE_BRIDGE2(setProcessStatsBuffer, RenderThread* thread, int fd) { - args->thread->jankTracker().switchStorageToAshmem(args->fd); + args->thread->globalProfileData().switchStorageToAshmem(args->fd); close(args->fd); return nullptr; } @@ -497,7 +498,7 @@ void RenderProxy::setProcessStatsBuffer(int fd) { } CREATE_BRIDGE1(rotateProcessStatsBuffer, RenderThread* thread) { - args->thread->jankTracker().rotateStorage(); + args->thread->globalProfileData().rotateStorage(); return nullptr; } @@ -718,6 +719,19 @@ void RenderProxy::post(RenderTask* task) { mRenderThread.queue(task); } +CREATE_BRIDGE1(repackVectorDrawableAtlas, RenderThread* thread) { + args->thread->cacheManager().acquireVectorDrawableAtlas()->repackIfNeeded( + args->thread->getGrContext()); + return nullptr; +} + +void RenderProxy::repackVectorDrawableAtlas() { + RenderThread& thread = RenderThread::getInstance(); + SETUP_TASK(repackVectorDrawableAtlas); + args->thread = &thread; + thread.queue(task); +} + void* RenderProxy::postAndWait(MethodInvokeRenderTask* task) { void* retval; task->setReturnPtr(&retval); diff --git a/libs/hwui/renderthread/RenderProxy.h b/libs/hwui/renderthread/RenderProxy.h index 31f0ce67e1a7..06eaebd066ee 100644 --- a/libs/hwui/renderthread/RenderProxy.h +++ b/libs/hwui/renderthread/RenderProxy.h @@ -140,6 +140,9 @@ public: static void onBitmapDestroyed(uint32_t pixelRefId); ANDROID_API static void disableVsync(); + + static void repackVectorDrawableAtlas(); + private: RenderThread& mRenderThread; CanvasContext* mContext; diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 13af2c4d15e8..72a428f1c70c 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -200,13 +200,12 @@ void RenderThread::initThreadLocals() { initializeDisplayEventReceiver(); mEglManager = new EglManager(*this); mRenderState = new RenderState(*this); - mJankTracker = new JankTracker(mDisplayInfo); mVkManager = new VulkanManager(*this); mCacheManager = new CacheManager(mDisplayInfo); } void RenderThread::dumpGraphicsMemory(int fd) { - jankTracker().dump(fd); + globalProfileData()->dump(fd); String8 cachesOutput; String8 pipeline; diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h index d9842572d7cd..bef47b3e27c5 100644 --- a/libs/hwui/renderthread/RenderThread.h +++ b/libs/hwui/renderthread/RenderThread.h @@ -97,7 +97,7 @@ public: TimeLord& timeLord() { return mTimeLord; } RenderState& renderState() const { return *mRenderState; } EglManager& eglManager() const { return *mEglManager; } - JankTracker& jankTracker() { return *mJankTracker; } + ProfileDataContainer& globalProfileData() { return mGlobalProfileData; } Readback& readback(); const DisplayInfo& mainDisplayInfo() { return mDisplayInfo; } @@ -160,7 +160,7 @@ private: RenderState* mRenderState; EglManager* mEglManager; - JankTracker* mJankTracker = nullptr; + ProfileDataContainer mGlobalProfileData; Readback* mReadback = nullptr; sk_sp<GrContext> mGrContext; diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp index a745320ca884..2195143658d2 100644 --- a/libs/hwui/renderthread/VulkanManager.cpp +++ b/libs/hwui/renderthread/VulkanManager.cpp @@ -22,6 +22,7 @@ #include "renderstate/RenderState.h" #include "utils/FatVector.h" +#include <GrBackendSurface.h> #include <GrContext.h> #include <GrTypes.h> #include <vk/GrVkTypes.h> @@ -297,13 +298,9 @@ void VulkanManager::createBuffers(VulkanSurface* surface, VkFormat format, VkExt SkSurfaceProps props(0, kUnknown_SkPixelGeometry); - bool wantSRGB = VK_FORMAT_R8G8B8A8_SRGB == format; - GrPixelConfig config = wantSRGB ? kSRGBA_8888_GrPixelConfig : kRGBA_8888_GrPixelConfig; - // set up initial image layouts and create surfaces surface->mImageInfos = new VulkanSurface::ImageInfo[surface->mImageCount]; for (uint32_t i = 0; i < surface->mImageCount; ++i) { - GrBackendRenderTargetDesc desc; GrVkImageInfo info; info.fImage = surface->mImages[i]; info.fAlloc = { VK_NULL_HANDLE, 0, 0, 0 }; @@ -312,17 +309,11 @@ void VulkanManager::createBuffers(VulkanSurface* surface, VkFormat format, VkExt info.fFormat = format; info.fLevelCount = 1; - desc.fWidth = extent.width; - desc.fHeight = extent.height; - desc.fConfig = config; - desc.fOrigin = kTopLeft_GrSurfaceOrigin; - desc.fSampleCnt = 0; - desc.fStencilBits = 0; - desc.fRenderTargetHandle = (GrBackendObject) &info; + GrBackendRenderTarget backendRT(extent.width, extent.height, 0, 0, info); VulkanSurface::ImageInfo& imageInfo = surface->mImageInfos[i]; imageInfo.mSurface = SkSurface::MakeFromBackendRenderTarget(mRenderThread.getGrContext(), - desc, &props); + backendRT, kTopLeft_GrSurfaceOrigin, nullptr, &props); } SkASSERT(mCommandPool != VK_NULL_HANDLE); |
