+ if (hReadDC) {
+ if (hReadDC == hDrawDC) {
+ fbRead = fb;
+ }
+ else {
+ fbRead = stw_framebuffer_from_hdc( hReadDC );
+
+ if (fbRead) {
+ stw_framebuffer_update(fbRead);
+ }
+ else {
+ /* Applications should call SetPixelFormat before creating a
+ * context, but not all do, and the opengl32 runtime seems to
+ * use a default pixel format in some cases, so we must create
+ * a framebuffer for those here.
+ */
+ int iPixelFormat = GetPixelFormat(hReadDC);
+ if (iPixelFormat)
+ fbRead = stw_framebuffer_create( hReadDC, iPixelFormat );
+ if (!fbRead)
+ goto fail;
+ }
+
+ if (fbRead->iPixelFormat != ctx->iPixelFormat) {
+ stw_framebuffer_unlock(fbRead);
+ SetLastError(ERROR_INVALID_PIXEL_FORMAT);
+ goto fail;
+ }
+ stw_framebuffer_unlock(fbRead);
+ }
+ ret = stw_dev->stapi->make_current(stw_dev->stapi, ctx->st,
+ fb->stfb, fbRead->stfb);
+ }
+ else {
+ /* Note: when we call this function we will wind up in the
+ * stw_st_framebuffer_validate_locked() function which will incur
+ * a recursive fb->mutex lock.
+ */
+ ret = stw_dev->stapi->make_current(stw_dev->stapi, ctx->st,
+ fb->stfb, fb->stfb);
+ }