Skip to content

Commit 6ddd17c

Browse files
committed
Upgrade rawkit
1 parent 3066280 commit 6ddd17c

File tree

12 files changed

+33
-42
lines changed

12 files changed

+33
-42
lines changed

editor/src/messages/tool/transform_layer/transform_layer_message_handler.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -184,23 +184,22 @@ impl MessageHandler<TransformLayerMessage, TransformData<'_>> for TransformLayer
184184
*selected.pivot = selected.mean_average_of_pivots();
185185
self.local_pivot = document.metadata().document_to_viewport.inverse().transform_point2(*selected.pivot);
186186
self.grab_target = document.metadata().document_to_viewport.inverse().transform_point2(selected.mean_average_of_pivots());
187-
} else {
188-
match selected_layers.first().and_then(|&layer| document.network_interface.compute_modified_vector(layer)) {
189-
Some(vector_data) => {
190-
*selected.original_transforms = OriginalTransforms::default();
191-
192-
let viewspace = document.metadata().transform_to_viewport(selected_layers[0]);
193-
let selected_points = shape_editor.selected_points().collect::<Vec<_>>();
194-
195-
let get_location = |point: &&ManipulatorPointId| point.get_position(&vector_data).map(|position| viewspace.transform_point2(position));
196-
match calculate_pivot(&selected_points, &vector_data, viewspace, |point: &ManipulatorPointId| get_location(&point)) {
197-
Some((new_pivot, grab_target)) => {
198-
*selected.pivot = new_pivot;
199-
200-
self.local_pivot = document_to_viewport.inverse().transform_point2(*selected.pivot);
201-
self.grab_target = document_to_viewport.inverse().transform_point2(grab_target);
202-
} else {
203-
log::warn!("Failed to calculate pivot.");
187+
} else if let Some(vector_data) = selected_layers.first().and_then(|&layer| document.network_interface.compute_modified_vector(layer)) {
188+
*selected.original_transforms = OriginalTransforms::default();
189+
190+
let viewspace = document.metadata().transform_to_viewport(selected_layers[0]);
191+
let selected_points = shape_editor.selected_points().collect::<Vec<_>>();
192+
193+
let get_location = |point: &&ManipulatorPointId| point.get_position(&vector_data).map(|position| viewspace.transform_point2(position));
194+
match calculate_pivot(&selected_points, &vector_data, viewspace, |point: &ManipulatorPointId| get_location(&point)) {
195+
Some((new_pivot, grab_target)) => {
196+
*selected.pivot = new_pivot;
197+
self.local_pivot = document_to_viewport.inverse().transform_point2(*selected.pivot);
198+
self.grab_target = document_to_viewport.inverse().transform_point2(grab_target);
199+
}
200+
_ => {
201+
log::warn!("Failed to calculate pivot.");
202+
}
204203
}
205204
}
206205

libraries/rawkit/rawkit-proc-macros/src/build_camera_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use proc_macro::TokenStream;
2-
use quote::{quote, ToTokens};
2+
use quote::{ToTokens, quote};
33
use toml::{Table, Value};
44

55
use std::fs;

libraries/rawkit/rawkit-proc-macros/src/tag_derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ pub fn tag_derive(input: TokenStream) -> TokenStream {
2424

2525
let new_name = format_ident!("_{}", name);
2626

27-
let gen = quote! {
27+
let r#gen = quote! {
2828
struct #new_name {
2929
#( #struct_idents: <#struct_types as Tag>::Output ),*
3030
}
@@ -39,5 +39,5 @@ pub fn tag_derive(input: TokenStream) -> TokenStream {
3939
}
4040
};
4141

42-
gen.into()
42+
r#gen.into()
4343
}

libraries/rawkit/src/decoder/arw1.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
use crate::tiff::Ifd;
12
use crate::tiff::file::TiffRead;
23
use crate::tiff::tags::SonyDataOffset;
3-
use crate::tiff::Ifd;
44
use crate::{RawImage, SubtractBlack, Transform};
55

6-
use bitstream_io::{BitRead, BitReader, Endianness, BE};
6+
use bitstream_io::{BE, BitRead, BitReader, Endianness};
77
use std::io::{Read, Seek};
88

99
pub fn decode_a100<R: Read + Seek>(ifd: Ifd, file: &mut TiffRead<R>) -> RawImage {
@@ -63,11 +63,7 @@ fn ljpeg_diff<R: Read + Seek, E: Endianness>(huff: &[u16], file: &mut BitReader<
6363

6464
let diff = read_n_bits_from_file(length, file) as i32;
6565

66-
if length == 0 || (diff & (1 << (length - 1))) == 0 {
67-
diff - (1 << length) - 1
68-
} else {
69-
diff
70-
}
66+
if length == 0 || (diff & (1 << (length - 1))) == 0 { diff - (1 << length) - 1 } else { diff }
7167
}
7268

7369
fn sony_arw_load_raw<R: Read + Seek>(width: usize, height: usize, file: &mut BitReader<R, BE>) -> Option<Vec<u16>> {

libraries/rawkit/src/postprocessing/convert_to_rgb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use crate::{Pixel, RawImage, CHANNELS_IN_RGB};
1+
use crate::{CHANNELS_IN_RGB, Pixel, RawImage};
22

33
impl RawImage {
4-
pub fn convert_to_rgb_fn(&self) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] {
4+
pub fn convert_to_rgb_fn(&self) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] + use<> {
55
let Some(camera_to_rgb) = self.camera_to_rgb else { todo!() };
66

77
move |pixel: Pixel| {

libraries/rawkit/src/postprocessing/gamma_correction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
use crate::{Histogram, Image, Pixel, CHANNELS_IN_RGB};
1+
use crate::{CHANNELS_IN_RGB, Histogram, Image, Pixel};
22
use std::f64::consts::E;
33

44
impl Image<u16> {
5-
pub fn gamma_correction_fn(&self, histogram: &Histogram) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] {
5+
pub fn gamma_correction_fn(&self, histogram: &Histogram) -> impl Fn(Pixel) -> [u16; CHANNELS_IN_RGB] + use<> {
66
let percentage = self.width * self.height;
77

88
let mut white = 0;

libraries/rawkit/src/postprocessing/record_histogram.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{Histogram, Pixel, PixelTransform, RawImage, CHANNELS_IN_RGB};
1+
use crate::{CHANNELS_IN_RGB, Histogram, Pixel, PixelTransform, RawImage};
22

33
impl RawImage {
44
pub fn record_histogram_fn(&self) -> RecordHistogram {

libraries/rawkit/src/preprocessing/scale_to_16bit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{RawImage, RawPixel, SubtractBlack};
22

33
impl RawImage {
4-
pub fn scale_to_16bit_fn(&self) -> impl Fn(RawPixel) -> u16 {
4+
pub fn scale_to_16bit_fn(&self) -> impl Fn(RawPixel) -> u16 + use<> {
55
let black_level = match self.black {
66
SubtractBlack::CfaGrid(x) => x,
77
_ => unreachable!(),

libraries/rawkit/src/preprocessing/scale_white_balance.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::{RawImage, RawPixel};
22

33
impl RawImage {
4-
pub fn scale_white_balance_fn(&self) -> impl Fn(RawPixel) -> u16 {
4+
pub fn scale_white_balance_fn(&self) -> impl Fn(RawPixel) -> u16 + use<> {
55
let Some(mut white_balance) = self.white_balance else { todo!() };
66

77
if white_balance[1] == 0. {

libraries/rawkit/src/preprocessing/subtract_black.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::RawPixel;
22
use crate::{RawImage, SubtractBlack};
33

44
impl RawImage {
5-
pub fn subtract_black_fn(&self) -> impl Fn(RawPixel) -> u16 {
5+
pub fn subtract_black_fn(&self) -> impl Fn(RawPixel) -> u16 + use<> {
66
match self.black {
77
SubtractBlack::CfaGrid(black_levels) => move |pixel: RawPixel| pixel.value.saturating_sub(black_levels[2 * (pixel.row % 2) + (pixel.column % 2)]),
88
_ => todo!(),

0 commit comments

Comments
 (0)