32constexpr int32_t kHalfSize = 4;
41 std::unique_ptr<Recorder> recorder = context->makeRecorder();
48 bitmap.eraseColor(kTopColor);
53 sk_gpu_test::ManagedGraphiteTexture::MakeFromPixmap(recorder.get(),
60 if (!managedTexture) {
65 managedTexture->texture(),
87 drawImageFn(
image, canvas, srcRect, dstRect);
93 bool peekPixelsSuccess =
result.peekPixels(&pm);
96 bool readPixelsSuccess =
surface->readPixels(pm, 0, 0);
105 SkColor4f expectedColor = ((
y < kHalfSize) == resultTopColorOnTop) ? kTopColor
108 color == expectedColor,
109 "At position {%d, %d}, "
110 "expected {%.1f, %.1f, %.1f, %.1f}, "
111 "found {%.1f, %.1f, %.1f, %.1f}",
113 expectedColor.fR, expectedColor.fG, expectedColor.fB, expectedColor.fA,
119const SkRect kTestSrcRects[] = {
128 DrawFn drawImageFn) {
130 for (
auto srcRect: kTestSrcRects) {
179 test_draw_fn(
reporter, context, draw_image_with_shader);
static void draw_image(SkCanvas *canvas, SkImage *img)
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
#define REPORTER_ASSERT(r, cond,...)
void drawRect(const SkRect &rect, const SkPaint &paint)
@ kStrict_SrcRectConstraint
sample only inside bounds; slower
void drawImageRect(const SkImage *, const SkRect &src, const SkRect &dst, const SkSamplingOptions &, const SkPaint *, SrcRectConstraint)
static sk_sp< SkShader > MakeSubset(sk_sp< SkImage >, const SkRect &subset, SkTileMode tmx, SkTileMode tmy, const SkSamplingOptions &, const SkMatrix *localMatrix, bool clampAsIfUnpremul=false)
static SkMatrix RectToRect(const SkRect &src, const SkRect &dst, ScaleToFit mode=kFill_ScaleToFit)
SkColor4f getColor4f(int x, int y) const
static const int kImageSize
constexpr SkColor4f kBlue
SK_API sk_sp< SkImage > WrapTexture(skgpu::graphite::Recorder *, const skgpu::graphite::BackendTexture &, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace, skgpu::Origin origin, GenerateMipmapsFromBase generateMipmapsFromBase, TextureReleaseProc=nullptr, ReleaseContext=nullptr, std::string_view label={})
sk_sp< const SkImage > image
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)
DEF_GRAPHITE_TEST_FOR_RENDERING_CONTEXTS(BufferManagerGpuOnlyBufferTest, reporter, context, CtsEnforcement::kNextRelease)
SkSamplingOptions(SkFilterMode::kLinear))
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
static constexpr SkRect MakeWH(float w, float h)
static void test_draw(SkCanvas *canvas, const char label[])