GraphiteDawnWindowContext example?

141 views
Skip to first unread message

Kalen White

unread,
Mar 5, 2024, 2:22:20 PM3/5/24
to skia-discuss
I'm looking for the user of tools/window example in Skia.  In particular GraphiteDawnWindowContext on unix.  What app uses this?  Does sk_app?  The tools/window simply builds a library called libwindow.a and I'm curious if an app somewhere in Skia makes use of this.

How do we get a live example of Dawn + Graphite on ANY os?  I am on Unix but also use Mac/Windows.

Kalen
Message has been deleted

Kalen White

unread,
Mar 5, 2024, 2:50:17 PM3/5/24
to skia-discuss
I am noticing the Window code does not support Graphite/Dawn, as its not flushing prior to Swap.  It seems like I am on my own with this one.  Its also very confusing how Window contexts are instanced on the various OS's.  I see no bindings for that.  In my case, I am instancing the Dawn and Graphite from skia's helper directly:
skwindow::XlibWindowInfo info = { };
info.fDisplay = XOpenDisplay(NULL);
XSetWindowAttributes attributes;
attributes.event_mask = ExposureMask | KeyPressMask;
info.fWindow = XCreateWindow(
info.fDisplay, DefaultRootWindow(info.fDisplay), 0, 0, 800, 600, 0,
CopyFromParent, InputOutput, CopyFromParent,
CWEventMask, &attributes);

info.fFBConfig = nullptr;
info.fVisualInfo = nullptr;
info.fWidth = 800;
info.fHeight = 600;

skwindow::DisplayParams dp = { };
dp.fColorType = kRGBA_8888_SkColorType;
dp.fColorSpace = SkColorSpace::MakeSRGB();
dp.fMSAASampleCount = 0;
dp.fGrContextOptions = GrContextOptions();
dp.fSurfaceProps = SkSurfaceProps(0, kBGR_H_SkPixelGeometry);
dp.fDisableVsync = false;
dp.fDelayDrawableAcquisition = false;
dp.fEnableBinaryArchive = false;
dp.fCreateProtectedNativeBackend = false;

std::unique_ptr<skwindow::WindowContext> ctx =
skwindow::MakeGraphiteDawnVulkanForXlib(info, dp);



The paint code is what I need to do now, and it doesnt work to flush anything.

void Window::onPaint() {
if (!fWindowContext) {
return;
}
if (!fIsActive) {
return;
}
sk_sp<SkSurface> backbuffer = fWindowContext->getBackbufferSurface();
if (backbuffer == nullptr) {
printf("no backbuffer!?\n");
// TODO: try recreating testcontext
return;
}

markInvalProcessed();

// draw into the canvas of this surface
this->visitLayers([](Layer* layer) { layer->onPrePaint(); });
this->visitLayers([=](Layer* layer) { layer->onPaint(backbuffer.get()); });

if (auto dContext = this->directContext()) { // <---- this is specific to Ganesh
dContext->flushAndSubmit(backbuffer.get(), GrSyncCpu::kNo);
}

fWindowContext->swapBuffers();
}
Reply all
Reply to author
Forward
0 new messages