mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-07-15 03:35:00 +00:00
Rename Raster to Bitmap
This commit is contained in:
parent
c5ed54cbd2
commit
5a6815dd91
9 changed files with 26 additions and 28 deletions
|
@ -56,7 +56,7 @@ pub enum FrontendMessage {
|
|||
#[serde(rename = "blobUrl")]
|
||||
blob_url: String,
|
||||
},
|
||||
TriggerDownloadRaster {
|
||||
TriggerDownloadImage {
|
||||
svg: String,
|
||||
name: String,
|
||||
mime: String,
|
||||
|
|
|
@ -388,7 +388,7 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
|||
} else {
|
||||
let mime = file_type.to_mime().to_string();
|
||||
let size = (size * scale_factor).into();
|
||||
responses.add(FrontendMessage::TriggerDownloadRaster { svg: document, name, mime, size });
|
||||
responses.add(FrontendMessage::TriggerDownloadImage { svg: document, name, mime, size });
|
||||
}
|
||||
}
|
||||
FlipSelectedLayers { flip_axis } => {
|
||||
|
|
|
@ -742,9 +742,8 @@ pub fn load_image_properties(document_node: &DocumentNode, node_id: NodeId, _con
|
|||
|
||||
pub fn output_properties(_document_node: &DocumentNode, _node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
let output_type = context.executor.previous_output_type(context.layer_path);
|
||||
let raster_output_type = concrete!(ImageFrame<Color>);
|
||||
let disabled = match output_type {
|
||||
Some(output_type) => output_type != raster_output_type,
|
||||
Some(output_type) => output_type != concrete!(ImageFrame<Color>),
|
||||
None => true,
|
||||
};
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
TriggerCopyToClipboardBlobUrl,
|
||||
TriggerFetchAndOpenDocument,
|
||||
TriggerDownloadBlobUrl,
|
||||
TriggerDownloadRaster,
|
||||
TriggerDownloadImage,
|
||||
TriggerDownloadTextFile,
|
||||
TriggerImport,
|
||||
TriggerOpenDocument,
|
||||
|
@ -83,8 +83,8 @@ export function createPortfolioState(editor: Editor) {
|
|||
editor.subscriptions.subscribeJsMessage(TriggerCopyToClipboardBlobUrl, (triggerDownloadBlobUrl) => {
|
||||
copyToClipboardFileURL(triggerDownloadBlobUrl.blobUrl);
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerDownloadRaster, async (triggerRasterDownload) => {
|
||||
const { svg, name, mime, size } = triggerRasterDownload;
|
||||
editor.subscriptions.subscribeJsMessage(TriggerDownloadImage, async (triggerDownloadImage) => {
|
||||
const { svg, name, mime, size } = triggerDownloadImage;
|
||||
|
||||
// Fill the canvas with white if it'll be a JPEG (which does not support transparency and defaults to black)
|
||||
const backgroundColor = mime.endsWith("jpeg") ? "white" : undefined;
|
||||
|
|
|
@ -541,7 +541,7 @@ export class TriggerDownloadBlobUrl extends JsMessage {
|
|||
readonly blobUrl!: string;
|
||||
}
|
||||
|
||||
export class TriggerDownloadRaster extends JsMessage {
|
||||
export class TriggerDownloadImage extends JsMessage {
|
||||
readonly svg!: string;
|
||||
|
||||
readonly name!: string;
|
||||
|
@ -1402,7 +1402,7 @@ export const messageMakers: Record<string, MessageMaker> = {
|
|||
TriggerCopyToClipboardBlobUrl,
|
||||
TriggerFetchAndOpenDocument,
|
||||
TriggerDownloadBlobUrl,
|
||||
TriggerDownloadRaster,
|
||||
TriggerDownloadImage,
|
||||
TriggerDownloadTextFile,
|
||||
TriggerFontLoad,
|
||||
TriggerGraphViewOverlay,
|
||||
|
|
|
@ -222,15 +222,14 @@ impl<'i, T: Sample> Sample for &'i T {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO: We might rename this to Bitmap at some point
|
||||
pub trait Raster {
|
||||
pub trait Bitmap {
|
||||
type Pixel: Pixel;
|
||||
fn width(&self) -> u32;
|
||||
fn height(&self) -> u32;
|
||||
fn get_pixel(&self, x: u32, y: u32) -> Option<Self::Pixel>;
|
||||
}
|
||||
|
||||
impl<'i, T: Raster> Raster for &'i T {
|
||||
impl<'i, T: Bitmap> Bitmap for &'i T {
|
||||
type Pixel = T::Pixel;
|
||||
|
||||
fn width(&self) -> u32 {
|
||||
|
@ -246,7 +245,7 @@ impl<'i, T: Raster> Raster for &'i T {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'i, T: Raster> Raster for &'i mut T {
|
||||
impl<'i, T: Bitmap> Bitmap for &'i mut T {
|
||||
type Pixel = T::Pixel;
|
||||
|
||||
fn width(&self) -> u32 {
|
||||
|
@ -262,7 +261,7 @@ impl<'i, T: Raster> Raster for &'i mut T {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait RasterMut: Raster {
|
||||
pub trait BitmapMut: Bitmap {
|
||||
fn get_pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut Self::Pixel>;
|
||||
fn set_pixel(&mut self, x: u32, y: u32, pixel: Self::Pixel) {
|
||||
*self.get_pixel_mut(x, y).unwrap() = pixel;
|
||||
|
@ -277,7 +276,7 @@ pub trait RasterMut: Raster {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'i, T: RasterMut + Raster> RasterMut for &'i mut T {
|
||||
impl<'i, T: BitmapMut + Bitmap> BitmapMut for &'i mut T {
|
||||
fn get_pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut Self::Pixel> {
|
||||
(*self).get_pixel_mut(x, y)
|
||||
}
|
||||
|
@ -567,7 +566,7 @@ impl<'a, P> Default for ImageSlice<'a, P> {
|
|||
}
|
||||
|
||||
#[cfg(not(target_arch = "spirv"))]
|
||||
impl<P: Copy + Debug + Pixel> Raster for ImageSlice<'_, P> {
|
||||
impl<P: Copy + Debug + Pixel> Bitmap for ImageSlice<'_, P> {
|
||||
type Pixel = P;
|
||||
fn get_pixel(&self, x: u32, y: u32) -> Option<P> {
|
||||
self.data.get((x + y * self.width) as usize).copied()
|
||||
|
|
|
@ -66,7 +66,7 @@ where
|
|||
type Static = Image<P::Static>;
|
||||
}
|
||||
|
||||
impl<P: Copy + Pixel> Raster for Image<P> {
|
||||
impl<P: Copy + Pixel> Bitmap for Image<P> {
|
||||
type Pixel = P;
|
||||
#[inline(always)]
|
||||
fn get_pixel(&self, x: u32, y: u32) -> Option<P> {
|
||||
|
@ -82,7 +82,7 @@ impl<P: Copy + Pixel> Raster for Image<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: Copy + Pixel> RasterMut for Image<P> {
|
||||
impl<P: Copy + Pixel> BitmapMut for Image<P> {
|
||||
fn get_pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut P> {
|
||||
self.data.get_mut((x + y * self.width) as usize)
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ impl<P: Debug + Copy + Pixel> Sample for ImageFrame<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: Copy + Pixel> Raster for ImageFrame<P> {
|
||||
impl<P: Copy + Pixel> Bitmap for ImageFrame<P> {
|
||||
type Pixel = P;
|
||||
|
||||
fn width(&self) -> u32 {
|
||||
|
@ -294,7 +294,7 @@ impl<P: Copy + Pixel> Raster for ImageFrame<P> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<P: Copy + Pixel> RasterMut for ImageFrame<P> {
|
||||
impl<P: Copy + Pixel> BitmapMut for ImageFrame<P> {
|
||||
fn get_pixel_mut(&mut self, x: u32, y: u32) -> Option<&mut Self::Pixel> {
|
||||
self.image.get_pixel_mut(x, y)
|
||||
}
|
||||
|
|
|
@ -352,5 +352,5 @@ impl UpcastNode {
|
|||
pub enum RenderOutput {
|
||||
CanvasFrame(graphene_core::SurfaceFrame),
|
||||
Svg(String),
|
||||
Raster(Vec<u8>),
|
||||
Image(Vec<u8>),
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ use dyn_any::{DynAny, StaticType};
|
|||
use glam::{DAffine2, DVec2, Vec2};
|
||||
use graph_craft::imaginate_input::{ImaginateController, ImaginateMaskStartingFill, ImaginateSamplingMethod};
|
||||
use graph_craft::proto::DynFuture;
|
||||
use graphene_core::raster::{Alpha, BlendMode, BlendNode, Image, ImageFrame, Linear, LinearChannel, Luminance, NoiseType, Pixel, RGBMut, Raster, RasterMut, RedGreenBlue, Sample};
|
||||
use graphene_core::raster::{Alpha, Bitmap, BitmapMut, BlendMode, BlendNode, Image, ImageFrame, Linear, LinearChannel, Luminance, NoiseType, Pixel, RGBMut, RedGreenBlue, Sample};
|
||||
use graphene_core::transform::{Footprint, Transform};
|
||||
|
||||
use crate::wasm_application_io::WasmEditorApi;
|
||||
|
@ -126,7 +126,7 @@ pub struct MapImageNode<P, MapFn> {
|
|||
}
|
||||
|
||||
#[node_macro::node_fn(MapImageNode<_P>)]
|
||||
fn map_image<MapFn, _P, Img: RasterMut<Pixel = _P>>(image: Img, map_fn: &'input MapFn) -> Img
|
||||
fn map_image<MapFn, _P, Img: BitmapMut<Pixel = _P>>(image: Img, map_fn: &'input MapFn) -> Img
|
||||
where
|
||||
MapFn: for<'any_input> Node<'any_input, _P, Output = _P> + 'input,
|
||||
{
|
||||
|
@ -150,8 +150,8 @@ fn insert_channel_node<
|
|||
_P: RGBMut,
|
||||
_S: Pixel + Luminance,
|
||||
// Input image
|
||||
Input: RasterMut<Pixel = _P>,
|
||||
Insertion: Raster<Pixel = _S>,
|
||||
Input: BitmapMut<Pixel = _P>,
|
||||
Insertion: Bitmap<Pixel = _S>,
|
||||
>(
|
||||
mut image: Input,
|
||||
insertion: Insertion,
|
||||
|
@ -200,7 +200,7 @@ fn mask_imge<
|
|||
// mask the input image
|
||||
_S: Luminance,
|
||||
// Input image
|
||||
Input: Transform + RasterMut<Pixel = _P>,
|
||||
Input: Transform + BitmapMut<Pixel = _P>,
|
||||
// Stencil
|
||||
Stencil: Transform + Sample<Pixel = _S>,
|
||||
>(
|
||||
|
@ -316,7 +316,7 @@ where
|
|||
blend_image(foreground, new_background, map_fn)
|
||||
}
|
||||
|
||||
fn blend_image<'input, _P: Alpha + Pixel + Debug, MapFn, Frame: Sample<Pixel = _P> + Transform, Background: RasterMut<Pixel = _P> + Transform + Sample<Pixel = _P>>(
|
||||
fn blend_image<'input, _P: Alpha + Pixel + Debug, MapFn, Frame: Sample<Pixel = _P> + Transform, Background: BitmapMut<Pixel = _P> + Transform + Sample<Pixel = _P>>(
|
||||
foreground: Frame,
|
||||
background: Background,
|
||||
map_fn: &'input MapFn,
|
||||
|
@ -327,7 +327,7 @@ where
|
|||
blend_image_closure(foreground, background, |a, b| map_fn.eval((a, b)))
|
||||
}
|
||||
|
||||
pub fn blend_image_closure<_P: Alpha + Pixel + Debug, MapFn, Frame: Sample<Pixel = _P> + Transform, Background: RasterMut<Pixel = _P> + Transform + Sample<Pixel = _P>>(
|
||||
pub fn blend_image_closure<_P: Alpha + Pixel + Debug, MapFn, Frame: Sample<Pixel = _P> + Transform, Background: BitmapMut<Pixel = _P> + Transform + Sample<Pixel = _P>>(
|
||||
foreground: Frame,
|
||||
mut background: Background,
|
||||
map_fn: MapFn,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue