5#include "flutter/testing/test_vulkan_surface.h"
7#include "flutter/fml/logging.h"
8#include "flutter/testing/test_vulkan_context.h"
22TestVulkanSurface::TestVulkanSurface(TestVulkanImage&&
image)
28 auto image_result = context.
CreateImage(surface_size);
30 if (!image_result.has_value()) {
36 .
fImage = image_result.value().GetImage(),
48 surface_size.
width(), surface_size.
height(), image_info);
52 auto result = std::unique_ptr<TestVulkanSurface>(
68 <<
"Could not wrap VkImage as an SkSurface Vulkan render texture.";
75bool TestVulkanSurface::IsValid()
const {
85 FML_LOG(
ERROR) <<
"Aborting snapshot because of on-screen surface "
86 "acquisition failure.";
90 auto device_snapshot =
surface_->makeImageSnapshot();
92 if (!device_snapshot) {
93 FML_LOG(
ERROR) <<
"Could not create the device snapshot while attempting "
94 "to snapshot the Vulkan surface.";
98 auto host_snapshot = device_snapshot->makeRasterImage();
100 if (!host_snapshot) {
101 FML_LOG(
ERROR) <<
"Could not create the host snapshot while attempting to "
102 "snapshot the Vulkan surface.";
106 return host_snapshot;
109VkImage TestVulkanSurface::GetImage() {
110 return image_.GetImage();
@ kTopLeft_GrSurfaceOrigin
static sk_sp< Effect > Create()
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkPixelGeometry
static sk_sp< SkColorSpace > MakeSRGB()
sk_sp< GrDirectContext > GetGrDirectContext() const
std::optional< TestVulkanImage > CreateImage(const SkISize &size) const
#define FML_LOG(severity)
SK_API GrBackendTexture MakeVk(int width, int height, const GrVkImageInfo &, std::string_view label={})
sk_sp< const SkImage > image
SK_API sk_sp< SkSurface > WrapBackendTexture(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, int sampleCnt, SkColorType colorType, sk_sp< SkColorSpace > colorSpace, const SkSurfaceProps *surfaceProps, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
constexpr int32_t width() const
constexpr int32_t height() const
@ VK_IMAGE_LAYOUT_UNDEFINED
@ VK_IMAGE_TILING_OPTIMAL
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
@ VK_IMAGE_USAGE_SAMPLED_BIT
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
@ VK_FORMAT_R8G8B8A8_UNORM