Browse Source

Basic sample works

flabbet 1 year ago
parent
commit
d7b26f1cc5

+ 1 - 1
src/PixiEditor.DrawingApi.Core/Shaders/ShaderBuilder.cs

@@ -20,7 +20,7 @@ public class ShaderBuilder
         AppendUniforms(sb);
         AppendUniforms(sb);
         sb.AppendLine("half4 main(float2 p)");
         sb.AppendLine("half4 main(float2 p)");
         sb.AppendLine("{");
         sb.AppendLine("{");
-        sb.AppendLine("return original.eval(p).rgba;");
+        sb.AppendLine("return sample(original, p);");
         sb.AppendLine("}");
         sb.AppendLine("}");
         
         
         return sb.ToString();
         return sb.ToString();

+ 4 - 2
src/PixiEditor.DrawingApi.Skia/Implementations/SkiaImageImplementation.cs

@@ -15,12 +15,13 @@ namespace PixiEditor.DrawingApi.Skia.Implementations
         private readonly SkObjectImplementation<SKData> _imgImplementation;
         private readonly SkObjectImplementation<SKData> _imgImplementation;
         private readonly SkiaPixmapImplementation _pixmapImplementation;
         private readonly SkiaPixmapImplementation _pixmapImplementation;
         private SkObjectImplementation<SKSurface>? _surfaceImplementation;
         private SkObjectImplementation<SKSurface>? _surfaceImplementation;
-        private SkiaColorSpaceImplementation colorSpaceImpl;
+        private SkiaShaderImplementation shaderImpl;
         
         
-        public SkiaImageImplementation(SkObjectImplementation<SKData> imgDataImplementation, SkiaPixmapImplementation pixmapImplementation)
+        public SkiaImageImplementation(SkObjectImplementation<SKData> imgDataImplementation, SkiaPixmapImplementation pixmapImplementation,  SkiaShaderImplementation shaderImplementation)
         {
         {
             _imgImplementation = imgDataImplementation;
             _imgImplementation = imgDataImplementation;
             _pixmapImplementation = pixmapImplementation;
             _pixmapImplementation = pixmapImplementation;
+            shaderImpl = shaderImplementation;
         }
         }
         
         
         public void SetSurfaceImplementation(SkObjectImplementation<SKSurface> surfaceImplementation)
         public void SetSurfaceImplementation(SkObjectImplementation<SKSurface> surfaceImplementation)
@@ -147,6 +148,7 @@ namespace PixiEditor.DrawingApi.Skia.Implementations
         public Shader ToShader(IntPtr objectPointer)
         public Shader ToShader(IntPtr objectPointer)
         {
         {
             var shader = ManagedInstances[objectPointer].ToShader();
             var shader = ManagedInstances[objectPointer].ToShader();
+            shaderImpl.ManagedInstances[shader.Handle] = shader;
             return new Shader(shader.Handle);
             return new Shader(shader.Handle);
         }
         }
 
 

+ 1 - 1
src/PixiEditor.DrawingApi.Skia/PixiEditor.DrawingApi.Skia.csproj

@@ -7,7 +7,7 @@
     </PropertyGroup>
     </PropertyGroup>
 
 
     <ItemGroup>
     <ItemGroup>
-      <PackageReference Include="SkiaSharp" Version="2.88.8" />
+      <PackageReference Include="SkiaSharp" Version="2.88.9-preview.1.1" />
     </ItemGroup>
     </ItemGroup>
 
 
     <ItemGroup>
     <ItemGroup>

+ 1 - 1
src/PixiEditor.DrawingApi.Skia/SkiaDrawingBackend.cs

@@ -73,7 +73,7 @@ namespace PixiEditor.DrawingApi.Skia
             SkiaPixmapImplementation pixmapImpl = new SkiaPixmapImplementation(colorSpaceImpl);
             SkiaPixmapImplementation pixmapImpl = new SkiaPixmapImplementation(colorSpaceImpl);
             PixmapImplementation = pixmapImpl;
             PixmapImplementation = pixmapImpl;
             
             
-            SkiaImageImplementation imgImpl = new SkiaImageImplementation(dataImpl, pixmapImpl);
+            SkiaImageImplementation imgImpl = new SkiaImageImplementation(dataImpl, pixmapImpl, shader);
             ImageImplementation = imgImpl;
             ImageImplementation = imgImpl;
             SkiaBitmapImplementation bitmapImpl = new SkiaBitmapImplementation(imgImpl, pixmapImpl);
             SkiaBitmapImplementation bitmapImpl = new SkiaBitmapImplementation(imgImpl, pixmapImpl);
             BitmapImplementation = bitmapImpl;
             BitmapImplementation = bitmapImpl;