Reland "[graphite] Add AHARDWAREBUFFER_FORMAT_B8G8R8A8_UNORM support"
This is a reland of commit 2b273431466193e5b257417e241ae597531846af
Original change's description:
> [graphite] Add AHARDWAREBUFFER_FORMAT_B8G8R8A8_UNORM support
>
> Change-Id: I21ee1d15bbcd8e5ca87e040464756ecc43e49472
> Bug: b/431290055
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1028696
> Commit-Queue: Nicolette Prevost <nicolettep@google.com>
> Reviewed-by: Michael Ludwig <michaelludwig@google.com>
> Commit-Queue: Michael Ludwig <michaelludwig@google.com>
> Auto-Submit: Nicolette Prevost <nicolettep@google.com>
Bug: b/431290055
Change-Id: I18241636c656773cf3efae340b7edb40fa8f3d07
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1029296
Commit-Queue: Nicolette Prevost <nicolettep@google.com>
Reviewed-by: Noelle Scobie <nscobie@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/gpu/android/AHardwareBufferUtils.cpp b/src/gpu/android/AHardwareBufferUtils.cpp
index d31c73d..246fe62 100644
--- a/src/gpu/android/AHardwareBufferUtils.cpp
+++ b/src/gpu/android/AHardwareBufferUtils.cpp
@@ -11,6 +11,12 @@
#include <android/hardware_buffer.h>
+#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
+// When building for the Android framework, there are formats defined outside of those publicly
+// available in android/hardware_buffer.h.
+#include <vndk/hardware_buffer.h>
+#endif
+
namespace AHardwareBufferUtils {
SkColorType GetSkColorTypeFromBufferFormat(uint32_t bufferFormat) {
@@ -35,6 +41,10 @@
case AHARDWAREBUFFER_FORMAT_R8_UNORM:
return kAlpha_8_SkColorType;
#endif
+#if defined(SK_BUILD_FOR_ANDROID_FRAMEWORK)
+ case AHARDWAREBUFFER_FORMAT_B8G8R8A8_UNORM:
+ return kBGRA_8888_SkColorType;
+#endif
default:
// Given that we only use this texture as a source, colorType will not impact how Skia
// uses the texture. The only potential affect this is anticipated to have is that for
@@ -46,4 +56,4 @@
} // namespace AHardwareBufferUtils
-#endif
+#endif // __ANDROID_API__ >= 26