Module: wine
Branch: master
Commit: a74ecc5f2f71dac7ace45dd45fcd4495ed0e542a
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a74ecc5f2f71dac7ace45dd45…
Author: Roderick Colenbrander <thunderbird2k(a)gmx.net>
Date: Mon Jan 7 21:18:34 2008 +0100
wined3d: Unify color conversion code.
---
dlls/wined3d/surface.c | 126 +++++++++++++-----------------------------------
1 files changed, 34 insertions(+), 92 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 2be1f89..0a7a4df 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -934,14 +934,11 @@ lock_end:
return IWineD3DBaseSurfaceImpl_LockRect(iface, pLockedRect, pRect, Flags);
}
-static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This) {
+static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fmt, GLenum type, UINT bpp, const BYTE *mem) {
GLint prev_store;
GLint prev_rasterpos[4];
GLint skipBytes = 0;
- BOOL storechanged = FALSE, memory_allocated = FALSE;
- GLint fmt, type;
- BYTE *mem;
- UINT bpp;
+ BOOL storechanged = FALSE;
UINT pitch = IWineD3DSurface_GetPitch((IWineD3DSurface *) This); /* target is argb, 4 byte */
IWineD3DDeviceImpl *myDevice = (IWineD3DDeviceImpl *) This->resource.wineD3DDevice;
IWineD3DSwapChainImpl *swapchain;
@@ -997,88 +994,6 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This) {
read = This->resource.allocatedMemory[0];
}
- switch (This->resource.format) {
- /* No special care needed */
- case WINED3DFMT_A4R4G4B4:
- case WINED3DFMT_R5G6B5:
- case WINED3DFMT_A1R5G5B5:
- case WINED3DFMT_R8G8B8:
- case WINED3DFMT_X4R4G4B4:
- case WINED3DFMT_X1R5G5B5:
- type = This->glDescription.glType;
- fmt = This->glDescription.glFormat;
- mem = This->resource.allocatedMemory;
- bpp = This->bytesPerPixel;
- break;
-
- /* In the past times we used to set the X channel of X8R8G8B8 and the above formats to
- * 1.0 because it happened to fix the intro movie in Pirates. However, this seems wrong.
- * If the game uses an X8R8G8B8 back buffer the GL alpha channel should not make any differences,
- * and the bug must be somewhere else. If we really have to set the alpha channel to 1.0 in
- * this case do it by clearing it after the draw instead of fixing it up in the CPU. Blending
- * is disabled via CTXUSAGE_BLIT context setup, so in the glDrawPixels call it does not
- * have any effects
- */
- case WINED3DFMT_X8R8G8B8:
- case WINED3DFMT_A8R8G8B8:
- {
- glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
- vcheckGLcall("glPixelStorei");
- storechanged = TRUE;
- type = This->glDescription.glType;
- fmt = This->glDescription.glFormat;
- mem = This->resource.allocatedMemory;
- bpp = This->bytesPerPixel;
- }
- break;
-
- case WINED3DFMT_A2R10G10B10:
- {
- glPixelStorei(GL_PACK_SWAP_BYTES, TRUE);
- vcheckGLcall("glPixelStorei");
- storechanged = TRUE;
- type = This->glDescription.glType;
- fmt = This->glDescription.glFormat;
- mem = This->resource.allocatedMemory;
- bpp = This->bytesPerPixel;
- }
- break;
-
- case WINED3DFMT_P8:
- {
- int height = This->glRect.bottom - This->glRect.top;
- type = GL_UNSIGNED_BYTE;
- fmt = GL_RGBA;
-
- mem = HeapAlloc(GetProcessHeap(), 0, This->resource.size * sizeof(DWORD));
- if(!mem) {
- ERR("Out of memory\n");
- goto cleanup;
- }
- memory_allocated = TRUE;
- d3dfmt_convert_surface(This->resource.allocatedMemory,
- mem,
- pitch,
- pitch,
- height,
- pitch * 4,
- CONVERT_PALETTED,
- This);
- bpp = This->bytesPerPixel * 4;
- pitch *= 4;
- }
- break;
-
- default:
- FIXME("Unsupported Format %u in locking func\n", This->resource.format);
-
- /* Give it a try */
- type = This->glDescription.glType;
- fmt = This->glDescription.glFormat;
- mem = This->resource.allocatedMemory;
- bpp = This->bytesPerPixel;
- }
-
if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, This->pbo));
checkGLcall("glBindBufferARB");
@@ -1090,7 +1005,6 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This) {
mem + bpp * This->lockedRect.left + pitch * This->lockedRect.top);
checkGLcall("glDrawPixels");
-cleanup:
if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_UNPACK_BUFFER_ARB, 0));
checkGLcall("glBindBufferARB");
@@ -1110,8 +1024,6 @@ cleanup:
vcheckGLcall("glPixelStorei GL_PACK_SWAP_BYTES");
}
- if(memory_allocated) HeapFree(GetProcessHeap(), 0, mem);
-
if(!swapchain) {
glDrawBuffer(myDevice->offscreenBuffer);
checkGLcall("glDrawBuffer(myDevice->offscreenBuffer)");
@@ -1390,7 +1302,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
p8_render_target = TRUE;
}
- /* Use conversion when the paletted texture extension OR fragment shaders are available. When either
+ /* Use conversion when the paletted texture extension OR fragment shaders are available. When either
* of the two is available make sure texturing is requested as neither of the two works in
* conjunction with calls like glDraw-/glReadPixels. Further also use conversion in case of color keying.
* Paletted textures can be emulated using shaders but only do that for 2D purposes e.g. situations
@@ -3832,7 +3744,37 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
if(This->Flags & SFLAG_INTEXTURE) {
surface_blt_to_drawable(This, rect);
} else {
- flush_to_framebuffer_drawpixels(This);
+ d3dfmt_get_conv(This, TRUE /* We need color keying */, FALSE /* We won't use textures */, &format, &internal, &type, &convert, &bpp, This->srgb);
+
+ /* The width is in 'length' not in bytes */
+ width = This->currentDesc.Width;
+ pitch = IWineD3DSurface_GetPitch(iface);
+
+ if((convert != NO_CONVERSION) && This->resource.allocatedMemory) {
+ int height = This->currentDesc.Height;
+
+ /* Stick to the alignment for the converted surface too, makes it easier to load the surface */
+ outpitch = width * bpp;
+ outpitch = (outpitch + device->surface_alignment - 1) & ~(device->surface_alignment - 1);
+
+ mem = HeapAlloc(GetProcessHeap(), 0, outpitch * height);
+ if(!mem) {
+ ERR("Out of memory %d, %d!\n", outpitch, height);
+ return WINED3DERR_OUTOFVIDEOMEMORY;
+ }
+ d3dfmt_convert_surface(This->resource.allocatedMemory, mem, pitch, width, height, outpitch, convert, This);
+
+ This->Flags |= SFLAG_CONVERTED;
+ } else {
+ This->Flags &= ~SFLAG_CONVERTED;
+ mem = This->resource.allocatedMemory;
+ }
+
+ flush_to_framebuffer_drawpixels(This, format, type, bpp, mem);
+
+ /* Don't delete PBO memory */
+ if((mem != This->resource.allocatedMemory) && !(This->Flags & SFLAG_PBO))
+ HeapFree(GetProcessHeap(), 0, mem);
}
} else /* if(flag == SFLAG_INTEXTURE) */ {
d3dfmt_get_conv(This, TRUE /* We need color keying */, TRUE /* We will use textures */, &format, &internal, &type, &convert, &bpp, This->srgb);
Module: wine
Branch: master
Commit: 1da9d47f1b06feccf25d1c8da345e93924b5c415
URL: http://source.winehq.org/git/wine.git/?a=commit;h=1da9d47f1b06feccf25d1c8da…
Author: Rob Shearman <rob(a)codeweavers.com>
Date: Mon Jan 7 15:21:02 2008 +0000
rpcrt4: Add tests for some async RPC functions.
---
dlls/rpcrt4/tests/Makefile.in | 1 +
dlls/rpcrt4/tests/rpc_async.c | 102 +++++++++++++++++++++++++++++++++++++++++
2 files changed, 103 insertions(+), 0 deletions(-)
diff --git a/dlls/rpcrt4/tests/Makefile.in b/dlls/rpcrt4/tests/Makefile.in
index c497aa3..3191973 100644
--- a/dlls/rpcrt4/tests/Makefile.in
+++ b/dlls/rpcrt4/tests/Makefile.in
@@ -15,6 +15,7 @@ CTESTS = \
generated.c \
ndr_marshall.c \
rpc.c \
+ rpc_async.c \
server.c
@MAKE_TEST_RULES@
diff --git a/dlls/rpcrt4/tests/rpc_async.c b/dlls/rpcrt4/tests/rpc_async.c
new file mode 100644
index 0000000..0d32fd1
--- /dev/null
+++ b/dlls/rpcrt4/tests/rpc_async.c
@@ -0,0 +1,102 @@
+/*
+ * Unit test suite for rpc functions
+ *
+ * Copyright 2008 Robert Shearman (for CodeWeavers)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+
+#include "wine/test.h"
+
+#include <rpc.h>
+#include <rpcasync.h>
+
+RPC_STATUS (RPC_ENTRY *pRpcAsyncInitializeHandle)(PRPC_ASYNC_STATE,unsigned int);
+RPC_STATUS (RPC_ENTRY *pRpcAsyncGetCallStatus)(PRPC_ASYNC_STATE);
+
+static void test_RpcAsyncInitializeHandle(void)
+{
+ char buffer[256];
+ RPC_ASYNC_STATE async;
+ RPC_STATUS status;
+ int i;
+
+ status = pRpcAsyncInitializeHandle((PRPC_ASYNC_STATE)buffer, sizeof(buffer));
+ todo_wine
+ ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with large Size should have returned ERROR_INVALID_PARAMETER instead of %ld\n", status);
+
+ status = pRpcAsyncInitializeHandle(&async, sizeof(async) - 1);
+ todo_wine
+ ok(status == ERROR_INVALID_PARAMETER, "RpcAsyncInitializeHandle with small Size should have returned ERROR_INVALID_PARAMETER instead of %ld\n", status);
+
+ memset(&async, 0xcc, sizeof(async));
+ status = pRpcAsyncInitializeHandle(&async, sizeof(async));
+ todo_wine
+ ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %ld\n", status);
+
+ todo_wine
+ ok(async.Size == sizeof(async), "async.Size wrong: %d\n", async.Size);
+ todo_wine
+ ok(async.Signature == 0x43595341, "async.Signature should be 0x43595341, but is 0x%x instead\n", async.Signature);
+ todo_wine
+ ok(async.Lock == 0, "async.Lock should be 0, but is %d instead\n", async.Lock);
+ todo_wine
+ ok(async.Flags == 0, "async.Flags should be 0, but is %d instead\n", async.Flags);
+ todo_wine
+ ok(async.StubInfo == NULL, "async.StubInfo should be NULL, not %p\n", async.StubInfo);
+ ok(async.UserInfo == (void *)0xcccccccc, "async.UserInfo should be unset, not %p\n", async.UserInfo);
+ todo_wine
+ ok(async.RuntimeInfo == NULL, "async.RuntimeInfo should be NULL, not %p\n", async.RuntimeInfo);
+ ok(async.Event == 0xcccccccc, "async.Event should be unset, not %d\n", async.Event);
+ ok(async.NotificationType == 0xcccccccc, "async.NotificationType should be unset, not %d\n", async.NotificationType);
+ for (i = 0; i < 4; i++)
+ todo_wine
+ ok(async.Reserved[i] == 0x0, "async.Reserved[%d] should be 0x0, not 0x%lx\n", i, async.Reserved[i]);
+}
+
+static void test_RpcAsyncGetCallStatus(void)
+{
+ RPC_ASYNC_STATE async;
+ RPC_STATUS status;
+
+ status = pRpcAsyncInitializeHandle(&async, sizeof(async));
+ todo_wine
+ ok(status == RPC_S_OK, "RpcAsyncInitializeHandle failed with error %ld\n", status);
+
+ status = pRpcAsyncGetCallStatus(&async);
+ todo_wine
+ ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %ld\n", status);
+
+ memset(&async, 0, sizeof(async));
+ status = pRpcAsyncGetCallStatus(&async);
+ todo_wine
+ ok(status == RPC_S_INVALID_BINDING, "RpcAsyncGetCallStatus should have returned RPC_S_INVALID_BINDING instead of %ld\n", status);
+}
+
+START_TEST( rpc_async )
+{
+ HMODULE hRpcRt4 = GetModuleHandle("rpcrt4.dll");
+ pRpcAsyncInitializeHandle = (void *)GetProcAddress(hRpcRt4, "RpcAsyncInitializeHandle");
+ pRpcAsyncGetCallStatus = (void *)GetProcAddress(hRpcRt4, "RpcAsyncGetCallStatus");
+ if (!pRpcAsyncInitializeHandle || !pRpcAsyncGetCallStatus)
+ {
+ skip("asynchronous functions not available\n");
+ return;
+ }
+ test_RpcAsyncInitializeHandle();
+ test_RpcAsyncGetCallStatus();
+}