Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
boytacean
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
João Magalhães
boytacean
Commits
bad45f95
Unverified
Commit
bad45f95
authored
9 months ago
by
João Magalhães
Committed by
GitHub
9 months ago
Browse files
Options
Downloads
Plain Diff
Merge pull request
#6
from itytophile/fix_copy_fast
debug assertions for copy_fast
parents
e4fd63ff
26944586
No related branches found
No related tags found
No related merge requests found
Pipeline
#4399
failed
9 months ago
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/color.rs
+14
-10
14 additions, 10 deletions
src/color.rs
src/util.rs
+7
-6
7 additions, 6 deletions
src/util.rs
with
21 additions
and
16 deletions
src/color.rs
+
14
−
10
View file @
bad45f95
...
@@ -91,11 +91,13 @@ pub fn rgb888_to_rgb1555_scalar(rgb888_pixels: &[u8], rgb1555_pixels: &mut [u8])
...
@@ -91,11 +91,13 @@ pub fn rgb888_to_rgb1555_scalar(rgb888_pixels: &[u8], rgb1555_pixels: &mut [u8])
rgb888_pixels
[
index
*
RGB_SIZE
+
2
],
rgb888_pixels
[
index
*
RGB_SIZE
+
2
],
);
);
let
rgb1555
=
rgb888_to_rgb1555
(
r
,
g
,
b
);
let
rgb1555
=
rgb888_to_rgb1555
(
r
,
g
,
b
);
copy_fast
(
unsafe
{
&
rgb1555
,
copy_fast
(
&
mut
rgb1555_pixels
[
index
*
RGB1555_SIZE
..
index
*
RGB1555_SIZE
+
1
],
&
rgb1555
,
RGB565_SIZE
,
&
mut
rgb1555_pixels
[
index
*
RGB1555_SIZE
..
index
*
RGB1555_SIZE
+
RGB565_SIZE
],
)
RGB565_SIZE
,
)
}
}
}
}
}
...
@@ -215,11 +217,13 @@ pub fn rgb888_to_rgb1555_simd(rgb888_pixels: &[u8], rgb1555_pixels: &mut [u8]) {
...
@@ -215,11 +217,13 @@ pub fn rgb888_to_rgb1555_simd(rgb888_pixels: &[u8], rgb1555_pixels: &mut [u8]) {
);
);
let
rgb1555
=
rgb888_to_rgb1555
(
r
,
g
,
b
);
let
rgb1555
=
rgb888_to_rgb1555
(
r
,
g
,
b
);
let
output_offset
=
offset_rgb1555
+
index
*
RGB565_SIZE
;
let
output_offset
=
offset_rgb1555
+
index
*
RGB565_SIZE
;
copy_fast
(
unsafe
{
&
rgb1555
,
copy_fast
(
&
mut
rgb1555_pixels
[
output_offset
..
output_offset
+
1
],
&
rgb1555
,
RGB565_SIZE
,
&
mut
rgb1555_pixels
[
output_offset
..
output_offset
+
RGB565_SIZE
],
);
RGB565_SIZE
,
);
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
src/util.rs
+
7
−
6
View file @
bad45f95
...
@@ -118,12 +118,13 @@ pub fn save_bmp(path: &str, pixels: &[u8], width: u32, height: u32) -> Result<()
...
@@ -118,12 +118,13 @@ pub fn save_bmp(path: &str, pixels: &[u8], width: u32, height: u32) -> Result<()
///
///
/// This function is optimized for performance and uses pointer-based
/// This function is optimized for performance and uses pointer-based
/// operations to copy the data as fast as possible.
/// operations to copy the data as fast as possible.
pub
fn
copy_fast
(
src
:
&
[
u8
],
dst
:
&
mut
[
u8
],
count
:
usize
)
{
pub
unsafe
fn
copy_fast
(
src
:
&
[
u8
],
dst
:
&
mut
[
u8
],
count
:
usize
)
{
unsafe
{
debug_assert!
(
src
.len
()
>=
count
);
let
src_ptr
=
src
.as_ptr
();
debug_assert!
(
dst
.len
()
>=
count
);
let
dst_ptr
=
dst
.as_mut_ptr
();
std
::
ptr
::
copy_nonoverlapping
(
src_ptr
,
dst_ptr
,
count
);
let
src_ptr
=
src
.as_ptr
();
}
let
dst_ptr
=
dst
.as_mut_ptr
();
std
::
ptr
::
copy_nonoverlapping
(
src_ptr
,
dst_ptr
,
count
);
}
}
// Interleaves two arrays of bytes into a single array using
// Interleaves two arrays of bytes into a single array using
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment