diff options
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/Caches.cpp | 34 | ||||
-rw-r--r-- | libs/hwui/Caches.h | 12 | ||||
-rw-r--r-- | libs/hwui/Debug.h | 3 |
3 files changed, 49 insertions, 0 deletions
diff --git a/libs/hwui/Caches.cpp b/libs/hwui/Caches.cpp index e232ddd..7114b6a 100644 --- a/libs/hwui/Caches.cpp +++ b/libs/hwui/Caches.cpp @@ -33,6 +33,16 @@ ANDROID_SINGLETON_STATIC_INSTANCE(Caches); namespace uirenderer { /////////////////////////////////////////////////////////////////////////////// +// Macros +/////////////////////////////////////////////////////////////////////////////// + +#if DEBUG_CACHE_FLUSH + #define FLUSH_LOGD(...) LOGD(__VA_ARGS__) +#else + #define FLUSH_LOGD(...) +#endif + +/////////////////////////////////////////////////////////////////////////////// // Constructors/destructor /////////////////////////////////////////////////////////////////////////////// @@ -150,6 +160,30 @@ void Caches::deleteLayerDeferred(Layer* layer) { mLayerGarbage.push(layer); } +void Caches::flush(FlushMode mode) { + FLUSH_LOGD("Flushing caches (mode %d)", mode); + + clearGarbage(); + + switch (mode) { + case kFlushMode_Full: + textureCache.clear(); + patchCache.clear(); + dropShadowCache.clear(); + gradientCache.clear(); + // fall through + case kFlushMode_Moderate: + layerCache.clear(); + pathCache.clear(); + roundRectShapeCache.clear(); + circleShapeCache.clear(); + ovalShapeCache.clear(); + rectShapeCache.clear(); + arcShapeCache.clear(); + break; + } +} + /////////////////////////////////////////////////////////////////////////////// // VBO /////////////////////////////////////////////////////////////////////////////// diff --git a/libs/hwui/Caches.h b/libs/hwui/Caches.h index e64d8ac..76dff4b 100644 --- a/libs/hwui/Caches.h +++ b/libs/hwui/Caches.h @@ -100,6 +100,18 @@ class Caches: public Singleton<Caches> { Vector<Layer*> mLayerGarbage; public: + enum FlushMode { + kFlushMode_Moderate = 0, + kFlushMode_Full + }; + + /** + * Flush the cache. + * + * @param mode Indicates how much of the cache should be flushed + */ + void flush(FlushMode mode); + /** * Indicates whether the renderer is in debug mode. * This debug mode provides limited information to app developers. diff --git a/libs/hwui/Debug.h b/libs/hwui/Debug.h index 2cdc8c3..5db73db 100644 --- a/libs/hwui/Debug.h +++ b/libs/hwui/Debug.h @@ -26,6 +26,9 @@ // Turn on to enable memory usage summary on each frame #define DEBUG_MEMORY_USAGE 0 +// Turn on to enable debugging of cache flushes +#define DEBUG_CACHE_FLUSH 1 + // Turn on to enable layers debugging when rendered as regions #define DEBUG_LAYERS_AS_REGIONS 0 |