Module: wine
Branch: refs/heads/master
Commit: 5702a310e998d29f3e1f8413d127d364d5c1fdd5
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=5702a310e998d29f3e1f841…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Sun Jul 16 10:08:26 2006 +0200
wined3d: Allocate 4 extra bytes in the dib section.
---
dlls/wined3d/surface.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index b827fa8..ce4e384 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -781,6 +781,7 @@ static HRESULT WINAPI IWineD3DSurfaceImp
GLint prev_store;
GLint prev_depth_test;
GLint prev_rasterpos[4];
+ int tex;
/* Some drivers(radeon dri, others?) don't like exceptions during
* glDrawPixels. If the surface is a DIB section, it might be in GDIMode
@@ -827,6 +828,17 @@ static HRESULT WINAPI IWineD3DSurfaceImp
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes);
glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width);
+ /* Disable all textures before calling glDrawPixels */
+ for(tex = 0; tex < GL_LIMITS(sampler_stages); tex++) {
+ if (GL_SUPPORT(ARB_MULTITEXTURE)) {
+ GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + tex));
+ checkGLcall("glActiveTextureARB");
+ }
+ glDisable(GL_TEXTURE_2D);
+ checkGLcall("glDisable GL_TEXTURE_2D");
+ glDisable(GL_TEXTURE_1D);
+ checkGLcall("glDisable GL_TEXTURE_1D");
+ }
/* And back buffers are not blended */
glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
@@ -993,6 +1005,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC
/* Create a DIB section if there isn't a hdc yet */
if(!This->hDC) {
+ int extraline = 0;
+ SYSTEM_INFO sysInfo;
+
if(This->Flags & SFLAG_ACTIVELOCK) {
ERR("Creating a DIB section while a lock is active. Uncertain consequences\n");
}
@@ -1017,17 +1032,28 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC
break;
}
+ /* Some apps access the surface in via DWORDs, and do not take the necessary care at the end of the
+ * surface. So we need at least extra 4 bytes at the end of the surface. Check against the page size,
+ * if the last page used for the surface has at least 4 spare bytes we're safe, otherwise
+ * add an extra line to the dib section
+ */
+ GetSystemInfo(&sysInfo);
+ if( ((This->resource.size + 3) % sysInfo.dwPageSize) < 4) {
+ extraline = 1;
+ TRACE("Adding an extra line to the dib section\n");
+ }
+
b_info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
if( (NP2_REPACK == wined3d_settings.nonpower2_mode || This->resource.usage & WINED3DUSAGE_RENDERTARGET)) {
b_info->bmiHeader.biWidth = This->currentDesc.Width;
- b_info->bmiHeader.biHeight = -This->currentDesc.Height;
+ b_info->bmiHeader.biHeight = -This->currentDesc.Height -extraline;
b_info->bmiHeader.biSizeImage = This->currentDesc.Width * This->currentDesc.Height * This->bytesPerPixel;
/* Use the full pow2 image size(assigned below) because LockRect
* will need it for a full glGetTexImage call
*/
} else {
b_info->bmiHeader.biWidth = This->pow2Width;
- b_info->bmiHeader.biHeight = -This->pow2Height;
+ b_info->bmiHeader.biHeight = -This->pow2Height -extraline;
b_info->bmiHeader.biSizeImage = This->resource.size;
}
b_info->bmiHeader.biPlanes = 1;