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
20af8e06
Commit
20af8e06
authored
Jul 25, 2011
by
Nathan Heisey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Variable name/debugging output changes
parent
96dd15dd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
114 deletions
+99
-114
SDL_BWin.h
src/video/bwindow/SDL_BWin.h
+87
-94
SDL_bmodes.cc
src/video/bwindow/SDL_bmodes.cc
+8
-16
SDL_bwindow.cc
src/video/bwindow/SDL_bwindow.cc
+4
-4
No files found.
src/video/bwindow/SDL_BWin.h
View file @
20af8e06
...
...
@@ -64,47 +64,46 @@ class SDL_BWin:public BDirectWindow
SDL_BWin
(
BRect
bounds
)
:
BDirectWindow
(
bounds
,
"Untitled"
,
B_TITLED_WINDOW
,
0
)
{
last_buttons
=
0
;
printf
(
"SDL_BWin.h: 69
\n
"
);
_last_buttons
=
0
;
#if SDL_VIDEO_OPENGL
SDL_GLView
=
NULL
;
_
SDL_GLView
=
NULL
;
#endif
_shown
=
false
;
inhibit_resize
=
false
;
mouse_focused
=
false
;
prev_frame
=
NULL
;
printf
(
"SDL_BWin.h: 79
\n
"
)
;
_
inhibit_resize
=
false
;
_
mouse_focused
=
false
;
_prev_frame
=
NULL
;
/* Handle framebuffer stuff */
_connected
=
connection_disabled
=
false
;
trash
_window_buffer
=
false
;
buffer_locker
=
new
BLocker
();
window_buffer
=
NULL
;
_connected
=
_
connection_disabled
=
false
;
_trash_
_window_buffer
=
false
;
_
buffer_locker
=
new
BLocker
();
_
window_buffer
=
NULL
;
// LockBuffer(); /* Unlocked by buffer initialization */
}
virtual
~
SDL_BWin
()
{
Lock
();
connection_disabled
=
true
;
_
connection_disabled
=
true
;
#if SDL_VIDEO_OPENGL
if
(
SDL_GLView
)
{
SDL_GLView
->
UnlockGL
();
if
(
_
SDL_GLView
)
{
_
SDL_GLView
->
UnlockGL
();
}
RemoveChild
(
SDL_GLView
);
RemoveChild
(
_
SDL_GLView
);
#endif
Unlock
();
#if SDL_VIDEO_OPENGL
if
(
SDL_GLView
)
{
delete
SDL_GLView
;
if
(
_
SDL_GLView
)
{
delete
_
SDL_GLView
;
}
#endif
/* Clean up framebuffer stuff */
buffer_locker
->
Lock
();
_
buffer_locker
->
Lock
();
free
(
_clips
);
delete
buffer_locker
;
delete
_
buffer_locker
;
}
...
...
@@ -117,24 +116,24 @@ printf("SDL_BWin.h: 69\n");
retval
=
0
;
Lock
();
if
(
flags
&
SDL_OPENGL
/*SDL_INTERNALOPENGL*/
)
{
if
(
SDL_GLView
==
NULL
)
{
SDL_GLView
=
new
BGLView
(
Bounds
(),
"SDL GLView"
,
if
(
_
SDL_GLView
==
NULL
)
{
_
SDL_GLView
=
new
BGLView
(
Bounds
(),
"SDL GLView"
,
B_FOLLOW_ALL_SIDES
,
(
B_WILL_DRAW
|
B_FRAME_EVENTS
),
gl_flags
);
}
if
(
the_view
!=
SDL_GLView
)
{
if
(
the_view
)
{
RemoveChild
(
the_view
);
if
(
_the_view
!=
_
SDL_GLView
)
{
if
(
_
the_view
)
{
RemoveChild
(
_
the_view
);
}
AddChild
(
SDL_GLView
);
SDL_GLView
->
LockGL
();
the_view
=
SDL_GLView
;
AddChild
(
_
SDL_GLView
);
_
SDL_GLView
->
LockGL
();
_the_view
=
_
SDL_GLView
;
}
}
else
{
if
(
the_view
)
{
SDL_GLView
->
UnlockGL
();
RemoveChild
(
the_view
);
if
(
_
the_view
)
{
_
SDL_GLView
->
UnlockGL
();
RemoveChild
(
_
the_view
);
}
}
Unlock
();
...
...
@@ -144,41 +143,41 @@ printf("SDL_BWin.h: 69\n");
/* * * * * Framebuffering* * * * */
virtual
void
DirectConnected
(
direct_buffer_info
*
info
)
{
if
(
!
_connected
&&
connection_disabled
)
{
if
(
!
_connected
&&
_
connection_disabled
)
{
return
;
}
LockBuffer
();
switch
(
info
->
buffer_state
&
B_DIRECT_MODE_MASK
)
{
case
B_DIRECT_START
:
printf
(
__FILE__
": %d; Direct start.
\n
"
,
__LINE__
);
_connected
=
true
;
case
B_DIRECT_MODIFY
:
if
(
_clips
)
{
free
(
_clips
);
_clips
=
NULL
;
}
/* Can we reuse the window's pixel buffer after this? */
trash
_window_buffer
=
((
info
->
buffer_state
&
B_BUFFER_RESIZED
)
_trash_
_window_buffer
=
((
info
->
buffer_state
&
B_BUFFER_RESIZED
)
||
(
info
->
buffer_state
&
B_BUFFER_RESET
)
||
((
info
->
buffer_state
&
B_DIRECT_MODE_MASK
)
==
B_DIRECT_START
));
num_clips
=
info
->
clip_list_count
;
_clips
=
(
clipping_rect
*
)
malloc
(
num_clips
*
sizeof
(
clipping_rect
));
_
num_clips
=
info
->
clip_list_count
;
_clips
=
(
clipping_rect
*
)
malloc
(
_
num_clips
*
sizeof
(
clipping_rect
));
if
(
_clips
)
{
memcpy
(
_clips
,
info
->
clip_list
,
num_clips
*
sizeof
(
clipping_rect
));
_
num_clips
*
sizeof
(
clipping_rect
));
_bits
=
(
uint8
*
)
info
->
bits
;
row_bytes
=
info
->
bytes_per_row
;
_
row_bytes
=
info
->
bytes_per_row
;
_bounds
=
info
->
window_bounds
;
bytes_per_px
=
info
->
bits_per_pixel
/
8
;
_
bytes_per_px
=
info
->
bits_per_pixel
/
8
;
}
/* Whatever the case, I think this merits a repaint event */
// _RepaintEvent();
break
;
case
B_DIRECT_STOP
:
...
...
@@ -218,7 +217,7 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
virtual
bool
QuitRequested
()
{
BMessage
msg
(
BAPP_WINDOW_CLOSE_REQUESTED
);
_PostWindowEvent
(
msg
);
/* We won't allow a quit unless asked by DestroyWindow() */
return
false
;
}
...
...
@@ -235,8 +234,8 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
_PostWindowEvent
(
msg
);
/* Before the window zooms, record its size */
if
(
!
prev_frame
)
prev_frame
=
new
BRect
(
Frame
());
if
(
!
_
prev_frame
)
_
prev_frame
=
new
BRect
(
Frame
());
/* Perform normal hook operations */
BDirectWindow
::
Zoom
(
origin
,
width
,
height
);
...
...
@@ -244,19 +243,19 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
/* Member functions */
virtual
void
Show
()
{
BDirectWindow
::
Show
();
while
(
IsHidden
())
{
BDirectWindow
::
Show
();
}
_shown
=
true
;
BMessage
msg
(
BAPP_SHOW
);
_PostWindowEvent
(
msg
);
}
virtual
void
Hide
()
{
/* FIXME: Multiple hides require multiple shows to undo. Should
this be altered to prevent this from happening? */
BDirectWindow
::
Hide
();
_shown
=
false
;
BMessage
msg
(
BAPP_HIDE
);
_PostWindowEvent
(
msg
);
}
...
...
@@ -273,7 +272,6 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
/* BView message interruption */
virtual
void
DispatchMessage
(
BMessage
*
msg
,
BHandler
*
target
)
{
BPoint
where
;
/* Used by mouse moved */
int32
buttons
;
/* Used for mouse button events */
int32
key
;
/* Used for key events */
...
...
@@ -326,11 +324,6 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
_KeyEvent
(
key
,
SDL_RELEASED
);
}
break
;
case
_UPDATE_
:
case
_UPDATE_IF_NEEDED_
:
/* Hopefully one doesn't call the other */
_RepaintEvent
();
break
;
default
:
/* move it after switch{} so it's always handled
...
...
@@ -341,6 +334,7 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
//BDirectWindow::DispatchMessage(msg, target);
break
;
}
BDirectWindow
::
DispatchMessage
(
msg
,
target
);
}
...
...
@@ -388,22 +382,22 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
/* Accessor methods */
bool
IsShown
()
{
return
_shown
;
}
int32
GetID
()
{
return
_id
;
}
void
LockBuffer
()
{
buffer_locker
->
Lock
();
}
void
UnlockBuffer
()
{
buffer_locker
->
Unlock
();
}
uint32
GetRowBytes
()
{
return
row_bytes
;
}
void
LockBuffer
()
{
_
buffer_locker
->
Lock
();
}
void
UnlockBuffer
()
{
_
buffer_locker
->
Unlock
();
}
uint32
GetRowBytes
()
{
return
_
row_bytes
;
}
int32
GetFbX
()
{
return
_bounds
.
left
;
}
int32
GetFbY
()
{
return
_bounds
.
top
;
}
int32
GetFbHeight
()
{
return
_bounds
.
bottom
-
_bounds
.
top
+
1
;
}
int32
GetFbWidth
()
{
return
_bounds
.
right
-
_bounds
.
left
+
1
;
}
bool
ConnectionEnabled
()
{
return
!
connection_disabled
;
}
bool
ConnectionEnabled
()
{
return
!
_
connection_disabled
;
}
bool
Connected
()
{
return
_connected
;
}
clipping_rect
*
GetClips
()
{
return
_clips
;
}
int32
GetNumClips
()
{
return
num_clips
;
}
int32
GetNumClips
()
{
return
_
num_clips
;
}
uint8
*
GetBufferPx
()
{
return
_bits
;
}
int32
GetBytesPerPx
()
{
return
bytes_per_px
;
}
void
SetWindowFramebuffer
(
uint8
*
fb
)
{
window_buffer
=
fb
;
}
uint8
*
GetWindowFramebuffer
()
{
return
window_buffer
;
}
bool
CanTrashWindowBuffer
()
{
return
trash
_window_buffer
;
}
int32
GetBytesPerPx
()
{
return
_
bytes_per_px
;
}
void
SetWindowFramebuffer
(
uint8
*
fb
)
{
_
window_buffer
=
fb
;
}
uint8
*
GetWindowFramebuffer
()
{
return
_
window_buffer
;
}
bool
CanTrashWindowBuffer
()
{
return
_trash_
_window_buffer
;
}
/* Setter methods */
void
SetID
(
int32
id
)
{
_id
=
id
;
}
...
...
@@ -413,14 +407,14 @@ printf(__FILE__": %d; Direct start.\n", __LINE__);
#if SDL_VIDEO_OPENGL
virtual
void
SwapBuffers
(
void
)
{
SDL_GLView
->
UnlockGL
();
SDL_GLView
->
LockGL
();
SDL_GLView
->
SwapBuffers
();
_
SDL_GLView
->
UnlockGL
();
_
SDL_GLView
->
LockGL
();
_
SDL_GLView
->
SwapBuffers
();
}
#endif
virtual
BView
*
View
(
void
)
{
return
(
the_view
);
return
(
_
the_view
);
}
...
...
@@ -434,27 +428,26 @@ private:
void
_MouseMotionEvent
(
BPoint
&
where
,
int32
transit
)
{
if
(
transit
==
B_EXITED_VIEW
)
{
/* Change mouse focus */
if
(
mouse_focused
)
{
if
(
_
mouse_focused
)
{
_MouseFocusEvent
(
false
);
}
}
else
{
static
int
x
=
0
,
y
=
0
;
/* Change mouse focus */
if
(
!
mouse_focused
)
{
if
(
!
_
mouse_focused
)
{
_MouseFocusEvent
(
true
);
}
// GetXYOffset(x, y); //FIXME: What is this doing? (from SDL 1.2)
BMessage
msg
(
BAPP_MOUSE_MOVED
);
msg
.
AddInt32
(
"dx"
,
where
.
x
-
x
);
msg
.
AddInt32
(
"dy"
,
where
.
y
-
y
);
x
=
(
int
)
where
.
x
;
y
=
(
int
)
where
.
y
;
y
=
(
int
)
where
.
y
;
_PostWindowEvent
(
msg
);
}
}
void
_MouseFocusEvent
(
bool
focusGained
)
{
mouse_focused
=
focusGained
;
_
mouse_focused
=
focusGained
;
BMessage
msg
(
BAPP_MOUSE_FOCUS
);
msg
.
AddBool
(
"focusGained"
,
focusGained
);
_PostWindowEvent
(
msg
);
...
...
@@ -465,7 +458,7 @@ private:
}
void
_MouseButtonEvent
(
int32
buttons
)
{
int32
buttonStateChange
=
buttons
^
last_buttons
;
int32
buttonStateChange
=
buttons
^
_
last_buttons
;
/* Make sure at least one button has changed state */
if
(
!
(
buttonStateChange
)
)
{
...
...
@@ -486,7 +479,7 @@ private:
B_PRIMARY_MOUSE_BUTTON
);
}
last_buttons
=
buttons
;
_
last_buttons
=
buttons
;
}
void
_SendMouseButton
(
int32
button
,
int32
state
)
{
...
...
@@ -561,9 +554,9 @@ private:
Minimize
(
false
);
}
else
if
(
IsHidden
())
{
Show
();
}
else
if
(
prev_frame
!=
NULL
)
{
/* Zoomed */
MoveTo
(
prev_frame
->
left
,
prev_frame
->
top
);
ResizeTo
(
prev_frame
->
Width
(),
prev_frame
->
Height
());
}
else
if
(
_
prev_frame
!=
NULL
)
{
/* Zoomed */
MoveTo
(
_prev_frame
->
left
,
_
prev_frame
->
top
);
ResizeTo
(
_prev_frame
->
Width
(),
_
prev_frame
->
Height
());
}
}
...
...
@@ -579,29 +572,29 @@ private:
/* Members */
#if SDL_VIDEO_OPENGL
BGLView
*
SDL_GLView
;
BGLView
*
_
SDL_GLView
;
#endif
BView
*
the_view
;
BView
*
_
the_view
;
int32
last_buttons
;
int32
_
last_buttons
;
int32
_id
;
/* Window id used by SDL_BApp */
bool
mouse_focused
;
/* Does this window have mouse focus? */
bool
_shown
;
bool
inhibit_resize
;
bool
_
mouse_focused
;
/* Does this window have mouse focus? */
bool
_shown
;
bool
_
inhibit_resize
;
BRect
*
prev_frame
;
/* Previous position and size of the window */
BRect
*
_
prev_frame
;
/* Previous position and size of the window */
/* Framebuffer members */
bool
_connected
,
connection_disabled
;
uint8
*
_bits
;
uint32
row_bytes
;
bool
_connected
,
_
connection_disabled
;
uint8
*
_bits
;
uint32
_
row_bytes
;
clipping_rect
_bounds
;
BLocker
*
buffer_locker
;
clipping_rect
*
_clips
;
int32
num_clips
;
int32
bytes_per_px
;
uint8
*
window_buffer
;
/* A copy of the window buffer */
bool
trash
_window_buffer
;
BLocker
*
_
buffer_locker
;
clipping_rect
*
_clips
;
int32
_
num_clips
;
int32
_
bytes_per_px
;
uint8
*
_
window_buffer
;
/* A copy of the window buffer */
bool
_trash_
_window_buffer
;
};
#endif
src/video/bwindow/SDL_bmodes.cc
View file @
20af8e06
...
...
@@ -118,20 +118,19 @@ static inline void BE_BDisplayModeToSdlDisplayMode(display_mode *bmode,
/* Later, there may be more than one monitor available */
void
BE_AddDisplay
(
BScreen
*
screen
)
{
SDL_VideoDisplay
display
;
SDL_DisplayMode
mode
;
SDL_DisplayMode
*
mode
=
(
SDL_DisplayMode
*
)
SDL_calloc
(
1
,
sizeof
(
SDL_DisplayMode
))
;
display_mode
bmode
;
screen
->
GetMode
(
&
bmode
);
BE_BDisplayModeToSdlDisplayMode
(
&
bmode
,
&
mode
);
BE_BDisplayModeToSdlDisplayMode
(
&
bmode
,
mode
);
SDL_zero
(
display
);
display
.
desktop_mode
=
mode
;
display
.
current_mode
=
mode
;
display
.
desktop_mode
=
*
mode
;
display
.
current_mode
=
*
mode
;
SDL_AddVideoDisplay
(
&
display
);
}
int
BE_InitModes
(
_THIS
)
{
printf
(
"Init Modes
\n
"
);
BScreen
screen
;
/* Save the current display mode */
...
...
@@ -144,6 +143,7 @@ int BE_InitModes(_THIS) {
}
int
BE_QuitModes
(
_THIS
)
{
printf
(
__FILE__
": %d; Begin quit
\n
"
,
__LINE__
);
/* Restore the previous video mode */
BScreen
screen
;
display_mode
*
savedMode
=
_GetBeApp
()
->
GetPrevMode
();
...
...
@@ -163,10 +163,9 @@ int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) {
}
void
BE_GetDisplayModes
(
_THIS
,
SDL_VideoDisplay
*
display
)
{
printf
(
"Get Display Modes
\n
"
);
/* Get the current screen */
BScreen
bscreen
;
/* Iterate through all of the modes */
SDL_DisplayMode
mode
;
display_mode
this_bmode
;
...
...
@@ -188,7 +187,6 @@ void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) {
}
int
BE_SetDisplayMode
(
_THIS
,
SDL_VideoDisplay
*
display
,
SDL_DisplayMode
*
mode
){
printf
(
"Set Display Modes
\n
"
);
/* Get the current screen */
BScreen
bscreen
;
...
...
@@ -212,7 +210,7 @@ int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
return
-
1
;
}
while
(
!
bwin
->
Connected
())
{
snooze
(
1
60
0
);
}
while
(
!
bwin
->
Connected
())
{
snooze
(
10
);
}
/* Make sure we have exclusive access to frame buffer data */
bwin
->
LockBuffer
();
...
...
@@ -228,7 +226,6 @@ int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
/* Create a copy of the pixel buffer if it doesn't recycle */
*
pixels
=
bwin
->
GetWindowFramebuffer
();
printf
(
__FILE__
": %d; window frame buffer make
\n
"
,
__LINE__
);
if
(
bwin
->
CanTrashWindowBuffer
()
||
(
*
pixels
)
==
NULL
)
{
if
(
(
*
pixels
)
!=
NULL
)
{
SDL_free
(
*
pixels
);
...
...
@@ -236,11 +233,6 @@ int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
*
pixels
=
SDL_calloc
((
*
pitch
)
*
bwin
->
GetFbHeight
()
*
bwin
->
GetBytesPerPx
(),
sizeof
(
uint8
));
bwin
->
SetWindowFramebuffer
((
uint8
*
)(
*
pixels
));
if
(
*
pixels
)
{
printf
(
__FILE__
": %d; Success!
\n
"
,
__LINE__
);
}
else
{
printf
(
__FILE__
": %d; FAIL!
\n
"
,
__LINE__
);
}
}
bwin
->
UnlockBuffer
();
...
...
@@ -283,7 +275,7 @@ int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window,
clips
[
i
].
top
*
bufferPitch
+
clips
[
i
].
left
*
BPP
;
windowpx
=
windowBaseAddress
+
clips
[
i
].
top
*
windowPitch
+
clips
[
i
].
left
*
BPP
-
windowSub
;
printf
(
__FILE__
": %d
\n\t
windowpx = 0x%x
\n\t
bufferpx = 0x%x
\n\t
windowPitch = %i
\n\t
bufferPitch = %i
\n
"
,
__LINE__
,
windowpx
,
bufferpx
,
windowPitch
,
bufferPitch
);
/* Copy each row of pixels from the window buffer into the frame
buffer */
for
(
y
=
0
;
y
<
height
;
++
y
)
...
...
src/video/bwindow/SDL_bwindow.cc
View file @
20af8e06
...
...
@@ -37,25 +37,25 @@ static inline SDL_BApp *_GetBeApp() {
return
((
SDL_BApp
*
)
be_app
);
}
int
_InitWindow
(
_THIS
,
SDL_Window
*
window
)
{
printf
(
"SDL_bwindow.cc: 40
\n
"
);
int
_InitWindow
(
_THIS
,
SDL_Window
*
window
)
{
BRect
bounds
(
window
->
x
,
window
->
y
,
window
->
x
+
window
->
w
-
1
,
//BeWindows have an off-by-one px w/h thing
window
->
y
+
window
->
h
-
1
);
printf
(
"SDL_bwindow.cc: 30
\n
"
);
SDL_BWin
*
bwin
=
new
(
std
::
nothrow
)
SDL_BWin
(
bounds
);
if
(
bwin
==
NULL
)
return
ENOMEM
;
printf
(
"SDL_bwindow.cc: 51
\n
"
);
window
->
driverdata
=
bwin
;
int32
winID
=
_GetBeApp
()
->
GetID
(
window
);
bwin
->
SetID
(
winID
);
return
0
;
}
int
BE_CreateWindow
(
_THIS
,
SDL_Window
*
window
)
{
printf
(
"SDL_bwindow.cc: 58
\n
"
);
int
BE_CreateWindow
(
_THIS
,
SDL_Window
*
window
)
{
if
(
_InitWindow
(
_this
,
window
)
==
ENOMEM
)
return
ENOMEM
;
...
...
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