Hi Skia Experts,
I have been using Skia for some time now, and I really like it. But, I have been struggling to get started with GPU features.
I can draw text and some cool things, but when the window is resized, the drawing is stretched. If I was to remove the Skia drawing, and use a glutWireCube, it is not stretched. Of course, I am resetting the viewport, but I am not sure how to do the equivalent with Skia. Is it correct to re-create the surface, or is there the correct way?
CODE:
Init once:
skiaContext = GrContext::Create(kOpenGL_GrBackend, 0);
GrBackendRenderTargetDesc desc;
desc.fWidth = w;
desc.fHeight = h;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fOrigin = kBottomLeft_GrSurfaceOrigin;
desc.fSampleCnt = 1;
desc.fStencilBits = 0;
desc.fRenderTargetHandle = 0; // assume default framebuffer
skiaSurface = SkSurface::MakeFromBackendRenderTarget(skiaContext, desc, NULL)
On each frame:
SkCanvas* skiaCanvas = skiaSurface->getCanvas();
SkPaint paint;
paint.setColor(SK_ColorWHITE);
skiaCanvas->drawCircle(100, 100, 50, paint);
skiaCanvas->flush();