summaryrefslogtreecommitdiff
path: root/src/pdf_view.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/pdf_view.zig')
-rw-r--r--src/pdf_view.zig78
1 files changed, 25 insertions, 53 deletions
diff --git a/src/pdf_view.zig b/src/pdf_view.zig
index bb960139..4da382fd 100644
--- a/src/pdf_view.zig
+++ b/src/pdf_view.zig
@@ -3338,6 +3338,15 @@ pub fn draw(
state.far,
);
if (state.document_scroll_y != shown) state.drawn_y = state.document_scroll_y;
+ // Below the notice chips, like an image: a placed page is drawn after
+ // the cells and would paint a chip out.
+ const body: pardes.RectCell = .{
+ .x = text_x,
+ .y = core.bodyTop(pane, rect) + pane.notices.span(),
+ .w = text_width,
+ .h = (rect.h -| pane.tag_rows) -| pane.notices.span(),
+ };
+ if (s.region(.body, pane_id)) |region| region.scroll_px = state.document_scroll_y;
var placed_any = false;
var page = visible.first;
const visible_end = visible.first + visible.len;
@@ -3352,73 +3361,36 @@ pub fn draw(
if (workers == null or pardes.platform == .macos) continue;
const size = state.page_sizes[page];
const rows = visibleRows(state, view, page, @intFromFloat(@max(1, @round(size.width * 8))), @intFromFloat(@max(1, @round(size.height * 8)))) orelse continue;
- if (!core.appendImagePlace(.{
+ if (!core.appendPlacement(.{
.pane = @intCast(pane_id),
- .serial = pane.serial,
- .native = .{
- .revision = 0,
- .page = @intCast(page),
- .fit = switch (state.fit) {
- .width => .width,
- .height => .height,
- },
- .pan_x = state.pan_x,
- .geometry = .{
- .src = .{ .x = 0, .y = 0, .w = 1, .h = 1 },
- .dst = .{ .x = rows.base.dst.x, .y = rows.dst_y, .w = rows.base.dst.w, .h = rows.dst_h },
- },
- .pixel_offset_y = rows.pixel_offset_y,
- },
- .x = text_x,
- .y = core.bodyTop(pane, rect) + pane.notices.span(),
- .w = text_width,
- .h = (rect.h -| pane.tag_rows) -| pane.notices.span(),
- .rgba = &state.blank,
- .iw = 1,
- .ih = 1,
+ .raster = .of(&state.blank, 1, 1),
+ .src = .{ .w = 1, .h = 1 },
+ .dst = body,
+ .at = .{ .x = rows.base.dst.x, .y = rows.dst_y, .w = rows.base.dst.w, .h = rows.dst_h },
+ .key = pardes.Placement.keyOf(pane.serial, @intCast(page), 0),
})) break;
placed_any = true;
continue;
};
const slot = rasterForPage(state, page).?;
- const patch: ?pardes.ImagePatch = if (slot.patch_from != 0 and
+ const dirty: ?pardes.Placement.Dirty = if (slot.patch_from != 0 and
slot.patch_rows.start < slot.patch_rows.end)
.{
- .from = slot.patch_from,
+ .from = pardes.Placement.keyOf(pane.serial, @intCast(placed.page), slot.patch_from),
.y = @intCast(slot.patch_rows.start - slot.band_y),
.h = @intCast(slot.patch_rows.end - slot.patch_rows.start),
}
else
null;
- if (!core.appendImagePlace(.{
+ if (!core.appendPlacement(.{
.pane = @intCast(pane_id),
- .serial = pane.serial,
- .native = .{
- .revision = placed.revision,
- .page = @intCast(placed.page),
- .fit = switch (placed.fit) {
- .width => .width,
- .height => .height,
- },
- .pan_x = placed.pan_x,
- .geometry = placed.geometry,
- .pixel_offset_y = placed.pixel_offset_y,
- .paper_bg = if (pardes.platform == .macos)
- (if (key.mode == .disabled) .{ 255, 255, 255 } else key.colors.background)
- else
- null,
- },
- .x = text_x,
- // Below the notice chips, like an image: a placed page is
- // drawn after the cells and would paint a chip out.
- .y = core.bodyTop(pane, rect) + pane.notices.span(),
- .w = text_width,
- .h = (rect.h -| pane.tag_rows) -| pane.notices.span(),
- .rgba = placed.rgba,
- .iw = placed.width,
- // The texture contains the retained band, not the full page.
- .ih = placed.band_height,
- .patch = patch,
+ // The texture is the retained band, not the full page.
+ .raster = .of(placed.rgba, placed.width, placed.band_height),
+ .src = placed.geometry.src,
+ .dst = body,
+ .at = placed.geometry.dst,
+ .key = pardes.Placement.keyOf(pane.serial, @intCast(placed.page), placed.revision),
+ .dirty = dirty,
})) break;
// A shell now holds (or will fetch whole) this revision.
slot.patch_from = slot.revision;