Skip to content

Commit 7b64c73

Browse files
committed
Rename TextureFrame to ImageTexture
1 parent f4943e1 commit 7b64c73

File tree

8 files changed

+43
-34
lines changed

8 files changed

+43
-34
lines changed

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use graphene_core::raster::{
1919
use graphene_core::text::Font;
2020
use graphene_core::vector::misc::CentroidType;
2121
use graphene_core::vector::style::{GradientType, LineCap, LineJoin};
22-
use graphene_std::application_io::TextureFrame;
22+
use graphene_std::application_io::TextureFrameTable;
2323
use graphene_std::transform::Footprint;
2424
use graphene_std::vector::misc::BooleanOperation;
2525
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops};
@@ -154,7 +154,7 @@ pub(crate) fn property_from_type(node_id: NodeId, index: usize, ty: &Type, numbe
154154
Some(x) if x == TypeId::of::<Curve>() => curves_widget(document_node, node_id, index, name, true),
155155
Some(x) if x == TypeId::of::<GradientStops>() => color_widget(document_node, node_id, index, name, ColorButton::default().allow_none(false), true),
156156
Some(x) if x == TypeId::of::<VectorDataTable>() => vector_widget(document_node, node_id, index, name, true).into(),
157-
Some(x) if x == TypeId::of::<RasterFrame>() || x == TypeId::of::<ImageFrameTable<Color>>() || x == TypeId::of::<TextureFrame>() => {
157+
Some(x) if x == TypeId::of::<RasterFrame>() || x == TypeId::of::<ImageFrameTable<Color>>() || x == TypeId::of::<TextureFrameTable>() => {
158158
raster_widget(document_node, node_id, index, name, true).into()
159159
}
160160
Some(x) if x == TypeId::of::<GraphicGroupTable>() => group_widget(document_node, node_id, index, name, true).into(),

node-graph/gcore/src/application_io.rs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,24 +64,25 @@ impl Size for web_sys::HtmlCanvasElement {
6464
}
6565
}
6666

67-
pub type TextureFrameTable = Instances<TextureFrame>;
67+
// TODO: Rename to ImageTextureTable
68+
pub type TextureFrameTable = Instances<ImageTexture>;
6869

6970
#[derive(Debug, Clone)]
70-
pub struct TextureFrame {
71+
pub struct ImageTexture {
7172
#[cfg(feature = "wgpu")]
7273
pub texture: Arc<wgpu::Texture>,
7374
#[cfg(not(feature = "wgpu"))]
7475
pub texture: (),
7576
}
7677

77-
impl Hash for TextureFrame {
78+
impl Hash for ImageTexture {
7879
fn hash<H: Hasher>(&self, state: &mut H) {
7980
#[cfg(feature = "wgpu")]
8081
self.texture.hash(state);
8182
}
8283
}
8384

84-
impl PartialEq for TextureFrame {
85+
impl PartialEq for ImageTexture {
8586
fn eq(&self, other: &Self) -> bool {
8687
#[cfg(feature = "wgpu")]
8788
return self.texture == other.texture;
@@ -91,12 +92,12 @@ impl PartialEq for TextureFrame {
9192
}
9293
}
9394

94-
unsafe impl StaticType for TextureFrame {
95-
type Static = TextureFrame;
95+
unsafe impl StaticType for ImageTexture {
96+
type Static = ImageTexture;
9697
}
9798

9899
#[cfg(feature = "wgpu")]
99-
impl Size for TextureFrame {
100+
impl Size for ImageTexture {
100101
fn size(&self) -> UVec2 {
101102
UVec2::new(self.texture.width(), self.texture.height())
102103
}

node-graph/gcore/src/graphic_element.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::application_io::{TextureFrame, TextureFrameTable};
1+
use crate::application_io::{ImageTexture, TextureFrameTable};
22
use crate::instances::Instances;
33
use crate::raster::image::{Image, ImageFrameTable};
44
use crate::raster::BlendMode;
@@ -106,9 +106,9 @@ impl From<ImageFrameTable<Color>> for GraphicGroupTable {
106106
Self::new(GraphicGroup::new(vec![GraphicElement::RasterFrame(RasterFrame::ImageFrame(image_frame))]))
107107
}
108108
}
109-
impl From<TextureFrame> for GraphicGroupTable {
110-
fn from(texture_frame: TextureFrame) -> Self {
111-
Self::new(GraphicGroup::new(vec![GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(texture_frame)))]))
109+
impl From<ImageTexture> for GraphicGroupTable {
110+
fn from(image_texture: ImageTexture) -> Self {
111+
Self::new(GraphicGroup::new(vec![GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(image_texture)))]))
112112
}
113113
}
114114
impl From<TextureFrameTable> for GraphicGroupTable {
@@ -179,11 +179,14 @@ impl GraphicElement {
179179
}
180180
}
181181

182+
// TODO: Rename to Raster
182183
#[derive(Clone, Debug, Hash, PartialEq, DynAny)]
183184
pub enum RasterFrame {
184185
/// A CPU-based bitmap image with a finite position and extent, equivalent to the SVG <image> tag: https://developer.mozilla.org/en-US/docs/Web/SVG/Element/image
186+
// TODO: Rename to ImageTable
185187
ImageFrame(ImageFrameTable<Color>),
186188
/// A GPU texture with a finite position and extent
189+
// TODO: Rename to ImageTextureTable
187190
TextureFrame(TextureFrameTable),
188191
}
189192

@@ -224,7 +227,7 @@ impl Artboard {
224227
pub fn new(location: IVec2, dimensions: IVec2) -> Self {
225228
Self {
226229
graphic_group: GraphicGroupTable::default(),
227-
label: String::from("Artboard"),
230+
label: "Artboard".to_string(),
228231
location: location.min(location + dimensions),
229232
dimensions: dimensions.abs(),
230233
background: Color::WHITE,
@@ -375,7 +378,8 @@ async fn append_artboard<C: Ctx + Clone + 'n>(
375378
let artboard = artboard.eval(ctx).await;
376379
// let foot = ctx.footprint();
377380
// log::debug!("{:?}", foot);
378-
// Get the penultimate element of the node path, or None if the path is too short
381+
// Get the penultimate element of the node path, or None if the path is too short.
382+
// This is used to get the ID of the user-facing "Artboard" node (which encapsulates this internal "Append Artboard" node).
379383
let encapsulating_node_id = node_path.get(node_path.len().wrapping_sub(2)).copied();
380384
artboards.append_artboard(artboard, encapsulating_node_id);
381385

@@ -394,8 +398,8 @@ impl From<ImageFrameTable<Color>> for GraphicElement {
394398
}
395399
}
396400
// TODO: Remove this one
397-
impl From<TextureFrame> for GraphicElement {
398-
fn from(texture: TextureFrame) -> Self {
401+
impl From<ImageTexture> for GraphicElement {
402+
fn from(texture: ImageTexture) -> Self {
399403
GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(texture)))
400404
}
401405
}
@@ -446,7 +450,7 @@ trait ToGraphicElement: Into<GraphicElement> {}
446450

447451
impl ToGraphicElement for VectorDataTable {}
448452
impl ToGraphicElement for ImageFrameTable<Color> {}
449-
impl ToGraphicElement for TextureFrame {}
453+
impl ToGraphicElement for ImageTexture {}
450454

451455
impl<T> From<T> for GraphicGroup
452456
where

node-graph/gcore/src/graphic_element/renderer.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ pub struct RenderMetadata {
276276
pub clip_targets: HashSet<NodeId>,
277277
}
278278

279+
// TODO: Rename to "Graphical"
279280
pub trait GraphicElementRendered {
280281
fn render_svg(&self, render: &mut SvgRender, render_params: &RenderParams);
281282

@@ -992,8 +993,8 @@ impl GraphicElementRendered for RasterFrame {
992993
};
993994

994995
match self {
995-
RasterFrame::ImageFrame(image_frame) => {
996-
for instance in image_frame.instances() {
996+
RasterFrame::ImageFrame(image) => {
997+
for instance in image.instances() {
997998
let image = &instance.instance;
998999
if image.data.is_empty() {
9991000
return;
@@ -1004,8 +1005,8 @@ impl GraphicElementRendered for RasterFrame {
10041005
render_stuff(image, *instance.alpha_blending);
10051006
}
10061007
}
1007-
RasterFrame::TextureFrame(texture) => {
1008-
for instance in texture.instances() {
1008+
RasterFrame::TextureFrame(image_texture) => {
1009+
for instance in image_texture.instances() {
10091010
let image =
10101011
vello::peniko::Image::new(vec![].into(), peniko::Format::Rgba8, instance.instance.texture.width(), instance.instance.texture.height()).with_extend(peniko::Extend::Repeat);
10111012

node-graph/gcore/src/instances.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::application_io::{TextureFrame, TextureFrameTable};
1+
use crate::application_io::{ImageTexture, TextureFrameTable};
22
use crate::raster::image::{Image, ImageFrameTable};
33
use crate::raster::Pixel;
44
use crate::transform::{Transform, TransformMut};
@@ -171,18 +171,18 @@ impl TransformMut for GraphicGroupTable {
171171
}
172172
}
173173

174-
// TEXTURE FRAME
175-
impl Transform for Instance<'_, TextureFrame> {
174+
// IMAGE TEXTURE
175+
impl Transform for Instance<'_, ImageTexture> {
176176
fn transform(&self) -> DAffine2 {
177177
*self.transform
178178
}
179179
}
180-
impl Transform for InstanceMut<'_, TextureFrame> {
180+
impl Transform for InstanceMut<'_, ImageTexture> {
181181
fn transform(&self) -> DAffine2 {
182182
*self.transform
183183
}
184184
}
185-
impl TransformMut for InstanceMut<'_, TextureFrame> {
185+
impl TransformMut for InstanceMut<'_, ImageTexture> {
186186
fn transform_mut(&mut self) -> &mut DAffine2 {
187187
self.transform
188188
}

node-graph/gcore/src/raster/image.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ pub struct Image<P: Pixel> {
5353
/// to an svg string. This is used as a cache in order to not have to encode the data on every graph evaluation.
5454
#[cfg_attr(feature = "serde", serde(skip))]
5555
pub base64_string: Option<String>,
56+
// TODO: Add an `origin` field to store where in the local space the image is anchored.
57+
// TODO: Currently it is always anchored at the top left corner at (0, 0). The bottom right corner of the new origin field would correspond to (1, 1).
5658
}
5759

5860
impl<P: Pixel + Debug> Debug for Image<P> {
@@ -256,6 +258,7 @@ pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) ->
256258
})
257259
}
258260

261+
// TODO: Rename to ImageTable
259262
pub type ImageFrameTable<P> = Instances<Image<P>>;
260263

261264
/// Construct a 0x0 image frame table. This is useful because ImageFrameTable::default() will return a 1x1 image frame table.

node-graph/interpreted-executor/src/node_registry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use graphene_core::{concrete, generic, Artboard, GraphicGroupTable};
1212
use graphene_core::{Cow, ProtoNodeIdentifier, Type};
1313
use graphene_core::{Node, NodeIO, NodeIOTypes};
1414
use graphene_std::any::{ComposeTypeErased, DowncastBothNode, DynAnyNode, FutureWrapperNode, IntoTypeErasedNode};
15-
use graphene_std::application_io::TextureFrame;
15+
use graphene_std::application_io::ImageTexture;
1616
use graphene_std::wasm_application_io::*;
1717
use graphene_std::Context;
1818
use graphene_std::GraphicElement;
@@ -122,7 +122,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
122122
async_node!(graphene_core::ops::IntoNode<GraphicGroupTable>, input: VectorDataTable, params: []),
123123
async_node!(graphene_core::ops::IntoNode<GraphicGroupTable>, input: ImageFrameTable<Color>, params: []),
124124
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ImageFrameTable<Color>]),
125-
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => TextureFrame]),
125+
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ImageTexture]),
126126
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => VectorDataTable]),
127127
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicGroupTable]),
128128
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicElement]),
@@ -293,7 +293,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
293293
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => ShaderInputFrame]),
294294
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => WgpuSurface]),
295295
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => Option<WgpuSurface>]),
296-
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => TextureFrame]),
296+
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => ImageTexture]),
297297
];
298298
let mut map: HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> = HashMap::new();
299299
for (id, entry) in graphene_core::registry::NODE_REGISTRY.lock().unwrap().iter() {

node-graph/wgpu-executor/src/lib.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub use executor::GpuExecutor;
66

77
use dyn_any::{DynAny, StaticType};
88
use gpu_executor::{ComputePassDimensions, GPUConstant, StorageBufferOptions, TextureBufferOptions, TextureBufferType, ToStorageBuffer, ToUniformBuffer};
9-
use graphene_core::application_io::{ApplicationIo, EditorApi, SurfaceHandle, TextureFrame};
9+
use graphene_core::application_io::{ApplicationIo, EditorApi, ImageTexture, SurfaceHandle};
1010
use graphene_core::raster::image::ImageFrameTable;
1111
use graphene_core::raster::{Image, SRGBA8};
1212
use graphene_core::transform::{Footprint, Transform};
@@ -912,7 +912,7 @@ async fn render_texture<'a: 'n>(
912912
}
913913

914914
#[node_macro::node(category(""))]
915-
async fn upload_texture<'a: 'n>(_: impl ExtractFootprint + Ctx, input: ImageFrameTable<Color>, executor: &'a WgpuExecutor) -> TextureFrame {
915+
async fn upload_texture<'a: 'n>(_: impl ExtractFootprint + Ctx, input: ImageFrameTable<Color>, executor: &'a WgpuExecutor) -> ImageTexture {
916916
// let new_data: Vec<RGBA16F> = input.image.data.into_iter().map(|c| c.into()).collect();
917917

918918
let input = input.one_instance().instance;
@@ -931,9 +931,9 @@ async fn upload_texture<'a: 'n>(_: impl ExtractFootprint + Ctx, input: ImageFram
931931
_ => unreachable!("Unsupported ShaderInput type"),
932932
};
933933

934-
TextureFrame {
934+
ImageTexture {
935935
texture: texture.into(),
936-
// TODO: Find an alternate way to encode the transform and alpha_blend now that these fields have been moved up out of TextureFrame
936+
// TODO: Find an alternate way to encode the transform and alpha_blend now that these fields have been moved up out of ImageTexture
937937
// transform: input.transform,
938938
// alpha_blend: Default::default(),
939939
}

0 commit comments

Comments
 (0)