Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
9a013cc1
Commit
9a013cc1
authored
Nov 24, 2004
by
Kevin Koltzau
Committed by
Alexandre Julliard
Nov 24, 2004
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CreateBrushIndirect should not return a stock brush.
parent
9d847413
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
79 additions
and
29 deletions
+79
-29
brush.c
dlls/gdi/brush.c
+0
-29
.cvsignore
dlls/gdi/tests/.cvsignore
+1
-0
Makefile.in
dlls/gdi/tests/Makefile.in
+1
-0
brush.c
dlls/gdi/tests/brush.c
+77
-0
No files found.
dlls/gdi/brush.c
View file @
9a013cc1
...
...
@@ -101,41 +101,12 @@ static HGLOBAL16 dib_copy(BITMAPINFO *info, UINT coloruse)
* - Windows 95 and earlier cannot create brushes from bitmaps or DIBs larger
* than 8x8 pixels. If a larger bitmap is given, only a portion of the bitmap
* is used.
* - If the brush to be created matches a stock brush, a stock brush will be
* returned. This behaviour is undocumented.
*/
HBRUSH
WINAPI
CreateBrushIndirect
(
const
LOGBRUSH
*
brush
)
{
static
const
DWORD
stockMap
[]
=
{
/* Map of RGB colors of stock brushes */
RGB
(
255
,
255
,
255
),
WHITE_BRUSH
,
RGB
(
192
,
192
,
192
),
LTGRAY_BRUSH
,
RGB
(
128
,
128
,
128
),
GRAY_BRUSH
,
RGB
(
0
,
0
,
0
),
BLACK_BRUSH
};
BRUSHOBJ
*
ptr
;
HBRUSH
hbrush
;
if
(
brush
->
lbStyle
==
BS_SOLID
)
{
size_t
i
;
/* If a solid brush is created in a color matching one of the
* stock brushes, native returns the stock object (GDI heap
* optimisation). Some apps rely on this as they otherwise
* would leak their brushes.
*/
for
(
i
=
0
;
i
<
(
sizeof
(
stockMap
)
/
sizeof
(
stockMap
[
0
]));
i
+=
2
)
{
if
(
brush
->
lbColor
==
stockMap
[
i
])
{
HBRUSH
hBr
=
GetStockObject
(
stockMap
[
i
+
1
]);
if
(
hBr
)
return
hBr
;
/* Return stock brush */
break
;
/* Being called to create a stock brush, fall through */
}
}
}
if
(
!
(
ptr
=
GDI_AllocObject
(
sizeof
(
BRUSHOBJ
),
BRUSH_MAGIC
,
(
HGDIOBJ
*
)
&
hbrush
,
&
brush_funcs
)))
return
0
;
ptr
->
logbrush
.
lbStyle
=
brush
->
lbStyle
;
...
...
dlls/gdi/tests/.cvsignore
View file @
9a013cc1
Makefile
bitmap.ok
brush.ok
gdiobj.ok
generated.ok
metafile.ok
...
...
dlls/gdi/tests/Makefile.in
View file @
9a013cc1
...
...
@@ -7,6 +7,7 @@ IMPORTS = user32 gdi32
CTESTS
=
\
bitmap.c
\
brush.c
\
gdiobj.c
\
generated.c
\
metafile.c
...
...
dlls/gdi/tests/brush.c
0 → 100644
View file @
9a013cc1
/*
* Unit test suite for brushes
*
* Copyright 2004 Kevin Koltzau
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "wine/test.h"
typedef
struct
_STOCK_BRUSH
{
COLORREF
color
;
int
stockobj
;
char
*
name
;
}
STOCK_BRUSH
;
static
void
test_solidbrush
()
{
static
const
STOCK_BRUSH
stock
[]
=
{
{
RGB
(
255
,
255
,
255
),
WHITE_BRUSH
,
"white"
},
{
RGB
(
192
,
192
,
192
),
LTGRAY_BRUSH
,
"ltgray"
},
{
RGB
(
128
,
128
,
128
),
GRAY_BRUSH
,
"gray"
},
{
RGB
(
0
,
0
,
0
),
BLACK_BRUSH
,
"black"
},
{
RGB
(
0
,
0
,
255
),
-
1
,
"blue"
}
};
HBRUSH
solidBrush
;
HBRUSH
stockBrush
;
LOGBRUSH
br
;
size_t
i
;
for
(
i
=
0
;
i
<
sizeof
(
stock
)
/
sizeof
(
stock
[
0
]);
i
++
)
{
solidBrush
=
CreateSolidBrush
(
stock
[
i
].
color
);
if
(
stock
[
i
].
stockobj
!=
-
1
)
{
stockBrush
=
(
HBRUSH
)
GetStockObject
(
stock
[
i
].
stockobj
);
ok
(
stockBrush
!=
solidBrush
,
"Stock %s brush equals solid %s brush
\n
"
,
stock
[
i
].
name
,
stock
[
i
].
name
);
}
else
stockBrush
=
NULL
;
memset
(
&
br
,
sizeof
(
br
),
0
);
ok
(
GetObject
(
solidBrush
,
sizeof
(
br
),
&
br
)
!=
0
,
"GetObject on solid %s brush failed, error=%ld
\n
"
,
stock
[
i
].
name
,
GetLastError
());
ok
(
br
.
lbStyle
==
BS_SOLID
,
"%s brush has wrong style, got %d expected %d
\n
"
,
stock
[
i
].
name
,
br
.
lbStyle
,
BS_SOLID
);
ok
(
br
.
lbColor
==
stock
[
i
].
color
,
"%s brush has wrong color, got 0x%08lx expected 0x%08lx
\n
"
,
stock
[
i
].
name
,
br
.
lbColor
,
stock
[
i
].
color
);
if
(
stockBrush
)
{
/* Sanity check, make sure the colors being compared do in fact have a stock brush */
ok
(
GetObject
(
stockBrush
,
sizeof
(
br
),
&
br
)
!=
0
,
"GetObject on stock %s brush failed, error=%ld
\n
"
,
stock
[
i
].
name
,
GetLastError
());
ok
(
br
.
lbColor
==
stock
[
i
].
color
,
"stock %s brush unexpected color, got 0x%08lx expected 0x%08lx
\n
"
,
stock
[
i
].
name
,
br
.
lbColor
,
stock
[
i
].
color
);
}
DeleteObject
(
solidBrush
);
ok
(
GetObject
(
solidBrush
,
sizeof
(
br
),
&
br
)
==
0
,
"GetObject succeeded on a deleted %s brush
\n
"
,
stock
[
i
].
name
);
}
}
START_TEST
(
brush
)
{
test_solidbrush
();
}
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