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

Sync changes from mozilla-central #3735

Merged
merged 11 commits into from Aug 15, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

Bug 1570442 - Flip upside down recorded frames right side up on non-A…

…NGLE configurations r=kvark

Frames captured by the composition recorder on non-ANGLE configurations were
previously written upside down to disk. We now flip them right side up when
mapping them into memory.

Differential Revision: https://phabricator.services.mozilla.com/D40113

[wrupdater] From https://hg.mozilla.org/mozilla-central/rev/dccb73a9ee2b1ae7e890eac4d18769bfa8f2857b
  • Loading branch information
brennie authored and moz-gfx committed Aug 13, 2019
commit 12327624ac112d941e1d20495062c0274bc5d272
@@ -8,6 +8,7 @@ use std::collections::HashMap;

use api::{ImageFormat, TextureTarget};
use api::units::*;
use gleam::gl::GlType;

use crate::device::{Device, PBO, DrawTarget, ReadTarget, Texture, TextureFilter};
use crate::internal_types::RenderTargetInfo;
@@ -328,14 +329,16 @@ impl AsyncScreenshotGrabber {
None => return false,
};

let gl_type = device.gl().get_type();

let success = if let Some(bound_pbo) = device.map_pbo_for_readback(&pbo) {
let src_buffer = &bound_pbo.data;
let src_stride = buffer_stride;
let src_width =
screenshot_size.width as usize * image_format.bytes_per_pixel() as usize;

for (src_slice, dst_slice) in src_buffer
.chunks(src_stride)
for (src_slice, dst_slice) in self
.iter_src_buffer_chunked(gl_type, src_buffer, src_stride)
.zip(dst_buffer.chunks_mut(dst_stride))
.take(screenshot_size.height as usize)
{
@@ -354,6 +357,28 @@ impl AsyncScreenshotGrabber {

success
}

fn iter_src_buffer_chunked<'a>(
&self,
gl_type: GlType,
src_buffer: &'a [u8],
src_stride: usize,
) -> Box<dyn Iterator<Item = &'a [u8]> + 'a> {
use AsyncScreenshotGrabberMode::*;

let is_angle = cfg!(windows) && gl_type == GlType::Gles;

if self.mode == CompositionRecorder && !is_angle {
// This is a non-ANGLE configuration. in this case, the recorded frames were captured
// upside down, so we have to flip them right side up.
Box::new(src_buffer.chunks(src_stride).rev())
} else {
// This is either an ANGLE configuration in the `CompositionRecorder` mode or a
// non-ANGLE configuration in the `ProfilerScreenshots` mode. In either case, the
// captured frames are right-side up.
Box::new(src_buffer.chunks(src_stride))
}
}
}

// Screen-capture specific Renderer impls.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.