Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
libSDL
Project
Project
Details
Activity
Releases
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
libSDL
Commits
20c4883d
Commit
20c4883d
authored
Jul 14, 2010
by
Eli Gottlieb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Numerous bug fixes that keep testeyes from crashing and dying.
parent
8d6d1c0e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
15 deletions
+35
-15
SDL_shape.c
src/video/SDL_shape.c
+2
-2
SDL_x11shape.c
src/video/x11/SDL_x11shape.c
+4
-1
testeyes.c
test/testeyes.c
+29
-12
No files found.
src/video/SDL_shape.c
View file @
20c4883d
...
...
@@ -48,7 +48,7 @@ SDL_bool SDL_IsShapedWindow(const SDL_Window *window) {
void
SDL_CalculateShapeBitmap
(
Uint8
alphacutoff
,
SDL_Surface
*
shape
,
Uint8
*
bitmap
,
Uint8
ppb
,
Uint8
value
)
{
int
x
=
0
;
int
y
=
0
;
Uint8
alpha
=
0
;
Uint8
r
=
0
,
g
=
0
,
b
=
0
,
alpha
=
0
;
Uint8
*
pixel
;
Uint32
bitmap_pixel
;
if
(
SDL_MUSTLOCK
(
shape
))
...
...
@@ -57,7 +57,7 @@ void SDL_CalculateShapeBitmap(Uint8 alphacutoff,SDL_Surface *shape,Uint8* bitmap
for
(
y
=
0
;
y
<
shape
->
h
;
y
++
)
{
pixel
=
shape
->
pixels
+
(
y
*
shape
->
pitch
)
+
(
x
*
shape
->
format
->
BytesPerPixel
);
alpha
=
0
;
SDL_GetRGBA
(
*
(
Uint32
*
)
pixel
,
shape
->
format
,
NULL
,
NULL
,
NULL
,
&
alpha
);
SDL_GetRGBA
(
*
(
Uint32
*
)
pixel
,
shape
->
format
,
&
r
,
&
g
,
&
b
,
&
alpha
);
Uint32
bitmap_pixel
=
y
*
shape
->
w
+
x
;
bitmap
[
bitmap_pixel
/
ppb
]
|=
(
alpha
>=
alphacutoff
?
value
:
0
)
<<
((
ppb
-
1
)
-
(
bitmap_pixel
%
ppb
));
}
...
...
src/video/x11/SDL_x11shape.c
View file @
20c4883d
...
...
@@ -34,7 +34,10 @@ SDL_WindowShaper* X11_CreateShaper(SDL_Window* window) {
result
->
window
=
window
;
result
->
alphacutoff
=
0
;
result
->
usershownflag
=
0
;
result
->
driverdata
=
malloc
(
sizeof
(
SDL_ShapeData
));
SDL_ShapeData
*
data
=
malloc
(
sizeof
(
SDL_ShapeData
));
result
->
driverdata
=
data
;
data
->
bitmapsize
=
0
;
data
->
bitmap
=
NULL
;
window
->
shaper
=
result
;
int
resized_properly
=
X11_ResizeWindowShape
(
window
);
assert
(
resized_properly
==
0
);
...
...
test/testeyes.c
View file @
20c4883d
...
...
@@ -143,31 +143,47 @@ int main(int argc,char** argv) {
exit
(
-
3
);
}
SDL_Color
bnw_palette
[
2
]
=
{{
0
,
0
,
0
,
255
},{
255
,
255
,
255
,
255
}};
SDL_Texture
*
eyes_texture
=
SDL_CreateTexture
(
SDL_PIXELFORMAT_INDEX1LSB
,
SDL_TEXTUREACCESS_STREAMING
,
eyes_width
,
eyes_height
);
if
(
eyes_texture
==
NULL
)
{
int
bpp
=
0
;
Uint32
r
=
0
,
g
=
0
,
b
=
0
,
a
=
0
;
SDL_PixelFormatEnumToMasks
(
SDL_PIXELFORMAT_ARGB4444
,
&
bpp
,
&
r
,
&
g
,
&
b
,
&
a
);
SDL_Surface
*
eyes
=
SDL_CreateRGBSurface
(
0
,
eyes_width
,
eyes_height
,
bpp
,
r
,
g
,
b
,
a
);
if
(
eyes
==
NULL
)
{
SDL_DestroyRenderer
(
window
);
SDL_DestroyWindow
(
window
);
SDL_VideoQuit
();
printf
(
"Could not create eyes
textur
e.
\n
"
);
printf
(
"Could not create eyes
surfac
e.
\n
"
);
exit
(
-
4
);
}
SDL_SetTexturePalette
(
eyes_texture
,
bnw_palette
,
0
,
2
);
void
*
pixels
=
NULL
;
int
pitch
=
0
;
SDL_Rect
rect
=
{
0
,
0
,
eyes_width
,
eyes_height
};
SDL_LockTexture
(
eyes_texture
,
&
rect
,
1
,
&
pixels
,
&
pitch
);
for
(
int
row
=
0
;
row
<
eyes_height
;
row
++
)
memcpy
(
pixels
+
pitch
*
row
,
eyes_bits
+
(
eyes_width
/
8
)
*
row
,
eyes_width
/
8
);
SDL_UnlockTexture
(
eyes_texture
);
int
bpp
=
0
;
Uint32
r
=
0
,
g
=
0
,
b
=
0
,
a
=
0
;
if
(
SDL_MUSTLOCK
(
eyes
))
SDL_LockSurface
(
eyes
);
pixels
=
eyes
->
pixels
;
pitch
=
eyes
->
pitch
;
for
(
int
y
=
0
;
y
<
eyes_height
;
y
++
)
for
(
int
x
=
0
;
x
<
eyes_width
;
x
++
)
{
Uint8
brightness
=
*
(
Uint8
*
)(
eyes_bits
+
(
eyes_width
/
8
)
*
y
+
(
x
/
8
))
&
(
1
<<
(
7
-
x
%
8
))
?
255
:
0
;
*
(
Uint16
*
)(
pixels
+
pitch
*
y
+
x
*
16
/
8
)
=
SDL_MapRGBA
(
eyes
->
format
,
brightness
,
brightness
,
brightness
,
255
);
}
if
(
SDL_MUSTLOCK
(
eyes
))
SDL_UnlockSurface
(
eyes
);
SDL_Texture
*
eyes_texture
=
SDL_CreateTextureFromSurface
(
SDL_PIXELFORMAT_ARGB4444
,
eyes
);
if
(
eyes_texture
==
NULL
)
{
SDL_FreeSurface
(
eyes
);
SDL_DestroyRenderer
(
window
);
SDL_DestroyWindow
(
window
);
SDL_VideoQuit
();
printf
(
"Could not create eyes texture.
\n
"
);
exit
(
-
5
);
}
SDL_PixelFormatEnumToMasks
(
SDL_PIXELFORMAT_ARGB4444
,
&
bpp
,
&
r
,
&
g
,
&
b
,
&
a
);
SDL_Surface
*
mask
=
SDL_CreateRGBSurface
(
0
,
eyesmask_width
,
eyesmask_height
,
bpp
,
r
,
g
,
b
,
a
);
if
(
mask
==
NULL
)
{
SDL_DestroyTexture
(
eyes_texture
);
SDL_FreeSurface
(
eyes
);
SDL_DestroyRenderer
(
window
);
SDL_DestroyWindow
(
window
);
SDL_VideoQuit
();
...
...
@@ -178,6 +194,7 @@ int main(int argc,char** argv) {
if
(
SDL_MUSTLOCK
(
mask
))
SDL_LockSurface
(
mask
);
pixels
=
mask
->
pixels
;
pitch
=
mask
->
pitch
;
for
(
int
y
=
0
;
y
<
eyesmask_height
;
y
++
)
for
(
int
x
=
0
;
x
<
eyesmask_width
;
x
++
)
{
Uint8
alpha
=
*
(
Uint8
*
)(
eyesmask_bits
+
(
eyesmask_width
/
8
)
*
y
+
(
x
/
8
))
&
(
1
<<
(
7
-
x
%
8
))
?
1
:
0
;
...
...
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