Cache VectorDrawables in an atlas
Optimize VectorDrawables for Skia pipeline: draw small VectorDrawables
in a GPU atlas instead of seprate offscreen buffers.
This implementation is using CacheManger and allows for the atlas to
be released if there is a memory pressure.
Test: A new unit test for VectorDrawableAtlas is passing. Systrace shows
0.5ms faster DrawFrame for fling in Settings app main screen.
Change-Id: Ide3884eefae777e1547f1dfdb67b807185839fb4
diff --git a/libs/hwui/renderthread/CacheManager.h b/libs/hwui/renderthread/CacheManager.h
index 43d58f2..90362f3 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 @@
class IRenderPipeline;
class RenderThread;
-struct VectorDrawableAtlas {
- sk_sp<SkSurface> surface;
- bool isNewAtlas = true;
-};
-
class CacheManager {
public:
enum class TrimMemoryMode {
@@ -53,8 +49,7 @@
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 @@
size_t surfaceArea = 0;
};
- std::unique_ptr<VectorDrawableAtlas> mVectorDrawableAtlas;
+ sp<skiapipeline::VectorDrawableAtlas> mVectorDrawableAtlas;
};
} /* namespace renderthread */