mirror of
https://github.com/servo/servo.git
synced 2025-07-16 03:43:38 +01:00
canvas: Use snapshot in canvas backends (#37863)
This removes assumption about pixel format from backend abstraction to actual backend implementation. This is important for vello. Testing: WPT tests --------- Signed-off-by: sagudev <16504129+sagudev@users.noreply.github.com>
This commit is contained in:
parent
8df5e1e74d
commit
e1a891ea96
10 changed files with 174 additions and 292 deletions
|
@ -2,15 +2,16 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
use canvas_traits::canvas::{
|
||||
CompositionOrBlending, FillOrStrokeStyle, LineCapStyle, LineJoinStyle, PathSegment,
|
||||
};
|
||||
use compositing_traits::SerializableImageData;
|
||||
use euclid::Angle;
|
||||
use euclid::default::{Point2D, Rect, Size2D, Transform2D, Vector2D};
|
||||
use lyon_geom::Arc;
|
||||
use pixels::Snapshot;
|
||||
use style::color::AbsoluteColor;
|
||||
use webrender_api::ImageDescriptor;
|
||||
|
||||
use crate::canvas_data::{CanvasPaintState, Filter, PathBuilderRef, TextRun};
|
||||
|
||||
|
@ -61,7 +62,7 @@ pub(crate) trait GenericDrawTarget<B: Backend> {
|
|||
destination: Point2D<i32>,
|
||||
);
|
||||
fn create_similar_draw_target(&self, size: &Size2D<i32>) -> Self;
|
||||
fn create_source_surface_from_data(&self, data: &[u8]) -> Option<B::SourceSurface>;
|
||||
fn create_source_surface_from_data(&self, data: Snapshot) -> Option<B::SourceSurface>;
|
||||
fn draw_surface(
|
||||
&mut self,
|
||||
surface: B::SourceSurface,
|
||||
|
@ -113,7 +114,8 @@ pub(crate) trait GenericDrawTarget<B: Backend> {
|
|||
draw_options: &B::DrawOptions,
|
||||
);
|
||||
fn surface(&self) -> B::SourceSurface;
|
||||
fn bytes(&self) -> Cow<[u8]>;
|
||||
fn image_descriptor_and_serializable_data(&self) -> (ImageDescriptor, SerializableImageData);
|
||||
fn snapshot(&self) -> Snapshot;
|
||||
}
|
||||
|
||||
/// A generic Path that abstracts the interface for raqote's PathBuilder/Path.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue