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
3c7c7216
Commit
3c7c7216
authored
Aug 03, 2011
by
Nathan Heisey
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced window backbuffer with BBitmap
parent
2dda4071
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
23 deletions
+32
-23
SDL_BWin.h
src/video/bwindow/SDL_BWin.h
+10
-6
SDL_bframebuffer.cc
src/video/bwindow/SDL_bframebuffer.cc
+22
-17
No files found.
src/video/bwindow/SDL_BWin.h
View file @
3c7c7216
...
@@ -81,7 +81,7 @@ class SDL_BWin:public BDirectWindow
...
@@ -81,7 +81,7 @@ class SDL_BWin:public BDirectWindow
_buffer_created
=
_buffer_dirty
=
false
;
_buffer_created
=
_buffer_dirty
=
false
;
_trash_window_buffer
=
false
;
_trash_window_buffer
=
false
;
_buffer_locker
=
new
BLocker
();
_buffer_locker
=
new
BLocker
();
_
window_buffer
=
NULL
;
_
bitmap
=
NULL
;
_draw_thread_id
=
spawn_thread
(
BE_DrawThread
,
"drawing_thread"
,
_draw_thread_id
=
spawn_thread
(
BE_DrawThread
,
"drawing_thread"
,
B_NORMAL_PRIORITY
,
(
void
*
)
this
);
B_NORMAL_PRIORITY
,
(
void
*
)
this
);
...
@@ -394,27 +394,29 @@ class SDL_BWin:public BDirectWindow
...
@@ -394,27 +394,29 @@ class SDL_BWin:public BDirectWindow
uint32
GetRowBytes
()
{
return
_row_bytes
;
}
uint32
GetRowBytes
()
{
return
_row_bytes
;
}
int32
GetFbX
()
{
return
_bounds
.
left
;
}
int32
GetFbX
()
{
return
_bounds
.
left
;
}
int32
GetFbY
()
{
return
_bounds
.
top
;
}
int32
GetFbY
()
{
return
_bounds
.
top
;
}
int32
GetFbHeight
()
{
return
_bounds
.
bottom
-
_bounds
.
top
+
1
;
}
//
int32 GetFbHeight() { return _bounds.bottom - _bounds.top + 1; }
int32
GetFbWidth
()
{
return
_bounds
.
right
-
_bounds
.
left
+
1
;
}
//
int32 GetFbWidth() { return _bounds.right - _bounds.left + 1; }
bool
ConnectionEnabled
()
{
return
!
_connection_disabled
;
}
bool
ConnectionEnabled
()
{
return
!
_connection_disabled
;
}
bool
Connected
()
{
return
_connected
;
}
bool
Connected
()
{
return
_connected
;
}
clipping_rect
*
GetClips
()
{
return
_clips
;
}
clipping_rect
*
GetClips
()
{
return
_clips
;
}
int32
GetNumClips
()
{
return
_num_clips
;
}
int32
GetNumClips
()
{
return
_num_clips
;
}
uint8
*
GetBufferPx
()
{
return
_bits
;
}
uint8
*
GetBufferPx
()
{
return
_bits
;
}
int32
GetBytesPerPx
()
{
return
_bytes_per_px
;
}
int32
GetBytesPerPx
()
{
return
_bytes_per_px
;
}
uint8
*
GetWindowFramebuffer
()
{
return
_window_buffer
;
}
//
uint8* GetWindowFramebuffer() { return _window_buffer; }
bool
CanTrashWindowBuffer
()
{
return
_trash_window_buffer
;
}
bool
CanTrashWindowBuffer
()
{
return
_trash_window_buffer
;
}
bool
BufferExists
()
{
return
_buffer_created
;
}
bool
BufferExists
()
{
return
_buffer_created
;
}
bool
BufferIsDirty
()
{
return
_buffer_dirty
;
}
bool
BufferIsDirty
()
{
return
_buffer_dirty
;
}
BBitmap
*
GetBitmap
()
{
return
_bitmap
;
}
/* Setter methods */
/* Setter methods */
void
SetID
(
int32
id
)
{
_id
=
id
;
}
void
SetID
(
int32
id
)
{
_id
=
id
;
}
void
SetBufferExists
(
bool
bufferExists
)
{
_buffer_created
=
bufferExists
;
}
void
SetBufferExists
(
bool
bufferExists
)
{
_buffer_created
=
bufferExists
;
}
void
SetWindowFramebuffer
(
uint8
*
fb
)
{
_window_buffer
=
fb
;
}
//
void SetWindowFramebuffer(uint8* fb) { _window_buffer = fb; }
void
LockBuffer
()
{
_buffer_locker
->
Lock
();
}
void
LockBuffer
()
{
_buffer_locker
->
Lock
();
}
void
UnlockBuffer
()
{
_buffer_locker
->
Unlock
();
}
void
UnlockBuffer
()
{
_buffer_locker
->
Unlock
();
}
void
SetBufferDirty
(
bool
bufferDirty
)
{
_buffer_dirty
=
bufferDirty
;
}
void
SetBufferDirty
(
bool
bufferDirty
)
{
_buffer_dirty
=
bufferDirty
;
}
void
SetTrashBuffer
(
bool
trash
)
{
_trash_window_buffer
=
trash
;
}
void
SetTrashBuffer
(
bool
trash
)
{
_trash_window_buffer
=
trash
;
}
void
SetBitmap
(
BBitmap
*
bitmap
)
{
_bitmap
=
bitmap
;
}
private
:
private
:
...
@@ -588,9 +590,11 @@ private:
...
@@ -588,9 +590,11 @@ private:
clipping_rect
*
_clips
;
clipping_rect
*
_clips
;
int32
_num_clips
;
int32
_num_clips
;
int32
_bytes_per_px
;
int32
_bytes_per_px
;
uint8
*
_window_buffer
;
/* A copy of the window buffer */
//
uint8 *_window_buffer; /* A copy of the window buffer */
bool
_trash_window_buffer
;
bool
_trash_window_buffer
;
thread_id
_draw_thread_id
;
thread_id
_draw_thread_id
;
BBitmap
*
_bitmap
;
};
};
#endif
#endif
src/video/bwindow/SDL_bframebuffer.cc
View file @
3c7c7216
...
@@ -60,17 +60,21 @@ int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
...
@@ -60,17 +60,21 @@ int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window,
int32
bpp
=
ColorSpaceToBitsPerPixel
(
bmode
.
space
);
int32
bpp
=
ColorSpaceToBitsPerPixel
(
bmode
.
space
);
*
format
=
BPPToSDLPxFormat
(
bpp
);
*
format
=
BPPToSDLPxFormat
(
bpp
);
/* pitch = width of screen, in bytes */
/* Create the new bitmap object */
*
pitch
=
bwin
->
GetFbWidth
()
*
bwin
->
GetBytesPerPx
();
BBitmap
*
bitmap
=
bwin
->
GetBitmap
();
if
(
bitmap
)
{
/* Create a copy of the pixel buffer if it doesn't recycle */
delete
bitmap
;
*
pixels
=
bwin
->
GetWindowFramebuffer
();
if
(
(
*
pixels
)
!=
NULL
)
{
SDL_free
(
*
pixels
);
}
}
*
pixels
=
SDL_calloc
((
*
pitch
)
*
bwin
->
GetFbHeight
()
*
bitmap
=
new
BBitmap
(
bwin
->
Bounds
(),
(
color_space
)
bmode
.
space
,
bwin
->
GetBytesPerPx
(),
sizeof
(
uint8
));
false
,
/* Views not accepted */
bwin
->
SetWindowFramebuffer
((
uint8
*
)(
*
pixels
));
true
);
/* Contiguous memory required */
bwin
->
SetBitmap
(
bitmap
);
/* Set the pixel pointer */
*
pixels
=
bitmap
->
Bits
();
/* pitch = width of window, in bytes */
*
pitch
=
bitmap
->
BytesPerRow
();
bwin
->
SetBufferExists
(
true
);
bwin
->
SetBufferExists
(
true
);
bwin
->
SetTrashBuffer
(
false
);
bwin
->
SetTrashBuffer
(
false
);
...
@@ -106,13 +110,13 @@ int32 BE_DrawThread(void *data) {
...
@@ -106,13 +110,13 @@ int32 BE_DrawThread(void *data) {
while
(
bwin
->
ConnectionEnabled
())
{
while
(
bwin
->
ConnectionEnabled
())
{
if
(
bwin
->
Connected
()
&&
bwin
->
BufferExists
()
&&
bwin
->
BufferIsDirty
()
)
{
if
(
bwin
->
Connected
()
&&
bwin
->
BufferExists
()
&&
bwin
->
BufferIsDirty
()
)
{
bwin
->
LockBuffer
();
bwin
->
LockBuffer
();
int32
windowPitch
=
window
->
surface
->
pitch
;
BBitmap
*
bitmap
=
bwin
->
GetBitmap
();
int32
windowPitch
=
bitmap
->
BytesPerRow
();
int32
bufferPitch
=
bwin
->
GetRowBytes
();
int32
bufferPitch
=
bwin
->
GetRowBytes
();
uint8
*
windowpx
;
uint8
*
windowpx
;
uint8
*
bufferpx
;
uint8
*
bufferpx
;
int32
BPP
=
bwin
->
GetBytesPerPx
();
int32
BPP
=
bwin
->
GetBytesPerPx
();
uint8
*
windowBaseAddress
=
(
uint8
*
)
window
->
surface
->
pixels
;
int32
windowSub
=
bwin
->
GetFbX
()
*
BPP
+
int32
windowSub
=
bwin
->
GetFbX
()
*
BPP
+
bwin
->
GetFbY
()
*
windowPitch
;
bwin
->
GetFbY
()
*
windowPitch
;
clipping_rect
*
clips
=
bwin
->
GetClips
();
clipping_rect
*
clips
=
bwin
->
GetClips
();
...
@@ -128,8 +132,9 @@ int32 BE_DrawThread(void *data) {
...
@@ -128,8 +132,9 @@ int32 BE_DrawThread(void *data) {
int32
height
=
clips
[
i
].
bottom
-
clips
[
i
].
top
+
1
;
int32
height
=
clips
[
i
].
bottom
-
clips
[
i
].
top
+
1
;
bufferpx
=
bwin
->
GetBufferPx
()
+
bufferpx
=
bwin
->
GetBufferPx
()
+
clips
[
i
].
top
*
bufferPitch
+
clips
[
i
].
left
*
BPP
;
clips
[
i
].
top
*
bufferPitch
+
clips
[
i
].
left
*
BPP
;
windowpx
=
windowBaseAddress
+
windowpx
=
(
uint8
*
)
bitmap
->
Bits
();
+
clips
[
i
].
top
*
windowPitch
+
clips
[
i
].
left
*
BPP
-
windowSub
;
clips
[
i
].
top
*
windowPitch
+
clips
[
i
].
left
*
BPP
-
windowSub
;
/* Copy each row of pixels from the window buffer into the frame
/* Copy each row of pixels from the window buffer into the frame
buffer */
buffer */
...
@@ -160,9 +165,9 @@ void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
...
@@ -160,9 +165,9 @@ void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) {
bwin
->
LockBuffer
();
bwin
->
LockBuffer
();
/* Free and clear the window buffer */
/* Free and clear the window buffer */
uint8
*
winBuffer
=
bwin
->
GetWindowFramebuffer
();
BBitmap
*
bitmap
=
bwin
->
GetBitmap
();
SDL_free
(
winBuffer
)
;
delete
bitmap
;
bwin
->
Set
WindowFramebuffer
(
NULL
);
bwin
->
Set
Bitmap
(
NULL
);
bwin
->
SetBufferExists
(
false
);
bwin
->
SetBufferExists
(
false
);
bwin
->
UnlockBuffer
();
bwin
->
UnlockBuffer
();
}
}
...
...
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