diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-10-04 18:22:15 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-04 18:22:15 -0400 |
commit | db1750673c81de852a3bfd6ad79941f4622eab94 (patch) | |
tree | 85f6534ad1adc69ac1dc4a673857834de5e68252 /components/script/dom/htmlvideoelement.rs | |
parent | c94ca298ca7b1ca8ff537e00c2e94cc814a4b227 (diff) | |
parent | 2010d896131cb0536634373edec99000ecc0c225 (diff) | |
download | servo-db1750673c81de852a3bfd6ad79941f4622eab94.tar.gz servo-db1750673c81de852a3bfd6ad79941f4622eab94.zip |
Auto merge of #24233 - ceyusa:get-image-pixels, r=jdm
get_image_pixels() implementation for video element
<!-- Please describe your changes on the following line: -->
Implements the webgl's get_image_pixels() call for video element
---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [ ] These changes fix #21995 (GitHub issue number if applicable)
<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because ___
<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->
<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->
<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24233)
<!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmlvideoelement.rs')
-rw-r--r-- | components/script/dom/htmlvideoelement.rs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/components/script/dom/htmlvideoelement.rs b/components/script/dom/htmlvideoelement.rs index e95a2ca8ccd..bca18c35a2b 100644 --- a/components/script/dom/htmlvideoelement.rs +++ b/components/script/dom/htmlvideoelement.rs @@ -23,6 +23,7 @@ use crate::fetch::FetchCanceller; use crate::image_listener::{add_cache_listener_for_element, ImageCacheListener}; use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; use dom_struct::dom_struct; +use euclid::default::Size2D; use html5ever::{LocalName, Prefix}; use ipc_channel::ipc; use ipc_channel::router::ROUTER; @@ -34,6 +35,7 @@ use net_traits::{ CoreResourceMsg, FetchChannels, FetchMetadata, FetchResponseListener, FetchResponseMsg, }; use net_traits::{NetworkError, ResourceFetchTiming, ResourceTimingType}; +use servo_media::player::frame::Frame; use servo_url::ServoUrl; use std::cell::Cell; use std::sync::{Arc, Mutex}; @@ -55,6 +57,9 @@ pub struct HTMLVideoElement { /// Load event blocker. Will block the load event while the poster frame /// is being fetched. load_blocker: DomRefCell<Option<LoadBlocker>>, + /// A copy of the last frame + #[ignore_malloc_size_of = "Frame"] + last_frame: DomRefCell<Option<Frame>>, } impl HTMLVideoElement { @@ -70,6 +75,7 @@ impl HTMLVideoElement { generation_id: Cell::new(0), poster_frame_canceller: DomRefCell::new(Default::default()), load_blocker: Default::default(), + last_frame: Default::default(), } } @@ -108,6 +114,27 @@ impl HTMLVideoElement { LoadBlocker::terminate(&mut *self.load_blocker.borrow_mut()); } + pub fn get_current_frame_data(&self) -> Option<(Option<ipc::IpcSharedMemory>, Size2D<u32>)> { + let frame = self.htmlmediaelement.get_current_frame(); + if frame.is_some() { + *self.last_frame.borrow_mut() = frame; + } + + match self.last_frame.borrow().as_ref() { + Some(frame) => { + let size = Size2D::new(frame.get_width() as u32, frame.get_height() as u32); + if !frame.is_gl_texture() { + let data = Some(ipc::IpcSharedMemory::from_bytes(&frame.get_data())); + Some((data, size)) + } else { + // XXX(victor): here we only have the GL texture ID. + Some((None, size)) + } + }, + None => None, + } + } + /// https://html.spec.whatwg.org/multipage/#poster-frame fn fetch_poster_frame(&self, poster_url: &str) { // Step 1. |