Loading libs/hwui/pipeline/skia/SkiaPipeline.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ SkiaPipeline::SkiaPipeline(RenderThread& thread) : mRenderThread(thread) { } TaskManager* SkiaPipeline::getTaskManager() { return &mTaskManager; return mRenderThread.cacheManager().getTaskManager(); } void SkiaPipeline::onDestroyHardwareResources() { Loading libs/hwui/pipeline/skia/SkiaPipeline.h +0 −1 Original line number Diff line number Diff line Loading @@ -126,7 +126,6 @@ private: */ void renderVectorDrawableCache(); TaskManager mTaskManager; std::vector<sk_sp<SkImage>> mPinnedImages; /** Loading libs/hwui/renderthread/CacheManager.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <gui/Surface.h> #include <GrContextOptions.h> #include <SkExecutor.h> #include <math.h> #include <set> Loading Loading @@ -73,6 +74,29 @@ void CacheManager::updateContextCacheSizes() { mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes); } class CacheManager::SkiaTaskProcessor : public TaskProcessor<bool>, public SkExecutor { public: explicit SkiaTaskProcessor(TaskManager* taskManager) : TaskProcessor<bool>(taskManager) {} // This is really a Task<void> but that doesn't really work when Future<> // expects to be able to get/set a value struct SkiaTask : public Task<bool> { std::function<void()> func; }; virtual void add(std::function<void(void)> func) override { sp<SkiaTask> task(new SkiaTask()); task->func = func; TaskProcessor<bool>::add(task); } virtual void onProcess(const sp<Task<bool> >& task) override { SkiaTask* t = static_cast<SkiaTask*>(task.get()); t->func(); task->setResult(true); } }; void CacheManager::configureContext(GrContextOptions* contextOptions) { contextOptions->fAllowPathMaskCaching = true; Loading @@ -95,6 +119,13 @@ void CacheManager::configureContext(GrContextOptions* contextOptions) { // Skia's implementation doesn't provide a mechanism to resize the font cache due to // the potential cost of recreating the glyphs. contextOptions->fGlyphCacheTextureMaximumBytes = fontCacheMB * 1024 * 1024; if (mTaskManager.canRunTasks()) { if (!mTaskProcessor.get()) { mTaskProcessor = new SkiaTaskProcessor(&mTaskManager); } contextOptions->fExecutor = mTaskProcessor.get(); } } void CacheManager::trimMemory(TrimMemoryMode mode) { Loading libs/hwui/renderthread/CacheManager.h +8 −0 Original line number Diff line number Diff line Loading @@ -22,7 +22,10 @@ #include <ui/DisplayInfo.h> #include <utils/String8.h> #include <vector> #include "pipeline/skia/VectorDrawableAtlas.h" #include "thread/TaskManager.h" #include "thread/TaskProcessor.h" namespace android { Loading Loading @@ -54,6 +57,7 @@ public: size_t getCacheSize() const { return mMaxResourceBytes; } size_t getBackgroundCacheSize() const { return mBackgroundResourceBytes; } TaskManager* getTaskManager() { return &mTaskManager; } private: friend class RenderThread; Loading @@ -77,6 +81,10 @@ private: }; sp<skiapipeline::VectorDrawableAtlas> mVectorDrawableAtlas; class SkiaTaskProcessor; sp<SkiaTaskProcessor> mTaskProcessor; TaskManager mTaskManager; }; } /* namespace renderthread */ Loading Loading
libs/hwui/pipeline/skia/SkiaPipeline.cpp +1 −1 Original line number Diff line number Diff line Loading @@ -46,7 +46,7 @@ SkiaPipeline::SkiaPipeline(RenderThread& thread) : mRenderThread(thread) { } TaskManager* SkiaPipeline::getTaskManager() { return &mTaskManager; return mRenderThread.cacheManager().getTaskManager(); } void SkiaPipeline::onDestroyHardwareResources() { Loading
libs/hwui/pipeline/skia/SkiaPipeline.h +0 −1 Original line number Diff line number Diff line Loading @@ -126,7 +126,6 @@ private: */ void renderVectorDrawableCache(); TaskManager mTaskManager; std::vector<sk_sp<SkImage>> mPinnedImages; /** Loading
libs/hwui/renderthread/CacheManager.cpp +31 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ #include <gui/Surface.h> #include <GrContextOptions.h> #include <SkExecutor.h> #include <math.h> #include <set> Loading Loading @@ -73,6 +74,29 @@ void CacheManager::updateContextCacheSizes() { mGrContext->setResourceCacheLimits(mMaxResources, mMaxResourceBytes); } class CacheManager::SkiaTaskProcessor : public TaskProcessor<bool>, public SkExecutor { public: explicit SkiaTaskProcessor(TaskManager* taskManager) : TaskProcessor<bool>(taskManager) {} // This is really a Task<void> but that doesn't really work when Future<> // expects to be able to get/set a value struct SkiaTask : public Task<bool> { std::function<void()> func; }; virtual void add(std::function<void(void)> func) override { sp<SkiaTask> task(new SkiaTask()); task->func = func; TaskProcessor<bool>::add(task); } virtual void onProcess(const sp<Task<bool> >& task) override { SkiaTask* t = static_cast<SkiaTask*>(task.get()); t->func(); task->setResult(true); } }; void CacheManager::configureContext(GrContextOptions* contextOptions) { contextOptions->fAllowPathMaskCaching = true; Loading @@ -95,6 +119,13 @@ void CacheManager::configureContext(GrContextOptions* contextOptions) { // Skia's implementation doesn't provide a mechanism to resize the font cache due to // the potential cost of recreating the glyphs. contextOptions->fGlyphCacheTextureMaximumBytes = fontCacheMB * 1024 * 1024; if (mTaskManager.canRunTasks()) { if (!mTaskProcessor.get()) { mTaskProcessor = new SkiaTaskProcessor(&mTaskManager); } contextOptions->fExecutor = mTaskProcessor.get(); } } void CacheManager::trimMemory(TrimMemoryMode mode) { Loading
libs/hwui/renderthread/CacheManager.h +8 −0 Original line number Diff line number Diff line Loading @@ -22,7 +22,10 @@ #include <ui/DisplayInfo.h> #include <utils/String8.h> #include <vector> #include "pipeline/skia/VectorDrawableAtlas.h" #include "thread/TaskManager.h" #include "thread/TaskProcessor.h" namespace android { Loading Loading @@ -54,6 +57,7 @@ public: size_t getCacheSize() const { return mMaxResourceBytes; } size_t getBackgroundCacheSize() const { return mBackgroundResourceBytes; } TaskManager* getTaskManager() { return &mTaskManager; } private: friend class RenderThread; Loading @@ -77,6 +81,10 @@ private: }; sp<skiapipeline::VectorDrawableAtlas> mVectorDrawableAtlas; class SkiaTaskProcessor; sp<SkiaTaskProcessor> mTaskProcessor; TaskManager mTaskManager; }; } /* namespace renderthread */ Loading