Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
drivers
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MLA98
drivers
Commits
b8aca0f5
Commit
b8aca0f5
authored
Mar 22, 2017
by
Jeremy Soller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix bugs in resize in vesad
parent
a0c5ab79
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
28 deletions
+46
-28
bgad/src/main.rs
bgad/src/main.rs
+1
-1
vesad/src/display.rs
vesad/src/display.rs
+41
-26
vesad/src/scheme.rs
vesad/src/scheme.rs
+4
-1
No files found.
bgad/src/main.rs
View file @
b8aca0f5
...
...
@@ -25,6 +25,6 @@ fn main() {
unsafe
{
iopl
(
3
)
.unwrap
()
};
let
mut
bga
=
Bga
::
new
();
print!
(
"{}"
,
format!
(
" - BGA {}x{}"
,
bga
.width
(),
bga
.height
()));
print!
(
"{}"
,
format!
(
" - BGA {}x{}
\n
"
,
bga
.width
(),
bga
.height
()));
}
}
vesad/src/display.rs
View file @
b8aca0f5
...
...
@@ -69,41 +69,56 @@ impl Display {
}
pub
fn
resize
(
&
mut
self
,
width
:
usize
,
height
:
usize
)
{
println!
(
"Resize display to {}, {}"
,
width
,
height
);
if
width
!=
self
.width
||
height
!=
self
.height
{
println!
(
"Resize display to {}, {}"
,
width
,
height
);
let
size
=
width
*
height
;
let
offscreen
=
unsafe
{
heap
::
allocate
(
size
*
4
,
4096
)
};
let
size
=
width
*
height
;
let
offscreen
=
unsafe
{
heap
::
allocate
(
size
*
4
,
4096
)
};
{
let
mut
old_ptr
=
self
.offscreen
.as_ptr
();
let
mut
new_ptr
=
offscreen
as
*
mut
u32
;
for
_
y
in
0
..
cmp
::
min
(
height
,
self
.height
)
{
unsafe
{
fast_copy
(
new_ptr
as
*
mut
u8
,
old_ptr
as
*
const
u8
,
cmp
::
min
(
width
,
self
.width
)
*
4
);
old_ptr
=
old_ptr
.offset
(
self
.width
as
isize
);
new_ptr
=
new_ptr
.offset
(
width
as
isize
);
{
let
mut
old_ptr
=
self
.offscreen
.as_ptr
();
let
mut
new_ptr
=
offscreen
as
*
mut
u32
;
for
_
y
in
0
..
cmp
::
min
(
height
,
self
.height
)
{
unsafe
{
fast_copy
(
new_ptr
as
*
mut
u8
,
old_ptr
as
*
const
u8
,
cmp
::
min
(
width
,
self
.width
)
*
4
);
if
width
>
self
.width
{
fast_set32
(
new_ptr
.offset
(
self
.width
as
isize
),
0
,
width
-
self
.width
);
}
old_ptr
=
old_ptr
.offset
(
self
.width
as
isize
);
new_ptr
=
new_ptr
.offset
(
width
as
isize
);
}
}
}
}
self
.width
=
width
;
self
.height
=
height
;
if
height
>
self
.height
{
for
_
y
in
self
.height
..
height
{
unsafe
{
fast_set32
(
new_ptr
,
0
,
width
);
new_ptr
=
new_ptr
.offset
(
width
as
isize
);
}
}
}
}
let
onscreen
=
self
.onscreen
.as_mut_ptr
()
;
self
.onscreen
=
unsafe
{
slice
::
from_raw_parts_mut
(
onscreen
,
size
)
}
;
self
.width
=
width
;
self
.height
=
height
;
unsafe
{
heap
::
deallocate
(
self
.offscreen
.as_mut_ptr
()
as
*
mut
u8
,
self
.offscreen
.len
()
*
4
,
4096
)
}
;
self
.offscreen
=
unsafe
{
slice
::
from_raw_parts_mut
(
offscreen
as
*
mut
u32
,
size
)
};
let
onscreen
=
self
.onscreen
.as_mut_ptr
()
;
self
.onscreen
=
unsafe
{
slice
::
from_raw_parts_mut
(
onscreen
,
size
)
};
self
.sync
(
0
,
0
,
width
,
height
);
unsafe
{
heap
::
deallocate
(
self
.offscreen
.as_mut_ptr
()
as
*
mut
u8
,
self
.offscreen
.len
()
*
4
,
4096
)
};
self
.offscreen
=
unsafe
{
slice
::
from_raw_parts_mut
(
offscreen
as
*
mut
u32
,
size
)
};
}
else
{
println!
(
"Display is already {}, {}"
,
width
,
height
);
}
}
/// Draw a rectangle
pub
fn
rect
(
&
mut
self
,
x
:
usize
,
y
:
usize
,
w
:
usize
,
h
:
usize
,
color
:
u32
)
{
let
start_y
=
cmp
::
min
(
self
.height
-
1
,
y
);
let
start_y
=
cmp
::
min
(
self
.height
,
y
);
let
end_y
=
cmp
::
min
(
self
.height
,
y
+
h
);
let
start_x
=
cmp
::
min
(
self
.width
-
1
,
x
);
let
start_x
=
cmp
::
min
(
self
.width
,
x
);
let
len
=
cmp
::
min
(
self
.width
,
x
+
w
)
-
start_x
;
let
mut
offscreen_ptr
=
self
.offscreen
.as_mut_ptr
()
as
usize
;
...
...
@@ -125,10 +140,10 @@ impl Display {
/// Invert a rectangle
pub
fn
invert
(
&
mut
self
,
x
:
usize
,
y
:
usize
,
w
:
usize
,
h
:
usize
)
{
let
start_y
=
cmp
::
min
(
self
.height
-
1
,
y
);
let
start_y
=
cmp
::
min
(
self
.height
,
y
);
let
end_y
=
cmp
::
min
(
self
.height
,
y
+
h
);
let
start_x
=
cmp
::
min
(
self
.width
-
1
,
x
);
let
start_x
=
cmp
::
min
(
self
.width
,
x
);
let
len
=
cmp
::
min
(
self
.width
,
x
+
w
)
-
start_x
;
let
mut
offscreen_ptr
=
self
.offscreen
.as_mut_ptr
()
as
usize
;
...
...
@@ -248,10 +263,10 @@ impl Display {
/// Copy from offscreen to onscreen
pub
fn
sync
(
&
mut
self
,
x
:
usize
,
y
:
usize
,
w
:
usize
,
h
:
usize
)
{
let
start_y
=
cmp
::
min
(
self
.height
-
1
,
y
);
let
start_y
=
cmp
::
min
(
self
.height
,
y
);
let
end_y
=
cmp
::
min
(
self
.height
,
y
+
h
);
let
start_x
=
cmp
::
min
(
self
.width
-
1
,
x
);
let
start_x
=
cmp
::
min
(
self
.width
,
x
);
let
len
=
(
cmp
::
min
(
self
.width
,
x
+
w
)
-
start_x
)
*
4
;
let
mut
offscreen_ptr
=
self
.offscreen
.as_mut_ptr
()
as
usize
;
...
...
vesad/src/scheme.rs
View file @
b8aca0f5
...
...
@@ -158,8 +158,11 @@ impl SchemeMut for DisplayScheme {
},
EventOption
::
Resize
(
resize_event
)
=>
{
println!
(
"Resizing to {}, {}"
,
resize_event
.width
,
resize_event
.height
);
for
(
_
screen_id
,
screen
)
in
self
.screens
.iter_mut
()
{
for
(
screen_id
,
screen
)
in
self
.screens
.iter_mut
()
{
screen
.resize
(
resize_event
.width
as
usize
,
resize_event
.height
as
usize
);
if
*
screen_id
==
self
.active
{
screen
.redraw
();
}
}
},
_
=>
()
...
...
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