35RasterWindowContext_xlib::RasterWindowContext_xlib(Display* display,
XWindow window,
int width,
40 fGC = XCreateGC(fDisplay, fWindow, 0,
nullptr);
48 XWindowAttributes attrs;
49 XGetWindowAttributes(fDisplay, fWindow, &attrs);
50 this->resize(attrs.width, attrs.height);
53void RasterWindowContext_xlib::resize(
int w,
int h) {
55 fDisplayParams.fColorSpace);
59sk_sp<SkSurface> RasterWindowContext_xlib::getBackbufferSurface() {
return fBackbufferSurface; }
61void RasterWindowContext_xlib::onSwapBuffers() {
63 if (!fBackbufferSurface->peekPixels(&pm)) {
71 image.format = ZPixmap;
73 image.byte_order = LSBFirst;
74 image.bitmap_unit = bitsPerPixel;
75 image.bitmap_bit_order = LSBFirst;
76 image.bitmap_pad = bitsPerPixel;
79 image.bits_per_pixel = bitsPerPixel;
80 if (!XInitImage(&
image)) {
83 XPutImage(fDisplay, fWindow, fGC, &
image, 0, 0, 0, 0, pm.
width(), pm.
height());
92 std::unique_ptr<WindowContext> ctx(
new RasterWindowContext_xlib(
94 if (!ctx->isValid()) {
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
@ kPremul_SkAlphaType
pixel components are premultiplied by alpha
static constexpr bool SkToBool(const T &x)
const SkImageInfo & info() const
void * writable_addr() const
virtual sk_sp< SkSurface > getBackbufferSurface()=0
virtual void setDisplayParams(const DisplayParams ¶ms)=0
virtual void resize(int w, int h)=0
virtual void onSwapBuffers()=0
const EmbeddedViewParams * params
sk_sp< const SkImage > image
SK_API sk_sp< SkSurface > Raster(const SkImageInfo &imageInfo, size_t rowBytes, const SkSurfaceProps *surfaceProps)
std::unique_ptr< WindowContext > MakeRasterForXlib(const XlibWindowInfo &info, const DisplayParams ¶ms)
int bytesPerPixel() const
static SkImageInfo Make(int width, int height, SkColorType ct, SkAlphaType at)