12#if defined(SK_GANESH) && defined(SK_VULKAN)
46namespace skgpu {
struct VulkanInterface; }
57 , fInterface(interface)
62 ~TestDrawable()
override {}
64 class DrawHandlerBasic :
public GpuDrawHandler {
68 , fInterface(interface)
71 ~DrawHandlerBasic()
override {}
87 clearRect.
rect.
extent = { (uint32_t)fWidth / 2, (uint32_t)fHeight };
114 typedef void (*SubmitProc)(TestDrawable*);
119 class DrawHandlerImport :
public GpuDrawHandler {
121 DrawHandlerImport(TestDrawable* td,
DrawProc drawProc, SubmitProc submitProc,
127 , fDrawProc(drawProc)
128 , fSubmitProc(submitProc)
130 , fClipBounds(clipBounds)
131 , fBufferInfo(bufferInfo) {}
132 ~DrawHandlerImport()
override {
133 fSubmitProc(fTestDrawable);
140 fDrawProc(fTestDrawable,
fMatrix, fClipBounds, fBufferInfo, vkInfo);
143 TestDrawable* fTestDrawable;
145 SubmitProc fSubmitProc;
159 if (!td->fDrawContext) {
163 SkCanvas* canvas = td->fDrawContext->getCanvas();
197 td->fDrawContext->flush();
202 static void ImportSubmitted(TestDrawable* td) {
209 td->fDrawContext->releaseResources();
216 td->fDContext->releaseResourcesAndAbandonContext();
220 std::unique_ptr<GpuDrawHandler> onSnapGpuDrawHandler(
GrBackendApi backendApi,
227 std::unique_ptr<GpuDrawHandler>
draw;
229 draw = std::make_unique<DrawHandlerImport>(
this, ImportDraw, ImportSubmitted,
matrix,
230 clipBounds, bufferInfo);
232 draw = std::make_unique<DrawHandlerBasic>(fInterface, fWidth, fHeight);
237 SkRect onGetBounds()
override {
280 const uint32_t* canvasPixels =
static_cast<const uint32_t*
>(
bitmap.getPixels());
281 bool failureFound =
false;
283 for (
int cy = 0; cy <
DEV_H && !failureFound; ++cy) {
284 for (
int cx = 0; cx <
DEV_W && !failureFound; ++cx) {
286 if (cy <
DEV_H / 2) {
287 if (cx <
DEV_W / 2) {
288 expectedPixel = 0xFFFF0000;
290 expectedPixel = 0xFF0000FF;
293 expectedPixel = 0xFF00FF00;
295 if (expectedPixel != canvasPixel) {
297 ERRORF(
reporter,
"Wrong color at %d, %d. Got 0x%08x when we expected 0x%08x",
298 cx, cy, canvasPixel, expectedPixel);
305 draw_drawable_test(
reporter, ctxInfo.directContext(),
nullptr);
const char *(* DrawProc)(const BezierRec *, int)
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
SkAssertResult(font.textToGlyphs("Hello", 5, SkTextEncoding::kUTF8, glyphs, std::size(glyphs))==count)
@ kTopLeft_GrSurfaceOrigin
#define GR_VK_CALL(IFACE, X)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
#define INHERITED(method,...)
GrDirectContext * fDContext
#define DEF_GANESH_TEST_FOR_VULKAN_CONTEXT(name, reporter, context_info, ctsEnforcement)
#define DEF_GANESH_TEST(name, reporter, options, ctsEnforcement)
static void draw(SkCanvas *canvas, SkRect &target, int x, int y)
GrDirectContextPriv priv()
const skgpu::VulkanInterface * vkInterface() const
static sk_sp< GrVkSecondaryCBDrawContext > Make(GrRecordingContext *, const SkImageInfo &, const GrVkDrawableInfo &, const SkSurfaceProps *props)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void drawDrawable(SkDrawable *drawable, const SkMatrix *matrix=nullptr)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
void drawIRect(const SkIRect &rect, const SkPaint &paint)
void clear(SkColor color)
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
void setMatrix(const SkM44 &matrix)
bool readPixels(const SkImageInfo &dstInfo, void *dstPixels, size_t dstRowBytes, int srcX, int srcY)
sk_sp< SkImage > makeImageSnapshot()
GrDirectContext * directContext() const
void reset(T *ptr=nullptr)
unsigned useCenter Optional< SkMatrix > matrix
sk_sp< SkBlender > blender SkRect rect
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)
static const int kContextTypeCount
@ kVulkan
ANGLE on Metal ES 3 context.
const char * ContextTypeName(skgpu::ContextType type)
Enable fReduceOpsTaskSplitting
uint32_t fColorAttachmentIndex
VkCommandBuffer fSecondaryCommandBuffer
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static constexpr SkIRect MakeXYWH(int32_t x, int32_t y, int32_t w, int32_t h)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)
static SkRect MakeIWH(int w, int h)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
VkImageAspectFlags aspectMask
@ VK_IMAGE_ASPECT_COLOR_BIT