27#if defined(__APPLE__) && TARGET_OS_MAC == 1
39bool initialize_gl_linux() {
40 Display* display = XOpenDisplay(
nullptr);
42 printf(
"Could not open an X display\n");
45 static int constexpr kChooseFBConfigAtt[] = {
46 GLX_RENDER_TYPE, GLX_RGBA_BIT,
47 GLX_DOUBLEBUFFER, True,
52 GLXFBConfig* fbConfig = glXChooseFBConfig(display, DefaultScreen(display), kChooseFBConfigAtt, &n);
53 XVisualInfo* visualInfo;
55 visualInfo = glXGetVisualFromFBConfig(display, *fbConfig);
58 int chooseVisualAtt[] = {
64 visualInfo = glXChooseVisual(display, DefaultScreen(display), chooseVisualAtt);
67 printf(
"Could not get X visualInfo\n");
70 GLXContext glContext = glXCreateContext(display, visualInfo,
nullptr, GL_TRUE);
72 printf(
"Could not make GL X context\n");
75 Colormap colorMap = XCreateColormap(display,
76 RootWindow(display, visualInfo->screen),
79 XSetWindowAttributes swa;
80 swa.colormap = colorMap;
83 RootWindow(display, visualInfo->screen),
90 CWEventMask | CWColormap,
93 if (!glXMakeCurrent(display,
window, glContext)) {
94 printf(
"Could not set GL X context to be the created one\n");
109 printf(
"Cannot open output file %s\n",
argv[1]);
115#if defined(__linux__)
116 if (!initialize_gl_linux()) {
120#elif defined(__APPLE__) && TARGET_OS_MAC == 1
127 printf(
"Could not make GL interface\n");
133 printf(
"Could not make GrDirectContext\n");
136 printf(
"Context made, now to make the surface\n");
144 printf(
"Could not make surface from GL DirectContext\n");
154 paint.setAntiAlias(
true);
160 printf(
"Drew to surface, now doing readback\n");
164 printf(
"Readback of pixels (or encoding) failed\n");
@ 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
GrSemaphoresSubmitted flush(const GrFlushInfo &info)
void clear(SkColor color)
void drawRRect(const SkRRect &rrect, const SkPaint &paint)
const void * data() const
static SkRRect MakeRectXY(const SkRect &rect, SkScalar xRad, SkScalar yRad)
int main(int argc, char **argv)
SK_API sk_sp< GrDirectContext > MakeGL(sk_sp< const GrGLInterface >, const GrContextOptions &)
SK_API sk_sp< const GrGLInterface > MakeMac()
SK_API sk_sp< const GrGLInterface > MakeGLX()
std::string printf(const char *fmt,...) SK_PRINTF_LIKE(1
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)
SK_API bool Encode(SkWStream *dst, const SkPixmap &src, const Options &options)
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)
static constexpr SkRect MakeLTRB(float l, float t, float r, float b)