Compare commits

..

2 Commits

Author SHA1 Message Date
itsjunetime 3026cbce32 switch benches over to other runtime 2026-03-05 12:05:25 -06:00
itsjunetime a4c04c71b6 Simpler tokio runtime; 3 threads and no io driver 2026-03-05 11:57:18 -06:00
3 changed files with 54 additions and 24 deletions
+37
View File
@@ -11,6 +11,7 @@ on:
env:
CARGO_TERM_COLOR: always
tip_release_path: RELEASE.md
jobs:
test-build:
@@ -106,3 +107,39 @@ jobs:
generate_release_notes: true
files: release-artifacts/*
prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') || contains(github.ref, 'rc') }}
tip-release:
name: Release tip on push to main
runs-on: ubuntu-slim
if: github.event_name == 'push' && github.ref_name == 'main'
needs: test-build
steps:
- uses: actions/checkout@v6
- name: Download prebuilt artifacts
uses: actions/download-artifact@v7
with:
path: release-artifacts
merge-multiple: true
- name: Generate release notes
run: |
tree release-artifacts/
echo "From commit: $(git rev-parse --short HEAD)" > ${{ env.tip_release_path }}
echo "Generated on: $(date -u +"%Y-%m-%d %H:%M") UTC" >> ${{ env.tip_release_path }}
cat ${{ env.tip_release_path }}
- name: Update the tip tag
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag --force tip && git push --force origin tag tip
- name: Update the draft tip release
uses: softprops/action-gh-release@v2
with:
prerelease: true
files: release-artifacts/*
tag_name: tip
name: Tip Build
body_path: ${{ env.tip_release_path }}
+16 -23
View File
@@ -1,12 +1,11 @@
use std::{
io::Cursor,
num::NonZeroUsize,
time::{SystemTime, UNIX_EPOCH}
};
use flume::{Receiver, SendError, Sender, TryRecvError};
use futures_util::stream::StreamExt as _;
use image::{DynamicImage, codecs::pnm::PnmDecoder};
use image::DynamicImage;
use kittage::{NumberOrId, action::NONZERO_ONE};
use ratatui::layout::Rect;
use ratatui_image::{
@@ -112,26 +111,22 @@ pub async fn run_conversion_loop(
return Ok(None);
};
let decoder = PnmDecoder::new(Cursor::new(&page_info.img_data.pixels)).map_err(|e| {
RenderError::Converting(format!(
"The image data provided from mupdf was not in pnm format ({e}); don't know how to convert"
))
})?;
let mut dyn_img = image::load_from_memory_with_format(
&page_info.img_data.pixels,
image::ImageFormat::Pnm
)
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?;
// The image we get should always already be `ImageRgb8`, so this `into` shouldn't do any
// conversions or anything, but just in case some underlying detail of mupdf or image
// changes, we do the `into` instead of just `match + unreachable!()` to avoid panicking
let mut dyn_img = DynamicImage::from_decoder(decoder)
.map_err(|e| RenderError::Converting(format!("Can't load image: {e}")))?
.into_rgb8();
for quad in &*page_info.result_rects {
dyn_img
.par_enumerate_pixels_mut()
.filter(|(x, y, _)| {
*x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y
})
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
match dyn_img {
DynamicImage::ImageRgb8(ref mut img) =>
for quad in &*page_info.result_rects {
img.par_enumerate_pixels_mut()
.filter(|(x, y, _)| {
*x > quad.ul_x && *x < quad.lr_x && *y > quad.ul_y && *y < quad.lr_y
})
.for_each(|(_, _, px)| px.0[2] = px.0[2].saturating_sub(u8::MAX / 2));
},
_ => unreachable!()
}
let img_area = Rect {
@@ -141,8 +136,6 @@ pub async fn run_conversion_loop(
y: 0
};
let dyn_img = DynamicImage::ImageRgb8(dyn_img);
let txt_img = match picker.protocol_type() {
ProtocolType::Kitty => {
let rn = SystemTime::now()