mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-18 07:48:02 +08:00
Instance tables refactor part 7: Remove RasterDataType and add Raster<CPU>/Raster<GPU>
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
use bezier_rs::{ManipulatorGroup, Subpath};
|
||||
use glam::{DAffine2, DVec2};
|
||||
use graphene_core::RasterDataType;
|
||||
use graphene_core::instances::{Instance, InstanceRef};
|
||||
use graphene_core::vector::misc::BooleanOperation;
|
||||
use graphene_core::vector::style::Fill;
|
||||
@@ -203,7 +202,7 @@ fn flatten_vector_data(graphic_group_table: &GraphicGroupTable) -> VectorDataTab
|
||||
result_table.push(sub_vector_data);
|
||||
}
|
||||
}
|
||||
GraphicElement::RasterDataType(image) => {
|
||||
GraphicElement::RasterDataCPU(image) => {
|
||||
let make_instance = |transform| {
|
||||
// Convert the image frame into a rectangular subpath with the image's transform
|
||||
let mut subpath = Subpath::new_rect(DVec2::ZERO, DVec2::ONE);
|
||||
@@ -217,17 +216,26 @@ fn flatten_vector_data(graphic_group_table: &GraphicGroupTable) -> VectorDataTab
|
||||
};
|
||||
|
||||
// Apply the parent group's transform to each element of raster data
|
||||
match image {
|
||||
RasterDataType::RasterData(image) => {
|
||||
for instance in image.instance_ref_iter() {
|
||||
result_table.push(make_instance(*element.transform * *instance.transform));
|
||||
}
|
||||
}
|
||||
RasterDataType::TextureData(image) => {
|
||||
for instance in image.instance_ref_iter() {
|
||||
result_table.push(make_instance(*element.transform * *instance.transform));
|
||||
}
|
||||
}
|
||||
for instance in image.instance_ref_iter() {
|
||||
result_table.push(make_instance(*element.transform * *instance.transform));
|
||||
}
|
||||
}
|
||||
GraphicElement::RasterDataGPU(image) => {
|
||||
let make_instance = |transform| {
|
||||
// Convert the image frame into a rectangular subpath with the image's transform
|
||||
let mut subpath = Subpath::new_rect(DVec2::ZERO, DVec2::ONE);
|
||||
subpath.apply_transform(transform);
|
||||
|
||||
// Create a vector data table row from the rectangular subpath, with a default black fill
|
||||
let mut instance = VectorData::from_subpath(subpath);
|
||||
instance.style.set_fill(Fill::Solid(Color::BLACK));
|
||||
|
||||
Instance { instance, ..Default::default() }
|
||||
};
|
||||
|
||||
// Apply the parent group's transform to each element of raster data
|
||||
for instance in image.instance_ref_iter() {
|
||||
result_table.push(make_instance(*element.transform * *instance.transform));
|
||||
}
|
||||
}
|
||||
GraphicElement::GraphicGroup(mut graphic_group) => {
|
||||
|
||||
Reference in New Issue
Block a user