Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

render/core: Fix of panic bug and rendering bug in #10955 . #11006

Merged
merged 3 commits into from
May 12, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
core: Fix drawing on cpu with color transform.
Taken directly from this commit, credits to Dinnerbone:
Dinnerbone@9b76090
  • Loading branch information
iwannabethedev committed May 11, 2023
commit 6600caa73157c47b426306a84b8ae2e53fab6206
42 changes: 14 additions & 28 deletions core/src/bitmap/operations.rs
Original file line number Diff line number Diff line change
@@ -1318,37 +1318,23 @@ fn blend_and_transform<'gc>(
dest_region: PixelRegion,
transform: &ColorTransform,
) {
if !source.transparency() && source.ptr_eq(dest) && source_region == dest_region {
// Copying the same area of opaque self to self, noop
return;
}
if source.ptr_eq(dest) {
let dest = dest.sync();
let mut write = dest.write(context.gc_context);

if write.transparency() {
for y in 0..dest_region.height() {
for x in 0..dest_region.width() {
let mut color =
write.get_pixel32_raw(source_region.x_min + x, source_region.y_min + y);
color = write
.get_pixel32_raw(dest_region.x_min + x, dest_region.y_min + y)
.blend_over(&color);
color =
Color::from(transform * swf::Color::from(color.to_un_multiplied_alpha()))
.to_premultiplied_alpha(true);
write.set_pixel32_raw(dest_region.x_min + x, dest_region.y_min + y, color);
}
}
} else {
// Can't blend if copying from opaque
for y in 0..dest_region.height() {
for x in 0..dest_region.width() {
let mut color =
write.get_pixel32_raw(source_region.x_min + x, source_region.y_min + y);
color = Color::from(transform * swf::Color::from(color)).with_alpha(255);
write.set_pixel32_raw(dest_region.x_min + x, dest_region.y_min + y, color);
for y in 0..dest_region.height() {
for x in 0..dest_region.width() {
let mut color =
write.get_pixel32_raw(source_region.x_min + x, source_region.y_min + y);
color = Color::from(transform * swf::Color::from(color.to_un_multiplied_alpha()))
.to_premultiplied_alpha(true);
color = write
.get_pixel32_raw(dest_region.x_min + x, dest_region.y_min + y)
.blend_over(&color);
if !write.transparency() {
color = color.with_alpha(255);
}
write.set_pixel32_raw(dest_region.x_min + x, dest_region.y_min + y, color);
}
}

@@ -1363,10 +1349,10 @@ fn blend_and_transform<'gc>(
for x in 0..dest_region.width() {
let mut color =
source_read.get_pixel32_raw(source_region.x_min + x, source_region.y_min + y);
color = Color::from(transform * swf::Color::from(color));
color = dest_write
.get_pixel32_raw(dest_region.x_min + x, dest_region.y_min + y)
.blend_over(&color);
color = Color::from(transform * swf::Color::from(color));
if opaque {
color = color.with_alpha(255);
}
@@ -1431,7 +1417,7 @@ pub fn draw<'gc>(
&mut source_region,
);

if transform.color_transform == ColorTransform::default() {
if transform.color_transform != ColorTransform::default() {
blend_and_transform(
context,
*source,