Loading libs/hwui/VectorDrawable.cpp +32 −12 Original line number Diff line number Diff line Loading @@ -16,19 +16,24 @@ #include "VectorDrawable.h" #include <math.h> #include <string.h> #include <utils/Log.h> #include "hwui/Paint.h" #include "PathParser.h" #include "SkColorFilter.h" #include "SkImageInfo.h" #include "SkShader.h" #include "hwui/Paint.h" #ifdef __ANDROID__ #include "renderthread/RenderThread.h" #endif #include "utils/Macros.h" #include "utils/TraceUtils.h" #include "utils/VectorDrawableUtils.h" #include <math.h> #include <string.h> namespace android { namespace uirenderer { namespace VectorDrawable { Loading Loading @@ -548,12 +553,27 @@ sk_sp<SkSurface> Tree::Cache::getSurface(SkRect* bounds) { void Tree::Cache::clear() { #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration if (mAtlasKey != INVALID_ATLAS_KEY) { if (renderthread::RenderThread::isCurrent()) { sp<skiapipeline::VectorDrawableAtlas> lockAtlas = mAtlas.promote(); if (lockAtlas.get()) { lockAtlas->releaseEntry(mAtlasKey); } mAtlas = nullptr; } else { // VectorDrawableAtlas can be accessed only on RenderThread. // Use by-copy capture of the current Cache variables, because "this" may not be valid // by the time the lambda is evaluated on RenderThread. renderthread::RenderThread::getInstance().queue().post( [atlas = mAtlas, atlasKey = mAtlasKey]() { sp<skiapipeline::VectorDrawableAtlas> lockAtlas = atlas.promote(); if (lockAtlas.get()) { lockAtlas->releaseEntry(atlasKey); } }); } mAtlasKey = INVALID_ATLAS_KEY; } mAtlas = nullptr; #endif } Loading libs/hwui/renderthread/RenderThread.h +5 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ namespace skiapipeline { class VkFunctorDrawHandler; } namespace VectorDrawable { class Tree; } namespace renderthread { class CanvasContext; Loading Loading @@ -138,6 +142,7 @@ private: friend class android::uirenderer::TestUtils; friend class android::uirenderer::WebViewFunctor; friend class android::uirenderer::skiapipeline::VkFunctorDrawHandler; friend class android::uirenderer::VectorDrawable::Tree; RenderThread(); virtual ~RenderThread(); Loading Loading
libs/hwui/VectorDrawable.cpp +32 −12 Original line number Diff line number Diff line Loading @@ -16,19 +16,24 @@ #include "VectorDrawable.h" #include <math.h> #include <string.h> #include <utils/Log.h> #include "hwui/Paint.h" #include "PathParser.h" #include "SkColorFilter.h" #include "SkImageInfo.h" #include "SkShader.h" #include "hwui/Paint.h" #ifdef __ANDROID__ #include "renderthread/RenderThread.h" #endif #include "utils/Macros.h" #include "utils/TraceUtils.h" #include "utils/VectorDrawableUtils.h" #include <math.h> #include <string.h> namespace android { namespace uirenderer { namespace VectorDrawable { Loading Loading @@ -548,12 +553,27 @@ sk_sp<SkSurface> Tree::Cache::getSurface(SkRect* bounds) { void Tree::Cache::clear() { #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration if (mAtlasKey != INVALID_ATLAS_KEY) { if (renderthread::RenderThread::isCurrent()) { sp<skiapipeline::VectorDrawableAtlas> lockAtlas = mAtlas.promote(); if (lockAtlas.get()) { lockAtlas->releaseEntry(mAtlasKey); } mAtlas = nullptr; } else { // VectorDrawableAtlas can be accessed only on RenderThread. // Use by-copy capture of the current Cache variables, because "this" may not be valid // by the time the lambda is evaluated on RenderThread. renderthread::RenderThread::getInstance().queue().post( [atlas = mAtlas, atlasKey = mAtlasKey]() { sp<skiapipeline::VectorDrawableAtlas> lockAtlas = atlas.promote(); if (lockAtlas.get()) { lockAtlas->releaseEntry(atlasKey); } }); } mAtlasKey = INVALID_ATLAS_KEY; } mAtlas = nullptr; #endif } Loading
libs/hwui/renderthread/RenderThread.h +5 −0 Original line number Diff line number Diff line Loading @@ -53,6 +53,10 @@ namespace skiapipeline { class VkFunctorDrawHandler; } namespace VectorDrawable { class Tree; } namespace renderthread { class CanvasContext; Loading Loading @@ -138,6 +142,7 @@ private: friend class android::uirenderer::TestUtils; friend class android::uirenderer::WebViewFunctor; friend class android::uirenderer::skiapipeline::VkFunctorDrawHandler; friend class android::uirenderer::VectorDrawable::Tree; RenderThread(); virtual ~RenderThread(); Loading