10#if defined(SK_GANESH) && defined(SK_VULKAN)
42static int round_and_clamp(
float x) {
43 int r =
static_cast<int>(
round(
x));
44 if (r > 255)
return 255;
55 VkYcbcrSamplerHelper ycbcrHelper(dContext);
56 if (!ycbcrHelper.isYCbCrSupported()) {
66 ycbcrHelper.grBackendTexture(),
84 surface->getCanvas()->drawImage(srcImage, 0, 0);
97 const int kColorTolerance = 1;
107 float yChannel = (
static_cast<float>(y2) - 16.0) / 219.0;
108 float uChannel = (
static_cast<float>(u) - 128.0) / 224.0;
109 float vChannel = (
static_cast<float>(v) - 128.0) / 224.0;
113 int expectedR = round_and_clamp((yChannel + 1.5748f * vChannel) * 255.0);
114 int expectedG = round_and_clamp((yChannel - 0.13397432f / 0.7152f * uChannel -
115 0.33480248f / 0.7152f * vChannel) *
117 int expectedB = round_and_clamp((yChannel + 1.8556f * uChannel) * 255.0);
120 if (
abs(r - expectedR) > kColorTolerance) {
121 ERRORF(
reporter,
"R should be %d, but is %d at (%zu, %zu)", expectedR, r,
x,
y);
125 if (
abs(g - expectedG) > kColorTolerance) {
126 ERRORF(
reporter,
"G should be %d, but is %d at (%zu, %zu)", expectedG, g,
x,
y);
130 if (
abs(
b - expectedB) > kColorTolerance) {
144 VkYcbcrSamplerHelper ycbcrHelper(dContext);
145 if (!ycbcrHelper.isYCbCrSupported()) {
158 "GrDirectContext::createBackendTexture() didn't fail as expected for Ycbcr format.");
static constexpr int kImageWidth
static constexpr int kImageHeight
static void round(SkPoint *p)
@ kTopLeft_GrSurfaceOrigin
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(name, reporter, context_info, ctsEnforcement)
void flushAndSubmit(GrSyncCpu sync=GrSyncCpu::kNo)
GrBackendTexture createBackendTexture(int width, int height, const GrBackendFormat &, skgpu::Mipmapped, GrRenderable, GrProtected=GrProtected::kNo, std::string_view label={})
SK_API sk_sp< SkImage > BorrowTextureFrom(GrRecordingContext *context, const GrBackendTexture &backendTexture, GrSurfaceOrigin origin, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, TextureReleaseProc textureReleaseProc=nullptr, ReleaseContext releaseContext=nullptr)
SK_API sk_sp< SkSurface > RenderTarget(GrRecordingContext *context, skgpu::Budgeted budgeted, const SkImageInfo &imageInfo, int sampleCount, GrSurfaceOrigin surfaceOrigin, const SkSurfaceProps *surfaceProps, bool shouldCreateWithMips=false, bool isProtected=false)
SIN Vec< N, float > abs(const Vec< N, float > &x)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
@ VK_FORMAT_G8_B8R8_2PLANE_420_UNORM