Commit eb379608 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Get rid of the SFLAG_LOCKED hack in flush_to_framebuffer_drawpixels().

parent 90592714
...@@ -1925,39 +1925,36 @@ lock_end: ...@@ -1925,39 +1925,36 @@ lock_end:
return IWineD3DBaseSurfaceImpl_Map(iface, pLockedRect, pRect, flags); return IWineD3DBaseSurfaceImpl_Map(iface, pLockedRect, pRect, flags);
} }
static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *surface,
GLenum fmt, GLenum type, UINT bpp, const BYTE *mem) const RECT *rect, GLenum fmt, GLenum type, UINT bpp, const BYTE *mem)
{ {
UINT pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This); /* target is argb, 4 byte */ UINT pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *)surface); /* target is argb, 4 byte */
IWineD3DDeviceImpl *device = This->resource.device; IWineD3DDeviceImpl *device = surface->resource.device;
const struct wined3d_gl_info *gl_info; const struct wined3d_gl_info *gl_info;
struct wined3d_context *context; struct wined3d_context *context;
RECT rect; RECT local_rect;
UINT w, h; UINT w, h;
if (This->flags & SFLAG_LOCKED) surface_get_rect(surface, rect, &local_rect);
rect = This->lockedRect;
else
SetRect(&rect, 0, 0, This->currentDesc.Width, This->currentDesc.Height);
mem += rect.top * pitch + rect.left * bpp; mem += local_rect.top * pitch + local_rect.left * bpp;
w = rect.right - rect.left; w = local_rect.right - local_rect.left;
h = rect.bottom - rect.top; h = local_rect.bottom - local_rect.top;
/* Activate the correct context for the render target */ /* Activate the correct context for the render target */
context = context_acquire(device, This); context = context_acquire(device, surface);
context_apply_blit_state(context, device); context_apply_blit_state(context, device);
gl_info = context->gl_info; gl_info = context->gl_info;
ENTER_GL(); ENTER_GL();
if (!surface_is_offscreen(This)) if (!surface_is_offscreen(surface))
{ {
GLenum buffer = surface_get_gl_buffer(This); GLenum buffer = surface_get_gl_buffer(surface);
TRACE("Unlocking %#x buffer.\n", buffer); TRACE("Unlocking %#x buffer.\n", buffer);
context_set_draw_buffer(context, buffer); context_set_draw_buffer(context, buffer);
surface_translate_drawable_coords(This, context->win_handle, &rect); surface_translate_drawable_coords(surface, context->win_handle, &local_rect);
glPixelZoom(1.0f, -1.0f); glPixelZoom(1.0f, -1.0f);
} }
else else
...@@ -1969,22 +1966,22 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, ...@@ -1969,22 +1966,22 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This,
glPixelZoom(1.0f, 1.0f); glPixelZoom(1.0f, 1.0f);
} }
glRasterPos3i(rect.left, rect.top, 1); glRasterPos3i(local_rect.left, local_rect.top, 1);
checkGLcall("glRasterPos3i"); checkGLcall("glRasterPos3i");
/* If not fullscreen, we need to skip a number of bytes to find the next row of data */ /* If not fullscreen, we need to skip a number of bytes to find the next row of data */
glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width); glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->currentDesc.Width);
if (This->flags & SFLAG_PBO) if (surface->flags & SFLAG_PBO)
{ {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, surface->pbo));
checkGLcall("glBindBufferARB"); checkGLcall("glBindBufferARB");
} }
glDrawPixels(w, h, fmt, type, mem); glDrawPixels(w, h, fmt, type, mem);
checkGLcall("glDrawPixels"); checkGLcall("glDrawPixels");
if (This->flags & SFLAG_PBO) if (surface->flags & SFLAG_PBO)
{ {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0)); GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB"); checkGLcall("glBindBufferARB");
...@@ -4509,7 +4506,7 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE ...@@ -4509,7 +4506,7 @@ HRESULT surface_load_location(IWineD3DSurfaceImpl *surface, DWORD flag, const RE
byte_count = format.byte_count; byte_count = format.byte_count;
} }
flush_to_framebuffer_drawpixels(surface, format.glFormat, format.glType, byte_count, mem); flush_to_framebuffer_drawpixels(surface, rect, format.glFormat, format.glType, byte_count, mem);
/* Don't delete PBO memory */ /* Don't delete PBO memory */
if ((mem != surface->resource.allocatedMemory) && !(surface->flags & SFLAG_PBO)) if ((mem != surface->resource.allocatedMemory) && !(surface->flags & SFLAG_PBO))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment