Store whether or not a VkImage is from a swapchain and return it in drawable info.
This is done for webview which needs to know whether it is drawing directly into the main window surface or in a layer. Change-Id: I0a3f6f81bcf65907f9d51651035bae912c3a34ac Reviewed-on: https://skia-review.googlesource.com/c/skia/+/468616 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com>
This commit is contained in:
parent
8a4ba51fa7
commit
2211c2c4bd
@ -374,13 +374,19 @@ public:
|
||||
@param colorSpace range of colors; may be nullptr
|
||||
@param surfaceProps LCD striping orientation and setting for device independent
|
||||
fonts; may be nullptr
|
||||
@param fromWindow Whether or not the AHardwareBuffer is part of an Android Window.
|
||||
Currently only used with Vulkan backend.
|
||||
@return created SkSurface, or nullptr
|
||||
*/
|
||||
static sk_sp<SkSurface> MakeFromAHardwareBuffer(GrDirectContext* context,
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
GrSurfaceOrigin origin,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* surfaceProps);
|
||||
const SkSurfaceProps* surfaceProps
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
, bool fromWindow = false
|
||||
#endif // SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
);
|
||||
#endif
|
||||
|
||||
#ifdef SK_METAL
|
||||
|
@ -109,16 +109,27 @@ struct GrVkImageInfo {
|
||||
GrProtected fProtected = GrProtected::kNo;
|
||||
GrVkYcbcrConversionInfo fYcbcrConversionInfo;
|
||||
VkSharingMode fSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
bool fPartOfSwapchainOrAndroidWindow = false;
|
||||
#endif
|
||||
|
||||
#if GR_TEST_UTILS
|
||||
bool operator==(const GrVkImageInfo& that) const {
|
||||
return fImage == that.fImage && fAlloc == that.fAlloc &&
|
||||
fImageTiling == that.fImageTiling && fImageLayout == that.fImageLayout &&
|
||||
fFormat == that.fFormat && fImageUsageFlags == that.fImageUsageFlags &&
|
||||
fSampleCount == that.fSampleCount && fLevelCount == that.fLevelCount &&
|
||||
fCurrentQueueFamily == that.fCurrentQueueFamily && fProtected == that.fProtected &&
|
||||
bool equal = fImage == that.fImage && fAlloc == that.fAlloc &&
|
||||
fImageTiling == that.fImageTiling &&
|
||||
fImageLayout == that.fImageLayout &&
|
||||
fFormat == that.fFormat &&
|
||||
fImageUsageFlags == that.fImageUsageFlags &&
|
||||
fSampleCount == that.fSampleCount &&
|
||||
fLevelCount == that.fLevelCount &&
|
||||
fCurrentQueueFamily == that.fCurrentQueueFamily &&
|
||||
fProtected == that.fProtected &&
|
||||
fYcbcrConversionInfo == that.fYcbcrConversionInfo &&
|
||||
fSharingMode == that.fSharingMode;
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
equal = equal && (fPartOfSwapchainOrAndroidWindow == that.fPartOfSwapchainOrAndroidWindow);
|
||||
#endif
|
||||
return equal;
|
||||
}
|
||||
#endif
|
||||
};
|
||||
@ -149,8 +160,6 @@ using GrVkGetProc = std::function<PFN_vkVoidFunction(
|
||||
* to render offscreen textures which will be sampled in draws added to the passed in
|
||||
* VkCommandBuffer. If this is done the SkDrawable is in charge of adding the required memory
|
||||
* barriers to the queue for the sampled images since the Skia backend will not do this.
|
||||
*
|
||||
* The VkImage is informational only and should not be used or modified in any ways.
|
||||
*/
|
||||
struct GrVkDrawableInfo {
|
||||
VkCommandBuffer fSecondaryCommandBuffer;
|
||||
@ -158,7 +167,9 @@ struct GrVkDrawableInfo {
|
||||
VkRenderPass fCompatibleRenderPass;
|
||||
VkFormat fFormat;
|
||||
VkRect2D* fDrawBounds;
|
||||
VkImage fImage;
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
bool fFromSwapchainOrAndroidWindow;
|
||||
#endif
|
||||
};
|
||||
|
||||
struct GrVkSurfaceInfo {
|
||||
|
@ -306,7 +306,8 @@ static GrBackendTexture make_vk_backend_texture(
|
||||
TexImageCtx* imageCtx,
|
||||
bool isProtectedContent,
|
||||
const GrBackendFormat& backendFormat,
|
||||
bool isRenderable) {
|
||||
bool isRenderable,
|
||||
bool fromAndroidWindow) {
|
||||
SkASSERT(dContext->backend() == GrBackendApi::kVulkan);
|
||||
GrVkGpu* gpu = static_cast<GrVkGpu*>(dContext->priv().getGpu());
|
||||
|
||||
@ -495,6 +496,9 @@ static GrBackendTexture make_vk_backend_texture(
|
||||
imageInfo.fProtected = isProtectedContent ? GrProtected::kYes : GrProtected::kNo;
|
||||
imageInfo.fYcbcrConversionInfo = *ycbcrConversion;
|
||||
imageInfo.fSharingMode = imageCreateInfo.sharingMode;
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
imageInfo.fPartOfSwapchainOrAndroidWindow = fromAndroidWindow;
|
||||
#endif
|
||||
|
||||
*deleteProc = delete_vk_image;
|
||||
*updateProc = update_vk_image;
|
||||
@ -539,7 +543,8 @@ GrBackendTexture MakeBackendTexture(GrDirectContext* dContext, AHardwareBuffer*
|
||||
TexImageCtx* imageCtx,
|
||||
bool isProtectedContent,
|
||||
const GrBackendFormat& backendFormat,
|
||||
bool isRenderable) {
|
||||
bool isRenderable,
|
||||
bool fromAndroidWindow) {
|
||||
SkASSERT(dContext);
|
||||
if (!dContext || dContext->abandoned()) {
|
||||
return GrBackendTexture();
|
||||
@ -555,7 +560,7 @@ GrBackendTexture MakeBackendTexture(GrDirectContext* dContext, AHardwareBuffer*
|
||||
#ifdef SK_VULKAN
|
||||
return make_vk_backend_texture(dContext, hardwareBuffer, width, height, deleteProc,
|
||||
updateProc, imageCtx, createProtectedImage, backendFormat,
|
||||
isRenderable);
|
||||
isRenderable, fromAndroidWindow);
|
||||
#else
|
||||
return GrBackendTexture();
|
||||
#endif
|
||||
|
@ -60,7 +60,8 @@ GrBackendTexture MakeBackendTexture(GrDirectContext* context, AHardwareBuffer* h
|
||||
TexImageCtx* imageCtx,
|
||||
bool isProtectedContent,
|
||||
const GrBackendFormat& backendFormat,
|
||||
bool isRenderable);
|
||||
bool isRenderable,
|
||||
bool fromAndroidWindow = false);
|
||||
|
||||
} // GrAHardwareBufferUtils
|
||||
|
||||
|
@ -860,9 +860,8 @@ void GrVkOpsRenderPass::onExecuteDrawable(std::unique_ptr<SkDrawable::GpuDrawHan
|
||||
vkInfo.fFormat = fFramebuffer->colorAttachment()->imageFormat();
|
||||
vkInfo.fDrawBounds = &bounds;
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
vkInfo.fImage = fFramebuffer->colorAttachment()->image();
|
||||
#else
|
||||
vkInfo.fImage = VK_NULL_HANDLE;
|
||||
vkInfo.fFromSwapchainOrAndroidWindow =
|
||||
fFramebuffer->colorAttachment()->vkImageInfo().fPartOfSwapchainOrAndroidWindow;
|
||||
#endif //SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
|
||||
GrBackendDrawableInfo info(vkInfo);
|
||||
|
@ -640,7 +640,11 @@ sk_sp<SkSurface> SkSurface::MakeFromAHardwareBuffer(GrDirectContext* dContext,
|
||||
AHardwareBuffer* hardwareBuffer,
|
||||
GrSurfaceOrigin origin,
|
||||
sk_sp<SkColorSpace> colorSpace,
|
||||
const SkSurfaceProps* surfaceProps) {
|
||||
const SkSurfaceProps* surfaceProps
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
, bool fromWindow
|
||||
#endif
|
||||
) {
|
||||
AHardwareBuffer_Desc bufferDesc;
|
||||
AHardwareBuffer_describe(hardwareBuffer, &bufferDesc);
|
||||
|
||||
@ -666,12 +670,23 @@ sk_sp<SkSurface> SkSurface::MakeFromAHardwareBuffer(GrDirectContext* dContext,
|
||||
bool isProtectedContent =
|
||||
SkToBool(bufferDesc.usage & AHARDWAREBUFFER_USAGE_PROTECTED_CONTENT);
|
||||
|
||||
bool fromWindowLocal = false;
|
||||
#ifdef SK_BUILD_FOR_ANDROID_FRAMEWORK
|
||||
fromWindowLocal = fromWindow;
|
||||
#endif
|
||||
|
||||
GrBackendTexture backendTexture =
|
||||
GrAHardwareBufferUtils::MakeBackendTexture(dContext, hardwareBuffer,
|
||||
bufferDesc.width, bufferDesc.height,
|
||||
&deleteImageProc, &updateImageProc,
|
||||
&deleteImageCtx, isProtectedContent,
|
||||
backendFormat, true);
|
||||
GrAHardwareBufferUtils::MakeBackendTexture(dContext,
|
||||
hardwareBuffer,
|
||||
bufferDesc.width,
|
||||
bufferDesc.height,
|
||||
&deleteImageProc,
|
||||
&updateImageProc,
|
||||
&deleteImageCtx,
|
||||
isProtectedContent,
|
||||
backendFormat,
|
||||
true,
|
||||
fromWindowLocal);
|
||||
if (!backendTexture.isValid()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -306,7 +306,6 @@ public:
|
||||
vkInfo.fCompatibleRenderPass = (VkRenderPass)1;
|
||||
vkInfo.fFormat = VK_FORMAT_R8G8B8A8_UNORM;
|
||||
vkInfo.fDrawBounds = nullptr;
|
||||
vkInfo.fImage = (VkImage)1;
|
||||
|
||||
return GrVkSecondaryCBDrawContext::Make(dContext, imageInfo, vkInfo, &fSurfaceProps);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user