wined3d: Add support for showing a logo.
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 402b08a..729acf7 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -1871,6 +1871,63 @@
return WINED3D_OK;
}
+static void IWineD3DDeviceImpl_LoadLogo(IWineD3DDeviceImpl *This, const char *filename) {
+ HBITMAP hbm;
+ BITMAP bm;
+ HRESULT hr;
+ HDC dcb = NULL, dcs = NULL;
+ WINEDDCOLORKEY colorkey;
+
+ hbm = (HBITMAP) LoadImageA(NULL, filename, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
+ if(hbm)
+ {
+ GetObjectA(hbm, sizeof(BITMAP), &bm);
+ dcb = CreateCompatibleDC(NULL);
+ if(!dcb) goto out;
+ SelectObject(dcb, hbm);
+ }
+ else
+ {
+ /* Create a 32x32 white surface to indicate that wined3d is used, but the specified image
+ * couldn't be loaded
+ */
+ memset(&bm, 0, sizeof(bm));
+ bm.bmWidth = 32;
+ bm.bmHeight = 32;
+ }
+
+ hr = IWineD3DDevice_CreateSurface((IWineD3DDevice *) This, bm.bmWidth, bm.bmHeight, WINED3DFMT_R5G6B5,
+ TRUE, FALSE, 0, &This->logo_surface, WINED3DRTYPE_SURFACE, 0,
+ WINED3DPOOL_DEFAULT, WINED3DMULTISAMPLE_NONE, 0, NULL, SURFACE_OPENGL, NULL);
+ if(FAILED(hr)) {
+ ERR("Wine logo requested, but failed to create surface\n");
+ goto out;
+ }
+
+ if(dcb) {
+ hr = IWineD3DSurface_GetDC(This->logo_surface, &dcs);
+ if(FAILED(hr)) goto out;
+ BitBlt(dcs, 0, 0, bm.bmWidth, bm.bmHeight, dcb, 0, 0, SRCCOPY);
+ IWineD3DSurface_ReleaseDC(This->logo_surface, dcs);
+
+ colorkey.dwColorSpaceLowValue = 0;
+ colorkey.dwColorSpaceHighValue = 0;
+ IWineD3DSurface_SetColorKey(This->logo_surface, WINEDDCKEY_SRCBLT, &colorkey);
+ } else {
+ /* Fill the surface with a white color to show that wined3d is there */
+ IWineD3DDevice_ColorFill((IWineD3DDevice *) This, This->logo_surface, NULL, 0xffffffff);
+ }
+
+ out:
+ if(dcb) {
+ DeleteDC(dcb);
+ }
+ if(hbm) {
+ DeleteObject(hbm);
+ }
+ return;
+}
+
static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPRESENT_PARAMETERS* pPresentationParameters, D3DCB_CREATEADDITIONALSWAPCHAIN D3DCB_CreateAdditionalSwapChain) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DSwapChainImpl *swapchain;
@@ -2007,6 +2064,10 @@
0x00, 1.0, 0);
This->d3d_initialized = TRUE;
+
+ if(wined3d_settings.logo) {
+ IWineD3DDeviceImpl_LoadLogo(This, wined3d_settings.logo);
+ }
return WINED3D_OK;
}
@@ -2023,6 +2084,8 @@
*/
ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
+ if(This->logo_surface) IWineD3DSurface_Release(This->logo_surface);
+
TRACE("Deleting high order patches\n");
for(i = 0; i < PATCHMAP_SIZE; i++) {
struct list *e1, *e2;
diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c
index f5ab22d..4ecab95 100644
--- a/dlls/wined3d/swapchain.c
+++ b/dlls/wined3d/swapchain.c
@@ -175,6 +175,10 @@
}
IWineD3DSurface_Blt(This->backBuffer[0], &destRect, (IWineD3DSurface *) &cursor, NULL, WINEDDBLT_KEYSRC, NULL, WINED3DTEXF_NONE);
}
+ if(This->wineD3DDevice->logo_surface) {
+ /* Blit the logo into the upper left corner of the drawable */
+ IWineD3DSurface_BltFast(This->backBuffer[0], 0, 0, This->wineD3DDevice->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY);
+ }
if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
/* TODO: If only source rect or dest rect are supplied then clip the window to match */
diff --git a/dlls/wined3d/wined3d_main.c b/dlls/wined3d/wined3d_main.c
index 13ab258..92bfe75 100644
--- a/dlls/wined3d/wined3d_main.c
+++ b/dlls/wined3d/wined3d_main.c
@@ -42,7 +42,8 @@
FALSE, /* Use of GLSL disabled by default */
ORM_BACKBUFFER, /* Use the backbuffer to do offscreen rendering */
RTL_AUTO, /* Automatically determine best locking method */
- 64*1024*1024 /* 64MB texture memory by default */
+ 64*1024*1024, /* 64MB texture memory by default */
+ NULL /* No wine logo by default */
};
WineD3DGlobalStatistics *wineD3DGlobalStatistics = NULL;
@@ -274,6 +275,11 @@
else
ERR("VideoMemorySize is %i but must be >0\n", TmpVideoMemorySize);
}
+ if ( !get_config_key( hkey, appkey, "WineLogo", buffer, size) )
+ {
+ wined3d_settings.logo = HeapAlloc(GetProcessHeap(), 0, strlen(buffer) + 1);
+ if(wined3d_settings.logo) strcpy(wined3d_settings.logo, buffer);
+ }
}
if (wined3d_settings.vs_mode == VS_HW)
TRACE("Allow HW vertex shaders\n");
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 7fa0335..b6f4bee 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -197,6 +197,7 @@
int rendertargetlock_mode;
/* Memory tracking and object counting */
unsigned int emulated_textureram;
+ char *logo;
} wined3d_settings_t;
extern wined3d_settings_t wined3d_settings;
@@ -728,6 +729,9 @@
BOOL haveHardwareCursor;
HCURSOR hardwareCursor;
+ /* The Wine logo surface */
+ IWineD3DSurface *logo_surface;
+
/* Textures for when no other textures are mapped */
UINT dummyTextureName[MAX_TEXTURES];