Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 0979e9c

Browse files
committed
Fix issues
1 parent a27e61e commit 0979e9c

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

lib/gpu/gpu.cc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,20 @@
1515

1616
namespace flutter {
1717

18+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
1819
IMPLEMENT_WRAPPERTYPEINFO(gpu, FlutterGpuTestClass);
1920

21+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
22+
FlutterGpuTestClass::~FlutterGpuTestClass() = default;
23+
2024
} // namespace flutter
2125

26+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
2227
uint32_t FlutterGpuTestProc() {
2328
return 1;
2429
}
2530

31+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
2632
Dart_Handle FlutterGpuTestProcWithCallback(Dart_Handle callback) {
2733
flutter::UIDartState::ThrowIfUIOperationsProhibited();
2834
if (!Dart_IsClosure(callback)) {
@@ -34,13 +40,21 @@ Dart_Handle FlutterGpuTestProcWithCallback(Dart_Handle callback) {
3440
return Dart_Null();
3541
}
3642

43+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
3744
void FlutterGpuTestClass_Create(Dart_Handle wrapper) {
3845
auto res = fml::MakeRefCounted<flutter::FlutterGpuTestClass>();
3946
res->AssociateWithDartWrapper(wrapper);
4047
FML_LOG(ERROR) << "FlutterGpuTestClass Wrapped.";
4148
}
4249

50+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
4351
void FlutterGpuTestClass_Method(flutter::FlutterGpuTestClass* self,
4452
int something) {
4553
FML_LOG(ERROR) << "Something: " << something;
4654
}
55+
56+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
57+
void FlutterGpuTestClass_Dispose(flutter::FlutterGpuTestClass* self,
58+
int something) {
59+
self->ClearDartWrapper();
60+
}

lib/gpu/gpu.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ base class FlutterGpuTestClass extends NativeFieldWrapperClass1 {
3131
external void _constructor();
3232

3333
/// This is a method that will supply a pointer to the C data counterpart when
34-
/// calling the function
34+
/// calling the gunction
3535
@Native<Void Function(Pointer<Void>, Int)>(
3636
symbol: 'FlutterGpuTestClass_Method')
3737
external void coolMethod(int something);
38+
39+
@Native<Void Function(Pointer<Void>)>(symbol: 'FlutterGpuTestClass_Dispose')
40+
external void dispose();
3841
}

lib/gpu/gpu.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,26 +20,33 @@
2020

2121
namespace flutter {
2222

23+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
2324
class FlutterGpuTestClass
2425
: public RefCountedDartWrappable<FlutterGpuTestClass> {
2526
DEFINE_WRAPPERTYPEINFO();
27+
FML_FRIEND_MAKE_REF_COUNTED(FlutterGpuTestClass);
2628

2729
public:
30+
~FlutterGpuTestClass() override;
2831
};
2932

3033
} // namespace flutter
3134

3235
extern "C" {
3336

37+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
3438
FLUTTER_EXPORT
3539
extern uint32_t FlutterGpuTestProc();
3640

41+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
3742
FLUTTER_EXPORT
3843
extern Dart_Handle FlutterGpuTestProcWithCallback(Dart_Handle callback);
3944

45+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
4046
FLUTTER_EXPORT
4147
extern void FlutterGpuTestClass_Create(Dart_Handle wrapper);
4248

49+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
4350
FLUTTER_EXPORT
4451
extern void FlutterGpuTestClass_Method(flutter::FlutterGpuTestClass* self,
4552
int something);

testing/dart/gpu_test.dart

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,16 @@ import 'package:litetest/litetest.dart';
1010
import '../../lib/gpu/gpu.dart' as gpu;
1111

1212
void main() {
13+
// TODO(131346): Remove this once we migrate the Dart GPU API into this space.
1314
test('no crash', () async {
1415
final int result = gpu.testProc();
1516
expect(result, 1);
1617

18+
final String? message = gpu.testProcWithCallback((int result) {
19+
expect(result, 1234);
20+
});
21+
expect(message, null);
22+
1723
final gpu.FlutterGpuTestClass a = gpu.FlutterGpuTestClass();
1824
a.coolMethod(9847);
1925
});

0 commit comments

Comments
 (0)