Move GraphicBuffer back into libandroid_runtime.

Update Bitmap to store AHardwareBuffer instead of GraphicBuffer and
begin removing references to GraphicBuffer from the graphics JNI code

Test: CtsUiRenderingTestCases
Bug: 137655431
Change-Id: If533b6d87a87ae7e94a9b6f16fc52043714087df
diff --git a/core/jni/Android.bp b/core/jni/Android.bp
index 844a898..a542475 100644
--- a/core/jni/Android.bp
+++ b/core/jni/Android.bp
@@ -104,6 +104,7 @@
                 "android_database_SQLiteConnection.cpp",
                 "android_database_SQLiteGlobal.cpp",
                 "android_database_SQLiteDebug.cpp",
+                "android_graphics_GraphicBuffer.cpp",
                 "android_view_CompositionSamplingListener.cpp",
                 "android_view_DisplayEventReceiver.cpp",
                 "android_view_InputChannel.cpp",
@@ -421,7 +422,6 @@
                 "android_view_ThreadedRenderer.cpp",
                 "android/graphics/BitmapRegionDecoder.cpp",
                 "android/graphics/GIFMovie.cpp",
-                "android/graphics/GraphicBuffer.cpp",
                 "android/graphics/Movie.cpp",
                 "android/graphics/MovieImpl.cpp",
                 "android/graphics/SurfaceTexture.cpp",
diff --git a/core/jni/android/graphics/Bitmap.cpp b/core/jni/android/graphics/Bitmap.cpp
index f3abcf1..78e8e13 100755
--- a/core/jni/android/graphics/Bitmap.cpp
+++ b/core/jni/android/graphics/Bitmap.cpp
@@ -19,11 +19,10 @@
 #include <utils/Color.h>
 
 #ifdef __ANDROID__ // Layoutlib does not support graphic buffer, parcel or render thread
-#include "GraphicBuffer.h"
 #include <binder/Parcel.h>
 #include <renderthread/RenderProxy.h>
+#include <android_runtime/android_graphics_GraphicBuffer.h>
 #include <android_runtime/android_hardware_HardwareBuffer.h>
-
 #include <private/android/AHardwareBufferHelpers.h>
 #endif
 
@@ -1129,12 +1128,10 @@
 static jobject Bitmap_wrapHardwareBufferBitmap(JNIEnv* env, jobject, jobject hardwareBuffer,
                                                jlong colorSpacePtr) {
 #ifdef __ANDROID__ // Layoutlib does not support graphic buffer
-    AHardwareBuffer* hwBuf = android_hardware_HardwareBuffer_getNativeHardwareBuffer(env,
+    AHardwareBuffer* buffer = android_hardware_HardwareBuffer_getNativeHardwareBuffer(env,
         hardwareBuffer);
-    sp<GraphicBuffer> buffer(AHardwareBuffer_to_GraphicBuffer(hwBuf));
-    SkColorType ct = uirenderer::PixelFormatToColorType(buffer->getPixelFormat());
-    sk_sp<Bitmap> bitmap = Bitmap::createFrom(buffer, ct,
-            GraphicsJNI::getNativeColorSpace(colorSpacePtr));
+    sk_sp<Bitmap> bitmap = Bitmap::createFrom(buffer,
+                                              GraphicsJNI::getNativeColorSpace(colorSpacePtr));
     if (!bitmap.get()) {
         ALOGW("failed to create hardware bitmap from hardware buffer");
         return NULL;
@@ -1151,9 +1148,8 @@
     LOG_ALWAYS_FATAL_IF(!bitmapHandle->isHardware(),
             "Hardware config is only supported config in Bitmap_getGraphicBuffer");
 
-    Bitmap& hwuiBitmap = bitmapHandle->bitmap();
-    sp<GraphicBuffer> buffer(hwuiBitmap.graphicBuffer());
-    return createJavaGraphicBuffer(env, buffer);
+    Bitmap& bitmap = bitmapHandle->bitmap();
+    return android_graphics_GraphicBuffer_createFromAHardwareBuffer(env, bitmap.hardwareBuffer());
 #else
     return NULL;
 #endif
diff --git a/core/jni/android/graphics/GraphicBuffer.cpp b/core/jni/android_graphics_GraphicBuffer.cpp
similarity index 95%
rename from core/jni/android/graphics/GraphicBuffer.cpp
rename to core/jni/android_graphics_GraphicBuffer.cpp
index 344e22c..bb9254c 100644
--- a/core/jni/android/graphics/GraphicBuffer.cpp
+++ b/core/jni/android_graphics_GraphicBuffer.cpp
@@ -21,10 +21,10 @@
 #include <inttypes.h>
 
 #include "android_os_Parcel.h"
-#include "GraphicBuffer.h"
-#include "GraphicsJNI.h"
+#include "android/graphics/GraphicsJNI.h"
 
 #include <android_runtime/AndroidRuntime.h>
+#include <android_runtime/android_graphics_GraphicBuffer.h>
 
 #include <binder/Parcel.h>
 
@@ -266,7 +266,7 @@
 // External helpers
 // ----------------------------------------------------------------------------
 
-sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj) {
+sp<GraphicBuffer> android_graphics_GraphicBuffer_getNativeGraphicsBuffer(JNIEnv* env, jobject obj) {
     if (obj) {
         jlong nativeObject = env->GetLongField(obj, gGraphicBufferClassInfo.mNativeObject);
         GraphicBufferWrapper* wrapper = (GraphicBufferWrapper*) nativeObject;
@@ -278,7 +278,9 @@
     return NULL;
 }
 
-jobject createJavaGraphicBuffer(JNIEnv* env, const sp<GraphicBuffer>& buffer) {
+jobject android_graphics_GraphicBuffer_createFromAHardwareBuffer(JNIEnv* env,
+                                                                 AHardwareBuffer* hardwareBuffer) {
+    GraphicBuffer* buffer = GraphicBuffer::fromAHardwareBuffer(hardwareBuffer);
     GraphicBufferWrapper* wrapper = new GraphicBufferWrapper(buffer);
     jobject obj = env->NewObject(gGraphicBufferClassInfo.mClass,
             gGraphicBufferClassInfo.mConstructorMethodID, buffer->getWidth(), buffer->getHeight(),
diff --git a/core/jni/android_hardware_HardwareBuffer.cpp b/core/jni/android_hardware_HardwareBuffer.cpp
index 706a2b8..e78e08e 100644
--- a/core/jni/android_hardware_HardwareBuffer.cpp
+++ b/core/jni/android_hardware_HardwareBuffer.cpp
@@ -20,9 +20,9 @@
 #include <nativehelper/JNIHelp.h>
 
 #include "android_os_Parcel.h"
-#include "android/graphics/GraphicBuffer.h"
 
 #include <android/hardware_buffer.h>
+#include <android_runtime/android_graphics_GraphicBuffer.h>
 #include <android_runtime/android_hardware_HardwareBuffer.h>
 #include <android_runtime/AndroidRuntime.h>
 #include <android_runtime/Log.h>
@@ -97,7 +97,8 @@
 }
 
 static jlong android_hardware_HardwareBuffer_createFromGraphicBuffer(JNIEnv* env, jobject clazz, jobject graphicBuffer) {
-    sp<GraphicBuffer> buffer(graphicBufferForJavaObject(env, graphicBuffer));
+    sp<GraphicBuffer> buffer(android_graphics_GraphicBuffer_getNativeGraphicsBuffer(env,
+                                                                                    graphicBuffer));
     GraphicBufferWrapper* wrapper = new GraphicBufferWrapper(buffer);
     return reinterpret_cast<jlong>(wrapper);
 }
diff --git a/core/jni/android_view_Surface.cpp b/core/jni/android_view_Surface.cpp
index 8eb9c9a..d65e252 100644
--- a/core/jni/android_view_Surface.cpp
+++ b/core/jni/android_view_Surface.cpp
@@ -21,12 +21,12 @@
 #include "jni.h"
 #include <nativehelper/JNIHelp.h>
 #include "android_os_Parcel.h"
-#include "android/graphics/GraphicBuffer.h"
 #include "android/graphics/GraphicsJNI.h"
 
 #include "core_jni_helpers.h"
-#include <android_runtime/android_view_Surface.h>
+#include <android_runtime/android_graphics_GraphicBuffer.h>
 #include <android_runtime/android_graphics_SurfaceTexture.h>
+#include <android_runtime/android_view_Surface.h>
 #include <android_runtime/Log.h>
 
 #include <binder/Parcel.h>
@@ -35,6 +35,7 @@
 #include <gui/view/Surface.h>
 #include <gui/SurfaceControl.h>
 
+#include <ui/GraphicBuffer.h>
 #include <ui/Rect.h>
 #include <ui/Region.h>
 
@@ -432,8 +433,9 @@
 static jint nativeAttachAndQueueBufferWithColorSpace(JNIEnv *env, jclass clazz, jlong nativeObject,
         jobject graphicBuffer, jint colorSpaceId) {
     Surface* surface = reinterpret_cast<Surface*>(nativeObject);
-    sp<GraphicBuffer> bp = graphicBufferForJavaObject(env, graphicBuffer);
-    int err = Surface::attachAndQueueBufferWithDataspace(surface, bp,
+    sp<GraphicBuffer> gb(android_graphics_GraphicBuffer_getNativeGraphicsBuffer(env,
+                                                                                graphicBuffer));
+    int err = Surface::attachAndQueueBufferWithDataspace(surface, gb,
             fromNamedColorSpaceValueToDataspace(colorSpaceId));
     return err;
 }
diff --git a/core/jni/android_view_ThreadedRenderer.cpp b/core/jni/android_view_ThreadedRenderer.cpp
index b0443a8..dd3a4d0 100644
--- a/core/jni/android_view_ThreadedRenderer.cpp
+++ b/core/jni/android_view_ThreadedRenderer.cpp
@@ -520,14 +520,13 @@
         // Continue I guess?
     }
 
-    SkColorType ct = uirenderer::PixelFormatToColorType(buffer->getPixelFormat());
     sk_sp<SkColorSpace> cs = uirenderer::DataSpaceToColorSpace(bufferItem.mDataSpace);
     if (cs == nullptr) {
         // nullptr is treated as SRGB in Skia, thus explicitly use SRGB in order to make sure
         // the returned bitmap has a color space.
         cs = SkColorSpace::MakeSRGB();
     }
-    sk_sp<Bitmap> bitmap = Bitmap::createFrom(buffer, ct, cs);
+    sk_sp<Bitmap> bitmap = Bitmap::createFrom(buffer->toAHardwareBuffer(), cs);
     return bitmap::createBitmap(env, bitmap.release(),
             android::bitmap::kBitmapCreateFlag_Premultiplied);
 }
diff --git a/core/jni/android/graphics/GraphicBuffer.h b/core/jni/include/android_runtime/android_graphics_GraphicBuffer.h
similarity index 69%
rename from core/jni/android/graphics/GraphicBuffer.h
rename to core/jni/include/android_runtime/android_graphics_GraphicBuffer.h
index 0d72669..5f15faa 100644
--- a/core/jni/android/graphics/GraphicBuffer.h
+++ b/core/jni/include/android_runtime/android_graphics_GraphicBuffer.h
@@ -14,16 +14,19 @@
  * limitations under the License.
  */
 
-#include <ui/GraphicBuffer.h>
+#include <android/hardware_buffer.h>
 
 #include "jni.h"
 
 namespace android {
 
+class GraphicBuffer;
+
 // This function does not perform any type checking, the specified
 // object must be an instance of android.view.GraphicBuffer
-extern sp<GraphicBuffer> graphicBufferForJavaObject(JNIEnv* env, jobject obj);
+sp<GraphicBuffer> android_graphics_GraphicBuffer_getNativeGraphicsBuffer(JNIEnv* env, jobject obj);
 
-jobject createJavaGraphicBuffer(JNIEnv* env, const sp<GraphicBuffer>& buffer);
+extern jobject android_graphics_GraphicBuffer_createFromAHardwareBuffer(JNIEnv* env,
+                                                                        AHardwareBuffer* buffer);
 
 }
diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp
index 0d837f2..ae90f11 100644
--- a/libs/hwui/Android.bp
+++ b/libs/hwui/Android.bp
@@ -88,6 +88,7 @@
                 "libvulkan",
                 "libui",
                 "libgui",
+                "libnativewindow",
                 "libprotobuf-cpp-lite",
                 "libft2",
                 "libandroidfw",
diff --git a/libs/hwui/HardwareBitmapUploader.cpp b/libs/hwui/HardwareBitmapUploader.cpp
index 9bb6031..40bff88 100644
--- a/libs/hwui/HardwareBitmapUploader.cpp
+++ b/libs/hwui/HardwareBitmapUploader.cpp
@@ -403,8 +403,9 @@
     if (!sUploader->uploadHardwareBitmap(bitmap, format, buffer)) {
         return nullptr;
     }
-    return Bitmap::createFrom(buffer, bitmap.colorType(), bitmap.refColorSpace(),
-                              bitmap.alphaType(), Bitmap::computePalette(bitmap));
+    return Bitmap::createFrom(buffer->toAHardwareBuffer(), bitmap.colorType(),
+                              bitmap.refColorSpace(), bitmap.alphaType(),
+			      Bitmap::computePalette(bitmap));
 }
 
 void HardwareBitmapUploader::initialize() {
diff --git a/libs/hwui/hwui/Bitmap.cpp b/libs/hwui/hwui/Bitmap.cpp
index 4c2f0ad..a1be5b7 100644
--- a/libs/hwui/hwui/Bitmap.cpp
+++ b/libs/hwui/hwui/Bitmap.cpp
@@ -148,12 +148,26 @@
 
 
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
-sk_sp<Bitmap> Bitmap::createFrom(sp<GraphicBuffer> graphicBuffer, SkColorType colorType,
+sk_sp<Bitmap> Bitmap::createFrom(AHardwareBuffer* hardwareBuffer, sk_sp<SkColorSpace> colorSpace,
+                                 BitmapPalette palette) {
+    AHardwareBuffer_Desc bufferDesc;
+    AHardwareBuffer_describe(hardwareBuffer, &bufferDesc);
+    SkImageInfo info = uirenderer::BufferDescriptionToImageInfo(bufferDesc, colorSpace);
+
+    const size_t rowBytes = info.bytesPerPixel() * bufferDesc.stride;
+    return sk_sp<Bitmap>(new Bitmap(hardwareBuffer, info, rowBytes, palette));
+}
+
+sk_sp<Bitmap> Bitmap::createFrom(AHardwareBuffer* hardwareBuffer, SkColorType colorType,
                                  sk_sp<SkColorSpace> colorSpace, SkAlphaType alphaType,
                                  BitmapPalette palette) {
-    SkImageInfo info = SkImageInfo::Make(graphicBuffer->getWidth(), graphicBuffer->getHeight(),
+    AHardwareBuffer_Desc bufferDesc;
+    AHardwareBuffer_describe(hardwareBuffer, &bufferDesc);
+    SkImageInfo info = SkImageInfo::Make(bufferDesc.width, bufferDesc.height,
                                          colorType, alphaType, colorSpace);
-    return sk_sp<Bitmap>(new Bitmap(graphicBuffer.get(), info, palette));
+
+    const size_t rowBytes = info.bytesPerPixel() * bufferDesc.stride;
+    return sk_sp<Bitmap>(new Bitmap(hardwareBuffer, info, rowBytes, palette));
 }
 #endif
 
@@ -238,18 +252,17 @@
 }
 
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
-Bitmap::Bitmap(GraphicBuffer* buffer, const SkImageInfo& info, BitmapPalette palette)
-        : SkPixelRef(info.width(), info.height(), nullptr,
-                     bytesPerPixel(buffer->getPixelFormat()) * buffer->getStride())
+Bitmap::Bitmap(AHardwareBuffer* buffer, const SkImageInfo& info, size_t rowBytes,
+               BitmapPalette palette)
+        : SkPixelRef(info.width(), info.height(), nullptr, rowBytes)
         , mInfo(validateAlpha(info))
         , mPixelStorageType(PixelStorageType::Hardware)
         , mPalette(palette)
         , mPaletteGenerationId(getGenerationID()) {
     mPixelStorage.hardware.buffer = buffer;
-    buffer->incStrong(buffer);
+    AHardwareBuffer_acquire(buffer);
     setImmutable();  // HW bitmaps are always immutable
-    mImage = SkImage::MakeFromAHardwareBuffer(reinterpret_cast<AHardwareBuffer*>(buffer),
-                                              mInfo.alphaType(), mInfo.refColorSpace());
+    mImage = SkImage::MakeFromAHardwareBuffer(buffer, mInfo.alphaType(), mInfo.refColorSpace());
 }
 #endif
 
@@ -274,7 +287,7 @@
         case PixelStorageType::Hardware:
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
             auto buffer = mPixelStorage.hardware.buffer;
-            buffer->decStrong(buffer);
+            AHardwareBuffer_release(buffer);
             mPixelStorage.hardware.buffer = nullptr;
 #endif
             break;
@@ -352,7 +365,7 @@
 }
 
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
-GraphicBuffer* Bitmap::graphicBuffer() {
+AHardwareBuffer* Bitmap::hardwareBuffer() {
     if (isHardware()) {
         return mPixelStorage.hardware.buffer;
     }
diff --git a/libs/hwui/hwui/Bitmap.h b/libs/hwui/hwui/Bitmap.h
index c7e18d1..00733c6 100644
--- a/libs/hwui/hwui/Bitmap.h
+++ b/libs/hwui/hwui/Bitmap.h
@@ -24,7 +24,7 @@
 #include <SkPixelRef.h>
 #include <cutils/compiler.h>
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
-#include <ui/GraphicBuffer.h>
+#include <android/hardware_buffer.h>
 #endif
 
 namespace android {
@@ -74,11 +74,15 @@
      * memory that is provided as an input param.
      */
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
-    static sk_sp<Bitmap> createFrom(sp<GraphicBuffer> graphicBuffer,
+    static sk_sp<Bitmap> createFrom(AHardwareBuffer* hardwareBuffer,
+                                    sk_sp<SkColorSpace> colorSpace,
+                                    BitmapPalette palette = BitmapPalette::Unknown);
+
+    static sk_sp<Bitmap> createFrom(AHardwareBuffer* hardwareBuffer,
                                     SkColorType colorType,
                                     sk_sp<SkColorSpace> colorSpace,
-                                    SkAlphaType alphaType = kPremul_SkAlphaType,
-                                    BitmapPalette palette = BitmapPalette::Unknown);
+                                    SkAlphaType alphaType,
+                                    BitmapPalette palette);
 #endif
     static sk_sp<Bitmap> createFrom(const SkImageInfo& info, size_t rowBytes, int fd, void* addr,
                                     size_t size, bool readOnly);
@@ -110,7 +114,7 @@
     PixelStorageType pixelStorageType() const { return mPixelStorageType; }
 
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
-    GraphicBuffer* graphicBuffer();
+     AHardwareBuffer* hardwareBuffer();
 #endif
 
     /**
@@ -143,7 +147,8 @@
            size_t rowBytes);
     Bitmap(void* address, int fd, size_t mappedSize, const SkImageInfo& info, size_t rowBytes);
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
-    Bitmap(GraphicBuffer* buffer, const SkImageInfo& info, BitmapPalette palette);
+    Bitmap(AHardwareBuffer* buffer, const SkImageInfo& info, size_t rowBytes,
+           BitmapPalette palette);
 #endif
 
     virtual ~Bitmap();
@@ -175,7 +180,7 @@
         } heap;
 #ifdef __ANDROID__ // Layoutlib does not support hardware acceleration
         struct {
-            GraphicBuffer* buffer;
+            AHardwareBuffer* buffer;
         } hardware;
 #endif
     } mPixelStorage;
diff --git a/libs/hwui/renderthread/VulkanSurface.h b/libs/hwui/renderthread/VulkanSurface.h
index 5717bb3..bd23626 100644
--- a/libs/hwui/renderthread/VulkanSurface.h
+++ b/libs/hwui/renderthread/VulkanSurface.h
@@ -18,6 +18,7 @@
 #include <system/graphics.h>
 #include <system/window.h>
 #include <ui/BufferQueueDefs.h>
+#include <ui/PixelFormat.h>
 #include <vulkan/vulkan.h>
 
 #include <SkRefCnt.h>
diff --git a/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp b/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp
index 3d0a2b2..5886ea3 100644
--- a/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp
+++ b/libs/hwui/tests/common/scenes/HwBitmapInCompositeShader.cpp
@@ -50,7 +50,7 @@
             pixels[4000 + 4 * i + 3] = 255;
         }
         buffer->unlock();
-        sk_sp<Bitmap> hardwareBitmap(Bitmap::createFrom(buffer, kRGBA_8888_SkColorType,
+        sk_sp<Bitmap> hardwareBitmap(Bitmap::createFrom(buffer->toAHardwareBuffer(),
                                                         SkColorSpace::MakeSRGB()));
         sk_sp<SkShader> hardwareShader(createBitmapShader(*hardwareBitmap));
 
diff --git a/libs/hwui/utils/Color.cpp b/libs/hwui/utils/Color.cpp
index cc7725b..9a27f28 100644
--- a/libs/hwui/utils/Color.cpp
+++ b/libs/hwui/utils/Color.cpp
@@ -19,12 +19,50 @@
 #include <utils/Log.h>
 #include <ui/ColorSpace.h>
 
+#ifdef __ANDROID__ // Layoutlib does not support hardware buffers or native windows
+#include <android/hardware_buffer.h>
+#endif
+
 #include <algorithm>
 #include <cmath>
 
 namespace android {
 namespace uirenderer {
 
+#ifdef __ANDROID__ // Layoutlib does not support hardware buffers or native windows
+SkImageInfo BufferDescriptionToImageInfo(const AHardwareBuffer_Desc& bufferDesc,
+                                         sk_sp<SkColorSpace> colorSpace) {
+    SkColorType colorType = kUnknown_SkColorType;
+    SkAlphaType alphaType = kOpaque_SkAlphaType;
+    switch (bufferDesc.format) {
+        case AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM:
+            colorType = kN32_SkColorType;
+            alphaType = kPremul_SkAlphaType;
+            break;
+        case AHARDWAREBUFFER_FORMAT_R8G8B8X8_UNORM:
+            colorType = kN32_SkColorType;
+            alphaType = kOpaque_SkAlphaType;
+            break;
+        case AHARDWAREBUFFER_FORMAT_R5G6B5_UNORM:
+            colorType = kRGB_565_SkColorType;
+            alphaType = kOpaque_SkAlphaType;
+            break;
+        case AHARDWAREBUFFER_FORMAT_R10G10B10A2_UNORM:
+            colorType = kRGBA_1010102_SkColorType;
+            alphaType = kPremul_SkAlphaType;
+            break;
+        case AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT:
+            colorType = kRGBA_F16_SkColorType;
+            alphaType = kPremul_SkAlphaType;
+            break;
+        default:
+            ALOGV("Unsupported format: %d, return unknown by default", bufferDesc.format);
+            break;
+    }
+    return SkImageInfo::Make(bufferDesc.width, bufferDesc.height, colorType, alphaType, colorSpace);
+}
+#endif
+
 android::PixelFormat ColorTypeToPixelFormat(SkColorType colorType) {
     switch (colorType) {
         case kRGBA_8888_SkColorType:
diff --git a/libs/hwui/utils/Color.h b/libs/hwui/utils/Color.h
index 79400de..7c2378a 100644
--- a/libs/hwui/utils/Color.h
+++ b/libs/hwui/utils/Color.h
@@ -25,6 +25,8 @@
 #include <SkColorSpace.h>
 #include <SkImageInfo.h>
 
+struct AHardwareBuffer_Desc;
+
 namespace android {
 namespace uirenderer {
 namespace Color {
@@ -89,6 +91,9 @@
     return srgb <= 0.04045f ? srgb / 12.92f : powf((srgb + 0.055f) / 1.055f, 2.4f);
 }
 
+SkImageInfo BufferDescriptionToImageInfo(const AHardwareBuffer_Desc& bufferDesc,
+                                         sk_sp<SkColorSpace> colorSpace);
+
 android::PixelFormat ColorTypeToPixelFormat(SkColorType colorType);
 ANDROID_API SkColorType PixelFormatToColorType(android::PixelFormat format);