[PATCH 2/4] wined3d: Use wined3d_texture_get_pitch() in read_from_framebuffer().
Riccardo Bortolato
rikyz619 at gmail.com
Thu Feb 11 15:51:42 CST 2016
Signed-off-by: Riccardo Bortolato <rikyz619 at gmail.com>
---
dlls/wined3d/surface.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index dc54808..cb7995d 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2472,6 +2472,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
int i;
BOOL srcIsUpsideDown;
struct wined3d_bo_address data;
+ unsigned int row_pitch, slice_pitch;
surface_get_memory(surface, &data, dst_location);
@@ -2512,9 +2513,11 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
checkGLcall("glBindBuffer");
}
+ wined3d_texture_get_pitch(surface->container, surface->texture_level, &row_pitch, &slice_pitch);
+
/* Setup pixel store pack state -- to glReadPixels into the correct place */
gl_info->gl_ops.gl.p_glPixelStorei(GL_PACK_ROW_LENGTH,
- wined3d_surface_get_pitch(surface) / surface->resource.format->byte_count);
+ row_pitch / surface->resource.format->byte_count);
checkGLcall("glPixelStorei");
gl_info->gl_ops.gl.p_glReadPixels(0, 0,
@@ -2531,9 +2534,7 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
{
/* glReadPixels returns the image upside down, and there is no way to prevent this.
* Flip the lines in software. */
- UINT pitch = wined3d_surface_get_pitch(surface);
-
- if (!(row = HeapAlloc(GetProcessHeap(), 0, pitch)))
+ if (!(row = HeapAlloc(GetProcessHeap(), 0, row_pitch)))
goto error;
if (data.buffer_object)
@@ -2545,14 +2546,14 @@ static void read_from_framebuffer(struct wined3d_surface *surface,
mem = data.addr;
top = mem;
- bottom = mem + pitch * (surface->resource.height - 1);
+ bottom = mem + row_pitch * (surface->resource.height - 1);
for (i = 0; i < surface->resource.height / 2; i++)
{
- memcpy(row, top, pitch);
- memcpy(top, bottom, pitch);
- memcpy(bottom, row, pitch);
- top += pitch;
- bottom -= pitch;
+ memcpy(row, top, row_pitch);
+ memcpy(top, bottom, row_pitch);
+ memcpy(bottom, row, row_pitch);
+ top += row_pitch;
+ bottom -= row_pitch;
}
HeapFree(GetProcessHeap(), 0, row);
--
1.9.1
More information about the wine-patches
mailing list