|
1 |
| -// Copyright 2024 Google LLC |
| 1 | +// Copyright 2024-2025 Google LLC |
2 | 2 | //
|
3 | 3 | // Licensed under the Apache License, Version 2.0 (the "License");
|
4 | 4 | // you may not use this file except in compliance with the License.
|
|
17 | 17 |
|
18 | 18 | #include <jni.h>
|
19 | 19 |
|
20 |
| -#include <string> |
21 |
| - |
22 | 20 | #include "ink/brush/brush.h"
|
23 | 21 | #include "ink/brush/brush_behavior.h"
|
24 | 22 | #include "ink/brush/brush_coat.h"
|
25 | 23 | #include "ink/brush/brush_family.h"
|
26 | 24 | #include "ink/brush/brush_paint.h"
|
27 | 25 | #include "ink/brush/brush_tip.h"
|
28 | 26 |
|
29 |
| -namespace ink { |
| 27 | +namespace ink::jni { |
30 | 28 |
|
31 | 29 | // Casts a Kotlin Brush.nativePointer to a C++ Brush. The returned
|
32 |
| -// Brush is a const ref as the kotlin Brush is immutable. |
33 |
| -inline const ink::Brush& CastToBrush(jlong brush_native_pointer) { |
34 |
| - return *reinterpret_cast<ink::Brush*>(brush_native_pointer); |
| 30 | +// Brush is a const ref as the Kotlin Brush is immutable. |
| 31 | +inline const Brush& CastToBrush(jlong brush_native_pointer) { |
| 32 | + return *reinterpret_cast<Brush*>(brush_native_pointer); |
35 | 33 | }
|
36 | 34 |
|
37 | 35 | // Casts a Kotlin BrushFamily.nativePointer to a C++ BrushFamily. The returned
|
38 |
| -// BrushFamily is a const ref as the kotlin BrushFamily is immutable. |
39 |
| -inline const ink::BrushFamily& CastToBrushFamily( |
40 |
| - jlong brush_family_native_pointer) { |
41 |
| - return *reinterpret_cast<ink::BrushFamily*>(brush_family_native_pointer); |
| 36 | +// BrushFamily is a const ref as the Kotlin BrushFamily is immutable. |
| 37 | +inline const BrushFamily& CastToBrushFamily(jlong brush_family_native_pointer) { |
| 38 | + return *reinterpret_cast<BrushFamily*>(brush_family_native_pointer); |
42 | 39 | }
|
43 | 40 |
|
44 | 41 | // Casts a Kotlin BrushCoat.nativePointer to a C++ BrushCoat. The returned
|
45 |
| -// BrushCoat is a const ref as the kotlin BrushCoat is immutable. |
46 |
| -inline const ink::BrushCoat& CastToBrushCoat(jlong brush_coat_native_pointer) { |
47 |
| - return *reinterpret_cast<ink::BrushCoat*>(brush_coat_native_pointer); |
| 42 | +// BrushCoat is a const ref as the Kotlin BrushCoat is immutable. |
| 43 | +inline const BrushCoat& CastToBrushCoat(jlong brush_coat_native_pointer) { |
| 44 | + return *reinterpret_cast<BrushCoat*>(brush_coat_native_pointer); |
48 | 45 | }
|
49 | 46 |
|
50 | 47 | // Casts a Kotlin BrushPaint.nativePointer to a C++ BrushPaint. The returned
|
51 |
| -// BrushPaint is a const ref as the kotlin BrushPaint is immutable. |
52 |
| -inline const ink::BrushPaint& CastToBrushPaint( |
53 |
| - jlong brush_paint_native_pointer) { |
54 |
| - return *reinterpret_cast<ink::BrushPaint*>(brush_paint_native_pointer); |
| 48 | +// BrushPaint is a const ref as the Kotlin BrushPaint is immutable. |
| 49 | +inline const BrushPaint& CastToBrushPaint(jlong brush_paint_native_pointer) { |
| 50 | + return *reinterpret_cast<BrushPaint*>(brush_paint_native_pointer); |
| 51 | +} |
| 52 | + |
| 53 | +// Casts a Kotlin BrushBehavior.nativePointer to a C++ BrushPaint::TextureLayer. |
| 54 | +// The returned TextureLayer is a const ref as the Kotlin BrushPaint is |
| 55 | +// immutable. |
| 56 | +inline const BrushPaint::TextureLayer& CastToTextureLayer( |
| 57 | + jlong texture_layer_native_pointer) { |
| 58 | + return *reinterpret_cast<BrushPaint::TextureLayer*>( |
| 59 | + texture_layer_native_pointer); |
55 | 60 | }
|
56 | 61 |
|
57 | 62 | // Casts a Kotlin BrushTip.nativePointer to a C++ BrushTip. The returned
|
58 |
| -// BrushTip is a const ref as the kotlin BrushTip is immutable. |
59 |
| -inline const ink::BrushTip& CastToBrushTip(jlong brush_tip_native_pointer) { |
60 |
| - return *reinterpret_cast<ink::BrushTip*>(brush_tip_native_pointer); |
| 63 | +// BrushTip is a const ref as the Kotlin BrushTip is immutable. |
| 64 | +inline const BrushTip& CastToBrushTip(jlong brush_tip_native_pointer) { |
| 65 | + return *reinterpret_cast<BrushTip*>(brush_tip_native_pointer); |
61 | 66 | }
|
62 | 67 |
|
63 | 68 | // Casts a Kotlin BrushBehavior.nativePointer to a C++ BrushBehavior. The
|
64 |
| -// returned BrushBehavior is a const ref as the kotlin BrushBehavior is |
| 69 | +// returned BrushBehavior is a const ref as the Kotlin BrushBehavior is |
65 | 70 | // immutable.
|
66 |
| -inline const ink::BrushBehavior& CastToBrushBehavior( |
| 71 | +inline const BrushBehavior& CastToBrushBehavior( |
67 | 72 | jlong brush_behavior_native_pointer) {
|
68 |
| - return *reinterpret_cast<ink::BrushBehavior*>(brush_behavior_native_pointer); |
| 73 | + return *reinterpret_cast<BrushBehavior*>(brush_behavior_native_pointer); |
69 | 74 | }
|
70 | 75 |
|
71 |
| -} // namespace ink |
| 76 | +} // namespace ink::jni |
| 77 | + |
72 | 78 | #endif // INK_STROKES_BRUSH_INTERNAL_JNI_BRUSH_JNI_HELPER_H_
|
0 commit comments