/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use std::collections::HashMap; use std::mem; use std::sync::Arc;
/// We use this to generate the async blob rendering requests. struct BlobImageTemplate {
descriptor: ImageDescriptor,
tile_size: TileSize,
dirty_rect: BlobDirtyRect, /// See ImageResource::visible_rect.
visible_rect: DeviceIntRect, // If the active rect of the blob changes, this represents the // range of tiles that remain valid. This must be taken into // account in addition to the valid rect when submitting blob // rasterization requests. // `None` means the bounds have not changed (tiles are still valid). // `Some(TileRange::zero())` means all of the tiles are invalid.
valid_tiles_after_bounds_change: Option<TileRange>,
}
pubstruct ApiResources {
blob_image_templates: HashMap<BlobImageKey, BlobImageTemplate>, pub blob_image_handler: Option<Box<dyn BlobImageHandler>>,
fonts: SharedFontResources, // This should only be true for CI or debugging purposes. If true, // we'll restrict the size of blob images as a result effectively // rendering them incorrectly.
debug_restrict_blob_size: bool,
}
iflet Some(descriptor) = descriptor {
image.descriptor = *descriptor;
} else { // make sure the descriptor size matches the visible rect. // This might not be necessary but let's stay on the safe side.
image.descriptor.size = blob_size;
}
letmut blob_request_params = Vec::new(); for key in keys { let template = self.blob_image_templates.get_mut(key)
.expect("no blob image template");
// If we know that only a portion of the blob image is in the viewport, // only request these visible tiles since blob images can be huge. let tiles = compute_tile_range(
&template.visible_rect,
template.tile_size,
);
// Don't request tiles that weren't invalidated. let dirty_tiles = match template.dirty_rect {
DirtyRect::Partial(dirty_rect) => {
compute_tile_range(
&dirty_rect.cast_unit(),
template.tile_size,
)
}
DirtyRect::All => tiles,
};
for_each_tile_in_range(&tiles, |tile| { let still_valid = template.valid_tiles_after_bounds_change
.map(|valid_tiles| valid_tiles.contains(tile))
.unwrap_or(true);
if still_valid && !dirty_tiles.contains(tile) { return;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.