Skip to content

Fix eyedropped not working on raster data when canvas is used #2958

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ pub struct DocumentMessageHandler {
/// Whether or not the editor has executed the network to render the document yet. If this is opened as an inactive tab, it won't be loaded initially because the active tab is prioritized.
#[serde(skip)]
pub is_loaded: bool,
/// Whether or not if rendering image data via the canvas should be disabled forcefully. Currently it only checks for eyedropper.
#[serde(skip)]
pub disable_canvas_override: bool,
}

impl Default for DocumentMessageHandler {
Expand Down Expand Up @@ -165,6 +168,7 @@ impl Default for DocumentMessageHandler {
auto_saved_hash: None,
layer_range_selection_reference: None,
is_loaded: false,
disable_canvas_override: false,
}
}
}
Expand All @@ -182,6 +186,8 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
device_pixel_ratio,
} = context;

self.disable_canvas_override = *current_tool == ToolType::Eyedropper;

match message {
// Sub-messages
DocumentMessage::Navigation(message) => {
Expand Down
4 changes: 4 additions & 0 deletions editor/src/node_graph_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl NodeGraphExecutor {

/// Adds an evaluate request for whatever current network is cached.
pub(crate) fn submit_current_node_graph_evaluation(&mut self, document: &mut DocumentMessageHandler, viewport_resolution: UVec2, time: TimingInformation) -> Result<(), String> {
let disable_canvas_override = document.disable_canvas_override;
let render_config = RenderConfig {
viewport: Footprint {
transform: document.metadata().document_to_viewport,
Expand All @@ -150,6 +151,7 @@ impl NodeGraphExecutor {
view_mode: document.view_mode,
hide_artboards: false,
for_export: false,
disable_canvas_override,
};

// Execute the node graph
Expand Down Expand Up @@ -200,6 +202,7 @@ impl NodeGraphExecutor {
view_mode: document.view_mode,
hide_artboards: export_config.transparent_background,
for_export: true,
disable_canvas_override: false,
};
export_config.size = size;

Expand Down Expand Up @@ -336,6 +339,7 @@ impl NodeGraphExecutor {
for_export: false,
for_mask: false,
alignment_parent_transform: None,
disable_canvas_override: false
};

// Render SVG
Expand Down
1 change: 1 addition & 0 deletions editor/src/node_graph_executor/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ impl NodeRuntime {
hide_artboards: false,
for_export: false,
for_mask: false,
disable_canvas_override: false,
alignment_parent_transform: None,
};
let mut render = SvgRender::new();
Expand Down
1 change: 1 addition & 0 deletions node-graph/gapplication-io/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ pub struct RenderConfig {
pub view_mode: ViewMode,
pub hide_artboards: bool,
pub for_export: bool,
pub disable_canvas_override: bool
}

struct Logger;
Expand Down
9 changes: 8 additions & 1 deletion node-graph/gstd/src/wasm_application_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ where
let resolution = footprint.resolution;
let render_params = RenderParams {
culling_bounds: None,
disable_canvas_override: false,
..Default::default()
};

Expand Down Expand Up @@ -311,7 +312,12 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>(
.into_context();
ctx.footprint();

let RenderConfig { hide_artboards, for_export, .. } = render_config;
let RenderConfig {
hide_artboards,
for_export,
disable_canvas_override,
..
} = render_config;
let render_params = RenderParams {
view_mode: render_config.view_mode,
culling_bounds: None,
Expand All @@ -320,6 +326,7 @@ async fn render<'a: 'n, T: 'n + GraphicElementRendered + WasmNotSend>(
for_export,
for_mask: false,
alignment_parent_transform: None,
disable_canvas_override,
};

let data = data.eval(ctx.clone()).await;
Expand Down
6 changes: 4 additions & 2 deletions node-graph/gsvg-renderer/src/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ pub struct RenderParams {
pub for_export: bool,
/// Are we generating a mask in this render pass? Used to see if fill should be multiplied with alpha.
pub for_mask: bool,
/// Are we generating a mask for alignment? Used to prevent unnecesary transforms in masks
/// Are we generating a mask for alignment? Used to prevent unnecesary transforms in masks.
pub alignment_parent_transform: Option<DAffine2>,
/// Whether or not if rendering image data via the canvas should be disabled forcefully. Currently it only checks for eyedropper.
pub disable_canvas_override: bool,
}

impl RenderParams {
Expand All @@ -178,7 +180,7 @@ impl RenderParams {
}

pub fn to_canvas(&self) -> bool {
!self.for_export && !self.thumbnail && !self.for_mask
!self.disable_canvas_override && !self.for_export && !self.thumbnail && !self.for_mask
}
}

Expand Down
Loading