mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-02 06:20:48 +01:00
address review: charge only the tiles a raster layer keeps
This commit is contained in:
1 parent
84b7b0b791
commit
1e002b18b0
1 file changed
+4
-2
@@ -1509,8 +1509,10 @@ impl Conv {
|
||||
let canvas = tiny_skia::Transform::from_row(k, 0.0, 0.0, k, -(x0 as f32), -(y0 as f32));
|
||||
let ts = canvas.pre_concat(parent).pre_translate(shift.x(), shift.y());
|
||||
resvg::render_node(node, ts, &mut pixmap.as_mut())?;
|
||||
let layer = Layer::new(name, LayerContent::Raster(surface(&pixmap, Rect::new(x0, y0, x1, y1), self.fmt)));
|
||||
let bytes = pixels * self.fmt.bytes_per_pixel() as u64;
|
||||
let surf = surface(&pixmap, Rect::new(x0, y0, x1, y1), self.fmt);
|
||||
// Charge what the layer keeps: surface() prunes transparent tiles.
|
||||
let bytes = photocraft_raster::stored_tiles_bytes(surf.tile_count() as u64, &self.fmt);
|
||||
let layer = Layer::new(name, LayerContent::Raster(surf));
|
||||
self.pixel_budget -= bytes;
|
||||
self.retained_pixel_bytes += bytes;
|
||||
Some(layer)
|
||||
|
||||
Reference in new issue
Block a user