diff options
Diffstat (limited to 'services/surfaceflinger/CompositionEngine/src/planner/TexturePool.cpp')
-rw-r--r-- | services/surfaceflinger/CompositionEngine/src/planner/TexturePool.cpp | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/services/surfaceflinger/CompositionEngine/src/planner/TexturePool.cpp b/services/surfaceflinger/CompositionEngine/src/planner/TexturePool.cpp index e3772a22d2..497c433c76 100644 --- a/services/surfaceflinger/CompositionEngine/src/planner/TexturePool.cpp +++ b/services/surfaceflinger/CompositionEngine/src/planner/TexturePool.cpp @@ -24,14 +24,22 @@ namespace android::compositionengine::impl::planner { +void TexturePool::allocatePool() { + mPool.clear(); + if (mEnabled && mSize.isValid()) { + mPool.resize(kMinPoolSize); + std::generate_n(mPool.begin(), kMinPoolSize, [&]() { + return Entry{genTexture(), nullptr}; + }); + } +} + void TexturePool::setDisplaySize(ui::Size size) { if (mSize == size) { return; } mSize = size; - mPool.clear(); - mPool.resize(kMinPoolSize); - std::generate_n(mPool.begin(), kMinPoolSize, [&]() { return Entry{genTexture(), nullptr}; }); + allocatePool(); } std::shared_ptr<TexturePool::AutoTexture> TexturePool::borrowTexture() { @@ -46,7 +54,12 @@ std::shared_ptr<TexturePool::AutoTexture> TexturePool::borrowTexture() { void TexturePool::returnTexture(std::shared_ptr<renderengine::ExternalTexture>&& texture, const sp<Fence>& fence) { - // Drop the texture on the floor if the pool is no longer tracking textures of the same size. + // Drop the texture on the floor if the pool is not enabled + if (!mEnabled) { + return; + } + + // Or the texture on the floor if the pool is no longer tracking textures of the same size. if (static_cast<int32_t>(texture->getBuffer()->getWidth()) != mSize.getWidth() || static_cast<int32_t>(texture->getBuffer()->getHeight()) != mSize.getHeight()) { ALOGV("Deallocating texture from Planner's pool - display size changed (previous: (%dx%d), " @@ -81,4 +94,15 @@ std::shared_ptr<renderengine::ExternalTexture> TexturePool::genTexture() { renderengine::ExternalTexture::Usage::WRITEABLE); } +void TexturePool::setEnabled(bool enabled) { + mEnabled = enabled; + allocatePool(); +} + +void TexturePool::dump(std::string& out) const { + base::StringAppendF(&out, + "TexturePool (%s) has %zu buffers of size [%" PRId32 ", %" PRId32 "]\n", + mEnabled ? "enabled" : "disabled", mPool.size(), mSize.width, mSize.height); +} + } // namespace android::compositionengine::impl::planner
\ No newline at end of file |