Skip to content

Commit 1771b3c

Browse files
committed
Rename TextureFrame to ImageTexture
1 parent 1ede93f commit 1771b3c

File tree

8 files changed

+43
-38
lines changed

8 files changed

+43
-38
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
@@ -20,7 +20,7 @@ use graphene_core::raster::{
2020
use graphene_core::text::Font;
2121
use graphene_core::vector::misc::CentroidType;
2222
use graphene_core::vector::style::{GradientType, LineCap, LineJoin};
23-
use graphene_std::application_io::TextureFrame;
23+
use graphene_std::application_io::TextureFrameTable;
2424
use graphene_std::transform::Footprint;
2525
use graphene_std::vector::misc::BooleanOperation;
2626
use graphene_std::vector::style::{Fill, FillChoice, FillType, GradientStops};
@@ -159,7 +159,7 @@ pub(crate) fn property_from_type(
159159
Some(x) if x == TypeId::of::<Curve>() => curves_widget(document_node, node_id, index, name, true),
160160
Some(x) if x == TypeId::of::<GradientStops>() => color_widget(document_node, node_id, index, name, ColorInput::default().allow_none(false), true),
161161
Some(x) if x == TypeId::of::<VectorDataTable>() => vector_widget(document_node, node_id, index, name, true).into(),
162-
Some(x) if x == TypeId::of::<RasterFrame>() || x == TypeId::of::<ImageFrameTable<Color>>() || x == TypeId::of::<TextureFrame>() => {
162+
Some(x) if x == TypeId::of::<RasterFrame>() || x == TypeId::of::<ImageFrameTable<Color>>() || x == TypeId::of::<TextureFrameTable>() => {
163163
raster_widget(document_node, node_id, index, name, true).into()
164164
}
165165
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,17 +64,18 @@ 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
#[cfg(feature = "wgpu")]
7980
fn hash<H: Hasher>(&self, state: &mut H) {
8081
self.texture.hash(state);
@@ -83,18 +84,18 @@ impl Hash for TextureFrame {
8384
fn hash<H: Hasher>(&self, _state: &mut H) {}
8485
}
8586

86-
impl PartialEq for TextureFrame {
87+
impl PartialEq for ImageTexture {
8788
fn eq(&self, other: &Self) -> bool {
8889
self.texture == other.texture
8990
}
9091
}
9192

92-
unsafe impl StaticType for TextureFrame {
93-
type Static = TextureFrame;
93+
unsafe impl StaticType for ImageTexture {
94+
type Static = ImageTexture;
9495
}
9596

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

node-graph/gcore/src/graphic_element.rs

Lines changed: 13 additions & 13 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;
@@ -121,9 +121,9 @@ impl From<ImageFrameTable<Color>> for GraphicGroupTable {
121121
Self::new(GraphicGroup::new(vec![GraphicElement::RasterFrame(RasterFrame::ImageFrame(image_frame))]))
122122
}
123123
}
124-
impl From<TextureFrame> for GraphicGroupTable {
125-
fn from(texture_frame: TextureFrame) -> Self {
126-
Self::new(GraphicGroup::new(vec![GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(texture_frame)))]))
124+
impl From<ImageTexture> for GraphicGroupTable {
125+
fn from(image_texture: ImageTexture) -> Self {
126+
Self::new(GraphicGroup::new(vec![GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(image_texture)))]))
127127
}
128128
}
129129
impl From<TextureFrameTable> for GraphicGroupTable {
@@ -194,11 +194,14 @@ impl GraphicElement {
194194
}
195195
}
196196

197+
// TODO: Rename to Raster
197198
#[derive(Clone, Debug, Hash, PartialEq, DynAny)]
198199
pub enum RasterFrame {
199200
/// 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
201+
// TODO: Rename to ImageTable
200202
ImageFrame(ImageFrameTable<Color>),
201203
/// A GPU texture with a finite position and extent
204+
// TODO: Rename to ImageTextureTable
202205
TextureFrame(TextureFrameTable),
203206
}
204207

@@ -239,7 +242,7 @@ impl Artboard {
239242
pub fn new(location: IVec2, dimensions: IVec2) -> Self {
240243
Self {
241244
graphic_group: GraphicGroupTable::default(),
242-
label: String::from("Artboard"),
245+
label: "Artboard".to_string(),
243246
location: location.min(location + dimensions),
244247
dimensions: dimensions.abs(),
245248
background: Color::WHITE,
@@ -387,11 +390,8 @@ async fn append_artboard(_ctx: impl Ctx, mut artboards: ArtboardGroup, artboard:
387390
// let artboard = artboard.eval(ctx).await;
388391
// let foot = ctx.footprint();
389392
// log::debug!("{:?}", foot);
390-
// Get the penultimate element of the node path, or None if the path is too short
391-
392-
// TODO: Delete this line
393-
let _ctx = ctx;
394-
393+
// Get the penultimate element of the node path, or None if the path is too short.
394+
// This is used to get the ID of the user-facing "Artboard" node (which encapsulates this internal "Append Artboard" node).
395395
let encapsulating_node_id = node_path.get(node_path.len().wrapping_sub(2)).copied();
396396
artboards.append_artboard(artboard, encapsulating_node_id);
397397

@@ -410,8 +410,8 @@ impl From<ImageFrameTable<Color>> for GraphicElement {
410410
}
411411
}
412412
// TODO: Remove this one
413-
impl From<TextureFrame> for GraphicElement {
414-
fn from(texture: TextureFrame) -> Self {
413+
impl From<ImageTexture> for GraphicElement {
414+
fn from(texture: ImageTexture) -> Self {
415415
GraphicElement::RasterFrame(RasterFrame::TextureFrame(TextureFrameTable::new(texture)))
416416
}
417417
}
@@ -462,7 +462,7 @@ trait ToGraphicElement: Into<GraphicElement> {}
462462

463463
impl ToGraphicElement for VectorDataTable {}
464464
impl ToGraphicElement for ImageFrameTable<Color> {}
465-
impl ToGraphicElement for TextureFrame {}
465+
impl ToGraphicElement for ImageTexture {}
466466

467467
impl<T> From<T> for GraphicGroup
468468
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};
@@ -180,18 +180,18 @@ impl TransformMut for GraphicGroupTable {
180180
}
181181
}
182182

183-
// TEXTURE FRAME
184-
impl Transform for Instance<'_, TextureFrame> {
183+
// IMAGE TEXTURE
184+
impl Transform for Instance<'_, ImageTexture> {
185185
fn transform(&self) -> DAffine2 {
186186
*self.transform
187187
}
188188
}
189-
impl Transform for InstanceMut<'_, TextureFrame> {
189+
impl Transform for InstanceMut<'_, ImageTexture> {
190190
fn transform(&self) -> DAffine2 {
191191
*self.transform
192192
}
193193
}
194-
impl TransformMut for InstanceMut<'_, TextureFrame> {
194+
impl TransformMut for InstanceMut<'_, ImageTexture> {
195195
fn transform_mut(&mut self) -> &mut DAffine2 {
196196
self.transform
197197
}

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> {
@@ -272,6 +274,7 @@ pub fn migrate_image_frame<'de, D: serde::Deserializer<'de>>(deserializer: D) ->
272274
})
273275
}
274276

277+
// TODO: Rename to ImageTable
275278
pub type ImageFrameTable<P> = Instances<Image<P>>;
276279

277280
/// 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::{fn_type_fut, future};
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;
@@ -79,7 +79,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
7979
async_node!(graphene_core::ops::IntoNode<GraphicGroupTable>, input: VectorDataTable, params: []),
8080
async_node!(graphene_core::ops::IntoNode<GraphicGroupTable>, input: ImageFrameTable<Color>, params: []),
8181
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ImageFrameTable<Color>]),
82-
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => TextureFrame]),
82+
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => ImageTexture]),
8383
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => VectorDataTable]),
8484
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicGroupTable]),
8585
async_node!(graphene_core::memo::MonitorNode<_, _, _>, input: Context, fn_params: [Context => GraphicElement]),
@@ -268,7 +268,7 @@ fn node_registry() -> HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeCons
268268
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => ShaderInputFrame]),
269269
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => WgpuSurface]),
270270
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => Option<WgpuSurface>]),
271-
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => TextureFrame]),
271+
async_node!(graphene_core::memo::ImpureMemoNode<_, _, _>, input: Context, fn_params: [Context => ImageTexture]),
272272
];
273273
let mut map: HashMap<ProtoNodeIdentifier, HashMap<NodeIOTypes, NodeConstructor>> = HashMap::new();
274274
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)