mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Auto merge of #17499 - asajeffrey:script-paint-worklets-zoom, r=glennw
Fixed scaling artefacts in paint worklets caused by zoom and hidpi <!-- Please describe your changes on the following line: --> This PR renders paint worklet canvases at the device pixel resolution, rather than the CSS pixel resolution. It's a dependent PR, building on #17239, #17326 and #17364. --- <!-- 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 - [X] These changes fix #17454 - [X] These changes do not require tests because we don't run reftests with zoom enabled <!-- 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/17499) <!-- Reviewable:end -->
This commit is contained in:
commit
9fcbeb3ca2
24 changed files with 160 additions and 77 deletions
|
@ -11,6 +11,7 @@ use bloom::StyleBloom;
|
|||
use cache::LRUCache;
|
||||
use data::{EagerPseudoStyles, ElementData};
|
||||
use dom::{OpaqueNode, TNode, TElement, SendElement};
|
||||
use euclid::ScaleFactor;
|
||||
use euclid::Size2D;
|
||||
use fnv::FnvHashMap;
|
||||
use font_metrics::FontMetricsProvider;
|
||||
|
@ -27,6 +28,8 @@ use std::fmt;
|
|||
use std::ops;
|
||||
#[cfg(feature = "servo")] use std::sync::Mutex;
|
||||
#[cfg(feature = "servo")] use std::sync::mpsc::Sender;
|
||||
use style_traits::CSSPixel;
|
||||
use style_traits::DevicePixel;
|
||||
use stylist::Stylist;
|
||||
use thread_state;
|
||||
use time;
|
||||
|
@ -152,6 +155,11 @@ impl<'a> SharedStyleContext<'a> {
|
|||
pub fn viewport_size(&self) -> Size2D<Au> {
|
||||
self.stylist.device().au_viewport_size()
|
||||
}
|
||||
|
||||
/// The device pixel ratio
|
||||
pub fn device_pixel_ratio(&self) -> ScaleFactor<f32, CSSPixel, DevicePixel> {
|
||||
self.stylist.device().device_pixel_ratio()
|
||||
}
|
||||
}
|
||||
|
||||
/// The structure holds various intermediate inputs that are eventually used by
|
||||
|
|
|
@ -4,9 +4,11 @@
|
|||
|
||||
//! Gecko's media-query device and expression representation.
|
||||
|
||||
use app_units::AU_PER_PX;
|
||||
use app_units::Au;
|
||||
use context::QuirksMode;
|
||||
use cssparser::{CssStringWriter, Parser, RGBA, Token, BasicParseError};
|
||||
use euclid::ScaleFactor;
|
||||
use euclid::Size2D;
|
||||
use font_metrics::get_metrics_provider_for_product;
|
||||
use gecko::values::convert_nscolor_to_rgba;
|
||||
|
@ -25,6 +27,7 @@ use std::fmt::{self, Write};
|
|||
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
|
||||
use str::starts_with_ignore_ascii_case;
|
||||
use string_cache::Atom;
|
||||
use style_traits::{CSSPixel, DevicePixel};
|
||||
use style_traits::{ToCss, ParseError, StyleParseError};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use values::{CSSFloat, specified};
|
||||
|
@ -153,6 +156,15 @@ impl Device {
|
|||
})
|
||||
}
|
||||
|
||||
/// Returns the device pixel ratio.
|
||||
pub fn device_pixel_ratio(&self) -> ScaleFactor<f32, CSSPixel, DevicePixel> {
|
||||
let override_dppx = self.pres_context().mOverrideDPPX;
|
||||
if override_dppx > 0.0 { return ScaleFactor::new(override_dppx); }
|
||||
let au_per_dpx = self.pres_context().mCurAppUnitsPerDevPixel as f32;
|
||||
let au_per_px = AU_PER_PX as f32;
|
||||
ScaleFactor::new(au_per_px / au_per_dpx)
|
||||
}
|
||||
|
||||
/// Returns whether document colors are enabled.
|
||||
pub fn use_document_colors(&self) -> bool {
|
||||
self.pres_context().mUseDocumentColors() != 0
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
use app_units::Au;
|
||||
use context::QuirksMode;
|
||||
use cssparser::{Parser, RGBA};
|
||||
use euclid::{Size2D, TypedSize2D};
|
||||
use euclid::{ScaleFactor, Size2D, TypedSize2D};
|
||||
use font_metrics::ServoMetricsProvider;
|
||||
use media_queries::MediaType;
|
||||
use parser::ParserContext;
|
||||
|
@ -16,7 +16,7 @@ use properties::longhands::font_size;
|
|||
use selectors::parser::SelectorParseError;
|
||||
use std::fmt;
|
||||
use std::sync::atomic::{AtomicBool, AtomicIsize, Ordering};
|
||||
use style_traits::{CSSPixel, ToCss, ParseError};
|
||||
use style_traits::{CSSPixel, DevicePixel, ToCss, ParseError};
|
||||
use style_traits::viewport::ViewportConstraints;
|
||||
use values::computed::{self, ToComputedValue};
|
||||
use values::specified;
|
||||
|
@ -31,6 +31,8 @@ pub struct Device {
|
|||
media_type: MediaType,
|
||||
/// The current viewport size, in CSS pixels.
|
||||
viewport_size: TypedSize2D<f32, CSSPixel>,
|
||||
/// The current device pixel ratio, from CSS pixels to device pixels.
|
||||
device_pixel_ratio: ScaleFactor<f32, CSSPixel, DevicePixel>,
|
||||
|
||||
/// The font size of the root element
|
||||
/// This is set when computing the style of the root
|
||||
|
@ -51,11 +53,13 @@ pub struct Device {
|
|||
impl Device {
|
||||
/// Trivially construct a new `Device`.
|
||||
pub fn new(media_type: MediaType,
|
||||
viewport_size: TypedSize2D<f32, CSSPixel>)
|
||||
viewport_size: TypedSize2D<f32, CSSPixel>,
|
||||
device_pixel_ratio: ScaleFactor<f32, CSSPixel, DevicePixel>)
|
||||
-> Device {
|
||||
Device {
|
||||
media_type: media_type,
|
||||
viewport_size: viewport_size,
|
||||
device_pixel_ratio: device_pixel_ratio,
|
||||
root_font_size: AtomicIsize::new(font_size::get_initial_value().0 as isize), // FIXME(bz): Seems dubious?
|
||||
used_root_font_size: AtomicBool::new(false),
|
||||
}
|
||||
|
@ -99,6 +103,11 @@ impl Device {
|
|||
self.viewport_size
|
||||
}
|
||||
|
||||
/// Returns the device pixel ratio.
|
||||
pub fn device_pixel_ratio(&self) -> ScaleFactor<f32, CSSPixel, DevicePixel> {
|
||||
self.device_pixel_ratio
|
||||
}
|
||||
|
||||
/// Take into account a viewport rule taken from the stylesheets.
|
||||
pub fn account_for_viewport_rule(&mut self, constraints: &ViewportConstraints) {
|
||||
self.viewport_size = constraints.size;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue