Merge "TextureVuew rebind GL texture, if AHB content has changed"
This commit is contained in:
@@ -71,13 +71,16 @@ public:
|
|||||||
void makeImage(sp<GraphicBuffer>& graphicBuffer, android_dataspace dataspace,
|
void makeImage(sp<GraphicBuffer>& graphicBuffer, android_dataspace dataspace,
|
||||||
GrContext* context);
|
GrContext* context);
|
||||||
|
|
||||||
|
void newBufferContent(GrContext* context);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// The only way to invoke dtor is with unref, when mUsageCount is 0.
|
// The only way to invoke dtor is with unref, when mUsageCount is 0.
|
||||||
~AutoBackendTextureRelease() {}
|
~AutoBackendTextureRelease() {}
|
||||||
|
|
||||||
GrBackendTexture mBackendTexture;
|
GrBackendTexture mBackendTexture;
|
||||||
GrAHardwareBufferUtils::DeleteImageProc mDeleteProc;
|
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
|
// Starting with refcount 1, because the first ref is held by SurfaceTexture. Additional refs
|
||||||
// are held by SkImages.
|
// are held by SkImages.
|
||||||
@@ -101,7 +104,8 @@ AutoBackendTextureRelease::AutoBackendTextureRelease(GrContext* context, Graphic
|
|||||||
buffer->getWidth(),
|
buffer->getWidth(),
|
||||||
buffer->getHeight(),
|
buffer->getHeight(),
|
||||||
&mDeleteProc,
|
&mDeleteProc,
|
||||||
&mDeleteCtx,
|
&mUpdateProc,
|
||||||
|
&mImageCtx,
|
||||||
createProtectedImage,
|
createProtectedImage,
|
||||||
backendFormat,
|
backendFormat,
|
||||||
false);
|
false);
|
||||||
@@ -123,7 +127,7 @@ void AutoBackendTextureRelease::unref(bool releaseImage) {
|
|||||||
mUsageCount--;
|
mUsageCount--;
|
||||||
if (mUsageCount <= 0) {
|
if (mUsageCount <= 0) {
|
||||||
if (mBackendTexture.isValid()) {
|
if (mBackendTexture.isValid()) {
|
||||||
mDeleteProc(mDeleteCtx);
|
mDeleteProc(mImageCtx);
|
||||||
mBackendTexture = {};
|
mBackendTexture = {};
|
||||||
}
|
}
|
||||||
delete this;
|
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,
|
void ImageConsumer::ImageSlot::createIfNeeded(sp<GraphicBuffer> graphicBuffer,
|
||||||
android_dataspace dataspace, bool forceCreate,
|
android_dataspace dataspace, bool forceCreate,
|
||||||
GrContext* context) {
|
GrContext* context) {
|
||||||
@@ -166,6 +176,8 @@ void ImageConsumer::ImageSlot::createIfNeeded(sp<GraphicBuffer> graphicBuffer,
|
|||||||
|
|
||||||
if (!mTextureRelease) {
|
if (!mTextureRelease) {
|
||||||
mTextureRelease = new AutoBackendTextureRelease(context, graphicBuffer.get());
|
mTextureRelease = new AutoBackendTextureRelease(context, graphicBuffer.get());
|
||||||
|
} else {
|
||||||
|
mTextureRelease->newBufferContent(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDataspace = dataspace;
|
mDataspace = dataspace;
|
||||||
|
|||||||
@@ -26,11 +26,6 @@
|
|||||||
#include <gui/BufferItem.h>
|
#include <gui/BufferItem.h>
|
||||||
#include <system/graphics.h>
|
#include <system/graphics.h>
|
||||||
|
|
||||||
namespace GrAHardwareBufferUtils {
|
|
||||||
typedef void* DeleteImageCtx;
|
|
||||||
typedef void (*DeleteImageProc)(DeleteImageCtx);
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace android {
|
namespace android {
|
||||||
|
|
||||||
namespace uirenderer {
|
namespace uirenderer {
|
||||||
|
|||||||
Reference in New Issue
Block a user