mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Bug 1507140 - Update webrender to commit dc442bfe38dcd9fc5033d2191b04c6242d167f05 (WR PR #3291). r=kats
Differential Revision: https://phabricator.services.mozilla.com/D12149 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
7bd284ed9d
commit
c1baccfc1a
@ -2,9 +2,9 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{AlphaType, ClipMode, DeviceIntRect, DeviceIntSize};
|
||||
use api::{DeviceUintRect, DeviceUintPoint, ExternalImageType, FilterOp, ImageRendering};
|
||||
use api::{YuvColorSpace, YuvFormat, ColorDepth, PictureRect};
|
||||
use api::{AlphaType, ClipMode, DeviceIntRect, DeviceIntPoint, DeviceIntSize};
|
||||
use api::{ExternalImageType, FilterOp, ImageRendering};
|
||||
use api::{YuvColorSpace, YuvFormat, PictureRect, ColorDepth};
|
||||
use clip::{ClipDataStore, ClipNodeFlags, ClipNodeRange, ClipItem, ClipStore};
|
||||
use clip_scroll_tree::{ClipScrollTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex};
|
||||
use glyph_rasterizer::GlyphFormat;
|
||||
@ -1995,8 +1995,8 @@ pub fn resolve_image(
|
||||
let cache_item = CacheItem {
|
||||
texture_id: TextureSource::External(external_image),
|
||||
uv_rect_handle: cache_handle,
|
||||
uv_rect: DeviceUintRect::new(
|
||||
DeviceUintPoint::zero(),
|
||||
uv_rect: DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
image_properties.descriptor.size,
|
||||
),
|
||||
texture_layer: 0,
|
||||
|
@ -8,6 +8,8 @@ use std::path::{Path, PathBuf};
|
||||
use api::{CaptureBits, ExternalImageData, ImageDescriptor, TexelRect};
|
||||
#[cfg(feature = "png")]
|
||||
use device::ReadPixelsFormat;
|
||||
#[cfg(feature = "png")]
|
||||
use api::DeviceIntSize;
|
||||
use ron;
|
||||
use serde;
|
||||
|
||||
@ -77,7 +79,7 @@ impl CaptureConfig {
|
||||
|
||||
#[cfg(feature = "png")]
|
||||
pub fn save_png(
|
||||
path: PathBuf, size: (u32, u32), format: ReadPixelsFormat, data: &[u8],
|
||||
path: PathBuf, size: DeviceIntSize, format: ReadPixelsFormat, data: &[u8],
|
||||
) {
|
||||
use api::ImageFormat;
|
||||
use png::{BitDepth, ColorType, Encoder, HasParameters};
|
||||
@ -97,7 +99,7 @@ impl CaptureConfig {
|
||||
}
|
||||
};
|
||||
let w = BufWriter::new(File::create(path).unwrap());
|
||||
let mut enc = Encoder::new(w, size.0, size.1);
|
||||
let mut enc = Encoder::new(w, size.width as u32, size.height as u32);
|
||||
enc
|
||||
.set(color_type)
|
||||
.set(BitDepth::Eight);
|
||||
|
@ -300,7 +300,7 @@ impl ClipNode {
|
||||
&image_rect,
|
||||
&visible_rect,
|
||||
&device_image_size,
|
||||
tile_size as u32,
|
||||
tile_size as i32,
|
||||
);
|
||||
for tile in tiles {
|
||||
resource_cache.request_image(
|
||||
|
@ -13,10 +13,10 @@ pub struct BakedGlyph {
|
||||
pub xa: f32,
|
||||
}
|
||||
|
||||
pub const FIRST_GLYPH_INDEX: u32 = 32;
|
||||
pub const BMP_WIDTH: u32 = 128;
|
||||
pub const BMP_HEIGHT: u32 = 128;
|
||||
pub const FONT_SIZE: u32 = 19;
|
||||
pub const FIRST_GLYPH_INDEX: i32 = 32;
|
||||
pub const BMP_WIDTH: i32 = 128;
|
||||
pub const BMP_HEIGHT: i32 = 128;
|
||||
pub const FONT_SIZE: i32 = 19;
|
||||
|
||||
pub const GLYPHS: [BakedGlyph; 96] = [
|
||||
BakedGlyph {
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{ColorU, ImageFormat, TextureTarget};
|
||||
use api::{DeviceIntRect, DeviceRect, DevicePoint, DeviceSize, DeviceUintSize};
|
||||
use api::{DeviceIntRect, DeviceRect, DevicePoint, DeviceSize, DeviceIntSize};
|
||||
use debug_font_data;
|
||||
use device::{Device, Program, Texture, TextureSlot, VertexDescriptor, ShaderError, VAO};
|
||||
use device::{TextureFilter, VertexAttribute, VertexAttributeKind, VertexUsageHint};
|
||||
@ -298,7 +298,7 @@ impl DebugRenderer {
|
||||
pub fn render(
|
||||
&mut self,
|
||||
device: &mut Device,
|
||||
viewport_size: Option<DeviceUintSize>,
|
||||
viewport_size: Option<DeviceIntSize>,
|
||||
) {
|
||||
if let Some(viewport_size) = viewport_size {
|
||||
device.disable_depth();
|
||||
|
@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{ApiMsg, DebugCommand};
|
||||
use api::{ApiMsg, DebugCommand, DeviceIntSize};
|
||||
use api::channel::MsgSender;
|
||||
use print_tree::PrintTreePrinter;
|
||||
use std::sync::mpsc::{channel, Receiver};
|
||||
@ -276,11 +276,16 @@ pub struct Screenshot {
|
||||
}
|
||||
|
||||
impl Screenshot {
|
||||
pub fn new(width: u32, height: u32, data: Vec<u8>) -> Self {
|
||||
let mut output = Vec::with_capacity((width * height) as usize);
|
||||
pub fn new(size: DeviceIntSize, data: Vec<u8>) -> Self {
|
||||
let mut output = Vec::with_capacity((size.width * size.height) as usize);
|
||||
{
|
||||
let encoder = image_loader::png::PNGEncoder::new(&mut output);
|
||||
encoder.encode(&data, width, height, image_loader::ColorType::RGBA(8)).unwrap();
|
||||
encoder.encode(
|
||||
&data,
|
||||
size.width as u32,
|
||||
size.height as u32,
|
||||
image_loader::ColorType::RGBA(8),
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
let data = encode(&output);
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use super::super::shader_source;
|
||||
use api::{ColorF, ImageFormat, MemoryReport};
|
||||
use api::{DeviceIntPoint, DeviceIntRect, DeviceUintRect, DeviceUintSize};
|
||||
use api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use api::TextureTarget;
|
||||
#[cfg(any(feature = "debug_renderer", feature="capture"))]
|
||||
use api::ImageDescriptor;
|
||||
@ -145,7 +145,7 @@ unsafe impl Texel for u8 {}
|
||||
unsafe impl Texel for f32 {}
|
||||
|
||||
/// Returns the size in bytes of a depth target with the given dimensions.
|
||||
fn depth_target_size_in_bytes(dimensions: &DeviceUintSize) -> usize {
|
||||
fn depth_target_size_in_bytes(dimensions: &DeviceIntSize) -> usize {
|
||||
// DEPTH24 textures generally reserve 3 bytes for depth and 1 byte
|
||||
// for stencil, so we measure them as 32 bits.
|
||||
let pixels = dimensions.width * dimensions.height;
|
||||
@ -483,8 +483,7 @@ pub struct Texture {
|
||||
target: gl::GLuint,
|
||||
layer_count: i32,
|
||||
format: ImageFormat,
|
||||
width: u32,
|
||||
height: u32,
|
||||
size: DeviceIntSize,
|
||||
filter: TextureFilter,
|
||||
flags: TextureFlags,
|
||||
/// Framebuffer Objects, one for each layer of the texture, allowing this
|
||||
@ -513,8 +512,8 @@ pub struct Texture {
|
||||
}
|
||||
|
||||
impl Texture {
|
||||
pub fn get_dimensions(&self) -> DeviceUintSize {
|
||||
DeviceUintSize::new(self.width, self.height)
|
||||
pub fn get_dimensions(&self) -> DeviceIntSize {
|
||||
self.size
|
||||
}
|
||||
|
||||
pub fn get_layer_count(&self) -> i32 {
|
||||
@ -557,10 +556,10 @@ impl Texture {
|
||||
/// Returns the number of bytes (generally in GPU memory) that each layer of
|
||||
/// this texture consumes.
|
||||
pub fn layer_size_in_bytes(&self) -> usize {
|
||||
assert!(self.layer_count > 0 || self.width + self.height == 0);
|
||||
assert!(self.layer_count > 0 || self.size.width + self.size.height == 0);
|
||||
let bpp = self.format.bytes_per_pixel() as usize;
|
||||
let w = self.width as usize;
|
||||
let h = self.height as usize;
|
||||
let w = self.size.width as usize;
|
||||
let h = self.size.height as usize;
|
||||
bpp * w * h
|
||||
}
|
||||
|
||||
@ -834,7 +833,7 @@ pub struct Device {
|
||||
///
|
||||
/// Render targets often have the same width/height, so we can save memory
|
||||
/// by sharing these across targets.
|
||||
depth_targets: FastHashMap<DeviceUintSize, SharedDepthTarget>,
|
||||
depth_targets: FastHashMap<DeviceIntSize, SharedDepthTarget>,
|
||||
|
||||
// debug
|
||||
inside_frame: bool,
|
||||
@ -842,7 +841,7 @@ pub struct Device {
|
||||
// resources
|
||||
resource_override_path: Option<PathBuf>,
|
||||
|
||||
max_texture_size: u32,
|
||||
max_texture_size: i32,
|
||||
max_texture_layers: u32,
|
||||
renderer_name: String,
|
||||
cached_programs: Option<Rc<ProgramCache>>,
|
||||
@ -867,7 +866,7 @@ pub struct Device {
|
||||
pub enum DrawTarget<'a> {
|
||||
/// Use the device's default draw target, with the provided dimensions,
|
||||
/// which are used to set the viewport.
|
||||
Default(DeviceUintSize),
|
||||
Default(DeviceIntSize),
|
||||
/// Use the provided texture.
|
||||
Texture {
|
||||
/// The target texture.
|
||||
@ -889,7 +888,7 @@ impl<'a> DrawTarget<'a> {
|
||||
}
|
||||
|
||||
/// Returns the dimensions of this draw-target.
|
||||
pub fn dimensions(&self) -> DeviceUintSize {
|
||||
pub fn dimensions(&self) -> DeviceIntSize {
|
||||
match *self {
|
||||
DrawTarget::Default(d) => d,
|
||||
DrawTarget::Texture { texture, .. } => texture.get_dimensions(),
|
||||
@ -934,7 +933,8 @@ impl Device {
|
||||
gl.get_integer_v(gl::MAX_TEXTURE_SIZE, &mut max_texture_size);
|
||||
gl.get_integer_v(gl::MAX_ARRAY_TEXTURE_LAYERS, &mut max_texture_layers);
|
||||
}
|
||||
let max_texture_size = max_texture_size[0] as u32;
|
||||
|
||||
let max_texture_size = max_texture_size[0];
|
||||
let max_texture_layers = max_texture_layers[0] as u32;
|
||||
let renderer_name = gl.get_string(gl::RENDERER);
|
||||
|
||||
@ -1079,12 +1079,12 @@ impl Device {
|
||||
/// Ensures that the maximum texture size is less than or equal to the
|
||||
/// provided value. If the provided value is less than the value supported
|
||||
/// by the driver, the latter is used.
|
||||
pub fn clamp_max_texture_size(&mut self, size: u32) {
|
||||
pub fn clamp_max_texture_size(&mut self, size: i32) {
|
||||
self.max_texture_size = self.max_texture_size.min(size);
|
||||
}
|
||||
|
||||
/// Returns the limit on texture dimensions (width or height).
|
||||
pub fn max_texture_size(&self) -> u32 {
|
||||
pub fn max_texture_size(&self) -> i32 {
|
||||
self.max_texture_size
|
||||
}
|
||||
|
||||
@ -1453,8 +1453,8 @@ impl Device {
|
||||
&mut self,
|
||||
target: TextureTarget,
|
||||
format: ImageFormat,
|
||||
mut width: u32,
|
||||
mut height: u32,
|
||||
mut width: i32,
|
||||
mut height: i32,
|
||||
filter: TextureFilter,
|
||||
render_target: Option<RenderTargetInfo>,
|
||||
layer_count: i32,
|
||||
@ -1471,8 +1471,7 @@ impl Device {
|
||||
let mut texture = Texture {
|
||||
id: self.gl.gen_textures(1)[0],
|
||||
target: get_gl_target(target),
|
||||
width,
|
||||
height,
|
||||
size: DeviceIntSize::new(width, height),
|
||||
layer_count,
|
||||
format,
|
||||
filter,
|
||||
@ -1517,8 +1516,8 @@ impl Device {
|
||||
gl::TEXTURE_2D_ARRAY,
|
||||
mipmap_levels,
|
||||
desc.internal,
|
||||
texture.width as gl::GLint,
|
||||
texture.height as gl::GLint,
|
||||
texture.size.width as gl::GLint,
|
||||
texture.size.height as gl::GLint,
|
||||
texture.layer_count,
|
||||
),
|
||||
(true, false) =>
|
||||
@ -1526,16 +1525,16 @@ impl Device {
|
||||
texture.target,
|
||||
mipmap_levels,
|
||||
desc.internal,
|
||||
texture.width as gl::GLint,
|
||||
texture.height as gl::GLint,
|
||||
texture.size.width as gl::GLint,
|
||||
texture.size.height as gl::GLint,
|
||||
),
|
||||
(false, true) =>
|
||||
self.gl.tex_image_3d(
|
||||
gl::TEXTURE_2D_ARRAY,
|
||||
0,
|
||||
desc.internal as gl::GLint,
|
||||
texture.width as gl::GLint,
|
||||
texture.height as gl::GLint,
|
||||
texture.size.width as gl::GLint,
|
||||
texture.size.height as gl::GLint,
|
||||
texture.layer_count,
|
||||
0,
|
||||
desc.external,
|
||||
@ -1547,8 +1546,8 @@ impl Device {
|
||||
texture.target,
|
||||
0,
|
||||
desc.internal as gl::GLint,
|
||||
texture.width as gl::GLint,
|
||||
texture.height as gl::GLint,
|
||||
texture.size.width as gl::GLint,
|
||||
texture.size.height as gl::GLint,
|
||||
0,
|
||||
desc.external,
|
||||
desc.pixel_type,
|
||||
@ -1599,8 +1598,8 @@ impl Device {
|
||||
src: &Texture,
|
||||
) {
|
||||
debug_assert!(self.inside_frame);
|
||||
debug_assert!(dst.width >= src.width);
|
||||
debug_assert!(dst.height >= src.height);
|
||||
debug_assert!(dst.size.width >= src.size.width);
|
||||
debug_assert!(dst.size.height >= src.size.height);
|
||||
debug_assert!(dst.layer_count >= src.layer_count);
|
||||
|
||||
// Note that zip() truncates to the shorter of the two iterators.
|
||||
@ -1714,7 +1713,7 @@ impl Device {
|
||||
}
|
||||
}
|
||||
|
||||
fn acquire_depth_target(&mut self, dimensions: DeviceUintSize) -> RBOId {
|
||||
fn acquire_depth_target(&mut self, dimensions: DeviceIntSize) -> RBOId {
|
||||
let gl = &self.gl;
|
||||
let target = self.depth_targets.entry(dimensions).or_insert_with(|| {
|
||||
let renderbuffer_ids = gl.gen_renderbuffers(1);
|
||||
@ -1738,7 +1737,7 @@ impl Device {
|
||||
target.rbo_id
|
||||
}
|
||||
|
||||
fn release_depth_target(&mut self, dimensions: DeviceUintSize) {
|
||||
fn release_depth_target(&mut self, dimensions: DeviceIntSize) {
|
||||
let mut entry = match self.depth_targets.entry(dimensions) {
|
||||
Entry::Occupied(x) => x,
|
||||
Entry::Vacant(..) => panic!("Releasing unknown depth target"),
|
||||
@ -1986,8 +1985,8 @@ impl Device {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
texture.width as gl::GLint,
|
||||
texture.height as gl::GLint,
|
||||
texture.size.width as gl::GLint,
|
||||
texture.size.height as gl::GLint,
|
||||
desc.external,
|
||||
desc.pixel_type,
|
||||
texels_to_u8_slice(pixels),
|
||||
@ -1999,8 +1998,8 @@ impl Device {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
texture.width as gl::GLint,
|
||||
texture.height as gl::GLint,
|
||||
texture.size.width as gl::GLint,
|
||||
texture.size.height as gl::GLint,
|
||||
texture.layer_count as gl::GLint,
|
||||
desc.external,
|
||||
desc.pixel_type,
|
||||
@ -2025,7 +2024,7 @@ impl Device {
|
||||
/// Read rectangle of pixels into the specified output slice.
|
||||
pub fn read_pixels_into(
|
||||
&mut self,
|
||||
rect: DeviceUintRect,
|
||||
rect: DeviceIntRect,
|
||||
format: ReadPixelsFormat,
|
||||
output: &mut [u8],
|
||||
) {
|
||||
@ -2646,9 +2645,9 @@ struct FormatDesc {
|
||||
}
|
||||
|
||||
struct UploadChunk {
|
||||
rect: DeviceUintRect,
|
||||
rect: DeviceIntRect,
|
||||
layer_index: i32,
|
||||
stride: Option<u32>,
|
||||
stride: Option<i32>,
|
||||
offset: usize,
|
||||
}
|
||||
|
||||
@ -2700,9 +2699,9 @@ impl<'a, T> Drop for TextureUploader<'a, T> {
|
||||
impl<'a, T> TextureUploader<'a, T> {
|
||||
pub fn upload(
|
||||
&mut self,
|
||||
rect: DeviceUintRect,
|
||||
rect: DeviceIntRect,
|
||||
layer_index: i32,
|
||||
stride: Option<u32>,
|
||||
stride: Option<i32>,
|
||||
data: &[T],
|
||||
) -> usize {
|
||||
let bytes_pp = self.target.texture.format.bytes_per_pixel();
|
||||
@ -2774,7 +2773,7 @@ impl<'a> UploadTarget<'a> {
|
||||
|
||||
let row_length = match chunk.stride {
|
||||
Some(value) => value / bpp,
|
||||
None => self.texture.width,
|
||||
None => self.texture.size.width,
|
||||
};
|
||||
|
||||
if chunk.stride.is_some() {
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{ColorF, DeviceIntPoint, DevicePixelScale, LayoutPixel, PicturePixel, RasterPixel};
|
||||
use api::{DeviceUintPoint, DeviceUintRect, DeviceUintSize, DocumentLayer, FontRenderMode};
|
||||
use api::{DeviceIntRect, DeviceIntSize, DocumentLayer, FontRenderMode};
|
||||
use api::{LayoutPoint, LayoutRect, LayoutSize, PipelineId, RasterSpace, WorldPoint, WorldRect, WorldPixel};
|
||||
use clip::{ClipDataStore, ClipStore};
|
||||
use clip_scroll_tree::{ClipScrollTree, ROOT_SPATIAL_NODE_INDEX, SpatialNodeIndex};
|
||||
@ -54,9 +54,9 @@ pub struct FrameBuilderConfig {
|
||||
|
||||
/// A builder structure for `tiling::Frame`
|
||||
pub struct FrameBuilder {
|
||||
screen_rect: DeviceUintRect,
|
||||
screen_rect: DeviceIntRect,
|
||||
background_color: Option<ColorF>,
|
||||
window_size: DeviceUintSize,
|
||||
window_size: DeviceIntSize,
|
||||
root_pic_index: PictureIndex,
|
||||
pub prim_store: PrimitiveStore,
|
||||
pub clip_store: ClipStore,
|
||||
@ -139,8 +139,8 @@ impl FrameBuilder {
|
||||
hit_testing_runs: Vec::new(),
|
||||
prim_store: PrimitiveStore::new(),
|
||||
clip_store: ClipStore::new(),
|
||||
screen_rect: DeviceUintRect::zero(),
|
||||
window_size: DeviceUintSize::zero(),
|
||||
screen_rect: DeviceIntRect::zero(),
|
||||
window_size: DeviceIntSize::zero(),
|
||||
background_color: None,
|
||||
root_pic_index: PictureIndex(0),
|
||||
config: FrameBuilderConfig {
|
||||
@ -153,9 +153,9 @@ impl FrameBuilder {
|
||||
}
|
||||
|
||||
pub fn with_display_list_flattener(
|
||||
screen_rect: DeviceUintRect,
|
||||
screen_rect: DeviceIntRect,
|
||||
background_color: Option<ColorF>,
|
||||
window_size: DeviceUintSize,
|
||||
window_size: DeviceIntSize,
|
||||
flattener: DisplayListFlattener,
|
||||
) -> Self {
|
||||
FrameBuilder {
|
||||
@ -321,7 +321,7 @@ impl FrameBuilder {
|
||||
) -> Frame {
|
||||
profile_scope!("build");
|
||||
debug_assert!(
|
||||
DeviceUintRect::new(DeviceUintPoint::zero(), self.window_size)
|
||||
DeviceIntRect::new(DeviceIntPoint::zero(), self.window_size)
|
||||
.contains_rect(&self.screen_rect)
|
||||
);
|
||||
|
||||
|
@ -433,8 +433,8 @@ impl GlyphFormat {
|
||||
pub struct RasterizedGlyph {
|
||||
pub top: f32,
|
||||
pub left: f32,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub scale: f32,
|
||||
pub format: GlyphFormat,
|
||||
pub bytes: Vec<u8>,
|
||||
|
@ -35,9 +35,9 @@ use std::ops::Add;
|
||||
use std::os::raw::c_void;
|
||||
|
||||
|
||||
pub const GPU_CACHE_INITIAL_HEIGHT: u32 = 512;
|
||||
pub const GPU_CACHE_INITIAL_HEIGHT: i32 = 512;
|
||||
const FRAMES_BEFORE_EVICTION: usize = 10;
|
||||
const NEW_ROWS_PER_RESIZE: u32 = 512;
|
||||
const NEW_ROWS_PER_RESIZE: i32 = 512;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
@ -247,7 +247,7 @@ pub struct GpuCacheUpdateList {
|
||||
pub frame_id: FrameId,
|
||||
/// The current height of the texture. The render thread
|
||||
/// should resize the texture if required.
|
||||
pub height: u32,
|
||||
pub height: i32,
|
||||
/// List of updates to apply.
|
||||
pub updates: Vec<GpuCacheUpdate>,
|
||||
/// A flat list of GPU blocks that are pending upload
|
||||
@ -316,7 +316,7 @@ impl FreeBlockLists {
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
struct Texture {
|
||||
// Current texture height
|
||||
height: u32,
|
||||
height: i32,
|
||||
// All blocks that have been created for this texture
|
||||
blocks: Vec<Block>,
|
||||
// Metadata about each allocated row.
|
||||
@ -379,7 +379,7 @@ impl Texture {
|
||||
|
||||
// See if we need a new row (if free-list has nothing available)
|
||||
if free_list.is_none() {
|
||||
if self.rows.len() as u32 == self.height {
|
||||
if self.rows.len() as i32 == self.height {
|
||||
self.height += NEW_ROWS_PER_RESIZE;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
//! GPU glyph rasterization using Pathfinder.
|
||||
|
||||
use api::{DeviceIntPoint, DeviceIntRect, DeviceUintSize, FontRenderMode};
|
||||
use api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize, FontRenderMode};
|
||||
use api::{ImageFormat, TextureTarget};
|
||||
use debug_colors;
|
||||
use device::{DrawTarget, Device, Texture, TextureFilter, VAO};
|
||||
@ -57,8 +57,8 @@ impl GpuGlyphRenderer {
|
||||
let area_lut_texture = device.create_texture(
|
||||
TextureTarget::Default,
|
||||
ImageFormat::R8,
|
||||
area_lut_width,
|
||||
area_lut_height,
|
||||
area_lut_width as i32,
|
||||
area_lut_height as i32,
|
||||
TextureFilter::Linear,
|
||||
None,
|
||||
1,
|
||||
@ -101,7 +101,7 @@ impl Renderer {
|
||||
pub fn stencil_glyphs(&mut self,
|
||||
glyphs: &[GlyphJob],
|
||||
projection: &Transform3D<f32>,
|
||||
target_size: &DeviceUintSize,
|
||||
target_size: &DeviceIntSize,
|
||||
stats: &mut RendererStats)
|
||||
-> Option<StenciledGlyphPage> {
|
||||
if glyphs.is_empty() {
|
||||
@ -183,7 +183,7 @@ impl Renderer {
|
||||
TextureTarget::Default,
|
||||
ImageFormat::RGBAF32,
|
||||
3,
|
||||
glyphs.len() as u32,
|
||||
glyphs.len() as i32,
|
||||
TextureFilter::Nearest,
|
||||
None,
|
||||
1,
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{TileOffset, TileRange, LayoutRect, LayoutSize, LayoutPoint};
|
||||
use api::{DeviceUintSize, DeviceUintRect};
|
||||
use api::{DeviceIntSize, DeviceIntRect};
|
||||
use euclid::{vec2, point2};
|
||||
use prim_store::EdgeAaSegmentMask;
|
||||
|
||||
@ -156,10 +156,10 @@ pub struct Tile {
|
||||
}
|
||||
|
||||
pub struct TileIterator {
|
||||
current_x: u32,
|
||||
x_count: u32,
|
||||
current_y: u32,
|
||||
y_count: u32,
|
||||
current_x: i32,
|
||||
x_count: i32,
|
||||
current_y: i32,
|
||||
y_count: i32,
|
||||
origin: TileOffset,
|
||||
tile_size: LayoutSize,
|
||||
leftover_offset: TileOffset,
|
||||
@ -225,8 +225,8 @@ impl Iterator for TileIterator {
|
||||
pub fn tiles(
|
||||
prim_rect: &LayoutRect,
|
||||
visible_rect: &LayoutRect,
|
||||
device_image_size: &DeviceUintSize,
|
||||
device_tile_size: u32,
|
||||
device_image_size: &DeviceIntSize,
|
||||
device_tile_size: i32,
|
||||
) -> TileIterator {
|
||||
// The image resource is tiled. We have to generate an image primitive
|
||||
// for each tile.
|
||||
@ -289,7 +289,7 @@ pub fn tiles(
|
||||
// The size in pixels of the tiles on the right and bottom edges, smaller
|
||||
// than the regular tile size if the image is not a multiple of the tile size.
|
||||
// Zero means the image size is a multiple of the tile size.
|
||||
let leftover_device_size = DeviceUintSize::new(
|
||||
let leftover_device_size = DeviceIntSize::new(
|
||||
device_image_size.width % device_tile_size,
|
||||
device_image_size.height % device_tile_size
|
||||
);
|
||||
@ -302,19 +302,19 @@ pub fn tiles(
|
||||
|
||||
// Offset of the row and column of tiles with leftover size.
|
||||
let leftover_offset = TileOffset::new(
|
||||
(device_image_size.width / device_tile_size) as u32,
|
||||
(device_image_size.height / device_tile_size) as u32,
|
||||
device_image_size.width / device_tile_size,
|
||||
device_image_size.height / device_tile_size,
|
||||
);
|
||||
|
||||
// Number of culled out tiles to skip before the first visible tile.
|
||||
let t0 = TileOffset::new(
|
||||
if visible_rect.origin.x > prim_rect.origin.x {
|
||||
f32::floor((visible_rect.origin.x - prim_rect.origin.x) / layer_tile_size.width) as u32
|
||||
f32::floor((visible_rect.origin.x - prim_rect.origin.x) / layer_tile_size.width) as i32
|
||||
} else {
|
||||
0
|
||||
},
|
||||
if visible_rect.origin.y > prim_rect.origin.y {
|
||||
f32::floor((visible_rect.origin.y - prim_rect.origin.y) / layer_tile_size.height) as u32
|
||||
f32::floor((visible_rect.origin.y - prim_rect.origin.y) / layer_tile_size.height) as i32
|
||||
} else {
|
||||
0
|
||||
},
|
||||
@ -324,7 +324,7 @@ pub fn tiles(
|
||||
// size due to floating point precision issues. Detect this case so that we don't return
|
||||
// tiles with an empty size.
|
||||
let x_max = {
|
||||
let result = f32::ceil((visible_rect.max_x() - prim_rect.origin.x) / layer_tile_size.width) as u32;
|
||||
let result = f32::ceil((visible_rect.max_x() - prim_rect.origin.x) / layer_tile_size.width) as i32;
|
||||
if result == leftover_offset.x + 1 && leftover_layer_size.width == 0.0f32 {
|
||||
leftover_offset.x
|
||||
} else {
|
||||
@ -332,7 +332,7 @@ pub fn tiles(
|
||||
}
|
||||
};
|
||||
let y_max = {
|
||||
let result = f32::ceil((visible_rect.max_y() - prim_rect.origin.y) / layer_tile_size.height) as u32;
|
||||
let result = f32::ceil((visible_rect.max_y() - prim_rect.origin.y) / layer_tile_size.height) as i32;
|
||||
if result == leftover_offset.y + 1 && leftover_layer_size.height == 0.0f32 {
|
||||
leftover_offset.y
|
||||
} else {
|
||||
@ -359,7 +359,7 @@ pub fn tiles(
|
||||
}
|
||||
|
||||
pub fn compute_tile_range(
|
||||
visible_area: &DeviceUintRect,
|
||||
visible_area: &DeviceIntRect,
|
||||
tile_size: u16,
|
||||
) -> TileRange {
|
||||
// Tile dimensions in normalized coordinates.
|
||||
@ -369,12 +369,12 @@ pub fn compute_tile_range(
|
||||
let t0 = point2(
|
||||
f32::floor(visible_area.origin.x as f32 * tw),
|
||||
f32::floor(visible_area.origin.y as f32 * th),
|
||||
).try_cast::<u32>().unwrap_or_else(|| panic!("compute_tile_range bad values {:?} {:?}", visible_area, tile_size));
|
||||
).try_cast::<i32>().unwrap_or_else(|| panic!("compute_tile_range bad values {:?} {:?}", visible_area, tile_size));
|
||||
|
||||
let t1 = point2(
|
||||
f32::ceil(visible_area.max_x() as f32 * tw),
|
||||
f32::ceil(visible_area.max_y() as f32 * th),
|
||||
).try_cast::<u32>().unwrap_or_else(|| panic!("compute_tile_range bad values {:?} {:?}", visible_area, tile_size));
|
||||
).try_cast::<i32>().unwrap_or_else(|| panic!("compute_tile_range bad values {:?} {:?}", visible_area, tile_size));
|
||||
|
||||
TileRange {
|
||||
origin: t0,
|
||||
@ -397,15 +397,15 @@ pub fn for_each_tile_in_range(
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::collections::HashSet;
|
||||
use api::{LayoutRect, DeviceUintSize};
|
||||
use api::{LayoutRect, DeviceIntSize};
|
||||
use euclid::{rect, size2};
|
||||
|
||||
// this checks some additional invariants
|
||||
fn checked_for_each_tile(
|
||||
prim_rect: &LayoutRect,
|
||||
visible_rect: &LayoutRect,
|
||||
device_image_size: &DeviceUintSize,
|
||||
device_tile_size: u32,
|
||||
device_image_size: &DeviceIntSize,
|
||||
device_tile_size: i32,
|
||||
callback: &mut FnMut(&LayoutRect, TileOffset, EdgeAaSegmentMask),
|
||||
) {
|
||||
let mut coverage = LayoutRect::zero();
|
||||
|
@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{DebugCommand, DeviceUintRect, DocumentId, ExternalImageData, ExternalImageId};
|
||||
use api::{DebugCommand, DeviceIntRect, DocumentId, ExternalImageData, ExternalImageId};
|
||||
use api::{ImageFormat, WorldPixel, NotificationRequest};
|
||||
use device::TextureFilter;
|
||||
use renderer::PipelineInfo;
|
||||
@ -122,8 +122,8 @@ pub struct TextureCacheAllocation {
|
||||
/// Information used when allocating / reallocating.
|
||||
#[derive(Debug)]
|
||||
pub struct TextureCacheAllocInfo {
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub layer_count: i32,
|
||||
pub format: ImageFormat,
|
||||
pub filter: TextureFilter,
|
||||
@ -148,9 +148,9 @@ pub enum TextureCacheAllocationKind {
|
||||
#[derive(Debug)]
|
||||
pub struct TextureCacheUpdate {
|
||||
pub id: CacheTextureId,
|
||||
pub rect: DeviceUintRect,
|
||||
pub stride: Option<u32>,
|
||||
pub offset: u32,
|
||||
pub rect: DeviceIntRect,
|
||||
pub stride: Option<i32>,
|
||||
pub offset: i32,
|
||||
pub layer_index: i32,
|
||||
pub source: TextureUpdateSource,
|
||||
}
|
||||
|
@ -55,8 +55,8 @@ struct GlyphMetrics {
|
||||
#[allow(dead_code)]
|
||||
rasterized_descent: i32,
|
||||
rasterized_ascent: i32,
|
||||
rasterized_width: u32,
|
||||
rasterized_height: u32,
|
||||
rasterized_width: i32,
|
||||
rasterized_height: i32,
|
||||
advance: f32,
|
||||
}
|
||||
|
||||
@ -156,8 +156,8 @@ fn get_glyph_metrics(
|
||||
|
||||
GlyphMetrics {
|
||||
rasterized_left: left,
|
||||
rasterized_width: width as u32,
|
||||
rasterized_height: height as u32,
|
||||
rasterized_width: width,
|
||||
rasterized_height: height,
|
||||
rasterized_ascent: top,
|
||||
rasterized_descent: -bottom,
|
||||
advance: advance.width as f32,
|
||||
@ -421,8 +421,8 @@ impl FontContext {
|
||||
Some(GlyphDimensions {
|
||||
left: metrics.rasterized_left,
|
||||
top: metrics.rasterized_ascent,
|
||||
width: metrics.rasterized_width as u32,
|
||||
height: metrics.rasterized_height as u32,
|
||||
width: metrics.rasterized_width,
|
||||
height: metrics.rasterized_height,
|
||||
advance: metrics.advance,
|
||||
})
|
||||
}
|
||||
@ -565,7 +565,10 @@ impl FontContext {
|
||||
return GlyphRasterResult::LoadFailed
|
||||
}
|
||||
|
||||
let raster_size = Size2D::new(metrics.rasterized_width, metrics.rasterized_height);
|
||||
let raster_size = Size2D::new(
|
||||
metrics.rasterized_width as u32,
|
||||
metrics.rasterized_height as u32
|
||||
);
|
||||
|
||||
// If the font render mode is Alpha, we support two different ways to
|
||||
// compute the grayscale mask, depending on the value of the platform
|
||||
|
@ -432,10 +432,10 @@ impl FontContext {
|
||||
let (mut left, mut top, mut width, mut height) = match format {
|
||||
FT_Glyph_Format::FT_GLYPH_FORMAT_BITMAP => {
|
||||
unsafe { (
|
||||
(*slot).bitmap_left,
|
||||
(*slot).bitmap_top,
|
||||
(*slot).bitmap.width,
|
||||
(*slot).bitmap.rows,
|
||||
(*slot).bitmap_left as i32,
|
||||
(*slot).bitmap_top as i32,
|
||||
(*slot).bitmap.width as i32,
|
||||
(*slot).bitmap.rows as i32,
|
||||
) }
|
||||
}
|
||||
FT_Glyph_Format::FT_GLYPH_FORMAT_OUTLINE => {
|
||||
@ -443,8 +443,8 @@ impl FontContext {
|
||||
(
|
||||
(cbox.xMin >> 6) as i32,
|
||||
(cbox.yMax >> 6) as i32,
|
||||
((cbox.xMax - cbox.xMin) >> 6) as u32,
|
||||
((cbox.yMax - cbox.yMin) >> 6) as u32,
|
||||
((cbox.xMax - cbox.xMin) >> 6) as i32,
|
||||
((cbox.yMax - cbox.yMin) >> 6) as i32,
|
||||
)
|
||||
}
|
||||
_ => return None,
|
||||
@ -458,8 +458,8 @@ impl FontContext {
|
||||
let y0 = y1 - height as f32 * scale;
|
||||
left = x0.round() as i32;
|
||||
top = y1.round() as i32;
|
||||
width = (x1.ceil() - x0.floor()) as u32;
|
||||
height = (y1.ceil() - y0.floor()) as u32;
|
||||
width = (x1.ceil() - x0.floor()) as i32;
|
||||
height = (y1.ceil() - y0.floor()) as i32;
|
||||
advance *= scale;
|
||||
}
|
||||
// An outline glyph's cbox would have already been transformed inside FT_Load_Glyph,
|
||||
@ -472,7 +472,7 @@ impl FontContext {
|
||||
font.synthetic_italics.to_skew(),
|
||||
);
|
||||
left += skew_min as i32;
|
||||
width += (skew_max - skew_min) as u32;
|
||||
width += (skew_max - skew_min) as i32;
|
||||
}
|
||||
if font.flags.contains(FontInstanceFlags::TRANSPOSE) {
|
||||
mem::swap(&mut width, &mut height);
|
||||
@ -804,8 +804,8 @@ impl FontContext {
|
||||
GlyphRasterResult::Bitmap(RasterizedGlyph {
|
||||
left: left as f32,
|
||||
top: top as f32,
|
||||
width: actual_width as u32,
|
||||
height: actual_height as u32,
|
||||
width: actual_width as i32,
|
||||
height: actual_height as i32,
|
||||
scale,
|
||||
format: glyph_format,
|
||||
bytes: final_buffer,
|
||||
|
@ -332,8 +332,8 @@ impl FontContext {
|
||||
|
||||
let bounds = analysis.get_alpha_texture_bounds(texture_type);
|
||||
|
||||
let width = (bounds.right - bounds.left) as u32;
|
||||
let height = (bounds.bottom - bounds.top) as u32;
|
||||
let width = (bounds.right - bounds.left) as i32;
|
||||
let height = (bounds.bottom - bounds.top) as i32;
|
||||
|
||||
// Alpha texture bounds can sometimes return an empty rect
|
||||
// Such as for spaces
|
||||
@ -464,8 +464,8 @@ impl FontContext {
|
||||
let texture_type = dwrite_texture_type(font.render_mode);
|
||||
|
||||
let bounds = analysis.get_alpha_texture_bounds(texture_type);
|
||||
let width = (bounds.right - bounds.left) as u32;
|
||||
let height = (bounds.bottom - bounds.top) as u32;
|
||||
let width = (bounds.right - bounds.left) as i32;
|
||||
let height = (bounds.bottom - bounds.top) as i32;
|
||||
|
||||
// Alpha texture bounds can sometimes return an empty rect
|
||||
// Such as for spaces
|
||||
|
@ -3204,7 +3204,7 @@ impl PrimitiveInstance {
|
||||
&image_rect,
|
||||
&visible_rect,
|
||||
&device_image_size,
|
||||
tile_size as u32,
|
||||
tile_size as i32,
|
||||
);
|
||||
|
||||
for tile in tiles {
|
||||
|
@ -11,7 +11,7 @@
|
||||
use api::{ApiMsg, BuiltDisplayList, ClearCache, DebugCommand};
|
||||
#[cfg(feature = "debugger")]
|
||||
use api::{BuiltDisplayListIter, SpecificDisplayItem};
|
||||
use api::{DeviceIntPoint, DevicePixelScale, DeviceUintPoint, DeviceUintRect, DeviceUintSize};
|
||||
use api::{DevicePixelScale, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use api::{DocumentId, DocumentLayer, ExternalScrollId, FrameMsg, HitTestFlags, HitTestResult};
|
||||
use api::{IdNamespace, LayoutPoint, PipelineId, RenderNotifier, SceneMsg, ScrollClamping};
|
||||
use api::{MemoryReport, VoidPtrToSizeFn};
|
||||
@ -61,8 +61,8 @@ use util::drain_filter;
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
#[derive(Clone)]
|
||||
pub struct DocumentView {
|
||||
pub window_size: DeviceUintSize,
|
||||
pub inner_rect: DeviceUintRect,
|
||||
pub window_size: DeviceIntSize,
|
||||
pub inner_rect: DeviceIntRect,
|
||||
pub layer: DocumentLayer,
|
||||
pub pan: DeviceIntPoint,
|
||||
pub device_pixel_ratio: f32,
|
||||
@ -197,7 +197,7 @@ struct Document {
|
||||
|
||||
impl Document {
|
||||
pub fn new(
|
||||
window_size: DeviceUintSize,
|
||||
window_size: DeviceIntSize,
|
||||
layer: DocumentLayer,
|
||||
default_device_pixel_ratio: f32,
|
||||
) -> Self {
|
||||
@ -206,7 +206,7 @@ impl Document {
|
||||
removed_pipelines: Vec::new(),
|
||||
view: DocumentView {
|
||||
window_size,
|
||||
inner_rect: DeviceUintRect::new(DeviceUintPoint::zero(), window_size),
|
||||
inner_rect: DeviceIntRect::new(DeviceIntPoint::zero(), window_size),
|
||||
layer,
|
||||
pan: DeviceIntPoint::zero(),
|
||||
page_zoom_factor: 1.0,
|
||||
|
@ -1213,8 +1213,8 @@ impl RenderTaskCache {
|
||||
};
|
||||
|
||||
let descriptor = ImageDescriptor::new(
|
||||
size.width as u32,
|
||||
size.height as u32,
|
||||
size.width,
|
||||
size.height,
|
||||
image_format,
|
||||
entry.is_opaque,
|
||||
false,
|
||||
|
@ -23,7 +23,7 @@
|
||||
//! that channel and operate on the `RenderBackend`.
|
||||
|
||||
use api::{BlobImageHandler, ColorF, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use api::{DeviceUintPoint, DeviceUintRect, DeviceUintSize, DocumentId, Epoch, ExternalImageId};
|
||||
use api::{DocumentId, Epoch, ExternalImageId};
|
||||
use api::{ExternalImageType, FontRenderMode, FrameMsg, ImageFormat, PipelineId};
|
||||
use api::{ImageRendering, Checkpoint, NotificationRequest};
|
||||
use api::{MemoryReport, VoidPtrToSizeFn};
|
||||
@ -1080,7 +1080,7 @@ impl GpuCacheTexture {
|
||||
|
||||
/// Ensures that we have an appropriately-sized texture. Returns true if a
|
||||
/// new texture was created.
|
||||
fn ensure_texture(&mut self, device: &mut Device, height: u32) -> bool {
|
||||
fn ensure_texture(&mut self, device: &mut Device, height: i32) -> bool {
|
||||
// If we already have a texture that works, we're done.
|
||||
if self.texture.as_ref().map_or(false, |t| t.get_dimensions().height >= height) {
|
||||
if GPU_CACHE_RESIZE_TEST && self.bus.uses_render_target() {
|
||||
@ -1093,7 +1093,7 @@ impl GpuCacheTexture {
|
||||
// Compute a few parameters for the new texture. We round the height up to
|
||||
// a multiple of 256 to avoid many small resizes.
|
||||
let new_height = (height + 255) & !255;
|
||||
let new_size = DeviceUintSize::new(MAX_VERTEX_TEXTURE_WIDTH as _, new_height);
|
||||
let new_size = DeviceIntSize::new(MAX_VERTEX_TEXTURE_WIDTH as _, new_height);
|
||||
let rt_info = if self.bus.uses_render_target() {
|
||||
Some(RenderTargetInfo { has_depth: false })
|
||||
} else {
|
||||
@ -1186,7 +1186,7 @@ impl GpuCacheTexture {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_height(&self) -> u32 {
|
||||
fn get_height(&self) -> i32 {
|
||||
self.texture.as_ref().map_or(0, |t| t.get_dimensions().height)
|
||||
}
|
||||
|
||||
@ -1194,7 +1194,7 @@ impl GpuCacheTexture {
|
||||
&mut self,
|
||||
device: &mut Device,
|
||||
total_block_count: usize,
|
||||
max_height: u32,
|
||||
max_height: i32,
|
||||
) {
|
||||
let allocated_new_texture = self.ensure_texture(device, max_height);
|
||||
match self.bus {
|
||||
@ -1320,9 +1320,9 @@ impl GpuCacheTexture {
|
||||
let block_index = row_index * MAX_VERTEX_TEXTURE_WIDTH;
|
||||
let cpu_blocks =
|
||||
&cpu_blocks[block_index .. (block_index + MAX_VERTEX_TEXTURE_WIDTH)];
|
||||
let rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(0, row_index as u32),
|
||||
DeviceUintSize::new(MAX_VERTEX_TEXTURE_WIDTH as u32, 1),
|
||||
let rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(0, row_index as i32),
|
||||
DeviceIntSize::new(MAX_VERTEX_TEXTURE_WIDTH as i32, 1),
|
||||
);
|
||||
|
||||
uploader.upload(rect, 0, None, cpu_blocks);
|
||||
@ -1399,8 +1399,8 @@ impl VertexDataTexture {
|
||||
}
|
||||
|
||||
let width =
|
||||
(MAX_VERTEX_TEXTURE_WIDTH - (MAX_VERTEX_TEXTURE_WIDTH % texels_per_item)) as u32;
|
||||
let needed_height = (data.len() / items_per_row) as u32;
|
||||
(MAX_VERTEX_TEXTURE_WIDTH - (MAX_VERTEX_TEXTURE_WIDTH % texels_per_item)) as i32;
|
||||
let needed_height = (data.len() / items_per_row) as i32;
|
||||
let existing_height = self.texture.as_ref().map_or(0, |t| t.get_dimensions().height);
|
||||
|
||||
// Create a new texture if needed.
|
||||
@ -1423,9 +1423,9 @@ impl VertexDataTexture {
|
||||
self.texture = Some(texture);
|
||||
}
|
||||
|
||||
let rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::zero(),
|
||||
DeviceUintSize::new(width, needed_height),
|
||||
let rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
DeviceIntSize::new(width, needed_height),
|
||||
);
|
||||
device
|
||||
.upload_texture(self.texture(), &self.pbo, 0)
|
||||
@ -1447,7 +1447,7 @@ struct FrameOutput {
|
||||
|
||||
#[derive(PartialEq)]
|
||||
struct TargetSelector {
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
num_layers: usize,
|
||||
format: ImageFormat,
|
||||
}
|
||||
@ -1671,7 +1671,7 @@ impl Renderer {
|
||||
device.supports_extension("GL_ARB_explicit_attrib_location");
|
||||
|
||||
// 512 is the minimum that the texture cache can work with.
|
||||
const MIN_TEXTURE_SIZE: u32 = 512;
|
||||
const MIN_TEXTURE_SIZE: i32 = 512;
|
||||
if let Some(user_limit) = options.max_texture_size {
|
||||
assert!(user_limit >= MIN_TEXTURE_SIZE);
|
||||
device.clamp_max_texture_size(user_limit);
|
||||
@ -2044,7 +2044,7 @@ impl Renderer {
|
||||
Ok((renderer, sender))
|
||||
}
|
||||
|
||||
pub fn get_max_texture_size(&self) -> u32 {
|
||||
pub fn get_max_texture_size(&self) -> i32 {
|
||||
self.device.max_texture_size()
|
||||
}
|
||||
|
||||
@ -2208,7 +2208,7 @@ impl Renderer {
|
||||
|
||||
let desc = ImageDescriptor::new(1024, 768, ImageFormat::BGRA8, true, false);
|
||||
let data = self.device.read_pixels(&desc);
|
||||
let screenshot = debug_server::Screenshot::new(desc.size.width, desc.size.height, data);
|
||||
let screenshot = debug_server::Screenshot::new(desc.size, data);
|
||||
|
||||
serde_json::to_string(&screenshot).unwrap()
|
||||
}
|
||||
@ -2493,7 +2493,7 @@ impl Renderer {
|
||||
/// [genframe]: ../../webrender_api/struct.DocumentApi.html#method.generate_frame
|
||||
pub fn render(
|
||||
&mut self,
|
||||
framebuffer_size: DeviceUintSize,
|
||||
framebuffer_size: DeviceIntSize,
|
||||
) -> Result<RendererStats, Vec<RendererError>> {
|
||||
let result = self.render_impl(Some(framebuffer_size));
|
||||
|
||||
@ -2517,7 +2517,7 @@ impl Renderer {
|
||||
// avoid doing a full frame render.
|
||||
fn render_impl(
|
||||
&mut self,
|
||||
framebuffer_size: Option<DeviceUintSize>,
|
||||
framebuffer_size: Option<DeviceIntSize>,
|
||||
) -> Result<RendererStats, Vec<RendererError>> {
|
||||
profile_scope!("render");
|
||||
if self.active_documents.is_empty() {
|
||||
@ -2581,7 +2581,7 @@ impl Renderer {
|
||||
.iter()
|
||||
.any(|&(_, RenderedDocument { ref frame, .. })| {
|
||||
frame.background_color.is_some() &&
|
||||
frame.inner_rect.origin == DeviceUintPoint::zero() &&
|
||||
frame.inner_rect.origin == DeviceIntPoint::zero() &&
|
||||
frame.inner_rect.size == framebuffer_size
|
||||
});
|
||||
|
||||
@ -3127,7 +3127,7 @@ impl Renderer {
|
||||
&mut self,
|
||||
draw_target: DrawTarget,
|
||||
target: &ColorRenderTarget,
|
||||
framebuffer_target_rect: DeviceUintRect,
|
||||
framebuffer_target_rect: DeviceIntRect,
|
||||
depth_is_ready: bool,
|
||||
clear_color: Option<[f32; 4]>,
|
||||
render_tasks: &RenderTaskTree,
|
||||
@ -3178,7 +3178,7 @@ impl Renderer {
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else if framebuffer_target_rect == DeviceUintRect::new(DeviceUintPoint::zero(), draw_target.dimensions()) {
|
||||
} else if framebuffer_target_rect == DeviceIntRect::new(DeviceIntPoint::zero(), draw_target.dimensions()) {
|
||||
// whole screen is covered, no need for scissor
|
||||
None
|
||||
} else {
|
||||
@ -3742,7 +3742,7 @@ impl Renderer {
|
||||
fn stencil_glyphs(&mut self,
|
||||
_: &[GlyphJob],
|
||||
_: &Transform3D<f32>,
|
||||
_: &DeviceUintSize,
|
||||
_: &DeviceIntSize,
|
||||
_: &mut RendererStats)
|
||||
-> Option<StenciledGlyphPage> {
|
||||
None
|
||||
@ -3872,9 +3872,9 @@ impl Renderer {
|
||||
bounding_rect = t.used_rect().union(&bounding_rect);
|
||||
}
|
||||
debug_assert_eq!(bounding_rect.origin, DeviceIntPoint::zero());
|
||||
let dimensions = DeviceUintSize::new(
|
||||
(bounding_rect.size.width as u32 + 255) & !255,
|
||||
(bounding_rect.size.height as u32 + 255) & !255,
|
||||
let dimensions = DeviceIntSize::new(
|
||||
(bounding_rect.size.width + 255) & !255,
|
||||
(bounding_rect.size.height + 255) & !255,
|
||||
);
|
||||
|
||||
counters.targets_used.inc();
|
||||
@ -3966,7 +3966,7 @@ impl Renderer {
|
||||
fn draw_tile_frame(
|
||||
&mut self,
|
||||
frame: &mut Frame,
|
||||
framebuffer_size: Option<DeviceUintSize>,
|
||||
framebuffer_size: Option<DeviceIntSize>,
|
||||
framebuffer_depth_is_ready: bool,
|
||||
frame_id: GpuFrameId,
|
||||
stats: &mut RendererStats,
|
||||
@ -4185,7 +4185,7 @@ impl Renderer {
|
||||
}
|
||||
|
||||
#[cfg(feature = "debug_renderer")]
|
||||
fn draw_render_target_debug(&mut self, framebuffer_size: DeviceUintSize) {
|
||||
fn draw_render_target_debug(&mut self, framebuffer_size: DeviceIntSize) {
|
||||
if !self.debug_flags.contains(DebugFlags::RENDER_TARGET_DBG) {
|
||||
return;
|
||||
}
|
||||
@ -4209,7 +4209,7 @@ impl Renderer {
|
||||
}
|
||||
|
||||
#[cfg(feature = "debug_renderer")]
|
||||
fn draw_texture_cache_debug(&mut self, framebuffer_size: DeviceUintSize) {
|
||||
fn draw_texture_cache_debug(&mut self, framebuffer_size: DeviceIntSize) {
|
||||
if !self.debug_flags.contains(DebugFlags::TEXTURE_CACHE_DBG) {
|
||||
return;
|
||||
}
|
||||
@ -4245,7 +4245,7 @@ impl Renderer {
|
||||
device: &mut Device,
|
||||
debug_renderer: &mut DebugRenderer,
|
||||
mut textures: Vec<&Texture>,
|
||||
framebuffer_size: DeviceUintSize,
|
||||
framebuffer_size: DeviceIntSize,
|
||||
bottom: i32,
|
||||
select_color: &Fn(&Texture) -> [f32; 4],
|
||||
) {
|
||||
@ -4361,7 +4361,7 @@ impl Renderer {
|
||||
}
|
||||
|
||||
#[cfg(feature = "debug_renderer")]
|
||||
fn draw_gpu_cache_debug(&mut self, framebuffer_size: DeviceUintSize) {
|
||||
fn draw_gpu_cache_debug(&mut self, framebuffer_size: DeviceIntSize) {
|
||||
if !self.debug_flags.contains(DebugFlags::GPU_CACHE_DBG) {
|
||||
return;
|
||||
}
|
||||
@ -4399,24 +4399,24 @@ impl Renderer {
|
||||
}
|
||||
|
||||
/// Pass-through to `Device::read_pixels_into`, used by Gecko's WR bindings.
|
||||
pub fn read_pixels_into(&mut self, rect: DeviceUintRect, format: ReadPixelsFormat, output: &mut [u8]) {
|
||||
pub fn read_pixels_into(&mut self, rect: DeviceIntRect, format: ReadPixelsFormat, output: &mut [u8]) {
|
||||
self.device.read_pixels_into(rect, format, output);
|
||||
}
|
||||
|
||||
pub fn read_pixels_rgba8(&mut self, rect: DeviceUintRect) -> Vec<u8> {
|
||||
pub fn read_pixels_rgba8(&mut self, rect: DeviceIntRect) -> Vec<u8> {
|
||||
let mut pixels = vec![0; (rect.size.width * rect.size.height * 4) as usize];
|
||||
self.device.read_pixels_into(rect, ReadPixelsFormat::Rgba8, &mut pixels);
|
||||
pixels
|
||||
}
|
||||
|
||||
pub fn read_gpu_cache(&mut self) -> (DeviceUintSize, Vec<u8>) {
|
||||
pub fn read_gpu_cache(&mut self) -> (DeviceIntSize, Vec<u8>) {
|
||||
let texture = self.gpu_cache_texture.texture.as_ref().unwrap();
|
||||
let size = texture.get_dimensions();
|
||||
let mut texels = vec![0; (size.width * size.height * 16) as usize];
|
||||
self.device.begin_frame();
|
||||
self.device.bind_read_target(ReadTarget::Texture { texture, layer: 0 });
|
||||
self.device.read_pixels_into(
|
||||
DeviceUintRect::new(DeviceUintPoint::zero(), size),
|
||||
DeviceIntRect::new(DeviceIntPoint::zero(), size),
|
||||
ReadPixelsFormat::Standard(ImageFormat::RGBAF32),
|
||||
&mut texels,
|
||||
);
|
||||
@ -4678,7 +4678,7 @@ pub struct RendererOptions {
|
||||
pub enable_subpixel_aa: bool,
|
||||
pub clear_color: Option<ColorF>,
|
||||
pub enable_clear_scissor: bool,
|
||||
pub max_texture_size: Option<u32>,
|
||||
pub max_texture_size: Option<i32>,
|
||||
pub scatter_gpu_cache_updates: bool,
|
||||
pub upload_method: UploadMethod,
|
||||
pub workers: Option<Arc<ThreadPool>>,
|
||||
@ -4780,7 +4780,7 @@ impl RendererStats {
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
struct PlainTexture {
|
||||
data: String,
|
||||
size: (u32, u32, i32),
|
||||
size: (DeviceIntSize, i32),
|
||||
format: ImageFormat,
|
||||
filter: TextureFilter,
|
||||
}
|
||||
@ -4850,8 +4850,8 @@ impl Renderer {
|
||||
|
||||
let bytes_per_pixel = texture.get_format().bytes_per_pixel();
|
||||
let read_format = ReadPixelsFormat::Standard(texture.get_format());
|
||||
let rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::zero(),
|
||||
let rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
texture.get_dimensions(),
|
||||
);
|
||||
|
||||
@ -4878,7 +4878,7 @@ impl Renderer {
|
||||
};
|
||||
CaptureConfig::save_png(
|
||||
root.join(format!("textures/{}-{}.png", name, layer_id)),
|
||||
(rect.size.width, rect.size.height), format,
|
||||
rect.size, format,
|
||||
data_ref,
|
||||
);
|
||||
}
|
||||
@ -4889,7 +4889,7 @@ impl Renderer {
|
||||
|
||||
PlainTexture {
|
||||
data: short_path,
|
||||
size: (rect.size.width, rect.size.height, texture.get_layer_count()),
|
||||
size: (rect.size, texture.get_layer_count()),
|
||||
format: texture.get_format(),
|
||||
filter: texture.get_filter(),
|
||||
}
|
||||
@ -4916,11 +4916,11 @@ impl Renderer {
|
||||
let texture = device.create_texture(
|
||||
target,
|
||||
plain.format,
|
||||
plain.size.0,
|
||||
plain.size.1,
|
||||
plain.size.0.width,
|
||||
plain.size.0.height,
|
||||
plain.filter,
|
||||
rt_info,
|
||||
plain.size.2,
|
||||
plain.size.1,
|
||||
);
|
||||
device.upload_texture_immediate(&texture, &texels);
|
||||
|
||||
@ -5146,7 +5146,7 @@ impl Renderer {
|
||||
let (layer_count, filter) = (1, TextureFilter::Linear);
|
||||
let plain_tex = PlainTexture {
|
||||
data: e.key().clone(),
|
||||
size: (descriptor.size.width, descriptor.size.height, layer_count),
|
||||
size: (descriptor.size, layer_count),
|
||||
format: descriptor.format,
|
||||
filter,
|
||||
};
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
use api::{AddFont, BlobImageResources, AsyncBlobImageRasterizer, ResourceUpdate};
|
||||
use api::{BlobImageDescriptor, BlobImageHandler, BlobImageRequest, RasterizedBlobImage};
|
||||
use api::{ClearCache, ColorF, DevicePoint, DeviceUintPoint, DeviceUintRect, DeviceUintSize};
|
||||
use api::{ClearCache, ColorF, DevicePoint, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use api::{FontInstanceKey, FontKey, FontTemplate, GlyphIndex};
|
||||
use api::{ExternalImageData, ExternalImageType, BlobImageResult, BlobImageParams};
|
||||
use api::{FontInstanceData, FontInstanceOptions, FontInstancePlatformOptions, FontVariation};
|
||||
@ -69,7 +69,7 @@ pub struct GlyphFetchResult {
|
||||
pub struct CacheItem {
|
||||
pub texture_id: TextureSource,
|
||||
pub uv_rect_handle: GpuCacheHandle,
|
||||
pub uv_rect: DeviceUintRect,
|
||||
pub uv_rect: DeviceIntRect,
|
||||
pub texture_layer: i32,
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ impl CacheItem {
|
||||
CacheItem {
|
||||
texture_id: TextureSource::Invalid,
|
||||
uv_rect_handle: GpuCacheHandle::new(),
|
||||
uv_rect: DeviceUintRect::zero(),
|
||||
uv_rect: DeviceIntRect::zero(),
|
||||
texture_layer: 0,
|
||||
}
|
||||
}
|
||||
@ -111,7 +111,7 @@ enum RasterizedBlob {
|
||||
struct BlobImageTemplate {
|
||||
descriptor: ImageDescriptor,
|
||||
tiling: Option<TileSize>,
|
||||
dirty_rect: Option<DeviceUintRect>,
|
||||
dirty_rect: Option<DeviceIntRect>,
|
||||
viewport_tiles: Option<TileRange>,
|
||||
}
|
||||
|
||||
@ -124,7 +124,7 @@ struct ImageResource {
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ImageTiling {
|
||||
pub image_size: DeviceUintSize,
|
||||
pub image_size: DeviceIntSize,
|
||||
pub tile_size: TileSize,
|
||||
}
|
||||
|
||||
@ -155,7 +155,7 @@ impl ImageTemplates {
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
struct CachedImageInfo {
|
||||
texture_cache_handle: TextureCacheHandle,
|
||||
dirty_rect: Option<DeviceUintRect>,
|
||||
dirty_rect: Option<DeviceIntRect>,
|
||||
manual_eviction: bool,
|
||||
}
|
||||
|
||||
@ -174,31 +174,31 @@ pub struct ResourceClassCache<K: Hash + Eq, V, U: Default> {
|
||||
}
|
||||
|
||||
pub fn intersect_for_tile(
|
||||
dirty: DeviceUintRect,
|
||||
clipped_tile_size: DeviceUintSize,
|
||||
dirty: DeviceIntRect,
|
||||
clipped_tile_size: DeviceIntSize,
|
||||
tile_size: TileSize,
|
||||
tile_offset: TileOffset,
|
||||
|
||||
) -> Option<DeviceUintRect> {
|
||||
dirty.intersection(&DeviceUintRect::new(
|
||||
DeviceUintPoint::new(
|
||||
tile_offset.x as u32 * tile_size as u32,
|
||||
tile_offset.y as u32 * tile_size as u32
|
||||
) -> Option<DeviceIntRect> {
|
||||
dirty.intersection(&DeviceIntRect::new(
|
||||
DeviceIntPoint::new(
|
||||
tile_offset.x as i32 * tile_size as i32,
|
||||
tile_offset.y as i32 * tile_size as i32
|
||||
),
|
||||
clipped_tile_size,
|
||||
)).map(|mut r| {
|
||||
// we can't translate by a negative size so do it manually
|
||||
r.origin.x -= tile_offset.x as u32 * tile_size as u32;
|
||||
r.origin.y -= tile_offset.y as u32 * tile_size as u32;
|
||||
r.origin.x -= tile_offset.x as i32 * tile_size as i32;
|
||||
r.origin.y -= tile_offset.y as i32 * tile_size as i32;
|
||||
r
|
||||
})
|
||||
}
|
||||
|
||||
fn merge_dirty_rect(
|
||||
prev_dirty_rect: &Option<DeviceUintRect>,
|
||||
dirty_rect: &Option<DeviceUintRect>,
|
||||
prev_dirty_rect: &Option<DeviceIntRect>,
|
||||
dirty_rect: &Option<DeviceIntRect>,
|
||||
descriptor: &ImageDescriptor,
|
||||
) -> Option<DeviceUintRect> {
|
||||
) -> Option<DeviceIntRect> {
|
||||
// It is important to never assume an empty dirty rect implies a full reupload here,
|
||||
// although we are able to do so elsewhere. We store the descriptor's full rect instead
|
||||
// There are update sequences which could cause us to forget the correct dirty regions
|
||||
@ -455,11 +455,11 @@ impl ResourceCache {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn max_texture_size(&self) -> u32 {
|
||||
pub fn max_texture_size(&self) -> i32 {
|
||||
self.texture_cache.max_texture_size()
|
||||
}
|
||||
|
||||
fn should_tile(limit: u32, descriptor: &ImageDescriptor, data: &ImageData) -> bool {
|
||||
fn should_tile(limit: i32, descriptor: &ImageDescriptor, data: &ImageData) -> bool {
|
||||
let size_check = descriptor.size.width > limit || descriptor.size.height > limit;
|
||||
match *data {
|
||||
ImageData::Raw(_) | ImageData::Blob(_) => size_check,
|
||||
@ -752,7 +752,7 @@ impl ResourceCache {
|
||||
image_key: ImageKey,
|
||||
descriptor: ImageDescriptor,
|
||||
data: ImageData,
|
||||
dirty_rect: Option<DeviceUintRect>,
|
||||
dirty_rect: Option<DeviceIntRect>,
|
||||
) {
|
||||
let max_texture_size = self.max_texture_size();
|
||||
let image = match self.resources.image_templates.get_mut(image_key) {
|
||||
@ -780,8 +780,8 @@ impl ResourceCache {
|
||||
let tile_size = image.tiling.unwrap();
|
||||
let clipped_tile_size = compute_tile_size(&descriptor, tile_size, tile);
|
||||
|
||||
rect.intersection(&DeviceUintRect::new(
|
||||
DeviceUintPoint::new(tile.x as u32, tile.y as u32) * tile_size as u32,
|
||||
rect.intersection(&DeviceIntRect::new(
|
||||
DeviceIntPoint::new(tile.x as i32, tile.y as i32) * tile_size as i32,
|
||||
clipped_tile_size,
|
||||
))
|
||||
}
|
||||
@ -819,8 +819,8 @@ impl ResourceCache {
|
||||
descriptor: *descriptor,
|
||||
tiling,
|
||||
dirty_rect: Some(
|
||||
DeviceUintRect::new(
|
||||
DeviceUintPoint::zero(),
|
||||
DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
descriptor.size,
|
||||
)
|
||||
),
|
||||
@ -834,7 +834,7 @@ impl ResourceCache {
|
||||
&mut self,
|
||||
key: ImageKey,
|
||||
descriptor: &ImageDescriptor,
|
||||
dirty_rect: &Option<DeviceUintRect>,
|
||||
dirty_rect: &Option<DeviceIntRect>,
|
||||
data: Arc<BlobImageData>,
|
||||
) {
|
||||
self.blob_image_handler.as_mut().unwrap().update(key, data, *dirty_rect);
|
||||
@ -904,7 +904,7 @@ impl ResourceCache {
|
||||
|
||||
let side_size =
|
||||
template.tiling.map_or(cmp::max(template.descriptor.size.width, template.descriptor.size.height),
|
||||
|tile_size| tile_size as u32);
|
||||
|tile_size| tile_size as i32);
|
||||
if side_size > self.texture_cache.max_texture_size() {
|
||||
// The image or tiling size is too big for hardware texture size.
|
||||
warn!("Dropping image, image:(w:{},h:{}, tile:{}) is too big for hardware!",
|
||||
@ -1049,7 +1049,7 @@ impl ResourceCache {
|
||||
let mut tiles = template.viewport_tiles.unwrap_or_else(|| {
|
||||
// Default to requesting the full range of tiles.
|
||||
compute_tile_range(
|
||||
&DeviceUintRect {
|
||||
&DeviceIntRect {
|
||||
origin: point2(0, 0),
|
||||
size: template.descriptor.size,
|
||||
},
|
||||
@ -1059,7 +1059,7 @@ impl ResourceCache {
|
||||
|
||||
// Don't request tiles that weren't invalidated.
|
||||
if let Some(dirty_rect) = template.dirty_rect {
|
||||
let dirty_rect = DeviceUintRect {
|
||||
let dirty_rect = DeviceIntRect {
|
||||
origin: point2(
|
||||
dirty_rect.origin.x,
|
||||
dirty_rect.origin.y,
|
||||
@ -1080,8 +1080,8 @@ impl ResourceCache {
|
||||
// This code tries to keep things sane if Gecko sends
|
||||
// nonsensical blob image requests.
|
||||
// Constant here definitely needs to be tweaked.
|
||||
const MAX_TILES_PER_REQUEST: u32 = 64;
|
||||
while tiles.size.width as u32 * tiles.size.height as u32 > MAX_TILES_PER_REQUEST {
|
||||
const MAX_TILES_PER_REQUEST: i32 = 64;
|
||||
while tiles.size.width as i32 * tiles.size.height as i32 > MAX_TILES_PER_REQUEST {
|
||||
// Remove tiles in the largest dimension.
|
||||
if tiles.size.width > tiles.size.height {
|
||||
tiles.size.width -= 2;
|
||||
@ -1179,7 +1179,7 @@ impl ResourceCache {
|
||||
fn discard_tiles_outside_visible_area(
|
||||
&mut self,
|
||||
key: ImageKey,
|
||||
area: &DeviceUintRect
|
||||
area: &DeviceIntRect
|
||||
) {
|
||||
let template = match self.blob_image_templates.get(&key) {
|
||||
Some(template) => template,
|
||||
@ -1483,7 +1483,7 @@ impl ResourceCache {
|
||||
let image_template = self.resources.image_templates.get_mut(request.key).unwrap();
|
||||
debug_assert!(image_template.data.uses_texture_cache());
|
||||
|
||||
let mut updates: SmallVec<[(ImageData, Option<DeviceUintRect>); 1]> = SmallVec::new();
|
||||
let mut updates: SmallVec<[(ImageData, Option<DeviceIntRect>); 1]> = SmallVec::new();
|
||||
|
||||
match image_template.data {
|
||||
ImageData::Raw(..) | ImageData::External(..) => {
|
||||
@ -1552,8 +1552,8 @@ impl ResourceCache {
|
||||
let stride = descriptor.compute_stride();
|
||||
descriptor.stride = Some(stride);
|
||||
descriptor.offset +=
|
||||
tile.y as u32 * tile_size as u32 * stride +
|
||||
tile.x as u32 * tile_size as u32 * bpp;
|
||||
tile.y as i32 * tile_size as i32 * stride +
|
||||
tile.x as i32 * tile_size as i32 * bpp;
|
||||
}
|
||||
|
||||
descriptor.size = clipped_tile_size;
|
||||
@ -1732,7 +1732,7 @@ impl Drop for ResourceCache {
|
||||
pub fn get_blob_tiling(
|
||||
tiling: Option<TileSize>,
|
||||
descriptor: &ImageDescriptor,
|
||||
max_texture_size: u32,
|
||||
max_texture_size: i32,
|
||||
) -> Option<TileSize> {
|
||||
if tiling.is_none() &&
|
||||
(descriptor.size.width > max_texture_size ||
|
||||
@ -1749,18 +1749,18 @@ pub fn compute_tile_size(
|
||||
descriptor: &ImageDescriptor,
|
||||
base_size: TileSize,
|
||||
tile: TileOffset,
|
||||
) -> DeviceUintSize {
|
||||
let base_size = base_size as u32;
|
||||
) -> DeviceIntSize {
|
||||
let base_size = base_size as i32;
|
||||
// Most tiles are going to have base_size as width and height,
|
||||
// except for tiles around the edges that are shrunk to fit the mage data
|
||||
// (See decompose_tiled_image in frame.rs).
|
||||
let actual_width = if (tile.x as u32) < descriptor.size.width / base_size {
|
||||
let actual_width = if (tile.x as i32) < descriptor.size.width / base_size {
|
||||
base_size
|
||||
} else {
|
||||
descriptor.size.width % base_size
|
||||
};
|
||||
|
||||
let actual_height = if (tile.y as u32) < descriptor.size.height / base_size {
|
||||
let actual_height = if (tile.y as i32) < descriptor.size.height / base_size {
|
||||
base_size
|
||||
} else {
|
||||
descriptor.size.height % base_size
|
||||
@ -1891,7 +1891,7 @@ impl ResourceCache {
|
||||
#[cfg(feature = "png")]
|
||||
CaptureConfig::save_png(
|
||||
root.join(format!("images/{}.png", image_id)),
|
||||
(desc.size.width, desc.size.height),
|
||||
desc.size,
|
||||
ReadPixelsFormat::Standard(desc.format),
|
||||
&arc,
|
||||
);
|
||||
@ -1935,7 +1935,7 @@ impl ResourceCache {
|
||||
#[cfg(feature = "png")]
|
||||
CaptureConfig::save_png(
|
||||
root.join(format!("blobs/{}.png", num_blobs)),
|
||||
(desc.size.width, desc.size.height),
|
||||
desc.size,
|
||||
ReadPixelsFormat::Standard(desc.format),
|
||||
&result.data,
|
||||
);
|
||||
|
@ -2,17 +2,17 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{DeviceUintPoint, DeviceUintRect, DeviceUintSize};
|
||||
use api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use std::slice::Iter;
|
||||
use util;
|
||||
|
||||
/// The minimum number of pixels on each side that we require for rects to be classified as
|
||||
/// "medium" within the free list.
|
||||
const MINIMUM_MEDIUM_RECT_SIZE: u32 = 16;
|
||||
const MINIMUM_MEDIUM_RECT_SIZE: i32 = 16;
|
||||
|
||||
/// The minimum number of pixels on each side that we require for rects to be classified as
|
||||
/// "large" within the free list.
|
||||
const MINIMUM_LARGE_RECT_SIZE: u32 = 32;
|
||||
const MINIMUM_LARGE_RECT_SIZE: i32 = 32;
|
||||
|
||||
/// A texture allocator using the guillotine algorithm with the rectangle merge improvement. See
|
||||
/// sections 2.2 and 2.2.5 in "A Thousand Ways to Pack the Bin - A Practical Approach to Two-
|
||||
@ -25,14 +25,14 @@ const MINIMUM_LARGE_RECT_SIZE: u32 = 32;
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct GuillotineAllocator {
|
||||
texture_size: DeviceUintSize,
|
||||
texture_size: DeviceIntSize,
|
||||
free_list: FreeRectList,
|
||||
allocations: u32,
|
||||
dirty: bool,
|
||||
}
|
||||
|
||||
impl GuillotineAllocator {
|
||||
pub fn new(texture_size: DeviceUintSize) -> GuillotineAllocator {
|
||||
pub fn new(texture_size: DeviceIntSize) -> GuillotineAllocator {
|
||||
let mut page = GuillotineAllocator {
|
||||
texture_size,
|
||||
free_list: FreeRectList::new(),
|
||||
@ -46,7 +46,7 @@ impl GuillotineAllocator {
|
||||
fn find_index_of_best_rect_in_bin(
|
||||
&self,
|
||||
bin: FreeListBin,
|
||||
requested_dimensions: &DeviceUintSize,
|
||||
requested_dimensions: &DeviceIntSize,
|
||||
) -> Option<FreeListIndex> {
|
||||
let mut smallest_index_and_area = None;
|
||||
for (candidate_index, candidate_rect) in self.free_list.iter(bin).enumerate() {
|
||||
@ -66,7 +66,7 @@ impl GuillotineAllocator {
|
||||
/// in terms of area (Best-Area-Fit, BAF).
|
||||
fn find_index_of_best_rect(
|
||||
&self,
|
||||
requested_dimensions: &DeviceUintSize,
|
||||
requested_dimensions: &DeviceIntSize,
|
||||
) -> Option<FreeListIndex> {
|
||||
let bin = FreeListBin::for_size(requested_dimensions);
|
||||
for &target_bin in &[FreeListBin::Small, FreeListBin::Medium, FreeListBin::Large] {
|
||||
@ -81,9 +81,9 @@ impl GuillotineAllocator {
|
||||
None
|
||||
}
|
||||
|
||||
pub fn allocate(&mut self, requested_dimensions: &DeviceUintSize) -> Option<DeviceUintPoint> {
|
||||
pub fn allocate(&mut self, requested_dimensions: &DeviceIntSize) -> Option<DeviceIntPoint> {
|
||||
if requested_dimensions.width == 0 || requested_dimensions.height == 0 {
|
||||
return Some(DeviceUintPoint::new(0, 0));
|
||||
return Some(DeviceIntPoint::new(0, 0));
|
||||
}
|
||||
let index = match self.find_index_of_best_rect(requested_dimensions) {
|
||||
None => return None,
|
||||
@ -93,22 +93,22 @@ impl GuillotineAllocator {
|
||||
// Remove the rect from the free list and decide how to guillotine it. We choose the split
|
||||
// that results in the single largest area (Min Area Split Rule, MINAS).
|
||||
let chosen_rect = self.free_list.remove(index);
|
||||
let candidate_free_rect_to_right = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(
|
||||
let candidate_free_rect_to_right = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(
|
||||
chosen_rect.origin.x + requested_dimensions.width,
|
||||
chosen_rect.origin.y,
|
||||
),
|
||||
DeviceUintSize::new(
|
||||
DeviceIntSize::new(
|
||||
chosen_rect.size.width - requested_dimensions.width,
|
||||
requested_dimensions.height,
|
||||
),
|
||||
);
|
||||
let candidate_free_rect_to_bottom = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(
|
||||
let candidate_free_rect_to_bottom = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(
|
||||
chosen_rect.origin.x,
|
||||
chosen_rect.origin.y + requested_dimensions.height,
|
||||
),
|
||||
DeviceUintSize::new(
|
||||
DeviceIntSize::new(
|
||||
requested_dimensions.width,
|
||||
chosen_rect.size.height - requested_dimensions.height,
|
||||
),
|
||||
@ -122,9 +122,9 @@ impl GuillotineAllocator {
|
||||
let new_free_rect_to_right;
|
||||
let new_free_rect_to_bottom;
|
||||
if candidate_free_rect_to_right_area > candidate_free_rect_to_bottom_area {
|
||||
new_free_rect_to_right = DeviceUintRect::new(
|
||||
new_free_rect_to_right = DeviceIntRect::new(
|
||||
candidate_free_rect_to_right.origin,
|
||||
DeviceUintSize::new(
|
||||
DeviceIntSize::new(
|
||||
candidate_free_rect_to_right.size.width,
|
||||
chosen_rect.size.height,
|
||||
),
|
||||
@ -132,9 +132,9 @@ impl GuillotineAllocator {
|
||||
new_free_rect_to_bottom = candidate_free_rect_to_bottom
|
||||
} else {
|
||||
new_free_rect_to_right = candidate_free_rect_to_right;
|
||||
new_free_rect_to_bottom = DeviceUintRect::new(
|
||||
new_free_rect_to_bottom = DeviceIntRect::new(
|
||||
candidate_free_rect_to_bottom.origin,
|
||||
DeviceUintSize::new(
|
||||
DeviceIntSize::new(
|
||||
chosen_rect.size.width,
|
||||
candidate_free_rect_to_bottom.size.height,
|
||||
),
|
||||
@ -161,8 +161,8 @@ impl GuillotineAllocator {
|
||||
|
||||
fn clear(&mut self) {
|
||||
self.free_list = FreeRectList::new();
|
||||
self.free_list.push(&DeviceUintRect::new(
|
||||
DeviceUintPoint::zero(),
|
||||
self.free_list.push(&DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
self.texture_size,
|
||||
));
|
||||
self.allocations = 0;
|
||||
@ -175,9 +175,9 @@ impl GuillotineAllocator {
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
struct FreeRectList {
|
||||
small: Vec<DeviceUintRect>,
|
||||
medium: Vec<DeviceUintRect>,
|
||||
large: Vec<DeviceUintRect>,
|
||||
small: Vec<DeviceIntRect>,
|
||||
medium: Vec<DeviceIntRect>,
|
||||
large: Vec<DeviceIntRect>,
|
||||
}
|
||||
|
||||
impl FreeRectList {
|
||||
@ -189,7 +189,7 @@ impl FreeRectList {
|
||||
}
|
||||
}
|
||||
|
||||
fn push(&mut self, rect: &DeviceUintRect) {
|
||||
fn push(&mut self, rect: &DeviceIntRect) {
|
||||
match FreeListBin::for_size(&rect.size) {
|
||||
FreeListBin::Small => self.small.push(*rect),
|
||||
FreeListBin::Medium => self.medium.push(*rect),
|
||||
@ -197,7 +197,7 @@ impl FreeRectList {
|
||||
}
|
||||
}
|
||||
|
||||
fn remove(&mut self, index: FreeListIndex) -> DeviceUintRect {
|
||||
fn remove(&mut self, index: FreeListIndex) -> DeviceIntRect {
|
||||
match index.0 {
|
||||
FreeListBin::Small => self.small.swap_remove(index.1),
|
||||
FreeListBin::Medium => self.medium.swap_remove(index.1),
|
||||
@ -205,7 +205,7 @@ impl FreeRectList {
|
||||
}
|
||||
}
|
||||
|
||||
fn iter(&self, bin: FreeListBin) -> Iter<DeviceUintRect> {
|
||||
fn iter(&self, bin: FreeListBin) -> Iter<DeviceIntRect> {
|
||||
match bin {
|
||||
FreeListBin::Small => self.small.iter(),
|
||||
FreeListBin::Medium => self.medium.iter(),
|
||||
@ -225,7 +225,7 @@ enum FreeListBin {
|
||||
}
|
||||
|
||||
impl FreeListBin {
|
||||
fn for_size(size: &DeviceUintSize) -> FreeListBin {
|
||||
fn for_size(size: &DeviceIntSize) -> FreeListBin {
|
||||
if size.width >= MINIMUM_LARGE_RECT_SIZE && size.height >= MINIMUM_LARGE_RECT_SIZE {
|
||||
FreeListBin::Large
|
||||
} else if size.width >= MINIMUM_MEDIUM_RECT_SIZE && size.height >= MINIMUM_MEDIUM_RECT_SIZE
|
||||
@ -242,8 +242,8 @@ trait FitsInside {
|
||||
fn fits_inside(&self, other: &Self) -> bool;
|
||||
}
|
||||
|
||||
impl FitsInside for DeviceUintSize {
|
||||
fn fits_inside(&self, other: &DeviceUintSize) -> bool {
|
||||
impl FitsInside for DeviceIntSize {
|
||||
fn fits_inside(&self, other: &DeviceIntSize) -> bool {
|
||||
self.width <= other.width && self.height <= other.height
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{DeviceUintPoint, DeviceUintRect, DeviceUintSize};
|
||||
use api::{DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use api::{ExternalImageType, ImageData, ImageFormat};
|
||||
use api::ImageDescriptor;
|
||||
use device::{TextureFilter, total_gpu_bytes_allocated};
|
||||
@ -20,7 +20,7 @@ use std::mem;
|
||||
use std::rc::Rc;
|
||||
|
||||
/// The size of each region/layer in shared cache texture arrays.
|
||||
const TEXTURE_REGION_DIMENSIONS: u32 = 512;
|
||||
const TEXTURE_REGION_DIMENSIONS: i32 = 512;
|
||||
|
||||
/// Items in the texture cache can either be standalone textures,
|
||||
/// or a sub-rect inside the shared cache.
|
||||
@ -31,7 +31,7 @@ enum EntryDetails {
|
||||
Standalone,
|
||||
Cache {
|
||||
// Origin within the texture layer where this item exists.
|
||||
origin: DeviceUintPoint,
|
||||
origin: DeviceIntPoint,
|
||||
// The layer index of the texture array.
|
||||
layer_index: usize,
|
||||
},
|
||||
@ -65,7 +65,7 @@ pub enum CacheEntryMarker {}
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
struct CacheEntry {
|
||||
/// Size the requested item, in device pixels.
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
/// Details specific to standalone or shared items.
|
||||
details: EntryDetails,
|
||||
/// Arbitrary user data associated with this item.
|
||||
@ -116,7 +116,7 @@ impl CacheEntry {
|
||||
fn update_gpu_cache(&mut self, gpu_cache: &mut GpuCache) {
|
||||
if let Some(mut request) = gpu_cache.request(&mut self.uv_rect_handle) {
|
||||
let (origin, layer_index) = match self.details {
|
||||
EntryDetails::Standalone { .. } => (DeviceUintPoint::zero(), 0.0),
|
||||
EntryDetails::Standalone { .. } => (DeviceIntPoint::zero(), 0.0),
|
||||
EntryDetails::Cache {
|
||||
origin,
|
||||
layer_index,
|
||||
@ -314,7 +314,7 @@ pub struct TextureCache {
|
||||
shared_textures: SharedTextures,
|
||||
|
||||
/// Maximum texture size supported by hardware.
|
||||
max_texture_size: u32,
|
||||
max_texture_size: i32,
|
||||
|
||||
/// Maximum number of texture layers supported by hardware.
|
||||
max_texture_layers: usize,
|
||||
@ -341,7 +341,7 @@ pub struct TextureCache {
|
||||
}
|
||||
|
||||
impl TextureCache {
|
||||
pub fn new(max_texture_size: u32, mut max_texture_layers: usize) -> Self {
|
||||
pub fn new(max_texture_size: i32, mut max_texture_layers: usize) -> Self {
|
||||
if cfg!(target_os = "macos") {
|
||||
// On MBP integrated Intel GPUs, texture arrays appear to be
|
||||
// implemented as a single texture of stacked layers, and that
|
||||
@ -367,6 +367,7 @@ impl TextureCache {
|
||||
// start to introduce performance issues.
|
||||
max_texture_layers = max_texture_layers.min(32);
|
||||
}
|
||||
|
||||
TextureCache {
|
||||
shared_textures: SharedTextures::new(),
|
||||
max_texture_size,
|
||||
@ -453,7 +454,7 @@ impl TextureCache {
|
||||
self.entries.get_opt(handle).is_none()
|
||||
}
|
||||
|
||||
pub fn max_texture_size(&self) -> u32 {
|
||||
pub fn max_texture_size(&self) -> i32 {
|
||||
self.max_texture_size
|
||||
}
|
||||
|
||||
@ -474,7 +475,7 @@ impl TextureCache {
|
||||
filter: TextureFilter,
|
||||
data: Option<ImageData>,
|
||||
user_data: [f32; 3],
|
||||
mut dirty_rect: Option<DeviceUintRect>,
|
||||
mut dirty_rect: Option<DeviceIntRect>,
|
||||
gpu_cache: &mut GpuCache,
|
||||
eviction_notice: Option<&EvictionNotice>,
|
||||
uv_rect_kind: UvRectKind,
|
||||
@ -525,7 +526,7 @@ impl TextureCache {
|
||||
// in GPU memory.
|
||||
if let Some(data) = data {
|
||||
let (layer_index, origin) = match entry.details {
|
||||
EntryDetails::Standalone { .. } => (0, DeviceUintPoint::zero()),
|
||||
EntryDetails::Standalone { .. } => (0, DeviceIntPoint::zero()),
|
||||
EntryDetails::Cache {
|
||||
layer_index,
|
||||
origin,
|
||||
@ -574,7 +575,7 @@ impl TextureCache {
|
||||
debug_assert_eq!(entry.last_access, self.frame_id);
|
||||
let (layer_index, origin) = match entry.details {
|
||||
EntryDetails::Standalone { .. } => {
|
||||
(0, DeviceUintPoint::zero())
|
||||
(0, DeviceIntPoint::zero())
|
||||
}
|
||||
EntryDetails::Cache {
|
||||
layer_index,
|
||||
@ -585,7 +586,7 @@ impl TextureCache {
|
||||
CacheItem {
|
||||
uv_rect_handle: entry.uv_rect_handle,
|
||||
texture_id: TextureSource::TextureCache(entry.texture_id),
|
||||
uv_rect: DeviceUintRect::new(origin, entry.size),
|
||||
uv_rect: DeviceIntRect::new(origin, entry.size),
|
||||
texture_layer: layer_index as i32,
|
||||
}
|
||||
}
|
||||
@ -597,14 +598,14 @@ impl TextureCache {
|
||||
pub fn get_cache_location(
|
||||
&self,
|
||||
handle: &TextureCacheHandle,
|
||||
) -> (CacheTextureId, LayerIndex, DeviceUintRect) {
|
||||
) -> (CacheTextureId, LayerIndex, DeviceIntRect) {
|
||||
let entry = self.entries
|
||||
.get_opt(handle)
|
||||
.expect("BUG: was dropped from cache or not updated!");
|
||||
debug_assert_eq!(entry.last_access, self.frame_id);
|
||||
let (layer_index, origin) = match entry.details {
|
||||
EntryDetails::Standalone { .. } => {
|
||||
(0, DeviceUintPoint::zero())
|
||||
(0, DeviceIntPoint::zero())
|
||||
}
|
||||
EntryDetails::Cache {
|
||||
layer_index,
|
||||
@ -614,7 +615,7 @@ impl TextureCache {
|
||||
};
|
||||
(entry.texture_id,
|
||||
layer_index as usize,
|
||||
DeviceUintRect::new(origin, entry.size))
|
||||
DeviceIntRect::new(origin, entry.size))
|
||||
}
|
||||
|
||||
pub fn mark_unused(&mut self, handle: &TextureCacheHandle) {
|
||||
@ -920,12 +921,12 @@ impl TextureCache {
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
struct SlabSize {
|
||||
width: u32,
|
||||
height: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
}
|
||||
|
||||
impl SlabSize {
|
||||
fn new(size: DeviceUintSize) -> SlabSize {
|
||||
fn new(size: DeviceIntSize) -> SlabSize {
|
||||
let x_size = quantize_dimension(size.width);
|
||||
let y_size = quantize_dimension(size.height);
|
||||
|
||||
@ -968,8 +969,8 @@ impl SlabSize {
|
||||
struct TextureLocation(u8, u8);
|
||||
|
||||
impl TextureLocation {
|
||||
fn new(x: u32, y: u32) -> Self {
|
||||
debug_assert!(x < 0x100 && y < 0x100);
|
||||
fn new(x: i32, y: i32) -> Self {
|
||||
debug_assert!(x >= 0 && y >= 0 && x < 0x100 && y < 0x100);
|
||||
TextureLocation(x as u8, y as u8)
|
||||
}
|
||||
}
|
||||
@ -1028,19 +1029,19 @@ impl TextureRegion {
|
||||
}
|
||||
|
||||
// Attempt to allocate a fixed size block from this region.
|
||||
fn alloc(&mut self) -> Option<DeviceUintPoint> {
|
||||
fn alloc(&mut self) -> Option<DeviceIntPoint> {
|
||||
debug_assert!(self.slab_size != SlabSize::invalid());
|
||||
|
||||
self.free_slots.pop().map(|location| {
|
||||
DeviceUintPoint::new(
|
||||
self.slab_size.width * location.0 as u32,
|
||||
self.slab_size.height * location.1 as u32,
|
||||
DeviceIntPoint::new(
|
||||
self.slab_size.width * location.0 as i32,
|
||||
self.slab_size.height * location.1 as i32,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// Free a block in this region.
|
||||
fn free(&mut self, point: DeviceUintPoint) {
|
||||
fn free(&mut self, point: DeviceIntPoint) {
|
||||
let x = point.x / self.slab_size.width;
|
||||
let y = point.y / self.slab_size.height;
|
||||
self.free_slots.push(TextureLocation::new(x, y));
|
||||
@ -1088,7 +1089,7 @@ impl TextureArray {
|
||||
fn update_profile(&self, counter: &mut ResourceProfileCounter) {
|
||||
let layer_count = self.regions.len();
|
||||
if layer_count != 0 {
|
||||
let size = layer_count as u32 * TEXTURE_REGION_DIMENSIONS *
|
||||
let size = layer_count as i32 * TEXTURE_REGION_DIMENSIONS *
|
||||
TEXTURE_REGION_DIMENSIONS * self.format.bytes_per_pixel();
|
||||
counter.set(layer_count as usize, size as usize);
|
||||
} else {
|
||||
@ -1172,11 +1173,11 @@ impl TextureCacheUpdate {
|
||||
fn new_update(
|
||||
data: ImageData,
|
||||
descriptor: &ImageDescriptor,
|
||||
origin: DeviceUintPoint,
|
||||
size: DeviceUintSize,
|
||||
origin: DeviceIntPoint,
|
||||
size: DeviceIntSize,
|
||||
texture_id: CacheTextureId,
|
||||
layer_index: i32,
|
||||
dirty_rect: Option<DeviceUintRect>,
|
||||
dirty_rect: Option<DeviceIntRect>,
|
||||
) -> TextureCacheUpdate {
|
||||
let source = match data {
|
||||
ImageData::Blob(..) => {
|
||||
@ -1209,9 +1210,9 @@ impl TextureCacheUpdate {
|
||||
|
||||
TextureCacheUpdate {
|
||||
id: texture_id,
|
||||
rect: DeviceUintRect::new(
|
||||
DeviceUintPoint::new(origin.x + dirty.origin.x, origin.y + dirty.origin.y),
|
||||
DeviceUintSize::new(
|
||||
rect: DeviceIntRect::new(
|
||||
DeviceIntPoint::new(origin.x + dirty.origin.x, origin.y + dirty.origin.y),
|
||||
DeviceIntSize::new(
|
||||
dirty.size.width.min(size.width - dirty.origin.x),
|
||||
dirty.size.height.min(size.height - dirty.origin.y),
|
||||
),
|
||||
@ -1225,7 +1226,7 @@ impl TextureCacheUpdate {
|
||||
None => {
|
||||
TextureCacheUpdate {
|
||||
id: texture_id,
|
||||
rect: DeviceUintRect::new(origin, size),
|
||||
rect: DeviceIntRect::new(origin, size),
|
||||
source,
|
||||
stride: descriptor.stride,
|
||||
offset: descriptor.offset,
|
||||
@ -1238,7 +1239,7 @@ impl TextureCacheUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
fn quantize_dimension(size: u32) -> u32 {
|
||||
fn quantize_dimension(size: i32) -> i32 {
|
||||
match size {
|
||||
0 => unreachable!(),
|
||||
1...16 => 16,
|
||||
|
@ -3,7 +3,7 @@
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use api::{ColorF, BorderStyle, DeviceIntPoint, DeviceIntRect, DeviceIntSize, DevicePixelScale};
|
||||
use api::{DeviceUintPoint, DeviceUintRect, DeviceUintSize, DocumentLayer, FilterOp, ImageFormat};
|
||||
use api::{DocumentLayer, FilterOp, ImageFormat};
|
||||
use api::{MixBlendMode, PipelineId, DeviceRect, LayoutSize};
|
||||
use batch::{AlphaBatchBuilder, AlphaBatchContainer, ClipBatcher, resolve_image};
|
||||
use clip::ClipStore;
|
||||
@ -36,7 +36,7 @@ const STYLE_MASK: i32 = 0x00FF_FF00;
|
||||
/// optimizations on some intel drivers. We sometimes need to go larger, but
|
||||
/// we try to avoid it. This can go away when proper tiling support lands,
|
||||
/// since we can then split large primitives across multiple textures.
|
||||
const IDEAL_MAX_TEXTURE_DIMENSION: u32 = 2048;
|
||||
const IDEAL_MAX_TEXTURE_DIMENSION: i32 = 2048;
|
||||
|
||||
/// Identifies a given `RenderTarget` in a `RenderTargetList`.
|
||||
#[derive(Debug, Copy, Clone)]
|
||||
@ -70,20 +70,20 @@ struct TextureAllocator {
|
||||
}
|
||||
|
||||
impl TextureAllocator {
|
||||
fn new(size: DeviceUintSize) -> Self {
|
||||
fn new(size: DeviceIntSize) -> Self {
|
||||
TextureAllocator {
|
||||
allocator: GuillotineAllocator::new(size),
|
||||
used_rect: DeviceIntRect::zero(),
|
||||
}
|
||||
}
|
||||
|
||||
fn allocate(&mut self, size: &DeviceUintSize) -> Option<DeviceUintPoint> {
|
||||
fn allocate(&mut self, size: &DeviceIntSize) -> Option<DeviceIntPoint> {
|
||||
let origin = self.allocator.allocate(size);
|
||||
|
||||
if let Some(origin) = origin {
|
||||
// TODO(gw): We need to make all the device rects
|
||||
// be consistent in the use of the
|
||||
// DeviceIntRect and DeviceUintRect types!
|
||||
// DeviceIntRect and DeviceIntRect types!
|
||||
let origin = DeviceIntPoint::new(origin.x as i32, origin.y as i32);
|
||||
let size = DeviceIntSize::new(size.width as i32, size.height as i32);
|
||||
let rect = DeviceIntRect::new(origin, size);
|
||||
@ -110,7 +110,7 @@ impl TextureAllocator {
|
||||
pub trait RenderTarget {
|
||||
/// Creates a new RenderTarget of the given type.
|
||||
fn new(
|
||||
size: Option<DeviceUintSize>,
|
||||
size: Option<DeviceIntSize>,
|
||||
screen_size: DeviceIntSize,
|
||||
) -> Self;
|
||||
|
||||
@ -119,7 +119,7 @@ pub trait RenderTarget {
|
||||
///
|
||||
/// If a non-`None` result is returned, that value is generally stored in
|
||||
/// a task which is then added to this target via `add_task()`.
|
||||
fn allocate(&mut self, size: DeviceUintSize) -> Option<DeviceUintPoint>;
|
||||
fn allocate(&mut self, size: DeviceIntSize) -> Option<DeviceIntPoint>;
|
||||
|
||||
/// Optional hook to provide additional processing for the target at the
|
||||
/// end of the build phase.
|
||||
@ -204,7 +204,7 @@ pub struct RenderTargetList<T> {
|
||||
/// IDEAL_MAX_TEXTURE_DIMENSION. If we encounter a larger primitive, the
|
||||
/// allocation will fail, but we'll bump max_dynamic_size, which will cause the
|
||||
/// allocator for the next slice to be just large enough to accomodate it.
|
||||
pub max_dynamic_size: DeviceUintSize,
|
||||
pub max_dynamic_size: DeviceIntSize,
|
||||
pub targets: Vec<T>,
|
||||
pub saved_index: Option<SavedTargetIndex>,
|
||||
}
|
||||
@ -217,7 +217,7 @@ impl<T: RenderTarget> RenderTargetList<T> {
|
||||
RenderTargetList {
|
||||
screen_size,
|
||||
format,
|
||||
max_dynamic_size: DeviceUintSize::new(0, 0),
|
||||
max_dynamic_size: DeviceIntSize::new(0, 0),
|
||||
targets: Vec::new(),
|
||||
saved_index: None,
|
||||
}
|
||||
@ -273,8 +273,8 @@ impl<T: RenderTarget> RenderTargetList<T> {
|
||||
|
||||
fn allocate(
|
||||
&mut self,
|
||||
alloc_size: DeviceUintSize,
|
||||
) -> (DeviceUintPoint, RenderTargetIndex) {
|
||||
alloc_size: DeviceIntSize,
|
||||
) -> (DeviceIntPoint, RenderTargetIndex) {
|
||||
let existing_origin = self.targets
|
||||
.last_mut()
|
||||
.and_then(|target| target.allocate(alloc_size));
|
||||
@ -285,7 +285,7 @@ impl<T: RenderTarget> RenderTargetList<T> {
|
||||
// Have the allocator restrict slice sizes to our max ideal
|
||||
// dimensions, unless we've already gone bigger on a previous
|
||||
// slice.
|
||||
let allocator_dimensions = DeviceUintSize::new(
|
||||
let allocator_dimensions = DeviceIntSize::new(
|
||||
cmp::max(IDEAL_MAX_TEXTURE_DIMENSION, self.max_dynamic_size.width),
|
||||
cmp::max(IDEAL_MAX_TEXTURE_DIMENSION, self.max_dynamic_size.height),
|
||||
);
|
||||
@ -392,7 +392,7 @@ pub struct ColorRenderTarget {
|
||||
}
|
||||
|
||||
impl RenderTarget for ColorRenderTarget {
|
||||
fn allocate(&mut self, size: DeviceUintSize) -> Option<DeviceUintPoint> {
|
||||
fn allocate(&mut self, size: DeviceIntSize) -> Option<DeviceIntPoint> {
|
||||
self.allocator
|
||||
.as_mut()
|
||||
.expect("bug: calling allocate on framebuffer")
|
||||
@ -400,7 +400,7 @@ impl RenderTarget for ColorRenderTarget {
|
||||
}
|
||||
|
||||
fn new(
|
||||
size: Option<DeviceUintSize>,
|
||||
size: Option<DeviceIntSize>,
|
||||
screen_size: DeviceIntSize,
|
||||
) -> Self {
|
||||
ColorRenderTarget {
|
||||
@ -544,9 +544,6 @@ impl RenderTarget for ColorRenderTarget {
|
||||
|
||||
// Work out a source rect to copy from the texture, depending on whether
|
||||
// a sub-rect is present or not.
|
||||
// TODO(gw): We have much type confusion below - f32, i32 and u32 for
|
||||
// various representations of the texel rects. We should make
|
||||
// this consistent!
|
||||
let source_rect = key.texel_rect.map_or(cache_item.uv_rect.to_i32(), |sub_rect| {
|
||||
DeviceIntRect::new(
|
||||
DeviceIntPoint::new(
|
||||
@ -608,12 +605,12 @@ pub struct AlphaRenderTarget {
|
||||
}
|
||||
|
||||
impl RenderTarget for AlphaRenderTarget {
|
||||
fn allocate(&mut self, size: DeviceUintSize) -> Option<DeviceUintPoint> {
|
||||
fn allocate(&mut self, size: DeviceIntSize) -> Option<DeviceIntPoint> {
|
||||
self.allocator.allocate(&size)
|
||||
}
|
||||
|
||||
fn new(
|
||||
size: Option<DeviceUintSize>,
|
||||
size: Option<DeviceIntSize>,
|
||||
_: DeviceIntSize,
|
||||
) -> Self {
|
||||
AlphaRenderTarget {
|
||||
@ -908,8 +905,8 @@ impl RenderPass {
|
||||
RenderTargetKind::Color => &mut color.max_dynamic_size,
|
||||
RenderTargetKind::Alpha => &mut alpha.max_dynamic_size,
|
||||
};
|
||||
max_size.width = cmp::max(max_size.width, size.width as u32);
|
||||
max_size.height = cmp::max(max_size.height, size.height as u32);
|
||||
max_size.width = cmp::max(max_size.width, size.width);
|
||||
max_size.height = cmp::max(max_size.height, size.height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -992,12 +989,11 @@ impl RenderPass {
|
||||
None
|
||||
}
|
||||
RenderTaskLocation::Dynamic(ref mut origin, size) => {
|
||||
let alloc_size = DeviceUintSize::new(size.width as u32, size.height as u32);
|
||||
let (alloc_origin, target_index) = match target_kind {
|
||||
RenderTargetKind::Color => color.allocate(alloc_size),
|
||||
RenderTargetKind::Alpha => alpha.allocate(alloc_size),
|
||||
RenderTargetKind::Color => color.allocate(size),
|
||||
RenderTargetKind::Alpha => alpha.allocate(size),
|
||||
};
|
||||
*origin = Some((alloc_origin.to_i32(), target_index));
|
||||
*origin = Some((alloc_origin, target_index));
|
||||
None
|
||||
}
|
||||
};
|
||||
@ -1105,8 +1101,8 @@ impl CompositeOps {
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct Frame {
|
||||
//TODO: share the fields with DocumentView struct
|
||||
pub window_size: DeviceUintSize,
|
||||
pub inner_rect: DeviceUintRect,
|
||||
pub window_size: DeviceIntSize,
|
||||
pub inner_rect: DeviceIntRect,
|
||||
pub background_color: Option<ColorF>,
|
||||
pub layer: DocumentLayer,
|
||||
pub device_pixel_ratio: f32,
|
||||
|
@ -12,8 +12,8 @@ use std::marker::PhantomData;
|
||||
use std::os::raw::c_void;
|
||||
use std::path::PathBuf;
|
||||
use std::u32;
|
||||
use {BuiltDisplayList, BuiltDisplayListDescriptor, ColorF, DeviceIntPoint, DeviceUintRect};
|
||||
use {DeviceUintSize, ExternalScrollId, FontInstanceKey, FontInstanceOptions};
|
||||
use {BuiltDisplayList, BuiltDisplayListDescriptor, ColorF, DeviceIntPoint, DeviceIntRect};
|
||||
use {DeviceIntSize, ExternalScrollId, FontInstanceKey, FontInstanceOptions};
|
||||
use {FontInstancePlatformOptions, FontKey, FontVariation, GlyphDimensions, GlyphIndex, ImageData};
|
||||
use {ImageDescriptor, ImageKey, ItemTag, LayoutPoint, LayoutSize, LayoutTransform, LayoutVector2D};
|
||||
use {NativeFontHandle, WorldPoint};
|
||||
@ -27,7 +27,7 @@ pub enum ResourceUpdate {
|
||||
AddImage(AddImage),
|
||||
UpdateImage(UpdateImage),
|
||||
DeleteImage(ImageKey),
|
||||
SetImageVisibleArea(ImageKey, DeviceUintRect),
|
||||
SetImageVisibleArea(ImageKey, DeviceIntRect),
|
||||
AddFont(AddFont),
|
||||
DeleteFont(FontKey),
|
||||
AddFontInstance(AddFontInstance),
|
||||
@ -117,7 +117,7 @@ impl Transaction {
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
/// # use webrender_api::{DeviceUintSize, PipelineId, RenderApiSender, Transaction};
|
||||
/// # use webrender_api::{DeviceIntSize, PipelineId, RenderApiSender, Transaction};
|
||||
/// # fn example() {
|
||||
/// let pipeline_id = PipelineId(0, 0);
|
||||
/// let mut txn = Transaction::new();
|
||||
@ -197,8 +197,8 @@ impl Transaction {
|
||||
|
||||
pub fn set_window_parameters(
|
||||
&mut self,
|
||||
window_size: DeviceUintSize,
|
||||
inner_rect: DeviceUintRect,
|
||||
window_size: DeviceIntSize,
|
||||
inner_rect: DeviceIntRect,
|
||||
device_pixel_ratio: f32,
|
||||
) {
|
||||
self.scene_ops.push(
|
||||
@ -321,7 +321,7 @@ impl Transaction {
|
||||
key: ImageKey,
|
||||
descriptor: ImageDescriptor,
|
||||
data: ImageData,
|
||||
dirty_rect: Option<DeviceUintRect>,
|
||||
dirty_rect: Option<DeviceIntRect>,
|
||||
) {
|
||||
self.resource_updates.push(ResourceUpdate::UpdateImage(UpdateImage {
|
||||
key,
|
||||
@ -335,7 +335,7 @@ impl Transaction {
|
||||
self.resource_updates.push(ResourceUpdate::DeleteImage(key));
|
||||
}
|
||||
|
||||
pub fn set_image_visible_area(&mut self, key: ImageKey, area: DeviceUintRect) {
|
||||
pub fn set_image_visible_area(&mut self, key: ImageKey, area: DeviceIntRect) {
|
||||
self.resource_updates.push(ResourceUpdate::SetImageVisibleArea(key, area))
|
||||
}
|
||||
|
||||
@ -464,7 +464,7 @@ pub struct UpdateImage {
|
||||
pub key: ImageKey,
|
||||
pub descriptor: ImageDescriptor,
|
||||
pub data: ImageData,
|
||||
pub dirty_rect: Option<DeviceUintRect>,
|
||||
pub dirty_rect: Option<DeviceIntRect>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
@ -535,8 +535,8 @@ pub enum SceneMsg {
|
||||
preserve_frame_state: bool,
|
||||
},
|
||||
SetWindowParameters {
|
||||
window_size: DeviceUintSize,
|
||||
inner_rect: DeviceUintRect,
|
||||
window_size: DeviceIntSize,
|
||||
inner_rect: DeviceIntRect,
|
||||
device_pixel_ratio: f32,
|
||||
},
|
||||
}
|
||||
@ -615,7 +615,7 @@ bitflags!{
|
||||
pub struct CapturedDocument {
|
||||
pub document_id: DocumentId,
|
||||
pub root_pipeline_id: Option<PipelineId>,
|
||||
pub window_size: DeviceUintSize,
|
||||
pub window_size: DeviceIntSize,
|
||||
}
|
||||
|
||||
#[derive(Clone, Deserialize, Serialize)]
|
||||
@ -683,7 +683,7 @@ pub enum ApiMsg {
|
||||
/// Adds a new document namespace.
|
||||
CloneApiByClient(IdNamespace),
|
||||
/// Adds a new document with given initial size.
|
||||
AddDocument(DocumentId, DeviceUintSize, DocumentLayer),
|
||||
AddDocument(DocumentId, DeviceIntSize, DocumentLayer),
|
||||
/// A message targeted at a particular document.
|
||||
UpdateDocument(DocumentId, TransactionMsg),
|
||||
/// Deletes an existing document.
|
||||
@ -932,7 +932,7 @@ impl RenderApi {
|
||||
RenderApiSender::new(self.api_sender.clone(), self.payload_sender.clone())
|
||||
}
|
||||
|
||||
pub fn add_document(&self, initial_size: DeviceUintSize, layer: DocumentLayer) -> DocumentId {
|
||||
pub fn add_document(&self, initial_size: DeviceIntSize, layer: DocumentLayer) -> DocumentId {
|
||||
let new_id = self.next_unique_id();
|
||||
let document_id = DocumentId(self.namespace_id, new_id);
|
||||
|
||||
@ -1103,8 +1103,8 @@ impl RenderApi {
|
||||
pub fn set_window_parameters(
|
||||
&self,
|
||||
document_id: DocumentId,
|
||||
window_size: DeviceUintSize,
|
||||
inner_rect: DeviceUintRect,
|
||||
window_size: DeviceIntSize,
|
||||
inner_rect: DeviceIntRect,
|
||||
device_pixel_ratio: f32,
|
||||
) {
|
||||
self.send_scene_msg(
|
||||
|
@ -350,10 +350,10 @@ pub struct NinePatchBorder {
|
||||
pub source: NinePatchBorderSource,
|
||||
|
||||
/// The width of the 9-part image.
|
||||
pub width: u32,
|
||||
pub width: i32,
|
||||
|
||||
/// The height of the 9-part image.
|
||||
pub height: u32,
|
||||
pub height: i32,
|
||||
|
||||
/// Distances from each edge where the image should be sliced up. These
|
||||
/// values are in 9-part-image space (the same space as width and height),
|
||||
@ -362,7 +362,7 @@ pub struct NinePatchBorder {
|
||||
/// stretching.
|
||||
/// Slices can be overlapping. In that case, the same pixels from the
|
||||
/// 9-part image will show up in multiple parts of the resulting border.
|
||||
pub slice: SideOffsets2D<u32>,
|
||||
pub slice: SideOffsets2D<i32>,
|
||||
|
||||
/// Controls whether the center of the 9 patch image is rendered or
|
||||
/// ignored. The center is never rendered if the slices are overlapping.
|
||||
|
@ -65,8 +65,8 @@ impl<'de> Deserialize<'de> for NativeFontHandle {
|
||||
pub struct GlyphDimensions {
|
||||
pub left: i32,
|
||||
pub top: i32,
|
||||
pub width: u32,
|
||||
pub height: u32,
|
||||
pub width: i32,
|
||||
pub height: i32,
|
||||
pub advance: f32,
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@ extern crate serde_bytes;
|
||||
|
||||
use font::{FontInstanceKey, FontInstanceData, FontKey, FontTemplate};
|
||||
use std::sync::Arc;
|
||||
use {DevicePoint, DeviceUintPoint, DeviceUintRect, DeviceUintSize};
|
||||
use {DevicePoint, DeviceIntPoint, DeviceIntRect, DeviceIntSize};
|
||||
use {IdNamespace, TileOffset, TileSize};
|
||||
use euclid::size2;
|
||||
|
||||
@ -105,7 +105,7 @@ pub enum ImageFormat {
|
||||
|
||||
impl ImageFormat {
|
||||
/// Returns the number of bytes per pixel for the given format.
|
||||
pub fn bytes_per_pixel(self) -> u32 {
|
||||
pub fn bytes_per_pixel(self) -> i32 {
|
||||
match self {
|
||||
ImageFormat::R8 => 1,
|
||||
ImageFormat::R16 => 2,
|
||||
@ -159,18 +159,18 @@ pub struct ImageDescriptor {
|
||||
/// Format of the image data.
|
||||
pub format: ImageFormat,
|
||||
/// Width and length of the image data, in pixels.
|
||||
pub size: DeviceUintSize,
|
||||
pub size: DeviceIntSize,
|
||||
/// The number of bytes from the start of one row to the next. If non-None,
|
||||
/// `compute_stride` will return this value, otherwise it returns
|
||||
/// `width * bpp`. Different source of images have different alignment
|
||||
/// constraints for rows, so the stride isn't always equal to width * bpp.
|
||||
pub stride: Option<u32>,
|
||||
pub stride: Option<i32>,
|
||||
/// Offset in bytes of the first pixel of this image in its backing buffer.
|
||||
/// This is used for tiling, wherein WebRender extracts chunks of input images
|
||||
/// in order to cache, manipulate, and render them individually. This offset
|
||||
/// tells the texture upload machinery where to find the bytes to upload for
|
||||
/// this tile. Non-tiled images generally set this to zero.
|
||||
pub offset: u32,
|
||||
pub offset: i32,
|
||||
/// Whether this image is opaque, or has an alpha channel. Avoiding blending
|
||||
/// for opaque surfaces is an important optimization.
|
||||
pub is_opaque: bool,
|
||||
@ -185,8 +185,8 @@ pub struct ImageDescriptor {
|
||||
impl ImageDescriptor {
|
||||
/// Mints a new ImageDescriptor.
|
||||
pub fn new(
|
||||
width: u32,
|
||||
height: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
format: ImageFormat,
|
||||
is_opaque: bool,
|
||||
allow_mipmaps: bool,
|
||||
@ -203,19 +203,19 @@ impl ImageDescriptor {
|
||||
|
||||
/// Returns the stride, either via an explicit stride stashed on the object
|
||||
/// or by the default computation.
|
||||
pub fn compute_stride(&self) -> u32 {
|
||||
pub fn compute_stride(&self) -> i32 {
|
||||
self.stride.unwrap_or(self.size.width * self.format.bytes_per_pixel())
|
||||
}
|
||||
|
||||
/// Computes the total size of the image, in bytes.
|
||||
pub fn compute_total_size(&self) -> u32 {
|
||||
pub fn compute_total_size(&self) -> i32 {
|
||||
self.compute_stride() * self.size.height
|
||||
}
|
||||
|
||||
/// Computes the bounding rectangle for the image, rooted at (0, 0).
|
||||
pub fn full_rect(&self) -> DeviceUintRect {
|
||||
DeviceUintRect::new(
|
||||
DeviceUintPoint::zero(),
|
||||
pub fn full_rect(&self) -> DeviceIntRect {
|
||||
DeviceIntRect::new(
|
||||
DeviceIntPoint::zero(),
|
||||
self.size,
|
||||
)
|
||||
}
|
||||
@ -322,7 +322,7 @@ pub trait BlobImageHandler: Send {
|
||||
fn add(&mut self, key: ImageKey, data: Arc<BlobImageData>, tiling: Option<TileSize>);
|
||||
|
||||
/// Update an already registered blob image.
|
||||
fn update(&mut self, key: ImageKey, data: Arc<BlobImageData>, dirty_rect: Option<DeviceUintRect>);
|
||||
fn update(&mut self, key: ImageKey, data: Arc<BlobImageData>, dirty_rect: Option<DeviceIntRect>);
|
||||
|
||||
/// Delete an already registered blob image.
|
||||
fn delete(&mut self, key: ImageKey);
|
||||
@ -365,7 +365,7 @@ pub struct BlobImageParams {
|
||||
/// the entire image when only a portion is updated.
|
||||
///
|
||||
/// If set to None the entire image is rasterized.
|
||||
pub dirty_rect: Option<DeviceUintRect>,
|
||||
pub dirty_rect: Option<DeviceIntRect>,
|
||||
}
|
||||
|
||||
/// Backing store for blob image command streams.
|
||||
@ -379,7 +379,7 @@ pub type BlobImageResult = Result<RasterizedBlobImage, BlobImageError>;
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct BlobImageDescriptor {
|
||||
/// Size in device pixels of the blob's output image.
|
||||
pub size: DeviceUintSize,
|
||||
pub size: DeviceIntSize,
|
||||
/// When tiling, offset point in device pixels of this tile in the full
|
||||
/// image. Generally (0, 0) outside of tiling.
|
||||
pub offset: DevicePoint,
|
||||
@ -391,7 +391,7 @@ pub struct BlobImageDescriptor {
|
||||
/// `BlobImageData` to the embedding via the rasterization callback.
|
||||
pub struct RasterizedBlobImage {
|
||||
/// The bounding rectangle for this blob image.
|
||||
pub rasterized_rect: DeviceUintRect,
|
||||
pub rasterized_rect: DeviceIntRect,
|
||||
/// Backing store. The format is stored out of band in `BlobImageDescriptor`.
|
||||
pub data: Arc<Vec<u8>>,
|
||||
}
|
||||
|
@ -27,10 +27,6 @@ pub type DeviceIntSize = TypedSize2D<i32, DevicePixel>;
|
||||
pub type DeviceIntLength = Length<i32, DevicePixel>;
|
||||
pub type DeviceIntSideOffsets = TypedSideOffsets2D<i32, DevicePixel>;
|
||||
|
||||
pub type DeviceUintRect = TypedRect<u32, DevicePixel>;
|
||||
pub type DeviceUintPoint = TypedPoint2D<u32, DevicePixel>;
|
||||
pub type DeviceUintSize = TypedSize2D<u32, DevicePixel>;
|
||||
|
||||
pub type DeviceRect = TypedRect<f32, DevicePixel>;
|
||||
pub type DevicePoint = TypedPoint2D<f32, DevicePixel>;
|
||||
pub type DeviceVector2D = TypedVector2D<f32, DevicePixel>;
|
||||
@ -93,8 +89,8 @@ pub type WorldVector3D = TypedVector3D<f32, WorldPixel>;
|
||||
/// Offset in number of tiles.
|
||||
#[derive(Hash, Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd)]
|
||||
pub struct Tiles;
|
||||
pub type TileOffset = TypedPoint2D<u32, Tiles>;
|
||||
pub type TileRange = TypedRect<u32, Tiles>;
|
||||
pub type TileOffset = TypedPoint2D<i32, Tiles>;
|
||||
pub type TileRange = TypedRect<i32, Tiles>;
|
||||
|
||||
/// Scaling ratio from world pixels to device pixels.
|
||||
pub type DevicePixelScale = TypedScale<f32, WorldPixel, DevicePixel>;
|
||||
|
@ -1,2 +1 @@
|
||||
9ec08a4cf0ce6762a98ddd4df34611dbf0694703
|
||||
plus servo/webrender#3316 cherry-picked
|
||||
dc442bfe38dcd9fc5033d2191b04c6242d167f05
|
||||
|
@ -38,7 +38,7 @@ fn render_blob(
|
||||
color: ColorU,
|
||||
descriptor: &BlobImageDescriptor,
|
||||
tile: Option<(TileSize, TileOffset)>,
|
||||
dirty_rect: Option<DeviceUintRect>,
|
||||
dirty_rect: Option<DeviceIntRect>,
|
||||
) -> BlobImageResult {
|
||||
// Allocate storage for the result. Right now the resource cache expects the
|
||||
// tiles to have have no stride or offset.
|
||||
@ -54,13 +54,13 @@ fn render_blob(
|
||||
None => true,
|
||||
};
|
||||
|
||||
let mut dirty_rect = dirty_rect.unwrap_or(DeviceUintRect::new(
|
||||
descriptor.offset.to_u32(),
|
||||
let mut dirty_rect = dirty_rect.unwrap_or(DeviceIntRect::new(
|
||||
descriptor.offset.to_i32(),
|
||||
descriptor.size,
|
||||
));
|
||||
|
||||
if let Some((tile_size, tile)) = tile {
|
||||
dirty_rect = intersect_for_tile(dirty_rect, size2(tile_size as u32, tile_size as u32),
|
||||
dirty_rect = intersect_for_tile(dirty_rect, size2(tile_size as i32, tile_size as i32),
|
||||
tile_size, tile)
|
||||
.expect("empty rects should be culled by webrender");
|
||||
}
|
||||
@ -69,8 +69,8 @@ fn render_blob(
|
||||
for x in dirty_rect.min_x() .. dirty_rect.max_x() {
|
||||
// Apply the tile's offset. This is important: all drawing commands should be
|
||||
// translated by this offset to give correct results with tiled blob images.
|
||||
let x2 = x + descriptor.offset.x as u32;
|
||||
let y2 = y + descriptor.offset.y as u32;
|
||||
let x2 = x + descriptor.offset.x as i32;
|
||||
let y2 = y + descriptor.offset.y as i32;
|
||||
|
||||
// Render a simple checkerboard pattern
|
||||
let checker = if (x2 % 20 >= 10) != (y2 % 20 >= 10) {
|
||||
@ -139,7 +139,7 @@ impl BlobImageHandler for CheckerboardRenderer {
|
||||
.insert(key, (deserialize_blob(&cmds[..]).unwrap(), tile_size));
|
||||
}
|
||||
|
||||
fn update(&mut self, key: ImageKey, cmds: Arc<BlobImageData>, _dirty_rect: Option<DeviceUintRect>) {
|
||||
fn update(&mut self, key: ImageKey, cmds: Arc<BlobImageData>, _dirty_rect: Option<DeviceIntRect>) {
|
||||
// Here, updating is just replacing the current version of the commands with
|
||||
// the new one (no incremental updates).
|
||||
self.image_cmds.get_mut(&key).unwrap().0 = deserialize_blob(&cmds[..]).unwrap();
|
||||
@ -175,7 +175,7 @@ struct Command {
|
||||
color: ColorU,
|
||||
descriptor: BlobImageDescriptor,
|
||||
tile: Option<(TileSize, TileOffset)>,
|
||||
dirty_rect: Option<DeviceUintRect>
|
||||
dirty_rect: Option<DeviceIntRect>
|
||||
}
|
||||
|
||||
struct Rasterizer {
|
||||
|
@ -31,9 +31,9 @@ struct CachedFontInstance {
|
||||
}
|
||||
|
||||
struct CachedImage {
|
||||
width: u32,
|
||||
height: u32,
|
||||
stride: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
stride: i32,
|
||||
format: ImageFormat,
|
||||
bytes: Option<Vec<u8>>,
|
||||
path: Option<PathBuf>,
|
||||
@ -227,8 +227,8 @@ impl JsonFrameWriter {
|
||||
save_buffer(
|
||||
&path_file,
|
||||
&bytes,
|
||||
data.width,
|
||||
data.height,
|
||||
data.width as u32,
|
||||
data.height as u32,
|
||||
ColorType::RGBA(8),
|
||||
).unwrap();
|
||||
true
|
||||
@ -239,8 +239,8 @@ impl JsonFrameWriter {
|
||||
save_buffer(
|
||||
&path_file,
|
||||
&bytes,
|
||||
data.width,
|
||||
data.height,
|
||||
data.width as u32,
|
||||
data.height as u32,
|
||||
ColorType::Gray(8),
|
||||
).unwrap();
|
||||
true
|
||||
|
@ -92,21 +92,21 @@ pub static mut CURRENT_FRAME_NUMBER: u32 = 0;
|
||||
|
||||
#[cfg(feature = "headless")]
|
||||
pub struct HeadlessContext {
|
||||
width: u32,
|
||||
height: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
_context: osmesa_sys::OSMesaContext,
|
||||
_buffer: Vec<u32>,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "headless"))]
|
||||
pub struct HeadlessContext {
|
||||
width: u32,
|
||||
height: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
}
|
||||
|
||||
impl HeadlessContext {
|
||||
#[cfg(feature = "headless")]
|
||||
fn new(width: u32, height: u32) -> Self {
|
||||
fn new(width: i32, height: i32) -> Self {
|
||||
let mut attribs = Vec::new();
|
||||
|
||||
attribs.push(osmesa_sys::OSMESA_PROFILE);
|
||||
@ -131,8 +131,8 @@ impl HeadlessContext {
|
||||
context,
|
||||
buffer.as_mut_ptr() as *mut _,
|
||||
gl::UNSIGNED_BYTE,
|
||||
width as i32,
|
||||
height as i32,
|
||||
width,
|
||||
height,
|
||||
);
|
||||
assert!(ret != 0);
|
||||
};
|
||||
@ -146,7 +146,7 @@ impl HeadlessContext {
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "headless"))]
|
||||
fn new(width: u32, height: u32) -> Self {
|
||||
fn new(width: i32, height: i32) -> Self {
|
||||
HeadlessContext { width, height }
|
||||
}
|
||||
|
||||
@ -179,18 +179,18 @@ impl WindowWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_inner_size(&self) -> DeviceUintSize {
|
||||
fn inner_size(window: &winit::Window) -> DeviceUintSize {
|
||||
fn get_inner_size(&self) -> DeviceIntSize {
|
||||
fn inner_size(window: &winit::Window) -> DeviceIntSize {
|
||||
let size = window
|
||||
.get_inner_size()
|
||||
.unwrap()
|
||||
.to_physical(window.get_hidpi_factor());
|
||||
DeviceUintSize::new(size.width as u32, size.height as u32)
|
||||
DeviceIntSize::new(size.width as i32, size.height as i32)
|
||||
}
|
||||
match *self {
|
||||
WindowWrapper::Window(ref window, _) => inner_size(window.window()),
|
||||
WindowWrapper::Angle(ref window, ..) => inner_size(window),
|
||||
WindowWrapper::Headless(ref context, _) => DeviceUintSize::new(context.width, context.height),
|
||||
WindowWrapper::Headless(ref context, _) => DeviceIntSize::new(context.width, context.height),
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,7 +202,7 @@ impl WindowWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
fn resize(&mut self, size: DeviceUintSize) {
|
||||
fn resize(&mut self, size: DeviceIntSize) {
|
||||
match *self {
|
||||
WindowWrapper::Window(ref mut window, _) => {
|
||||
window.set_inner_size(LogicalSize::new(size.width as f64, size.height as f64))
|
||||
@ -240,7 +240,7 @@ impl WindowWrapper {
|
||||
}
|
||||
|
||||
fn make_window(
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
dp_ratio: Option<f32>,
|
||||
vsync: bool,
|
||||
events_loop: &Option<winit::EventsLoop>,
|
||||
@ -411,20 +411,20 @@ fn main() {
|
||||
});
|
||||
let size = args.value_of("size")
|
||||
.map(|s| if s == "720p" {
|
||||
DeviceUintSize::new(1280, 720)
|
||||
DeviceIntSize::new(1280, 720)
|
||||
} else if s == "1080p" {
|
||||
DeviceUintSize::new(1920, 1080)
|
||||
DeviceIntSize::new(1920, 1080)
|
||||
} else if s == "4k" {
|
||||
DeviceUintSize::new(3840, 2160)
|
||||
DeviceIntSize::new(3840, 2160)
|
||||
} else {
|
||||
let x = s.find('x').expect(
|
||||
"Size must be specified exactly as 720p, 1080p, 4k, or width x height",
|
||||
);
|
||||
let w = s[0 .. x].parse::<u32>().expect("Invalid size width");
|
||||
let h = s[x + 1 ..].parse::<u32>().expect("Invalid size height");
|
||||
DeviceUintSize::new(w, h)
|
||||
let w = s[0 .. x].parse::<i32>().expect("Invalid size width");
|
||||
let h = s[x + 1 ..].parse::<i32>().expect("Invalid size height");
|
||||
DeviceIntSize::new(w, h)
|
||||
})
|
||||
.unwrap_or(DeviceUintSize::new(1920, 1080));
|
||||
.unwrap_or(DeviceIntSize::new(1920, 1080));
|
||||
let zoom_factor = args.value_of("zoom").map(|z| z.parse::<f32>().unwrap());
|
||||
let chase_primitive = match args.value_of("chase") {
|
||||
Some(s) => {
|
||||
@ -528,7 +528,7 @@ fn main() {
|
||||
fn render<'a>(
|
||||
wrench: &mut Wrench,
|
||||
window: &mut WindowWrapper,
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
events_loop: &mut Option<winit::EventsLoop>,
|
||||
subargs: &clap::ArgMatches<'a>,
|
||||
) {
|
||||
@ -744,7 +744,7 @@ fn render<'a>(
|
||||
match *events_loop {
|
||||
None => {
|
||||
while body(wrench, winit::Event::Awakened) == winit::ControlFlow::Continue {}
|
||||
let rect = DeviceUintRect::new(DeviceUintPoint::zero(), size);
|
||||
let rect = DeviceIntRect::new(DeviceIntPoint::zero(), size);
|
||||
let pixels = wrench.renderer.read_pixels_rgba8(rect);
|
||||
save_flipped("screenshot.png", pixels, size);
|
||||
}
|
||||
|
@ -25,12 +25,14 @@ pub struct SaveSettings {
|
||||
pub fn save<P: Clone + AsRef<Path>>(
|
||||
path: P,
|
||||
orig_pixels: Vec<u8>,
|
||||
mut size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
settings: SaveSettings
|
||||
) {
|
||||
let mut width = size.width as u32;
|
||||
let mut height = size.height as u32;
|
||||
let mut buffer = image::RgbaImage::from_raw(
|
||||
size.width,
|
||||
size.height,
|
||||
width,
|
||||
height,
|
||||
orig_pixels,
|
||||
).expect("bug: unable to construct image buffer");
|
||||
|
||||
@ -43,28 +45,28 @@ pub fn save<P: Clone + AsRef<Path>>(
|
||||
if let Ok(existing_image) = image::open(path.clone()) {
|
||||
let old_dims = existing_image.dimensions();
|
||||
println!("Crop from {:?} to {:?}", size, old_dims);
|
||||
size.width = old_dims.0;
|
||||
size.height = old_dims.1;
|
||||
width = old_dims.0;
|
||||
height = old_dims.1;
|
||||
buffer = image::imageops::crop(
|
||||
&mut buffer,
|
||||
0,
|
||||
0,
|
||||
size.width,
|
||||
size.height
|
||||
width,
|
||||
height
|
||||
).to_image();
|
||||
}
|
||||
}
|
||||
|
||||
let encoder = PNGEncoder::new(File::create(path).unwrap());
|
||||
encoder
|
||||
.encode(&buffer, size.width, size.height, ColorType::RGBA(8))
|
||||
.encode(&buffer, width, height, ColorType::RGBA(8))
|
||||
.expect("Unable to encode PNG!");
|
||||
}
|
||||
|
||||
pub fn save_flipped<P: Clone + AsRef<Path>>(
|
||||
path: P,
|
||||
orig_pixels: Vec<u8>,
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
) {
|
||||
save(path, orig_pixels, size, SaveSettings {
|
||||
flip_vertical: true,
|
||||
@ -88,7 +90,7 @@ pub fn png(
|
||||
let (device_size, data, settings) = match surface {
|
||||
ReadSurface::Screen => {
|
||||
let dim = window.get_inner_size();
|
||||
let rect = DeviceUintRect::new(DeviceUintPoint::zero(), dim);
|
||||
let rect = DeviceIntRect::new(DeviceIntPoint::zero(), dim);
|
||||
let data = wrench.renderer
|
||||
.read_pixels_rgba8(rect);
|
||||
(rect.size, data, SaveSettings {
|
||||
|
@ -55,7 +55,7 @@ impl<'a> RawtestHarness<'a> {
|
||||
self.test_zero_height_window();
|
||||
}
|
||||
|
||||
fn render_and_get_pixels(&mut self, window_rect: DeviceUintRect) -> Vec<u8> {
|
||||
fn render_and_get_pixels(&mut self, window_rect: DeviceIntRect) -> Vec<u8> {
|
||||
self.rx.recv().unwrap();
|
||||
self.wrench.render();
|
||||
self.wrench.renderer.read_pixels_rgba8(window_rect)
|
||||
@ -138,10 +138,10 @@ impl<'a> RawtestHarness<'a> {
|
||||
|
||||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = DeviceUintSize::new(800, 800);
|
||||
let test_size = DeviceIntSize::new(800, 800);
|
||||
|
||||
let window_rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(0, window_size.height - test_size.height),
|
||||
let window_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
||||
@ -185,7 +185,7 @@ impl<'a> RawtestHarness<'a> {
|
||||
);
|
||||
txn.set_image_visible_area(
|
||||
blob_img,
|
||||
DeviceUintRect {
|
||||
DeviceIntRect {
|
||||
origin: point2(0, 111256 / 30),
|
||||
size: size2(1510, 111256 / 30),
|
||||
}
|
||||
@ -253,9 +253,9 @@ impl<'a> RawtestHarness<'a> {
|
||||
assert_eq!(self.wrench.device_pixel_ratio, 1.);
|
||||
|
||||
let window_size = self.window.get_inner_size();
|
||||
let test_size = DeviceUintSize::new(800, 800);
|
||||
let window_rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(0, window_size.height - test_size.height),
|
||||
let test_size = DeviceIntSize::new(800, 800);
|
||||
let window_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
let layout_size = LayoutSize::new(800.0, 800.0);
|
||||
@ -269,8 +269,8 @@ impl<'a> RawtestHarness<'a> {
|
||||
txn.add_image(
|
||||
blob_img1,
|
||||
ImageDescriptor::new(
|
||||
image_size.width as u32,
|
||||
image_size.height as u32,
|
||||
image_size.width as i32,
|
||||
image_size.height as i32,
|
||||
ImageFormat::BGRA8,
|
||||
false,
|
||||
false
|
||||
@ -299,8 +299,8 @@ impl<'a> RawtestHarness<'a> {
|
||||
txn.add_image(
|
||||
blob_img2,
|
||||
ImageDescriptor::new(
|
||||
image_size.width as u32,
|
||||
image_size.height as u32,
|
||||
image_size.width as i32,
|
||||
image_size.height as i32,
|
||||
ImageFormat::BGRA8,
|
||||
false,
|
||||
false
|
||||
@ -310,7 +310,7 @@ impl<'a> RawtestHarness<'a> {
|
||||
);
|
||||
// Set a visible rectangle that is too small.
|
||||
// This will force sync rasterization of the missing tiles during frame building.
|
||||
txn.set_image_visible_area(blob_img2, DeviceUintRect {
|
||||
txn.set_image_visible_area(blob_img2, DeviceIntRect {
|
||||
origin: point2(200, 200),
|
||||
size: size2(80, 80),
|
||||
});
|
||||
@ -343,10 +343,10 @@ impl<'a> RawtestHarness<'a> {
|
||||
|
||||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = DeviceUintSize::new(800, 800);
|
||||
let test_size = DeviceIntSize::new(800, 800);
|
||||
|
||||
let window_rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(0, window_size.height - test_size.height),
|
||||
let window_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
|
||||
@ -454,10 +454,10 @@ impl<'a> RawtestHarness<'a> {
|
||||
let blob_img;
|
||||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = DeviceUintSize::new(400, 400);
|
||||
let test_size = DeviceIntSize::new(400, 400);
|
||||
|
||||
let window_rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(0, window_size.height - test_size.height),
|
||||
let window_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
let layout_size = LayoutSize::new(400., 400.);
|
||||
@ -542,9 +542,9 @@ impl<'a> RawtestHarness<'a> {
|
||||
let (blob_img, blob_img2);
|
||||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = DeviceUintSize::new(400, 400);
|
||||
let test_size = DeviceIntSize::new(400, 400);
|
||||
|
||||
let window_rect = DeviceUintRect::new(
|
||||
let window_rect = DeviceIntRect::new(
|
||||
point(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
@ -669,9 +669,9 @@ impl<'a> RawtestHarness<'a> {
|
||||
println!("\tblob update test...");
|
||||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = DeviceUintSize::new(400, 400);
|
||||
let test_size = DeviceIntSize::new(400, 400);
|
||||
|
||||
let window_rect = DeviceUintRect::new(
|
||||
let window_rect = DeviceIntRect::new(
|
||||
point(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
@ -767,10 +767,10 @@ impl<'a> RawtestHarness<'a> {
|
||||
println!("\tsave/restore...");
|
||||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = DeviceUintSize::new(400, 400);
|
||||
let test_size = DeviceIntSize::new(400, 400);
|
||||
|
||||
let window_rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(0, window_size.height - test_size.height),
|
||||
let window_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
let layout_size = LayoutSize::new(400., 400.);
|
||||
@ -845,10 +845,10 @@ impl<'a> RawtestHarness<'a> {
|
||||
println!("\tblur cache...");
|
||||
let window_size = self.window.get_inner_size();
|
||||
|
||||
let test_size = DeviceUintSize::new(400, 400);
|
||||
let test_size = DeviceIntSize::new(400, 400);
|
||||
|
||||
let window_rect = DeviceUintRect::new(
|
||||
DeviceUintPoint::new(0, window_size.height - test_size.height),
|
||||
let window_rect = DeviceIntRect::new(
|
||||
DeviceIntPoint::new(0, window_size.height - test_size.height),
|
||||
test_size,
|
||||
);
|
||||
let layout_size = LayoutSize::new(400., 400.);
|
||||
@ -889,9 +889,9 @@ impl<'a> RawtestHarness<'a> {
|
||||
let path = "../captures/test";
|
||||
let layout_size = LayoutSize::new(400., 400.);
|
||||
let dim = self.window.get_inner_size();
|
||||
let window_rect = DeviceUintRect::new(
|
||||
point(0, dim.height - layout_size.height as u32),
|
||||
size(layout_size.width as u32, layout_size.height as u32),
|
||||
let window_rect = DeviceIntRect::new(
|
||||
point(0, dim.height - layout_size.height as i32),
|
||||
size(layout_size.width as i32, layout_size.height as i32),
|
||||
);
|
||||
|
||||
// 1. render some scene
|
||||
@ -971,7 +971,7 @@ impl<'a> RawtestHarness<'a> {
|
||||
println!("\tzero height test...");
|
||||
|
||||
let layout_size = LayoutSize::new(120.0, 0.0);
|
||||
let window_size = DeviceUintSize::new(layout_size.width as u32, layout_size.height as u32);
|
||||
let window_size = DeviceIntSize::new(layout_size.width as i32, layout_size.height as i32);
|
||||
let doc_id = self.wrench.api.add_document(window_size, 1);
|
||||
|
||||
let mut builder = DisplayListBuilder::new(self.wrench.root_pipeline_id, layout_size);
|
||||
|
@ -96,7 +96,7 @@ impl Display for Reftest {
|
||||
|
||||
struct ReftestImage {
|
||||
data: Vec<u8>,
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
}
|
||||
enum ReftestImageComparison {
|
||||
Equal,
|
||||
@ -157,7 +157,7 @@ impl ReftestImage {
|
||||
{
|
||||
let encoder = PNGEncoder::new(&mut png);
|
||||
encoder
|
||||
.encode(&self.data[..], width, height, ColorType::RGBA(8))
|
||||
.encode(&self.data[..], width as u32, height as u32, ColorType::RGBA(8))
|
||||
.expect("Unable to encode PNG!");
|
||||
}
|
||||
let png_base64 = base64::encode(&png);
|
||||
@ -470,14 +470,14 @@ impl<'a> ReftestHarness<'a> {
|
||||
let size = img.dimensions();
|
||||
ReftestImage {
|
||||
data: img.into_raw(),
|
||||
size: DeviceUintSize::new(size.0, size.1),
|
||||
size: DeviceIntSize::new(size.0 as i32, size.1 as i32),
|
||||
}
|
||||
}
|
||||
|
||||
fn render_yaml(
|
||||
&mut self,
|
||||
filename: &Path,
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
font_render_mode: Option<FontRenderMode>,
|
||||
allow_mipmaps: bool,
|
||||
) -> (ReftestImage, RendererStats) {
|
||||
@ -500,7 +500,7 @@ impl<'a> ReftestHarness<'a> {
|
||||
);
|
||||
|
||||
// taking the bottom left sub-rectangle
|
||||
let rect = DeviceUintRect::new(DeviceUintPoint::new(0, window_size.height - size.height), size);
|
||||
let rect = DeviceIntRect::new(DeviceIntPoint::new(0, window_size.height - size.height), size);
|
||||
let pixels = self.wrench.renderer.read_pixels_rgba8(rect);
|
||||
self.window.swap_buffers();
|
||||
|
||||
|
@ -18,8 +18,8 @@ enum CachedFont {
|
||||
}
|
||||
|
||||
struct CachedImage {
|
||||
width: u32,
|
||||
height: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
format: ImageFormat,
|
||||
bytes: Option<Vec<u8>>,
|
||||
path: Option<PathBuf>,
|
||||
|
@ -146,7 +146,7 @@ impl WrenchThing for CapturedDocument {
|
||||
}
|
||||
|
||||
pub struct Wrench {
|
||||
window_size: DeviceUintSize,
|
||||
window_size: DeviceIntSize,
|
||||
pub device_pixel_ratio: f32,
|
||||
page_zoom_factor: ZoomFactor,
|
||||
|
||||
@ -174,7 +174,7 @@ impl Wrench {
|
||||
shader_override_path: Option<PathBuf>,
|
||||
dp_ratio: f32,
|
||||
save_type: Option<SaveType>,
|
||||
size: DeviceUintSize,
|
||||
size: DeviceIntSize,
|
||||
do_rebuild: bool,
|
||||
no_subpixel_aa: bool,
|
||||
verbose: bool,
|
||||
@ -491,7 +491,7 @@ impl Wrench {
|
||||
self.api.update_resources(txn.resource_updates);
|
||||
}
|
||||
|
||||
pub fn update(&mut self, dim: DeviceUintSize) {
|
||||
pub fn update(&mut self, dim: DeviceIntSize) {
|
||||
if dim != self.window_size {
|
||||
self.window_size = dim;
|
||||
}
|
||||
|
@ -121,7 +121,7 @@ fn generate_checkerboard_image(
|
||||
}
|
||||
|
||||
(
|
||||
ImageDescriptor::new(width, height, ImageFormat::BGRA8, true, false),
|
||||
ImageDescriptor::new(width as i32, height as i32, ImageFormat::BGRA8, true, false),
|
||||
ImageData::new(pixels),
|
||||
)
|
||||
}
|
||||
@ -139,7 +139,7 @@ fn generate_xy_gradient_image(w: u32, h: u32) -> (ImageDescriptor, ImageData) {
|
||||
}
|
||||
|
||||
(
|
||||
ImageDescriptor::new(w, h, ImageFormat::BGRA8, true, false),
|
||||
ImageDescriptor::new(w as i32, h as i32, ImageFormat::BGRA8, true, false),
|
||||
ImageData::new(pixels),
|
||||
)
|
||||
}
|
||||
@ -169,7 +169,7 @@ fn generate_solid_color_image(
|
||||
}
|
||||
|
||||
(
|
||||
ImageDescriptor::new(w, h, ImageFormat::BGRA8, a == 255, false),
|
||||
ImageDescriptor::new(w as i32, h as i32, ImageFormat::BGRA8, a == 255, false),
|
||||
ImageData::new(pixels),
|
||||
)
|
||||
}
|
||||
@ -461,8 +461,8 @@ impl YamlFrameReader {
|
||||
_ => panic!("We don't support whatever your crazy image type is, come on"),
|
||||
};
|
||||
let descriptor = ImageDescriptor::new(
|
||||
image_width,
|
||||
image_height,
|
||||
image_width as i32,
|
||||
image_height as i32,
|
||||
format,
|
||||
is_image_opaque(format, &bytes[..]),
|
||||
self.allow_mipmaps,
|
||||
@ -967,9 +967,9 @@ impl YamlFrameReader {
|
||||
|
||||
Some(BorderDetails::NinePatch(NinePatchBorder {
|
||||
source,
|
||||
width: image_width as u32,
|
||||
height: image_height as u32,
|
||||
slice: SideOffsets2D::new(slice[0], slice[1], slice[2], slice[3]),
|
||||
width: image_width as i32,
|
||||
height: image_height as i32,
|
||||
slice: SideOffsets2D::new(slice[0] as i32, slice[1] as i32, slice[2] as i32, slice[3] as i32),
|
||||
fill,
|
||||
repeat_horizontal,
|
||||
repeat_vertical,
|
||||
|
@ -113,6 +113,10 @@ fn u32_node(parent: &mut Table, key: &str, value: u32) {
|
||||
yaml_node(parent, key, Yaml::Integer(value as i64));
|
||||
}
|
||||
|
||||
fn i32_node(parent: &mut Table, key: &str, value: i32) {
|
||||
yaml_node(parent, key, Yaml::Integer(value as i64));
|
||||
}
|
||||
|
||||
fn usize_node(parent: &mut Table, key: &str, value: usize) {
|
||||
yaml_node(parent, key, Yaml::Integer(value as i64));
|
||||
}
|
||||
@ -145,6 +149,14 @@ fn u32_vec_yaml(value: &[u32], check_unique: bool) -> Yaml {
|
||||
}
|
||||
}
|
||||
|
||||
fn i32_vec_yaml(value: &[i32], check_unique: bool) -> Yaml {
|
||||
if !value.is_empty() && check_unique && array_elements_are_same(value) {
|
||||
Yaml::Integer(value[0] as i64)
|
||||
} else {
|
||||
Yaml::Array(value.iter().map(|v| Yaml::Integer(*v as i64)).collect())
|
||||
}
|
||||
}
|
||||
|
||||
fn u32_vec_node(parent: &mut Table, key: &str, value: &[u32]) {
|
||||
yaml_node(parent, key, u32_vec_yaml(value, false));
|
||||
}
|
||||
@ -346,9 +358,9 @@ struct CachedFontInstance {
|
||||
}
|
||||
|
||||
struct CachedImage {
|
||||
width: u32,
|
||||
height: u32,
|
||||
stride: u32,
|
||||
width: i32,
|
||||
height: i32,
|
||||
stride: i32,
|
||||
format: ImageFormat,
|
||||
bytes: Option<Vec<u8>>,
|
||||
path: Option<PathBuf>,
|
||||
@ -639,7 +651,13 @@ impl YamlFrameWriter {
|
||||
if data.format == ImageFormat::BGRA8 {
|
||||
unpremultiply(bytes.as_mut_slice());
|
||||
}
|
||||
save_buffer(&path_file, &bytes, data.width, data.height, color_type).unwrap();
|
||||
save_buffer(
|
||||
&path_file,
|
||||
&bytes,
|
||||
data.width as u32,
|
||||
data.height as u32,
|
||||
color_type,
|
||||
).unwrap();
|
||||
} else {
|
||||
// takes a buffer with a stride and copies it into a new buffer that has stride == width
|
||||
assert!(data.stride > data.width * bpp);
|
||||
@ -653,7 +671,13 @@ impl YamlFrameWriter {
|
||||
unpremultiply(tmp.as_mut_slice());
|
||||
}
|
||||
|
||||
save_buffer(&path_file, &tmp, data.width, data.height, color_type).unwrap();
|
||||
save_buffer(
|
||||
&path_file,
|
||||
&tmp,
|
||||
data.width as u32,
|
||||
data.height as u32,
|
||||
color_type
|
||||
).unwrap();
|
||||
}
|
||||
|
||||
data.path = Some(path.clone());
|
||||
@ -925,15 +949,15 @@ impl YamlFrameWriter {
|
||||
}
|
||||
}
|
||||
|
||||
u32_node(&mut v, "image-width", details.width);
|
||||
u32_node(&mut v, "image-height", details.height);
|
||||
let slice: Vec<u32> = vec![
|
||||
i32_node(&mut v, "image-width", details.width);
|
||||
i32_node(&mut v, "image-height", details.height);
|
||||
let slice = [
|
||||
details.slice.top,
|
||||
details.slice.right,
|
||||
details.slice.bottom,
|
||||
details.slice.left,
|
||||
];
|
||||
yaml_node(&mut v, "slice", u32_vec_yaml(&slice, true));
|
||||
yaml_node(&mut v, "slice", i32_vec_yaml(&slice, true));
|
||||
yaml_node(&mut v, "outset", f32_vec_yaml(&outset, true));
|
||||
match details.repeat_horizontal {
|
||||
RepeatMode::Stretch => {
|
||||
|
Loading…
Reference in New Issue
Block a user