mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Rename Raster to Bitmap
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user