[HWUI] remove libui from HWUI's dependencies
Bug: 136263238
Test: builds
Test: interact with device
Change-Id: I18540f78a4ee5ffcc30c96ff7862480e1d8fe50a
diff --git a/libs/hwui/renderthread/EglManager.h b/libs/hwui/renderthread/EglManager.h
index a893e24..f67fb31 100644
--- a/libs/hwui/renderthread/EglManager.h
+++ b/libs/hwui/renderthread/EglManager.h
@@ -21,7 +21,6 @@
#include <SkImageInfo.h>
#include <SkRect.h>
#include <cutils/compiler.h>
-#include <ui/GraphicBuffer.h>
#include <utils/StrongPointer.h>
#include "IRenderPipeline.h"
diff --git a/libs/hwui/renderthread/ReliableSurface.cpp b/libs/hwui/renderthread/ReliableSurface.cpp
index 8a0b4e8..14a4c28 100644
--- a/libs/hwui/renderthread/ReliableSurface.cpp
+++ b/libs/hwui/renderthread/ReliableSurface.cpp
@@ -143,21 +143,25 @@
return AHardwareBuffer_to_ANativeWindowBuffer(mScratchBuffer.get());
}
- AHardwareBuffer_Desc desc;
- desc.usage = mUsage;
- desc.format = mFormat;
- desc.width = 1;
- desc.height = 1;
- desc.layers = 1;
- desc.rfu0 = 0;
- desc.rfu1 = 0;
- AHardwareBuffer* newBuffer = nullptr;
- int err = AHardwareBuffer_allocate(&desc, &newBuffer);
- if (err) {
+ AHardwareBuffer_Desc desc = AHardwareBuffer_Desc{
+ .usage = mUsage,
+ .format = mFormat,
+ .width = 1,
+ .height = 1,
+ .layers = 1,
+ .rfu0 = 0,
+ .rfu1 = 0,
+ };
+
+ AHardwareBuffer* newBuffer;
+ int result = AHardwareBuffer_allocate(&desc, &newBuffer);
+
+ if (result != NO_ERROR) {
// Allocate failed, that sucks
- ALOGW("Failed to allocate scratch buffer, error=%d", err);
+ ALOGW("Failed to allocate scratch buffer, error=%d", result);
return nullptr;
}
+
mScratchBuffer.reset(newBuffer);
return AHardwareBuffer_to_ANativeWindowBuffer(newBuffer);
}
diff --git a/libs/hwui/renderthread/ReliableSurface.h b/libs/hwui/renderthread/ReliableSurface.h
index 58cd067..c80a7ea 100644
--- a/libs/hwui/renderthread/ReliableSurface.h
+++ b/libs/hwui/renderthread/ReliableSurface.h
@@ -20,6 +20,7 @@
#include <apex/window.h>
#include <utils/Errors.h>
#include <utils/Macros.h>
+#include <utils/NdkUtils.h>
#include <utils/StrongPointer.h>
#include <memory>
@@ -56,8 +57,7 @@
uint64_t mUsage = AHARDWAREBUFFER_USAGE_GPU_FRAMEBUFFER;
AHardwareBuffer_Format mFormat = AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM;
- std::unique_ptr<AHardwareBuffer, void (*)(AHardwareBuffer*)> mScratchBuffer{
- nullptr, AHardwareBuffer_release};
+ UniqueAHardwareBuffer mScratchBuffer;
ANativeWindowBuffer* mReservedBuffer = nullptr;
base::unique_fd mReservedFenceFd;
bool mHasDequeuedBuffer = false;
diff --git a/libs/hwui/renderthread/VulkanSurface.cpp b/libs/hwui/renderthread/VulkanSurface.cpp
index a7ea21d..9cbb754b 100644
--- a/libs/hwui/renderthread/VulkanSurface.cpp
+++ b/libs/hwui/renderthread/VulkanSurface.cpp
@@ -207,9 +207,9 @@
}
}
- outWindowInfo->pixelFormat = ColorTypeToPixelFormat(colorType);
+ outWindowInfo->bufferFormat = ColorTypeToBufferFormat(colorType);
VkFormat vkPixelFormat = VK_FORMAT_R8G8B8A8_UNORM;
- if (outWindowInfo->pixelFormat == PIXEL_FORMAT_RGBA_FP16) {
+ if (outWindowInfo->bufferFormat == AHARDWAREBUFFER_FORMAT_R16G16B16A16_FLOAT) {
vkPixelFormat = VK_FORMAT_R16G16B16A16_SFLOAT;
}
@@ -263,10 +263,10 @@
bool VulkanSurface::UpdateWindow(ANativeWindow* window, const WindowInfo& windowInfo) {
ATRACE_CALL();
- int err = native_window_set_buffers_format(window, windowInfo.pixelFormat);
+ int err = native_window_set_buffers_format(window, windowInfo.bufferFormat);
if (err != 0) {
ALOGE("VulkanSurface::UpdateWindow() native_window_set_buffers_format(%d) failed: %s (%d)",
- windowInfo.pixelFormat, strerror(-err), err);
+ windowInfo.bufferFormat, strerror(-err), err);
return false;
}
diff --git a/libs/hwui/renderthread/VulkanSurface.h b/libs/hwui/renderthread/VulkanSurface.h
index bd23626..40a44b1 100644
--- a/libs/hwui/renderthread/VulkanSurface.h
+++ b/libs/hwui/renderthread/VulkanSurface.h
@@ -17,8 +17,6 @@
#include <system/graphics.h>
#include <system/window.h>
-#include <ui/BufferQueueDefs.h>
-#include <ui/PixelFormat.h>
#include <vulkan/vulkan.h>
#include <SkRefCnt.h>
@@ -91,7 +89,7 @@
struct WindowInfo {
SkISize size;
- PixelFormat pixelFormat;
+ uint32_t bufferFormat;
android_dataspace dataspace;
int transform;
size_t bufferCount;
@@ -111,8 +109,13 @@
static bool UpdateWindow(ANativeWindow* window, const WindowInfo& windowInfo);
void releaseBuffers();
+ // TODO: This number comes from ui/BufferQueueDefs. We're not pulling the
+ // header in so that we don't need to depend on libui, but we should share
+ // this constant somewhere. But right now it's okay to keep here because we
+ // can't safely change the slot count anyways.
+ static constexpr size_t kNumBufferSlots = 64;
// TODO: Just use a vector?
- NativeBufferInfo mNativeBuffers[android::BufferQueueDefs::NUM_BUFFER_SLOTS];
+ NativeBufferInfo mNativeBuffers[kNumBufferSlots];
sp<ANativeWindow> mNativeWindow;
WindowInfo mWindowInfo;