surface_gdi.c revision 040b4a09341f574825386333398110f4db3e1e51
/*
* 2D Surface implementation without OpenGL
*
* Copyright 1997-2000 Marcus Meissner
* Copyright 1998-2000 Lionel Ulmer
* Copyright 2000-2001 TransGaming Technologies Inc.
* Copyright 2002-2005 Jason Edmeades
* Copyright 2002-2003 Raphael Junqueira
* Copyright 2004 Christian Costa
* Copyright 2005 Oliver Stieber
* Copyright 2006-2008 Stefan Dösinger
*
* 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
*/
/*
* Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
* other than GPL or LGPL is available it will apply instead, Sun elects to use only
* the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
* a choice of LGPL license versions is made available with the language indicating
* that LGPLv2 or any later version may be used, or where a choice of which version
* of the LGPL is applied is otherwise unspecified.
*/
#include "config.h"
#include "wined3d_private.h"
#include <stdio.h>
/* Use the d3d_surface debug channel to have one channel for all surfaces */
{
{
/* Release the DC. */
/* Release the DIB section. */
}
}
/*****************************************************************************
* IWineD3DSurface::Release, GDI version
*
* In general a normal COM Release method, but the GDI version doesn't have
* to destroy all the GL things.
*
*****************************************************************************/
if (!ref)
{
}
return ref;
}
/*****************************************************************************
* IWineD3DSurface::PreLoad, GDI version
*
* This call is unsupported on GDI surfaces, if it's called something went
* wrong in the parent library. Write an informative warning
*
*****************************************************************************/
static void WINAPI
{
}
/*****************************************************************************
* IWineD3DSurface::UnLoad, GDI version
*
* This call is unsupported on GDI surfaces, if it's called something went
* wrong in the parent library. Write an informative warning.
*
*****************************************************************************/
{
}
/*****************************************************************************
* IWineD3DSurface::LockRect, GDI version
*
* Locks the surface and returns a pointer to the surface memory
*
* Params:
* pLockedRect: Address to return the locking info at
* pRect: Rectangle to lock
* Flags: Some flags
*
* Returns:
* WINED3D_OK on success
* WINED3DERR_INVALIDCALL on errors
*
*****************************************************************************/
{
/* Already locked? */
{
/* What should I return here? */
return WINED3DERR_INVALIDCALL;
}
/* This happens on gdi surfaces if the application set a user pointer and resets it.
* Recreate the DIB section
*/
}
}
/*****************************************************************************
* IWineD3DSurface::UnlockRect, GDI version
*
* Unlocks a surface. This implementation doesn't do much, except updating
* the window if the front buffer is unlocked
*
* Returns:
* WINED3D_OK on success
* WINED3DERR_INVALIDCALL on failure
*
*****************************************************************************/
{
{
return WINEDDERR_NOTLOCKED;
}
/* Can be useful for debugging */
#if 0
{
static unsigned int gen = 0;
char buffer[4096];
++gen;
if ((gen % 10) == 0) {
}
/*
* debugging crash code
if (gen == 250) {
void** test = NULL;
*test = 0;
}
*/
}
#endif
/* Tell the swapchain to update the screen */
{
{
}
}
return WINED3D_OK;
}
/*****************************************************************************
* IWineD3DSurface::Flip, GDI version
*
* Flips 2 flipping enabled surfaces. Determining the 2 targets is done by
* the parent library. This implementation changes the data pointers of the
* surfaces and copies the new front buffer content to the screen
*
* Params:
* override: Flipping target(e.g. back buffer)
*
* Returns:
* WINED3D_OK on success
*
*****************************************************************************/
{
{
ERR("Flipped surface is not on a swapchain\n");
return WINEDDERR_NOTFLIPPABLE;
}
return hr;
}
/*****************************************************************************
* IWineD3DSurface::LoadTexture, GDI version
*
* This is mutually unsupported by GDI surfaces
*
* Returns:
* D3DERR_INVALIDCALL
*
*****************************************************************************/
{
ERR("Unsupported on X11 surfaces\n");
return WINED3DERR_INVALIDCALL;
}
/*****************************************************************************
* IWineD3DSurface::SaveSnapshot, GDI version
*
* This method writes the surface's contents to the in tga format to the
* file specified in filename.
*
* Params:
* filename: File to write to
*
* Returns:
* WINED3DERR_INVALIDCALL if the file couldn't be opened
* WINED3D_OK on success
*
*****************************************************************************/
int shift = 0;
while (color_mask > 0xFF) {
color_mask >>= 1;
shift += 1;
}
while ((color_mask & 0x80) == 0) {
color_mask <<= 1;
shift -= 1;
}
return shift;
}
const char* filename)
{
UINT y = 0, x = 0;
}
if (NULL == f) {
return WINED3DERR_INVALIDCALL;
}
{
int i;
fclose(f);
return WINED3DERR_INVALIDCALL;
}
for (i = 0; i < 256; i++) {
}
for (y = 0; y < This->pow2Height; y++) {
src += 1;
}
}
} else {
for (y = 0; y < This->pow2Height; y++) {
const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
unsigned int color;
unsigned int comp;
int i;
color = 0;
for (i = 0; i < pix_width; i++) {
}
}
}
}
fclose(f);
return WINED3D_OK;
}
ERR("Not supported on surfaces with an application-provided surfaces\n");
return WINEDDERR_NODC;
}
/* Give more detailed info for ddraw */
return WINEDDERR_DCALREADYCREATED;
/* Can't GetDC if the surface is locked */
return WINED3DERR_INVALIDCALL;
/* Should have a DIB section already */
/* Lock the surface */
&lock,
NULL,
0);
/* keep the dib section */
return hr;
}
{
unsigned int n;
} else {
}
if (pal) {
for (n=0; n<256; n++) {
col[n].rgbReserved = 0;
}
}
}
return WINED3D_OK;
}
return WINEDDERR_NODC;
return WINEDDERR_NODC;
}
/* we locked first, so unlock now */
return WINED3D_OK;
}
unsigned int n;
if (!pal) return WINED3D_OK;
for (n=0; n<256; n++) {
col[n].rgbReserved = 0;
}
}
/* Update the image because of the palette change. Some games like e.g Red Alert
call SetEntries a lot to implement fading. */
/* Tell the swapchain to update the screen */
{
{
}
}
return WINED3D_OK;
}
/*****************************************************************************
* IWineD3DSurface::PrivateSetup, GDI version
*
* Initializes the GDI surface, aka creates the DIB section we render to
* The DIB section creation is done by calling GetDC, which will create the
* section and releasing the dc to allow the app to use it. The dib section
* will stay until the surface is released
*
* GDI surfaces do not need to be a power of 2 in size, so the pow2 sizes
* are set to the real sizes to save memory. The NONPOW2 flag is unset to
* avoid confusion in the shared surface code.
*
* Returns:
* WINED3D_OK on success
* The return values of called methods on failure
*
*****************************************************************************/
{
{
return WINED3DERR_INVALIDCALL;
}
/* Sysmem textures have memory already allocated -
* release it, this avoids an unnecessary memcpy
*/
/* We don't mind the nonpow2 stuff in GDI */
return WINED3D_OK;
}
/* Render targets depend on their hdc, and we can't create an hdc on a user pointer */
ERR("Not supported on render targets\n");
return WINED3DERR_INVALIDCALL;
}
WARN("Surface is locked or the HDC is in use\n");
return WINED3DERR_INVALIDCALL;
}
/* Do I have to copy the old surface content? */
/* Release the DC. No need to hold the critical section for the update
* Thread because this thread runs only on front buffers, but this method
* fails for render targets in the check above.
*/
/* Release the DIB section */
}
/* Now free the old memory if any */
/* LockRect and GetDC will re-create the dib section and allocated memory */
}
return WINED3D_OK;
}
/***************************
*
***************************/
static void WINAPI IWineGDISurfaceImpl_ModifyLocation(IWineD3DSurface *iface, DWORD flag, BOOL persistent) {
flag == SFLAG_INSYSMEM ? "SFLAG_INSYSMEM" : flag == SFLAG_INDRAWABLE ? "SFLAG_INDRAWABLE" : "SFLAG_INTEXTURE",
/* GDI surfaces can be in system memory only */
if(flag != SFLAG_INSYSMEM) {
}
}
static HRESULT WINAPI IWineGDISurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) {
if(flag != SFLAG_INSYSMEM) {
ERR("GDI Surface requested to be copied to gl %s\n", flag == SFLAG_INTEXTURE ? "texture" : "drawable");
} else {
TRACE("Surface requested in surface memory\n");
}
return WINED3D_OK;
}
return SURFACE_GDI;
}
FIXME("GDI surfaces can't draw overlays yet\n");
return E_FAIL;
}
/* FIXME: This vtable should not use any IWineD3DSurface* implementation functions,
* only IWineD3DBaseSurface and IWineGDISurface ones.
*/
{
/* IUnknown */
/* IWineD3DResource */
/* IWineD3DSurface */
/* Internal use: */
};