Skip to content

Commit

Permalink
Keep types for the linker
Browse files Browse the repository at this point in the history
  • Loading branch information
mattleibow committed Feb 11, 2024
1 parent c644dff commit 3f3dba2
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 17 deletions.
1 change: 1 addition & 0 deletions gn/core.gni
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ skia_core_sources = [
"$_src/c/sk_types_priv.h",
"$_src/c/sk_vertices.cpp",
"$_src/c/gr_context.cpp",
"$_src/c/sk_linker.cpp",
"$_src/c/skottie_animation.cpp",
"$_src/c/skresources_resource_provider.cpp",
"$_src/c/sksg_invalidation_controller.cpp",
Expand Down
19 changes: 19 additions & 0 deletions include/c/sk_linker.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2024 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_linker_DEFINED
#define sk_linker_DEFINED

#include "include/c/sk_types.h"

SK_C_PLUS_PLUS_BEGIN_GUARD

SK_C_API void sk_linker_keep_alive(void);

SK_C_PLUS_PLUS_END_GUARD

#endif
2 changes: 0 additions & 2 deletions include/c/skottie_animation.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ SK_C_PLUS_PLUS_BEGIN_GUARD
* skottie::Animation
*/

SK_C_API void skottie_animation_keepalive(void);

SK_C_API skottie_animation_t* skottie_animation_make_from_string(const char* data, size_t length);
SK_C_API skottie_animation_t* skottie_animation_make_from_data(const char* data, size_t length);
SK_C_API skottie_animation_t* skottie_animation_make_from_stream(sk_stream_t* stream);
Expand Down
25 changes: 25 additions & 0 deletions src/c/sk_linker.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "include/c/sk_linker.h"

#include "src/c/sk_types_priv.h"

#include "include/core/SkCubicMap.h"
#include "include/utils/SkAnimCodecPlayer.h"

#include "src/utils/SkJSON.h"
#include "src/utils/SkOSPath.h"

void sk_linker_keep_alive(void) {
// This function is needed on Tizen to ensure required types are kept alive
// It is not meant to be executed.

skjson::ObjectValue* a = nullptr;
auto r = (*a)["tmp"].getType();

SkCubicMap* b = nullptr;
(*b).computeYFromX((int)r);

SkAnimCodecPlayer* c = nullptr;
(*c).seek((uint32_t)123);

SkOSPath::Join(nullptr, nullptr);
}
14 changes: 0 additions & 14 deletions src/c/skottie_animation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,10 @@

#include "src/c/sk_types_priv.h"

#include "src/utils/SkJSON.h"
#include "include/core/SkCubicMap.h"

/*
* skottie::Animation
*/

void skottie_animation_keepalive(void) {
// This function is needed on Tizen to ensure required types are kept alive
// It is not meant to be executed.

skjson::ObjectValue* a = nullptr;
auto r = (*a)["tmp"].getType();

SkCubicMap* b = nullptr;
(*b).computeYFromX((int)r);
}

void skottie_animation_ref(skottie_animation_t* instance) {
SkSafeRef(AsSkottieAnimation(instance));
}
Expand Down
5 changes: 4 additions & 1 deletion src/xamarin/SkiaKeeper.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "include/c/sk_graphics.h"
#include "include/c/sk_image.h"
#include "include/c/sk_imagefilter.h"
#include "include/c/sk_linker.h"
#include "include/c/sk_maskfilter.h"
#include "include/c/sk_matrix.h"
#include "include/c/sk_paint.h"
Expand Down Expand Up @@ -97,14 +98,16 @@ void** KeepSkiaCSymbols (void)
// Animation
(void*)skottie_animation_make_from_stream,
(void*)sksg_invalidation_controller_new,
(void*)skottie_animation_keepalive,
(void*)skresources_resource_provider_ref,

// Xamarin
(void*)sk_compatpaint_new,
(void*)sk_managedstream_new,
(void*)sk_manageddrawable_new,
(void*)sk_managedtracememorydump_new,

// Linker
(void*)sk_linker_keep_alive,
};
return ret;
}

0 comments on commit 3f3dba2

Please sign in to comment.