Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
01273e7e
Commit
01273e7e
authored
Jun 17, 2006
by
Stefan Dösinger
Committed by
Alexandre Julliard
Jun 19, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ddraw: Palette refcounting fixes + tests.
parent
e4b51580
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
174 additions
and
3 deletions
+174
-3
ddraw.c
dlls/ddraw/ddraw.c
+19
-2
palette.c
dlls/ddraw/palette.c
+1
-0
surface.c
dlls/ddraw/surface.c
+4
-0
.gitignore
dlls/ddraw/tests/.gitignore
+1
-0
Makefile.in
dlls/ddraw/tests/Makefile.in
+2
-1
refcount.c
dlls/ddraw/tests/refcount.c
+147
-0
No files found.
dlls/ddraw/ddraw.c
View file @
01273e7e
...
...
@@ -2950,13 +2950,29 @@ IDirectDrawImpl_CreatePalette(IDirectDraw7 *iface,
HRESULT
hr
=
DDERR_GENERIC
;
TRACE
(
"(%p)->(%lx,%p,%p,%p)
\n
"
,
This
,
Flags
,
ColorTable
,
Palette
,
pUnkOuter
);
if
(
pUnkOuter
!=
NULL
)
return
CLASS_E_NOAGGREGATION
;
/* unchecked */
if
(
pUnkOuter
!=
NULL
)
{
WARN
(
"pUnkOuter is %p, returning CLASS_E_NOAGGREGATION
\n
"
,
pUnkOuter
);
return
CLASS_E_NOAGGREGATION
;
}
/* The refcount test shows that a cooplevel is required for this */
if
(
!
This
->
cooperative_level
)
{
WARN
(
"No cooperative level set, returning DDERR_NOCOOPERATIVELEVELSET
\n
"
);
return
DDERR_NOCOOPERATIVELEVELSET
;
}
object
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
IDirectDrawPaletteImpl
));
if
(
!
object
)
return
E_OUTOFMEMORY
;
if
(
!
object
)
{
ERR
(
"Out of memory when allocating memory for a palette implementation
\n
"
);
return
E_OUTOFMEMORY
;
}
ICOM_INIT_INTERFACE
(
object
,
IDirectDrawPalette
,
IDirectDrawPalette_Vtbl
);
object
->
ref
=
1
;
object
->
ddraw_owner
=
This
;
hr
=
IWineD3DDevice_CreatePalette
(
This
->
wineD3DDevice
,
Flags
,
ColorTable
,
&
object
->
wineD3DPalette
,
(
IUnknown
*
)
ICOM_INTERFACE
(
object
,
IDirectDrawPalette
)
);
if
(
hr
!=
DD_OK
)
...
...
@@ -2965,6 +2981,7 @@ IDirectDrawImpl_CreatePalette(IDirectDraw7 *iface,
return
hr
;
}
IDirectDraw7_AddRef
(
iface
);
*
Palette
=
ICOM_INTERFACE
(
object
,
IDirectDrawPalette
);
return
DD_OK
;
}
...
...
dlls/ddraw/palette.c
View file @
01273e7e
...
...
@@ -104,6 +104,7 @@ IDirectDrawPaletteImpl_Release(IDirectDrawPalette *iface)
if
(
ref
==
0
)
{
IWineD3DPalette_Release
(
This
->
wineD3DPalette
);
IDirectDraw7_Release
(
ICOM_INTERFACE
(
This
->
ddraw_owner
,
IDirectDraw7
));
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
dlls/ddraw/surface.c
View file @
01273e7e
...
...
@@ -360,6 +360,10 @@ IDirectDrawSurfaceImpl_Release(IDirectDrawSurface7 *iface)
}
}
/* The refcount test shows that the palette is detached when the surface is destroyed */
IDirectDrawSurface7_SetPalette
(
ICOM_INTERFACE
(
This
,
IDirectDrawSurface7
),
NULL
);
/* Loop through all complex attached surfaces,
* and destroy them
*/
...
...
dlls/ddraw/tests/.gitignore
View file @
01273e7e
...
...
@@ -2,4 +2,5 @@ Makefile
d3d.ok
ddrawmodes.ok
dsurface.ok
refcount.ok
testlist.c
dlls/ddraw/tests/Makefile.in
View file @
01273e7e
...
...
@@ -9,7 +9,8 @@ EXTRALIBS = -ldxguid
CTESTS
=
\
d3d.c
\
ddrawmodes.c
\
dsurface.c
dsurface.c
\
refcount.c
@MAKE_TEST_RULES@
...
...
dlls/ddraw/tests/refcount.c
0 → 100644
View file @
01273e7e
/*
* Some unit tests for ddraw reference counting
*
* Copyright (C) 2006 Stefan Dösinger
*
* 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
*/
#define COBJMACROS
#include <assert.h>
#include "wine/test.h"
#include "ddraw.h"
#include "d3d.h"
#include "unknwn.h"
static
HRESULT
(
WINAPI
*
pDirectDrawCreateEx
)(
LPGUID
,
LPVOID
*
,
REFIID
,
LPUNKNOWN
);
static
void
init_function_pointers
(
void
)
{
HMODULE
hmod
=
GetModuleHandleA
(
"ddraw.dll"
);
if
(
hmod
)
{
pDirectDrawCreateEx
=
(
void
*
)
GetProcAddress
(
hmod
,
"DirectDrawCreateEx"
);
}
}
unsigned
long
getRefcount
(
IUnknown
*
iface
)
{
IUnknown_AddRef
(
iface
);
return
IUnknown_Release
(
iface
);
}
static
void
test_ddraw
(
void
)
{
HRESULT
hr
;
unsigned
long
ref
;
IDirectDraw7
*
DDraw
;
IDirectDrawPalette
*
palette
;
IDirectDrawSurface7
*
surface
;
PALETTEENTRY
Table
[
256
];
DDSURFACEDESC2
ddsd
;
hr
=
pDirectDrawCreateEx
(
NULL
,
(
void
**
)
&
DDraw
,
&
IID_IDirectDraw7
,
NULL
);
ok
(
hr
==
DD_OK
||
hr
==
DDERR_NODIRECTDRAWSUPPORT
,
"DirectDrawCreateEx returned: %lx
\n
"
,
hr
);
if
(
!
DDraw
)
{
trace
(
"Couldn't create DDraw interface, skipping tests
\n
"
);
return
;
}
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
/* Fails without a cooplevel */
hr
=
IDirectDraw7_CreatePalette
(
DDraw
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
ok
(
hr
==
DDERR_NOCOOPERATIVELEVELSET
,
"CreatePalette returned %08lx
\n
"
,
hr
);
/* This check is before the cooplevel check */
hr
=
IDirectDraw7_CreatePalette
(
DDraw
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
(
void
*
)
0xdeadbeef
);
ok
(
hr
==
CLASS_E_NOAGGREGATION
,
"CreatePalette returned %08lx
\n
"
,
hr
);
hr
=
IDirectDraw7_SetCooperativeLevel
(
DDraw
,
0
,
DDSCL_NORMAL
);
ok
(
hr
==
DD_OK
,
"SetCooperativeLevel failed with %08lx
\n
"
,
hr
);
memset
(
&
ddsd
,
0
,
sizeof
(
ddsd
));
ddsd
.
dwSize
=
sizeof
(
ddsd
);
ddsd
.
dwFlags
=
DDSD_CAPS
|
DDSD_WIDTH
|
DDSD_HEIGHT
|
DDSD_PIXELFORMAT
;
ddsd
.
dwWidth
=
64
;
ddsd
.
dwHeight
=
64
;
ddsd
.
ddsCaps
.
dwCaps
=
DDSCAPS_OFFSCREENPLAIN
;
ddsd
.
ddpfPixelFormat
.
dwSize
=
sizeof
(
ddsd
.
ddpfPixelFormat
);
ddsd
.
ddpfPixelFormat
.
dwFlags
=
DDPF_PALETTEINDEXED8
|
DDPF_RGB
;
ddsd
.
ddpfPixelFormat
.
dwRGBBitCount
=
8
;
hr
=
IDirectDraw7_CreateSurface
(
DDraw
,
&
ddsd
,
&
surface
,
NULL
);
ok
(
hr
==
DD_OK
,
"CreateSurface failed with %08lx
\n
"
,
hr
);
/* DDraw refcount increased by 1 */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ok
(
ref
==
2
,
"Got refcount %ld, expected 2
\n
"
,
ref
);
/* Surface refcount starts with 1 */
ref
=
getRefcount
(
(
IUnknown
*
)
surface
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
hr
=
IDirectDraw7_CreatePalette
(
DDraw
,
DDPCAPS_ALLOW256
|
DDPCAPS_8BIT
,
Table
,
&
palette
,
NULL
);
ok
(
hr
==
DD_OK
,
"CreatePalette returned %08lx
\n
"
,
hr
);
/* DDraw refcount increased by 1 */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ok
(
ref
==
3
,
"Got refcount %ld, expected 3
\n
"
,
ref
);
/* Palette starts with 1 */
ref
=
getRefcount
(
(
IUnknown
*
)
palette
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
/* Test attaching a palette to a surface */
hr
=
IDirectDrawSurface7_SetPalette
(
surface
,
palette
);
ok
(
hr
==
DD_OK
,
"IDirectDrawSurface_SetPalette failed with %08lx
\n
"
,
hr
);
/* Palette refcount increased, surface stays the same */
ref
=
getRefcount
(
(
IUnknown
*
)
palette
);
ok
(
ref
==
2
,
"Got refcount %ld, expected 2
\n
"
,
ref
);
ref
=
getRefcount
(
(
IUnknown
*
)
surface
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
IDirectDrawSurface7_Release
(
surface
);
/* Incresed before - decrease now */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ok
(
ref
==
2
,
"Got refcount %ld, expected 2
\n
"
,
ref
);
/* Releasing the surface detaches the palette */
ref
=
getRefcount
(
(
IUnknown
*
)
palette
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
IDirectDrawPalette_Release
(
palette
);
/* Incresed before - decrease now */
ref
=
getRefcount
(
(
IUnknown
*
)
DDraw
);
ok
(
ref
==
1
,
"Got refcount %ld, expected 1
\n
"
,
ref
);
IDirectDraw7_Release
(
DDraw
);
}
START_TEST
(
refcount
)
{
init_function_pointers
();
if
(
!
pDirectDrawCreateEx
)
{
trace
(
"function DirectDrawCreateEx not available, skipping tests
\n
"
);
return
;
}
test_ddraw
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment