Skip to content

Commit

Permalink
Revert "SkDrawable support"
Browse files Browse the repository at this point in the history
This reverts commit d83a3a3.
  • Loading branch information
MarcinZiabek committed Dec 18, 2024
1 parent d83a3a3 commit 27bdca4
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 88 deletions.
28 changes: 1 addition & 27 deletions managed/NativeSkia.Tests/PictureRecorderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public void PictureWorkflow()
recorderCanvas.DrawFilledRectangle(new SkRect(100, 100, 300, 200), 0xFF3F51B5);
recorderCanvas.DrawFilledRectangle(new SkRect(150, 150, 350, 250), 0xFF2196F3);

using var picture = recorder.EndRecordingWithPicture();
using var picture = recorder.EndRecording();

// serialization test
using var serializedPictureData = picture.Serialize();
Expand All @@ -40,30 +40,4 @@ public void PictureWorkflow()
TestFixture.SaveOutput("picture.png", pngData);
pngData.ShouldHaveSize(1_269);
}

[Test]
public void DrawableWorkflow()
{
// generate picture
using var recorder = new SkPictureRecorder();
using var recorderCanvas = recorder.BeginRecording(400, 300);

recorderCanvas.DrawFilledRectangle(new SkRect(0, 0, 400, 300), 0xFFFFFFFF);
recorderCanvas.DrawFilledRectangle(new SkRect(50, 50, 250, 150), 0xFF673AB7);
recorderCanvas.DrawFilledRectangle(new SkRect(100, 100, 300, 200), 0xFF3F51B5);
recorderCanvas.DrawFilledRectangle(new SkRect(150, 150, 350, 250), 0xFF2196F3);

using var drawable = recorder.EndRecordingWithDrawable();

// draw picture
using var bitmap = new SkBitmap(400, 300);
using var outputBitmapCanvas = SkCanvas.CreateFromBitmap(bitmap);

outputBitmapCanvas.DrawDrawable(drawable);

// save output
using var pngData = bitmap.EncodeAsPng();
TestFixture.SaveOutput("drawable.png", pngData);
pngData.ShouldHaveSize(1_269);
}
}
8 changes: 0 additions & 8 deletions managed/NativeSkia/SkCanvas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,6 @@ public void DrawPicture(SkPicture picture)
{
API.canvas_draw_picture(Instance, picture.Instance);
}

public void DrawDrawable(SkDrawable drawable)
{
API.canvas_draw_drawable(Instance, drawable.Instance);
}

public void DrawParagraph(SkParagraph paragraph)
{
Expand Down Expand Up @@ -179,9 +174,6 @@ private static class API
[DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void canvas_draw_picture(IntPtr canvas, IntPtr picture);

[DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void canvas_draw_drawable(IntPtr canvas, IntPtr drawable);

[DllImport(SkiaAPI.LibraryName, CallingConvention = CallingConvention.Cdecl)]
public static extern void canvas_draw_filled_rectangle(IntPtr canvas, SkRect position, uint color);

Expand Down
34 changes: 0 additions & 34 deletions managed/NativeSkia/SkDrawable.cs

This file was deleted.

4 changes: 0 additions & 4 deletions native/src/canvas.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,6 @@ QUEST_API void canvas_draw_picture(SkCanvas *canvas, SkPicture *picture) {
canvas->drawPicture(sk_ref_sp(picture));
}

QUEST_API void canvas_draw_drawable(SkCanvas *canvas, SkDrawable *drawable) {
canvas->drawDrawable(drawable);
}

QUEST_API void canvas_draw_paragraph(SkCanvas *canvas, skia::textlayout::Paragraph *paragraph) {
paragraph->paint(canvas, 0, 0);
}
Expand Down
10 changes: 0 additions & 10 deletions native/src/drawable.cpp

This file was deleted.

6 changes: 1 addition & 5 deletions native/src/pictureRecorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,10 @@ QUEST_API SkCanvas *picture_recorder_begin_recording(SkPictureRecorder *pictureR
return pictureRecorder->beginRecording(width, height);
}

QUEST_API SkPicture *picture_recorder_end_recording_with_picture(SkPictureRecorder *pictureRecorder) {
QUEST_API SkPicture *picture_recorder_end_recording(SkPictureRecorder *pictureRecorder) {
return pictureRecorder->finishRecordingAsPicture().release();
}

QUEST_API SkDrawable *picture_recorder_end_recording_with_drawable(SkPictureRecorder *pictureRecorder) {
return pictureRecorder->finishRecordingAsDrawable().release();
}

QUEST_API void picture_recorder_delete(SkPictureRecorder *pictureRecorder) {
delete pictureRecorder;
}
Expand Down

0 comments on commit 27bdca4

Please sign in to comment.