summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/VulkanManager.cpp
diff options
context:
space:
mode:
authorStan Iliev <stani@google.com>2019-09-17 14:07:23 -0400
committerStan Iliev <stani@google.com>2019-11-08 15:37:17 +0000
commitaaa9e834d443a56671eccbe97c755c253fa94afe (patch)
treee67daf0782137e572f6be35e9a24b146c4fd4b57 /libs/hwui/renderthread/VulkanManager.cpp
parent707ba29a6621220c2713468bf095178dcc1e376e (diff)
downloadbase-aaa9e834d443a56671eccbe97c755c253fa94afe.tar.gz
Decouple SurfaceTexture from HWUI
Remove all Skia and HWUI types from SurfaceTexture implementation. Move SurfaceTexture to libgui (ag/9578265). Define private C++ API for SurfaceTexture, which is consumed by DeferredLayerUpdater. Move AutoBackendTextureRelease/Skia code from SurfaceTexture to HWUI. Test: pass CtsUiRenderingTestCases and CtsViewTestCases Bug: 136263580 Change-Id: I3f971bb490f64a3ac0b2a66a89ba935bf7f08213
Diffstat (limited to 'libs/hwui/renderthread/VulkanManager.cpp')
-rw-r--r--libs/hwui/renderthread/VulkanManager.cpp46
1 files changed, 22 insertions, 24 deletions
diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp
index 35abc57fbe57..a5355fc3499d 100644
--- a/libs/hwui/renderthread/VulkanManager.cpp
+++ b/libs/hwui/renderthread/VulkanManager.cpp
@@ -16,23 +16,22 @@
#include "VulkanManager.h"
-#include <android/sync.h>
#include <EGL/egl.h>
#include <EGL/eglext.h>
-
-#include "Properties.h"
-#include "RenderThread.h"
-#include "renderstate/RenderState.h"
-#include "utils/FatVector.h"
-#include "utils/TraceUtils.h"
-
#include <GrBackendSemaphore.h>
#include <GrBackendSurface.h>
#include <GrContext.h>
#include <GrTypes.h>
+#include <android/sync.h>
#include <vk/GrVkExtensions.h>
#include <vk/GrVkTypes.h>
+#include "Properties.h"
+#include "RenderThread.h"
+#include "renderstate/RenderState.h"
+#include "utils/FatVector.h"
+#include "utils/TraceUtils.h"
+
namespace android {
namespace uirenderer {
namespace renderthread {
@@ -482,7 +481,7 @@ struct DestroySemaphoreInfo {
int mRefs = 2;
DestroySemaphoreInfo(PFN_vkDestroySemaphore destroyFunction, VkDevice device,
- VkSemaphore semaphore)
+ VkSemaphore semaphore)
: mDestroyFunction(destroyFunction), mDevice(device), mSemaphore(semaphore) {}
};
@@ -524,12 +523,11 @@ void VulkanManager::swapBuffers(VulkanSurface* surface, const SkRect& dirtyRect)
backendSemaphore.initVulkan(semaphore);
int fenceFd = -1;
- DestroySemaphoreInfo* destroyInfo = new DestroySemaphoreInfo(mDestroySemaphore, mDevice,
- semaphore);
- GrSemaphoresSubmitted submitted =
- bufferInfo->skSurface->flush(SkSurface::BackendSurfaceAccess::kPresent,
- kNone_GrFlushFlags, 1, &backendSemaphore,
- destroy_semaphore, destroyInfo);
+ DestroySemaphoreInfo* destroyInfo =
+ new DestroySemaphoreInfo(mDestroySemaphore, mDevice, semaphore);
+ GrSemaphoresSubmitted submitted = bufferInfo->skSurface->flush(
+ SkSurface::BackendSurfaceAccess::kPresent, kNone_GrFlushFlags, 1, &backendSemaphore,
+ destroy_semaphore, destroyInfo);
if (submitted == GrSemaphoresSubmitted::kYes) {
VkSemaphoreGetFdInfoKHR getFdInfo;
getFdInfo.sType = VK_STRUCTURE_TYPE_SEMAPHORE_GET_FD_INFO_KHR;
@@ -571,14 +569,14 @@ VulkanSurface* VulkanManager::createSurface(ANativeWindow* window, ColorMode col
*this, extraBuffers);
}
-status_t VulkanManager::fenceWait(sp<Fence>& fence, GrContext* grContext) {
+status_t VulkanManager::fenceWait(int fence, GrContext* grContext) {
if (!hasVkContext()) {
ALOGE("VulkanManager::fenceWait: VkDevice not initialized");
return INVALID_OPERATION;
}
// Block GPU on the fence.
- int fenceFd = fence->dup();
+ int fenceFd = ::dup(fence);
if (fenceFd == -1) {
ALOGE("VulkanManager::fenceWait: error dup'ing fence fd: %d", errno);
return -errno;
@@ -619,7 +617,8 @@ status_t VulkanManager::fenceWait(sp<Fence>& fence, GrContext* grContext) {
return OK;
}
-status_t VulkanManager::createReleaseFence(sp<Fence>& nativeFence, GrContext* grContext) {
+status_t VulkanManager::createReleaseFence(int* nativeFence, GrContext* grContext) {
+ *nativeFence = -1;
if (!hasVkContext()) {
ALOGE("VulkanManager::createReleaseFence: VkDevice not initialized");
return INVALID_OPERATION;
@@ -644,14 +643,13 @@ status_t VulkanManager::createReleaseFence(sp<Fence>& nativeFence, GrContext* gr
GrBackendSemaphore backendSemaphore;
backendSemaphore.initVulkan(semaphore);
- DestroySemaphoreInfo* destroyInfo = new DestroySemaphoreInfo(mDestroySemaphore, mDevice,
- semaphore);
+ DestroySemaphoreInfo* destroyInfo =
+ new DestroySemaphoreInfo(mDestroySemaphore, mDevice, semaphore);
// Even if Skia fails to submit the semaphore, it will still call the destroy_semaphore callback
// which will remove its ref to the semaphore. The VulkanManager must still release its ref,
// when it is done with the semaphore.
- GrSemaphoresSubmitted submitted =
- grContext->flush(kNone_GrFlushFlags, 1, &backendSemaphore,
- destroy_semaphore, destroyInfo);
+ GrSemaphoresSubmitted submitted = grContext->flush(kNone_GrFlushFlags, 1, &backendSemaphore,
+ destroy_semaphore, destroyInfo);
if (submitted == GrSemaphoresSubmitted::kNo) {
ALOGE("VulkanManager::createReleaseFence: Failed to submit semaphore");
@@ -673,7 +671,7 @@ status_t VulkanManager::createReleaseFence(sp<Fence>& nativeFence, GrContext* gr
ALOGE("VulkanManager::createReleaseFence: Failed to get semaphore Fd");
return INVALID_OPERATION;
}
- nativeFence = new Fence(fenceFd);
+ *nativeFence = fenceFd;
return OK;
}