mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
canvas: Update the image as part of update the rendering (#35996)
* Create `update_rendering` in `CanvasState` instead of manually updating in layout Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Mark as dirty and do flushes Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * fixup rebase Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> * Update components/script/dom/htmlcanvaselement.rs Co-authored-by: Martin Robinson <mrobinson@igalia.com> Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
ed995e61a6
commit
62737b3830
11 changed files with 72 additions and 51 deletions
|
@ -3,7 +3,7 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::marker::PhantomData;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
|
||||
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
|
||||
use base::id::{BrowsingContextId, PipelineId};
|
||||
|
@ -155,9 +155,7 @@ where
|
|||
let canvas_data = node.canvas_data()?;
|
||||
let source = match canvas_data.source {
|
||||
HTMLCanvasDataSource::WebGL(texture_id) => CanvasSource::WebGL(texture_id),
|
||||
HTMLCanvasDataSource::Image((image_key, canvas_id, ipc_sender)) => {
|
||||
CanvasSource::Image((image_key, canvas_id, Arc::new(Mutex::new(ipc_sender))))
|
||||
},
|
||||
HTMLCanvasDataSource::Image(image_key) => CanvasSource::Image(image_key),
|
||||
HTMLCanvasDataSource::WebGPU(image_key) => CanvasSource::WebGPU(image_key),
|
||||
HTMLCanvasDataSource::Empty => CanvasSource::Empty,
|
||||
};
|
||||
|
|
|
@ -4,14 +4,12 @@
|
|||
|
||||
use std::cell::LazyCell;
|
||||
use std::fmt;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::sync::Arc;
|
||||
|
||||
use app_units::Au;
|
||||
use base::id::{BrowsingContextId, PipelineId};
|
||||
use canvas_traits::canvas::{CanvasId, CanvasMsg, FromLayoutMsg};
|
||||
use data_url::DataUrl;
|
||||
use euclid::Size2D;
|
||||
use ipc_channel::ipc::{self, IpcSender};
|
||||
use net_traits::image_cache::{ImageOrMetadataAvailable, UsePlaceholder};
|
||||
use pixels::Image;
|
||||
use script_layout_interface::IFrameSize;
|
||||
|
@ -98,7 +96,7 @@ impl NaturalSizes {
|
|||
|
||||
pub(crate) enum CanvasSource {
|
||||
WebGL(ImageKey),
|
||||
Image((ImageKey, CanvasId, Arc<Mutex<IpcSender<CanvasMsg>>>)),
|
||||
Image(ImageKey),
|
||||
WebGPU(ImageKey),
|
||||
/// transparent black
|
||||
Empty,
|
||||
|
@ -381,18 +379,7 @@ impl ReplacedContents {
|
|||
let image_key = match canvas_info.source {
|
||||
CanvasSource::WebGL(image_key) => image_key,
|
||||
CanvasSource::WebGPU(image_key) => image_key,
|
||||
CanvasSource::Image((image_key, canvas_id, ref ipc_renderer)) => {
|
||||
let ipc_renderer = ipc_renderer.lock().unwrap();
|
||||
let (sender, receiver) = ipc::channel().unwrap();
|
||||
ipc_renderer
|
||||
.send(CanvasMsg::FromLayout(
|
||||
FromLayoutMsg::UpdateImage(sender),
|
||||
canvas_id,
|
||||
))
|
||||
.unwrap();
|
||||
receiver.recv().unwrap();
|
||||
image_key
|
||||
},
|
||||
CanvasSource::Image(image_key) => image_key,
|
||||
CanvasSource::Empty => return vec![],
|
||||
};
|
||||
vec![Fragment::Image(ArcRefCell::new(ImageFragment {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue