Add GrSurfaceOrigin to MakeFromAHardwareBuffer
Add support for kBottomLeft_GrSurfaceOrigin origin for SkImage
backed by an Android hardware buffer.
Bug: b/115610873
Change-Id: I8ba142007ee01c3fc2fd48317b29388d07a7b6e0
Reviewed-on: https://skia-review.googlesource.com/154301
Commit-Queue: Stan Iliev <stani@google.com>
Reviewed-by: Greg Daniel <egdaniel@google.com>
diff --git a/src/gpu/GrAHardwareBufferImageGenerator.cpp b/src/gpu/GrAHardwareBufferImageGenerator.cpp
index 06b4131..7f99b3c 100644
--- a/src/gpu/GrAHardwareBufferImageGenerator.cpp
+++ b/src/gpu/GrAHardwareBufferImageGenerator.cpp
@@ -65,7 +65,8 @@
}
std::unique_ptr<SkImageGenerator> GrAHardwareBufferImageGenerator::Make(
- AHardwareBuffer* graphicBuffer, SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace) {
+ AHardwareBuffer* graphicBuffer, SkAlphaType alphaType, sk_sp<SkColorSpace> colorSpace,
+ GrSurfaceOrigin surfaceOrigin) {
AHardwareBuffer_Desc bufferDesc;
AHardwareBuffer_describe(graphicBuffer, &bufferDesc);
SkColorType colorType;
@@ -97,17 +98,19 @@
SkImageInfo info = SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType,
alphaType, std::move(colorSpace));
bool createProtectedImage = 0 != (bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
- return std::unique_ptr<SkImageGenerator>(new GrAHardwareBufferImageGenerator(info, graphicBuffer,
- alphaType, createProtectedImage, bufferDesc.format));
+ return std::unique_ptr<SkImageGenerator>(new GrAHardwareBufferImageGenerator(
+ info, graphicBuffer, alphaType, createProtectedImage,
+ bufferDesc.format, surfaceOrigin));
}
GrAHardwareBufferImageGenerator::GrAHardwareBufferImageGenerator(const SkImageInfo& info,
AHardwareBuffer* hardwareBuffer, SkAlphaType alphaType, bool isProtectedContent,
- uint32_t bufferFormat)
+ uint32_t bufferFormat, GrSurfaceOrigin surfaceOrigin)
: INHERITED(info)
, fHardwareBuffer(hardwareBuffer)
, fBufferFormat(bufferFormat)
- , fIsProtectedContent(isProtectedContent) {
+ , fIsProtectedContent(isProtectedContent)
+ , fSurfaceOrigin(surfaceOrigin) {
AHardwareBuffer_acquire(fHardwareBuffer);
}
@@ -545,7 +548,7 @@
return tex;
},
- desc, kTopLeft_GrSurfaceOrigin, GrMipMapped::kNo, textureType, SkBackingFit::kExact,
+ desc, fSurfaceOrigin, GrMipMapped::kNo, textureType, SkBackingFit::kExact,
SkBudgeted::kNo);
if (!texProxy) {