10#if defined(SK_BUILD_FOR_ANDROID) && __ANDROID_API__ >= 26
38 AHardwareBuffer_Desc bufferDesc;
39 AHardwareBuffer_describe(graphicBuffer, &bufferDesc);
42 AHardwareBufferUtils::GetSkColorTypeFromBufferFormat(bufferDesc.format);
44 alphaType, std::move(colorSpace));
46 bool createProtectedImage = 0 != (bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
48 info, graphicBuffer, alphaType, createProtectedImage,
49 bufferDesc.format, surfaceOrigin));
52GrAHardwareBufferImageGenerator::GrAHardwareBufferImageGenerator(
const SkImageInfo&
info,
56 , fHardwareBuffer(hardwareBuffer)
57 , fBufferFormat(bufferFormat)
58 , fIsProtectedContent(isProtectedContent)
59 , fSurfaceOrigin(surfaceOrigin) {
60 AHardwareBuffer_acquire(fHardwareBuffer);
64 AHardwareBuffer_release(fHardwareBuffer);
79 GrBackendFormat backendFormat = GrAHardwareBufferUtils::GetBackendFormat(direct,
92 AHardwareBuffer_acquire(hardwareBuffer);
94 class AutoAHBRelease {
98 AutoAHBRelease(
const AutoAHBRelease&) {
SkASSERT(0); }
99 AutoAHBRelease(AutoAHBRelease&& that) : fAhb(that.fAhb) { that.fAhb =
nullptr; }
100 ~AutoAHBRelease() { fAhb ? AHardwareBuffer_release(fAhb) : void(); }
102 AutoAHBRelease& operator=(AutoAHBRelease&& that) {
103 fAhb = std::exchange(that.fAhb,
nullptr);
106 AutoAHBRelease& operator=(
const AutoAHBRelease&) =
delete;
115 [direct,
buffer = AutoAHBRelease(hardwareBuffer)](
119 GrAHardwareBufferUtils::DeleteImageProc deleteImageProc =
nullptr;
120 GrAHardwareBufferUtils::UpdateImageProc updateImageProc =
nullptr;
121 GrAHardwareBufferUtils::TexImageCtx texImageCtx =
nullptr;
125 GrAHardwareBufferUtils::MakeBackendTexture(direct,
127 desc.fDimensions.width(),
128 desc.fDimensions.height(),
138 SkASSERT(deleteImageProc && texImageCtx);
152 deleteImageProc(texImageCtx);
156 if (deleteImageProc) {
157 tex->setRelease(deleteImageProc, texImageCtx);
164 skgpu::Mipmapped::kNo,
171 "AHardwareBufferImageGenerator_MakeView");
184 if (!texProxyView.
proxy()) {
200 std::move(texProxyView),
205 "AHardwareBufferImageGenerator_GenerateTexture");
209 if (
nullptr == context) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
struct AHardwareBuffer AHardwareBuffer
@ kBorrow_GrWrapOwnership
static constexpr GrColorType SkColorTypeToGrColorType(SkColorType ct)
skgpu::Protected GrProtected
@ kNew_Uncached_Unbudgeted
static SkColorType colorType(AImageDecoder *decoder, const AImageDecoderHeaderInfo *headerInfo)
bool onIsValid(GrRecordingContext *) const override
static std::unique_ptr< SkImageGenerator > Make(AHardwareBuffer *, SkAlphaType, sk_sp< SkColorSpace >, GrSurfaceOrigin)
~GrAHardwareBufferImageGenerator() override
GrSurfaceProxyView onGenerateTexture(GrRecordingContext *, const SkImageInfo &, skgpu::Mipmapped, GrImageTexGenPolicy) override
const GrCaps * caps() const
skgpu::Swizzle getReadSwizzle(const GrBackendFormat &format, GrColorType colorType) const
virtual GrDirectContext * asDirectContext()
SK_API GrBackendApi backend() const
GrProxyProvider * proxyProvider()
GrRecordingContextPriv priv()
bool abandoned() override
sk_sp< GrTexture > wrapBackendTexture(const GrBackendTexture &tex, GrWrapOwnership, GrWrapCacheable, GrIOType)
GrTextureProxy * asTextureProxy() const
GrSurfaceProxy * proxy() const
static GrSurfaceProxyView Copy(GrRecordingContext *context, GrSurfaceProxyView src, skgpu::Mipmapped mipmapped, SkIRect srcRect, SkBackingFit fit, skgpu::Budgeted budgeted, std::string_view label)
const SkImageInfo & getInfo() const
static const uint8_t buffer[]
const myers::Point & get(const myers::Segment &)
static constexpr SkIRect MakeWH(int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)