浏览代码

TextureView rebind GL texture, if AHB content has changed

Bug: 138674291
Test: Ran apps with TextureView and CTS
Change-Id: Ieecf7daf160761de719356644ddaeda8f9c068e1
ten
Stan Iliev 2 年前
父节点
当前提交
9bf6d264c5
共有 2 个文件被更改,包括 15 次插入8 次删除
  1. 15
    3
      libs/hwui/surfacetexture/ImageConsumer.cpp
  2. 0
    5
      libs/hwui/surfacetexture/ImageConsumer.h

+ 15
- 3
libs/hwui/surfacetexture/ImageConsumer.cpp 查看文件

@@ -71,13 +71,16 @@ public:
void makeImage(sp<GraphicBuffer>& graphicBuffer, android_dataspace dataspace,
GrContext* context);

void newBufferContent(GrContext* context);

private:
// The only way to invoke dtor is with unref, when mUsageCount is 0.
~AutoBackendTextureRelease() {}

GrBackendTexture mBackendTexture;
GrAHardwareBufferUtils::DeleteImageProc mDeleteProc;
GrAHardwareBufferUtils::DeleteImageCtx mDeleteCtx;
GrAHardwareBufferUtils::UpdateImageProc mUpdateProc;
GrAHardwareBufferUtils::TexImageCtx mImageCtx;

// Starting with refcount 1, because the first ref is held by SurfaceTexture. Additional refs
// are held by SkImages.
@@ -101,7 +104,8 @@ AutoBackendTextureRelease::AutoBackendTextureRelease(GrContext* context, Graphic
buffer->getWidth(),
buffer->getHeight(),
&mDeleteProc,
&mDeleteCtx,
&mUpdateProc,
&mImageCtx,
createProtectedImage,
backendFormat,
false);
@@ -123,7 +127,7 @@ void AutoBackendTextureRelease::unref(bool releaseImage) {
mUsageCount--;
if (mUsageCount <= 0) {
if (mBackendTexture.isValid()) {
mDeleteProc(mDeleteCtx);
mDeleteProc(mImageCtx);
mBackendTexture = {};
}
delete this;
@@ -154,6 +158,12 @@ void AutoBackendTextureRelease::makeImage(sp<GraphicBuffer>& graphicBuffer,
}
}

void AutoBackendTextureRelease::newBufferContent(GrContext* context) {
if (mBackendTexture.isValid()) {
mUpdateProc(mImageCtx, context);
}
}

void ImageConsumer::ImageSlot::createIfNeeded(sp<GraphicBuffer> graphicBuffer,
android_dataspace dataspace, bool forceCreate,
GrContext* context) {
@@ -166,6 +176,8 @@ void ImageConsumer::ImageSlot::createIfNeeded(sp<GraphicBuffer> graphicBuffer,

if (!mTextureRelease) {
mTextureRelease = new AutoBackendTextureRelease(context, graphicBuffer.get());
} else {
mTextureRelease->newBufferContent(context);
}

mDataspace = dataspace;

+ 0
- 5
libs/hwui/surfacetexture/ImageConsumer.h 查看文件

@@ -26,11 +26,6 @@
#include <gui/BufferItem.h>
#include <system/graphics.h>

namespace GrAHardwareBufferUtils {
typedef void* DeleteImageCtx;
typedef void (*DeleteImageProc)(DeleteImageCtx);
}

namespace android {

namespace uirenderer {

正在加载...
取消
保存