Resizing window with SkSurface::MakeFromBackendRenderTarget

99 views
Skip to first unread message

Tome Bundalevski

unread,
Apr 15, 2023, 5:12:51 PM4/15/23
to skia-discuss
Hello, I managed to build Skia with ANGLE, I am using D3D11 to draw directly onto the Window HWND. I am not copying the pixels themselves and then setting them by StretchDIBits or SetDIBitsToDevice to the HDC, rather, I am using flushAndSubmit from the SkSurface, followed by eglSwapBuffers. However, when resizing the window, I get this weird glitchy error:

https://s12.gifyu.com/images/ezgif.com-video-to-gif235ce5b51949e0e4.gif

I get a ghost/bounce effect. I don't have this effect when I am drawing with Raster.

The drawing code is very simple:

eglMakeCurrent(m_EGLDisplay, m_EGLSurface, m_EGLSurface, m_EGLContext);

m_EGLInterface->fFunctions.fClearColor(0.0f, 0.0f, 0.0f, 1.0f);
m_EGLInterface->fFunctions.fClear(GR_GL_DEPTH_BUFFER_BIT | GR_GL_STENCIL_BUFFER_BIT | GR_GL_COLOR_BUFFER_BIT);

SkRect rect = SkRect::MakeLTRB(0, 0, SkIntToScalar(m_Width), 100);
SkRRect circle = SkRRect::MakeRectXY(SkRect::MakeLTRB(200, 200, 400, 400), 100, 100);

SkPaint paint;
paint.setAntiAlias(true);
paint.setColor(SK_ColorRED);

m_WindowSurface->getCanvas()->clear(SK_ColorWHITE);
m_WindowSurface->getCanvas()->drawRect(rect, paint);
m_WindowSurface->getCanvas()->drawRRect(circle, paint);

m_WindowSurface->flushAndSubmit(true);

eglSwapBuffers(m_EGLDisplay, m_EGLSurface);


I can also upload the code somewhere for the setup, if I need to.

craste...@gmail.com

unread,
Apr 16, 2023, 4:07:24 PM4/16/23
to skia-discuss
I don't know anything about ANGLE.  But have you checked to see if Skia came with some kind of wrapper class for Windows+ANGLE ?  I don't mean an official component of the Skia library. But rather some code that Skia was using to build their test applications.  Some helper classes that sort of wrapped up these concepts in ways that I found convenient to copy into my own test application. 

Specifically a class or two that encapsulated making a Windows application with an HWND that used OpenGL and had an SkSurface instance all setup for me.

I copy-pasta'd that class / code in to my own test application and have not needed to look back.

I don't know for a fact that there might be an example of an ANGLE-based version of that, but you might want to take a look...

Reply all
Reply to author
Forward
0 new messages