23#if defined(SK_GRAPHITE)
36static void release_ycbcrhelper(
void* releaseContext) {
37 VkYcbcrSamplerHelper* ycbcrHelper =
reinterpret_cast<VkYcbcrSamplerHelper*
>(releaseContext);
44class YCbCrImageGM :
public GM {
47 this->setBGColor(0xFFCCCCCC);
57#if defined(SK_GRAPHITE)
61 if (!graphiteTestContext || !recorder) {
62 *errorMsg =
"Cannot generate a YCbCr image without a valid GraphiteTestContext and "
69 VulkanTestContext* vkTestCtxt =
static_cast<VulkanTestContext*
>(graphiteTestContext);
71 const VulkanSharedContext* vulkanSharedCtxt =
72 static_cast<const VulkanSharedContext*
>(recorder->
priv().sharedContext());
75 std::unique_ptr<VkYcbcrSamplerHelper> ycbcrHelper(
76 new VkYcbcrSamplerHelper(vulkanSharedCtxt,
77 vkTestCtxt->getBackendContext().fPhysicalDevice));
79 *errorMsg =
"Failed to create VkYcbcrSamplerHelper.";
82 if (!ycbcrHelper->isYCbCrSupported()) {
83 *errorMsg =
"YCbCr sampling is not supported.";
87 *errorMsg =
"Failed to create I420 backend texture.";
97 ycbcrHelper.release();
117 std::unique_ptr<VkYcbcrSamplerHelper> ycbcrHelper(
new VkYcbcrSamplerHelper(dContext));
119 if (!ycbcrHelper->isYCbCrSupported()) {
120 *errorMsg =
"YCbCr sampling not supported.";
125 *errorMsg =
"Failed to create I420 backend texture.";
131 ycbcrHelper->grBackendTexture(),
138 ycbcrHelper.release();
140 *errorMsg =
"Failed to create I420 image.";
149 GraphiteTestContext* graphiteTestContext)
override {
150#if defined(SK_GRAPHITE)
155 *errorMsg =
"This GM requires using Vulkan.";
159 return this->createYCbCrImage(recorder, graphiteTestContext, errorMsg);
165 if (!dContext || dContext->
abandoned()) {
170 *errorMsg =
"This GM requires a Vulkan context.";
183 void onGpuTeardown()
override {
184 fYCbCrImage =
nullptr;
195 static const int kPad = 8;
204DEF_GM(
return new YCbCrImageGM;)
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kTopLeft_GrSurfaceOrigin
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
#define SkASSERT_RELEASE(cond)
@ kRGB_888x_SkColorType
pixel with 8 bits each for red, green, blue; in 32-bit word
#define INHERITED(method,...)
SK_API GrBackendApi backend() const
bool abandoned() override
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
BackendApi backend() const
void deleteBackendTexture(const BackendTexture &)
static const int kImageSize
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)
DEF_GM(return F(C(clipbox), 0.0f, 0.0f, {})) DEF_GM(return F(C(clipbox)
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkISize Make(int32_t w, int32_t h)