33#if defined(SK_GRAPHITE)
60#if defined(SK_GRAPHITE)
75 paint.setAntiAlias(
true);
76 paint.setDither(
true);
80 paint.setShader(
nullptr);
94 "Unknown geometry, default contrast/gamma",
98 "RGB_H, default contrast/gamma",
102 "BGR_H, default contrast/gamma",
106 "RGB_V, default contrast/gamma",
110 "BGR_V, default contrast/gamma",
123 fFlags != 0 ?
"_df" :
"");
137 for (
const auto& rec : recs) {
141 SkDebugf(
"failed to create surface! label: %s", rec.fLabel);
151 struct SurfacePropsInput {
157 std::vector<SurfacePropsInput> recs;
161 using INHERITED =
GM;
194 auto surf2(surf->makeSurface(
info));
205 using INHERITED =
GM;
242#define DEF_BASIC_SURFACE_TEST(name, canvas, main, W, H) \
243 DEF_SIMPLE_GM(name, canvas, W, H) { \
244 auto make = [canvas](const SkImageInfo& ii) { \
245 return make_surface(ii, canvas, SurfaceType::kManaged); \
247 main(canvas, MakeSurfaceFn(make)); \
250#define DEF_BACKEND_SURFACE_TEST(name, canvas, main, type, W, H) \
251 DEF_SIMPLE_GM_CAN_FAIL(name, canvas, err_msg, W, H) { \
252 GrDirectContext* direct = GrAsDirectContext(canvas->recordingContext()); \
253 if (!direct || direct->abandoned()) { \
254 *err_msg = "Requires non-abandoned GrDirectContext"; \
255 return skiagm::DrawResult::kSkip; \
257 auto make = [canvas](const SkImageInfo& ii) { return make_surface(ii, canvas, type); }; \
258 main(canvas, MakeSurfaceFn(make)); \
259 return skiagm::DrawResult::kOk; \
262#define DEF_BET_SURFACE_TEST(name, canvas, main, W, H) \
263 DEF_BACKEND_SURFACE_TEST(SK_MACRO_CONCAT(name, _bet), canvas, main, \
264 SurfaceType::kBackendTexture, W, H)
266#define DEF_BERT_SURFACE_TEST(name, canvas, main, W, H) \
267 DEF_BACKEND_SURFACE_TEST(SK_MACRO_CONCAT(name, _bert), canvas, main, \
268 SurfaceType::kBackendRenderTarget, W, H)
272#define DEF_SURFACE_TESTS(name, canvas, W, H) \
273 static void SK_MACRO_CONCAT(name, _main)(SkCanvas*, const MakeSurfaceFn&); \
274 DEF_BASIC_SURFACE_TEST(name, canvas, SK_MACRO_CONCAT(name, _main), W, H) \
275 DEF_BET_SURFACE_TEST (name, canvas, SK_MACRO_CONCAT(name, _main), W, H) \
276 DEF_BERT_SURFACE_TEST (name, canvas, SK_MACRO_CONCAT(name, _main), W, H) \
277 static void SK_MACRO_CONCAT(name, _main)(SkCanvas * canvas, const MakeSurfaceFn& make)
324 canvas->drawImage(std::move(
image), 0, 0);
336 canvas->drawImage(std::move(
image), 0, 0);
342 : canvas->imageInfo().colorType();
346 canvas->imageInfo().refColorSpace());
358 return surface->makeImageSnapshot()->withDefaultMipmaps();
361 static constexpr int kPad = 8;
365 for (
int y = 0;
y < 3; ++
y) {
368 for (
int x = 0;
x < 2; ++
x) {
370 canvas->drawImage(
image, 0, 0, kSampling);
371 canvas->translate(ii.width() +
kPad, 0);
374 canvas->translate(0, ii.width() +
kPad);
375 canvas->scale(.4f, .4f);
392 paint.setAlphaf(0.25f);
409 SkPoint pts[] = {{0, 0}, {40, 50}};
414 surf->getCanvas()->drawPaint(
paint);
429 SkRect r = { 0, 10, 256, 35 };
431 surf->getCanvas()->drawRect(r,
paint);
451 surf->getCanvas()->drawImage(saveImg,
457 surf->draw(canvas, 0, 0);
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
static GrDirectContext * GrAsDirectContext(GrContext_Base *base)
@ kTopLeft_GrSurfaceOrigin
static bool equal(const SkBitmap &a, const SkBitmap &b)
@ kOpaque_SkAlphaType
pixel is opaque
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
@ kDstOver
r = d + (1-da)*s
@ kRGBA_8888_SkColorType
pixel with 8 bits for red, green, blue, alpha; in 32-bit word
@ kUnknown_SkColorType
uninitialized
#define SkColorSetRGB(r, g, b)
constexpr SkColor SK_ColorBLUE
constexpr SkColor SK_ColorRED
constexpr SkColor SK_ColorGREEN
constexpr SkColor SK_ColorWHITE
void SK_SPI SkDebugf(const char format[],...) SK_PRINTF_LIKE(1
SK_API SkString SkStringPrintf(const char *format,...) SK_PRINTF_LIKE(1
Creates a new string and writes into it using a printf()-style format.
@ kUnknown_SkPixelGeometry
#define SK_GAMMA_CONTRAST
#define SK_GAMMA_EXPONENT
SkISize getISize() override
SkString getName() const override
void onDraw(SkCanvas *canvas) override
static void drawInto(SkCanvas *canvas)
int saveLayer(const SkRect *bounds, const SkPaint *paint)
void drawRect(const SkRect &rect, const SkPaint &paint)
void clipRect(const SkRect &rect, SkClipOp op, bool doAntiAlias)
void drawColor(SkColor color, SkBlendMode mode=SkBlendMode::kSrcOver)
virtual GrRecordingContext * recordingContext() const
virtual skgpu::graphite::Recorder * recorder() const
void clear(SkColor color)
void drawImage(const SkImage *image, SkScalar left, SkScalar top)
@ kSubpixelAntiAlias
glyph positioned in pixel using transparency
static sk_sp< SkShader > MakeLinear(const SkPoint pts[2], const SkColor colors[], const SkScalar pos[], int count, SkTileMode mode, uint32_t flags=0, const SkMatrix *localMatrix=nullptr)
@ kUseDeviceIndependentFonts_Flag
sk_sp< SkImage > makeImageSnapshot()
static void DrawString(SkCanvas *canvas, const char text[], SkScalar x, SkScalar y, const SkFont &font, const SkPaint &paint, Align align=kLeft_Align)
SurfacePropsGM(uint32_t flags)
SkISize getISize() override
SkString getName() const override
void onDraw(SkCanvas *canvas) override
void reset(T *ptr=nullptr)
GM(SkColor backgroundColor=SK_ColorWHITE)
FlutterSemanticsFlag flags
sk_sp< const SkImage > image
PODArray< SkColor > colors
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
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)
font
Font Metadata and Metrics.
sk_sp< SkSurface > MakeBackendRenderTargetSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, GrProtected isProtected, const SkSurfaceProps *props)
sk_sp< SkSurface > MakeBackendTextureSurface(GrDirectContext *dContext, const SkImageInfo &ii, GrSurfaceOrigin origin, int sampleCnt, skgpu::Mipmapped mipmapped, GrProtected isProtected, const SkSurfaceProps *props)
static void make(SkBitmap *bitmap, SkColorType colorType, SkAlphaType alphaType, sk_sp< SkColorSpace > colorSpace)
constexpr int32_t top() const
static constexpr SkIRect MakeLTRB(int32_t l, int32_t t, int32_t r, int32_t b)
constexpr int32_t right() const
constexpr int32_t left() const
static constexpr SkISize Make(int32_t w, int32_t h)
static SkImageInfo MakeN32Premul(int width, int height)
static SkImageInfo MakeN32(int width, int height, SkAlphaType at)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static SkRect Make(const SkISize &size)
SkScalar fBottom
larger y-axis bounds
void offset(float dx, float dy)
constexpr float height() const
static constexpr SkRect MakeWH(float w, float h)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)
DEF_SIMPLE_GM(snap_with_mips, canvas, 80, 75)
std::function< sk_sp< SkSurface >(const SkImageInfo &)> MakeSurfaceFn
#define DEF_SURFACE_TESTS(name, canvas, W, H)
static void test_draw(SkCanvas *canvas, const char label[])
static sk_sp< SkShader > make_shader()
static sk_sp< SkSurface > make_surface(GrRecordingContext *ctx, skgpu::graphite::Recorder *recorder, const SkImageInfo &info, uint32_t flags, SkPixelGeometry geo, SkScalar contrast, SkScalar gamma)