Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -3089,13 +3089,21 @@ skiasharp_build("SkiaSharp") {

sources = [
"src/xamarin/sk_compatpaint.cpp",
"src/xamarin/sk_managedidchangelistener.cpp",
"src/xamarin/sk_managedidchangelistenerlist.cpp",
"src/xamarin/sk_manageddrawable.cpp",
"src/xamarin/sk_managedallocator.cpp",
"src/xamarin/sk_managedpixelref.cpp",
"src/xamarin/sk_managedstream.cpp",
"src/xamarin/sk_managedtracememorydump.cpp",
"src/xamarin/sk_xamarin.cpp",
"src/xamarin/SkiaKeeper.c",
"src/xamarin/SkCompatPaint.cpp",
"src/xamarin/SkManagedIDChangeListener.cpp",
"src/xamarin/SkManagedIDChangeListenerList.cpp",
"src/xamarin/SkManagedDrawable.cpp",
"src/xamarin/SkManagedAllocator.cpp",
"src/xamarin/SkManagedPixelRef.cpp",
"src/xamarin/SkManagedStream.cpp",
"src/xamarin/SkManagedTraceMemoryDump.cpp",
"src/xamarin/WinRTCompat.cpp",
Expand Down
5 changes: 5 additions & 0 deletions include/c/sk_bitmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,21 @@ SK_C_API void sk_bitmap_get_pixel_colors(sk_bitmap_t* cbitmap, sk_color_t* color
SK_C_API bool sk_bitmap_install_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* cinfo, void* pixels, size_t rowBytes, const sk_bitmap_release_proc releaseProc, void* context);
SK_C_API bool sk_bitmap_install_pixels_with_pixmap(sk_bitmap_t* cbitmap, const sk_pixmap_t* cpixmap);
SK_C_API bool sk_bitmap_install_mask_pixels(sk_bitmap_t* cbitmap, const sk_mask_t* cmask);
SK_C_API bool sk_bitmap_try_alloc_pixels_with_allocator(sk_bitmap_t* cbitmap, sk_bitmapallocator_t* allocator);
SK_C_API bool sk_bitmap_try_alloc_pixels(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, size_t rowBytes);
SK_C_API bool sk_bitmap_try_alloc_pixels_with_flags(sk_bitmap_t* cbitmap, const sk_imageinfo_t* requestedInfo, uint32_t flags);
SK_C_API void sk_bitmap_set_pixels(sk_bitmap_t* cbitmap, void* pixels);
SK_C_API bool sk_bitmap_peek_pixels(sk_bitmap_t* cbitmap, sk_pixmap_t* cpixmap);
SK_C_API void* sk_bitmap_get_pixelref(sk_bitmap_t* cbitmap);
SK_C_API void sk_bitmap_set_pixelref(sk_bitmap_t* cbitmap, void* cpixelref, int x, int y);
SK_C_API bool sk_bitmap_extract_subset(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, sk_irect_t* subset);
SK_C_API bool sk_bitmap_extract_alpha(sk_bitmap_t* cbitmap, sk_bitmap_t* dst, const sk_paint_t* paint, sk_ipoint_t* offset);
SK_C_API void sk_bitmap_notify_pixels_changed(sk_bitmap_t* cbitmap);
SK_C_API void sk_bitmap_swap(sk_bitmap_t* cbitmap, sk_bitmap_t* cother);
SK_C_API sk_shader_t* sk_bitmap_make_shader(sk_bitmap_t* cbitmap, sk_shader_tilemode_t tmx, sk_shader_tilemode_t tmy, const sk_matrix_t* cmatrix);

SK_C_API bool sk_bitmap_heapalloc(sk_bitmap_t* cbitmap);

SK_C_PLUS_PLUS_END_GUARD

#endif
6 changes: 6 additions & 0 deletions include/c/sk_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,11 +343,17 @@ typedef struct sk_string_t sk_string_t;
A sk_bitmap_t is an abstraction that specifies a raster bitmap.
*/
typedef struct sk_bitmap_t sk_bitmap_t;
typedef struct sk_bitmapallocator_t sk_bitmapallocator_t;
typedef struct sk_pixmap_t sk_pixmap_t;
typedef struct sk_colorfilter_t sk_colorfilter_t;
// placed here to help seperate in PR
typedef struct sk_pixelref_t sk_pixelref_t;
typedef struct sk_imagefilter_t sk_imagefilter_t;
typedef struct sk_imagefilter_croprect_t sk_imagefilter_croprect_t;

typedef struct sk_idchangelistener_t sk_idchangelistener_t;
typedef struct sk_idchangelistenerlist_t sk_idchangelistenerlist_t;

/**
A sk_typeface_t pecifies the typeface and intrinsic style of a font.
This is used in the paint, along with optionally algorithmic settings like
Expand Down
49 changes: 49 additions & 0 deletions include/xamarin/SkManagedAllocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2022 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef SkManagedAllocator_h
#define SkManagedAllocator_h

#include "include/core/SkBitmap.h"
#include "include/core/SkTypes.h"

class SkBitmap;

class SK_API SkManagedAllocator;

// delegate declarations

// managed Allocator
class SkManagedAllocator : public SkBitmap::Allocator {
public:
SkManagedAllocator(void* context);

~SkManagedAllocator() override;

public:
typedef bool (*AllocProc) (SkManagedAllocator* d, void* context, SkBitmap* bitmap);
typedef void (*DestroyProc) (SkManagedAllocator* d, void* context);

struct Procs {
AllocProc fAllocPixelRef = nullptr;
DestroyProc fDestroy = nullptr;
};

static void setProcs(Procs procs);

protected:
bool allocPixelRef(SkBitmap* bitmap) override;

private:
void* fContext;
static Procs fProcs;

typedef SkBitmap::Allocator INHERITED;
};


#endif
49 changes: 49 additions & 0 deletions include/xamarin/SkManagedIDChangeListener.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* Copyright 2022 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef SkManagedIDChangeListener_h
#define SkManagedIDChangeListener_h

#include "include/private/SkIDChangeListener.h"
#include "include/core/SkTypes.h"

class SkIDChangeListener;

class SK_API SkManagedIDChangeListener;

// delegate declarations

// managed Allocator
class SkManagedIDChangeListener : public SkIDChangeListener {
public:
SkManagedIDChangeListener(void* context);

~SkManagedIDChangeListener() override;

public:
typedef void (*ChangedProc) (SkManagedIDChangeListener* d, void* context);
typedef void (*DestroyProc) (SkManagedIDChangeListener* d, void* context);

struct Procs {
ChangedProc fChanged = nullptr;
DestroyProc fDestroy = nullptr;
};

static void setProcs(Procs procs);

protected:
void changed() override;

private:
void* fContext;
static Procs fProcs;

typedef SkIDChangeListener INHERITED;
};


#endif
41 changes: 41 additions & 0 deletions include/xamarin/SkManagedIDChangeListenerList.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright 2022 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef SkManagedIDChangeListenerList_h
#define SkManagedIDChangeListenerList_h

#include "include/private/SkIDChangeListener.h"
#include "include/core/SkTypes.h"

class SK_API SkManagedIDChangeListenerList;

// delegate declarations

// managed Allocator
class SkManagedIDChangeListenerList : public SkIDChangeListener::List {
public:
SkManagedIDChangeListenerList(void* context);

~SkManagedIDChangeListenerList();

typedef void (*DestroyProc)(SkManagedIDChangeListenerList* d, void* context);

struct Procs {
DestroyProc fDestroy = nullptr;
};

static void setProcs(Procs procs);

private:
void* fContext;
static Procs fProcs;

typedef SkIDChangeListener::List INHERITED;
};


#endif
46 changes: 46 additions & 0 deletions include/xamarin/SkManagedPixelRef.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2022 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef SkManagedPixelRef_h
#define SkManagedPixelRef_h

#include "include/core/SkPixelRef.h"
#include "include/core/SkTypes.h"

class SkPixelRef;

class SK_API SkManagedPixelRef;

// delegate declarations

// managed Allocator
class SkManagedPixelRef {
public:

sk_sp<SkPixelRef> pixelRef;

SkManagedPixelRef(void* context, SkPixelRef * pixelRef);

SkManagedPixelRef(void* context, int32_t, int32_t, void*, size_t);

virtual ~SkManagedPixelRef();

typedef void (*DestroyProc)(SkManagedPixelRef* d, void* context);

struct Procs {
DestroyProc fDestroy = nullptr;
};

static void setProcs(Procs procs);

private:
void* fContext;
static Procs fProcs;
};


#endif
33 changes: 33 additions & 0 deletions include/xamarin/sk_managedallocator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright 2022 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef sk_managedallocator_DEFINED
#define sk_managedallocator_DEFINED

#include "sk_xamarin.h"

#include "include/c/sk_types.h"

SK_C_PLUS_PLUS_BEGIN_GUARD

typedef struct sk_managedallocator_t sk_managedallocator_t;

typedef bool (*sk_managedallocator_allocpixelref_proc) (sk_managedallocator_t* d, void* context, sk_bitmap_t* bitmap);
typedef void (*sk_managedallocator_destroy_proc) (sk_managedallocator_t* d, void* context);

typedef struct {
sk_managedallocator_allocpixelref_proc fAllocPixelRef;
sk_managedallocator_destroy_proc fDestroy;
} sk_managedallocator_procs_t;

SK_X_API sk_managedallocator_t* sk_managedallocator_new(void* context);
SK_X_API void sk_managedallocator_delete(sk_managedallocator_t*);
SK_X_API void sk_managedallocator_set_procs(sk_managedallocator_procs_t procs);

SK_C_PLUS_PLUS_END_GUARD

#endif
35 changes: 35 additions & 0 deletions include/xamarin/sk_managedidchangelistener.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2014 Google Inc.
* Copyright 2015 Xamarin Inc.
* Copyright 2017 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef sk_managedidchangelistener_DEFINED
#define sk_managedidchangelistener_DEFINED

#include "sk_xamarin.h"

#include "include/c/sk_types.h"

SK_C_PLUS_PLUS_BEGIN_GUARD

typedef void (*sk_idchangelistener_changed_proc)(sk_idchangelistener_t* d, void* context);
typedef void (*sk_idchangelistener_destroy_proc)(sk_idchangelistener_t* d, void* context);

typedef struct {
sk_idchangelistener_changed_proc fChanged;
sk_idchangelistener_destroy_proc fDestroy;
} sk_idchangelistener_procs_t;

SK_X_API sk_idchangelistener_t* sk_managedidchangelistener_new(void* context);
SK_X_API void sk_managedidchangelistener_delete(sk_idchangelistener_t*);
SK_X_API void sk_managedidchangelistener_mark_should_deregister(sk_idchangelistener_t*);
SK_X_API bool sk_managedidchangelistener_should_deregister(sk_idchangelistener_t*);
SK_X_API void sk_managedidchangelistener_set_procs(sk_idchangelistener_procs_t procs);

SK_C_PLUS_PLUS_END_GUARD

#endif
35 changes: 35 additions & 0 deletions include/xamarin/sk_managedidchangelistenerlist.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright 2014 Google Inc.
* Copyright 2015 Xamarin Inc.
* Copyright 2017 Microsoft Corporation. All rights reserved.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/

#ifndef sk_managedidchangelistenerlist_DEFINED
#define sk_managedidchangelistenerlist_DEFINED

#include "sk_xamarin.h"

#include "include/c/sk_types.h"

SK_C_PLUS_PLUS_BEGIN_GUARD

typedef void (*sk_idchangelistenerlist_destroy_proc)(sk_idchangelistenerlist_t* d, void* context);

typedef struct {
sk_idchangelistenerlist_destroy_proc fDestroy;
} sk_idchangelistenerlist_procs_t;

SK_X_API sk_idchangelistenerlist_t* sk_managedidchangelistenerlist_new(void* context);
SK_X_API void sk_managedidchangelistenerlist_delete(sk_idchangelistenerlist_t*);
SK_X_API void sk_managedidchangelistenerlist_add(sk_idchangelistenerlist_t*, sk_idchangelistener_t*, bool single_threaded);
SK_X_API int32_t sk_managedidchangelistenerlist_count(sk_idchangelistenerlist_t*);
SK_X_API void sk_managedidchangelistenerlist_changed(sk_idchangelistenerlist_t*, bool single_threaded);
SK_X_API void sk_managedidchangelistenerlist_reset(sk_idchangelistenerlist_t*, bool single_threaded);
SK_X_API void sk_managedidchangelistenerlist_set_procs(sk_idchangelistenerlist_procs_t procs);

SK_C_PLUS_PLUS_END_GUARD

#endif
Loading