@blotch/angular-lynx-native 22.3.1 → 22.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -15
- package/dist/android/project.d.ts +114 -1
- package/dist/android/project.d.ts.map +1 -1
- package/dist/android/project.js +440 -5
- package/dist/eject.d.ts +15 -1
- package/dist/eject.d.ts.map +1 -1
- package/dist/eject.js +14 -2
- package/dist/features.d.ts +70 -0
- package/dist/features.d.ts.map +1 -0
- package/dist/features.js +115 -0
- package/dist/files.d.ts +24 -0
- package/dist/files.d.ts.map +1 -0
- package/dist/files.js +41 -0
- package/dist/generate.d.ts +34 -3
- package/dist/generate.d.ts.map +1 -1
- package/dist/generate.js +78 -19
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/ios/build.d.ts.map +1 -1
- package/dist/ios/build.js +8 -2
- package/dist/ios/frameworks.d.ts +6 -5
- package/dist/ios/frameworks.d.ts.map +1 -1
- package/dist/ios/frameworks.js +46 -15
- package/dist/ios/project.d.ts +192 -11
- package/dist/ios/project.d.ts.map +1 -1
- package/dist/ios/project.js +823 -33
- package/dist/options.d.ts +208 -1
- package/dist/options.d.ts.map +1 -1
- package/dist/options.js +154 -0
- package/dist/permissions.d.ts +18 -1
- package/dist/permissions.d.ts.map +1 -1
- package/dist/permissions.js +79 -4
- package/dist/plugins.d.ts +245 -0
- package/dist/plugins.d.ts.map +1 -0
- package/dist/plugins.js +1244 -0
- package/package.json +1 -1
- package/templates/android/README.md +46 -5
- package/templates/android/angular-lynx.properties +2 -0
- package/templates/android/app/build.gradle.kts +78 -11
- package/templates/android/app/src/main/AndroidManifest.xml +19 -3
- package/templates/android/app/src/main/java/dev/angularlynx/shell/AngularLynxPlugins.kt +13 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/AudioRecorderModule.kt +520 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/BarcodeScannerModule.kt +144 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/BiometricsModule.kt +433 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/BitmapPresenter.kt +98 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/BitmapRendererContext.kt +175 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/BluetoothModule.kt +1288 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/CalendarModule.kt +127 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/Canvas2DContext.kt +1557 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/Canvas2DOps.kt +63 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/CanvasFilter.kt +357 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/CanvasUI.kt +4 -3
- package/templates/android/app/src/main/java/dev/angularlynx/shell/EdgeToEdgeOverlay.kt +24 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/EngineThreadHint.kt +156 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/FilePickerModule.kt +263 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/GeolocationModule.kt +557 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/HapticsModule.kt +82 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/HostElementUI.kt +331 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ImagePickerModule.kt +143 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ImagePipeline.kt +83 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MainActivity.kt +523 -9
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ModuleBytes.kt +58 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/MotionModule.kt +332 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/NetworkStatus.kt +121 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/NfcModule.kt +274 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/PermissionRequests.kt +35 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/PhotoLibraryModule.kt +355 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShareTargetModule.kt +234 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellApplication.kt +7 -8
- package/templates/android/app/src/main/java/dev/angularlynx/shell/ShellModule.kt +58 -4
- package/templates/android/app/src/main/java/dev/angularlynx/shell/StoreReviewModule.kt +66 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/SystemFontFamilies.kt +68 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/TrackingModule.kt +74 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/VideoFrameTarget.kt +429 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/VideoUI.kt +676 -0
- package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLContext.kt +128 -13
- package/templates/android/app/src/main/java/dev/angularlynx/shell/WebGLModule.kt +493 -65
- package/templates/android/app/src/main/java/dev/angularlynx/shell/WifiModule.kt +429 -0
- package/templates/android/app/src/main/res/values/biometrics.xml +9 -0
- package/templates/android/app/src/main/res/values/share_target.xml +11 -0
- package/templates/android/app/src/main/res/xml/backup_rules.xml +5 -3
- package/templates/android/app/src/main/res/xml/data_extraction_rules.xml +6 -3
- package/templates/android/app/src/main/res/xml/share_paths.xml +7 -2
- package/templates/android/build.gradle.kts +1 -1
- package/templates/android/gradle/wrapper/gradle-wrapper.properties +2 -2
- package/templates/ios/App/AngularLynxBitmapRendererContext.m +188 -0
- package/templates/ios/App/AngularLynxCanvas2DContext.m +2467 -0
- package/templates/ios/App/AngularLynxCanvas2DOps.h +61 -0
- package/templates/ios/App/AngularLynxPlugins.swift +22 -0
- package/templates/ios/App/AngularLynxVideo.h +37 -0
- package/templates/ios/App/AngularLynxVideo.m +435 -0
- package/templates/ios/App/AngularLynxWebGL.h +69 -7
- package/templates/ios/App/AngularLynxWebGL.m +538 -29
- package/templates/ios/App/AngularLynxWebGLContext.m +148 -46
- package/templates/ios/App/AnimationFrameRate.swift +66 -0
- package/templates/ios/App/AppDelegate.swift +37 -3
- package/templates/ios/App/AppleSignInButton.swift +106 -0
- package/templates/ios/App/AppleSignInModule.swift +222 -0
- package/templates/ios/App/AudioRecorderModule.swift +433 -0
- package/templates/ios/App/BarcodeScannerModule.swift +284 -0
- package/templates/ios/App/BiometricsModule.swift +256 -0
- package/templates/ios/App/BluetoothModule.swift +1086 -0
- package/templates/ios/App/CalendarModule.swift +158 -0
- package/templates/ios/App/FilePickerModule.swift +240 -0
- package/templates/ios/App/GeolocationModule.swift +455 -0
- package/templates/ios/App/HapticsModule.swift +90 -0
- package/templates/ios/App/HostElementUI.swift +270 -0
- package/templates/ios/App/ImagePickerModule.swift +160 -1
- package/templates/ios/App/Info.plist +2 -0
- package/templates/ios/App/LynxViewController.swift +274 -9
- package/templates/ios/App/MotionModule.swift +430 -0
- package/templates/ios/App/NetworkStatus.swift +41 -0
- package/templates/ios/App/NfcModule.swift +346 -0
- package/templates/ios/App/PhotoLibraryModule.swift +169 -0
- package/templates/ios/App/ShareTargetModule.swift +150 -0
- package/templates/ios/App/ShellModule.swift +17 -0
- package/templates/ios/App/StoreReviewModule.swift +61 -0
- package/templates/ios/App/TrackingModule.swift +121 -0
- package/templates/ios/App/WifiModule.swift +237 -0
- package/templates/ios/App/XElementRegistry.swift +13 -3
- package/templates/ios/ShareExtension/Info.plist +42 -0
- package/templates/ios/ShareExtension/ShareViewController.swift +387 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Generated from packages/runtime/src/lib/canvas/canvas-2d-ops.ts by
|
|
2
|
+
// packages/native/scripts/webgl-ops.ts: run `npm run generate:webgl-ops -w
|
|
3
|
+
// packages/native` rather than editing it.
|
|
4
|
+
|
|
5
|
+
package dev.angularlynx.shell
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The commands of the 2D context's bridge, as `<canvas>`'s 2D context in
|
|
9
|
+
* the runtime records them: below 200 they return nothing, from 200 each
|
|
10
|
+
* answers one query.
|
|
11
|
+
*/
|
|
12
|
+
internal object Canvas2DOps {
|
|
13
|
+
const val SAVE = 1
|
|
14
|
+
const val RESTORE = 2
|
|
15
|
+
const val RESET = 3
|
|
16
|
+
const val RESIZE = 4
|
|
17
|
+
const val PRESENT = 5
|
|
18
|
+
const val SET_TRANSFORM = 10
|
|
19
|
+
const val SET_GLOBAL_ALPHA = 11
|
|
20
|
+
const val SET_COMPOSITE_OPERATION = 12
|
|
21
|
+
const val SET_FILL_COLOR = 13
|
|
22
|
+
const val SET_FILL_GRADIENT = 14
|
|
23
|
+
const val SET_FILL_PATTERN = 15
|
|
24
|
+
const val SET_STROKE_COLOR = 16
|
|
25
|
+
const val SET_STROKE_GRADIENT = 17
|
|
26
|
+
const val SET_STROKE_PATTERN = 18
|
|
27
|
+
const val SET_LINE_WIDTH = 19
|
|
28
|
+
const val SET_LINE_CAP = 20
|
|
29
|
+
const val SET_LINE_JOIN = 21
|
|
30
|
+
const val SET_MITER_LIMIT = 22
|
|
31
|
+
const val SET_LINE_DASH = 23
|
|
32
|
+
const val SET_SHADOW = 24
|
|
33
|
+
const val SET_FONT = 25
|
|
34
|
+
const val SET_TEXT_ALIGN = 26
|
|
35
|
+
const val SET_TEXT_BASELINE = 27
|
|
36
|
+
const val SET_DIRECTION = 28
|
|
37
|
+
const val SET_LETTER_SPACING = 29
|
|
38
|
+
const val SET_IMAGE_SMOOTHING = 30
|
|
39
|
+
const val SET_FILTER = 31
|
|
40
|
+
const val CREATE_PATTERN = 44
|
|
41
|
+
const val RELEASE_OBJECT = 46
|
|
42
|
+
const val CLEAR_PATH = 50
|
|
43
|
+
const val FILL = 51
|
|
44
|
+
const val STROKE = 52
|
|
45
|
+
const val CLIP = 53
|
|
46
|
+
const val FILL_TEXT = 54
|
|
47
|
+
const val STROKE_TEXT = 55
|
|
48
|
+
const val DRAW_IMAGE = 56
|
|
49
|
+
const val PUT_IMAGE_DATA = 57
|
|
50
|
+
const val MEASURE_TEXT = 200
|
|
51
|
+
const val GET_IMAGE_DATA = 201
|
|
52
|
+
const val IS_POINT_IN_PATH = 202
|
|
53
|
+
const val IS_POINT_IN_STROKE = 203
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** The segments of a path, each followed by its points. */
|
|
57
|
+
internal object Canvas2DPathOps {
|
|
58
|
+
const val MOVE_TO = 0
|
|
59
|
+
const val LINE_TO = 1
|
|
60
|
+
const val QUAD_TO = 2
|
|
61
|
+
const val CUBIC_TO = 3
|
|
62
|
+
const val CLOSE = 4
|
|
63
|
+
}
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
package dev.angularlynx.shell
|
|
2
|
+
|
|
3
|
+
import kotlin.math.PI
|
|
4
|
+
import kotlin.math.abs
|
|
5
|
+
import kotlin.math.ceil
|
|
6
|
+
import kotlin.math.exp
|
|
7
|
+
import kotlin.math.floor
|
|
8
|
+
import kotlin.math.min
|
|
9
|
+
import kotlin.math.roundToInt
|
|
10
|
+
import kotlin.math.sqrt
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* The 2D context's `filter`, which the runtime parses into steps
|
|
14
|
+
* (packages/runtime/src/lib/canvas/css-filter.ts): a Gaussian blur, a color
|
|
15
|
+
* matrix, or a drop shadow, applied in order to the layer what's drawn went
|
|
16
|
+
* into, after its alpha and before its shadow and compositing, as the canvas
|
|
17
|
+
* spec has it.
|
|
18
|
+
*
|
|
19
|
+
* They work on the layer's bytes as `copyPixelsToBuffer` gives them,
|
|
20
|
+
* premultiplied RGBA, in sRGB, which is where the spec has filter functions
|
|
21
|
+
* work. Android's own effects don't fit: `RenderEffect` needs Android 12 and
|
|
22
|
+
* a hardware canvas, and `BlurMaskFilter` blurs only a shape's coverage, not
|
|
23
|
+
* its colors. The iOS shell runs the same steps the same way
|
|
24
|
+
* (AngularLynxCanvas2DContext.m), so the two draw alike.
|
|
25
|
+
*/
|
|
26
|
+
internal object CanvasFilter {
|
|
27
|
+
/** The steps' kinds, as css-filter.ts's FILTER_STEP numbers them. */
|
|
28
|
+
private const val BLUR = 0
|
|
29
|
+
private const val MATRIX = 1
|
|
30
|
+
private const val DROP_SHADOW = 2
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The most drop shadows in one filter that can be cast from a layer of
|
|
34
|
+
* their own (see Canvas2DContext.lastFar): the last ones moved by an
|
|
35
|
+
* offset. Each works out the steps before it twice, over the layer it
|
|
36
|
+
* goes under and over that moved back by its offset, so the draws double
|
|
37
|
+
* with each one; past this, the earlier ones are planned as any step is,
|
|
38
|
+
* within the layers' cap, as before issue #824. Three keep a fill to
|
|
39
|
+
* eight draws.
|
|
40
|
+
*/
|
|
41
|
+
private const val MAX_OWN_LAYERS = 3
|
|
42
|
+
|
|
43
|
+
/** A step of the filter: its kind (as css-filter.ts's FILTER_STEP numbers them) and its numbers. */
|
|
44
|
+
class Step(val kind: Int, val values: DoubleArray) {
|
|
45
|
+
val isBlur: Boolean get() = kind == BLUR
|
|
46
|
+
|
|
47
|
+
/** Whether it's a drop shadow moved by an offset. */
|
|
48
|
+
val isMovedShadow: Boolean get() = kind == DROP_SHADOW && (values[0] != 0.0 || values[1] != 0.0)
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether, when the filter reaches past the layers' cap, it's cast
|
|
52
|
+
* from a layer of its own: one of the filter's last MAX_OWN_LAYERS
|
|
53
|
+
* drop shadows moved by an offset, which [parse] marks.
|
|
54
|
+
*/
|
|
55
|
+
var castsAlone: Boolean = false
|
|
56
|
+
|
|
57
|
+
/** Its deviation, for a blur or a drop shadow; 0 for a color matrix. */
|
|
58
|
+
val sigma: Double get() = when (kind) {
|
|
59
|
+
BLUR -> values[0]
|
|
60
|
+
DROP_SHADOW -> values[2]
|
|
61
|
+
else -> 0.0
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* How far it can move what's drawn, in the canvas's pixels: three
|
|
66
|
+
* deviations, and a drop shadow's offset. Uncapped: planFor caps
|
|
67
|
+
* the layer it sizes (MAX_REACH).
|
|
68
|
+
*/
|
|
69
|
+
val reach: Double get() = when (kind) {
|
|
70
|
+
BLUR -> ceil(values[0] * 3)
|
|
71
|
+
DROP_SHADOW -> ceil(values[2] * 3) + ceil(maxOf(abs(values[0]), abs(values[1])))
|
|
72
|
+
else -> 0.0
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
companion object {
|
|
76
|
+
/** A blur of deviation `sigma`, as blur() makes. */
|
|
77
|
+
fun blur(sigma: Double): Step = Step(BLUR, doubleArrayOf(sigma))
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** The filter's steps, as the runtime sends them. */
|
|
82
|
+
fun parse(steps: DoubleArray): List<Step> {
|
|
83
|
+
val parsed = ArrayList<Step>()
|
|
84
|
+
var i = 0
|
|
85
|
+
while (i < steps.size) {
|
|
86
|
+
val kind = steps[i++].toInt()
|
|
87
|
+
val arity = when (kind) {
|
|
88
|
+
BLUR -> 1
|
|
89
|
+
MATRIX -> 20
|
|
90
|
+
DROP_SHADOW -> 7
|
|
91
|
+
else -> 0
|
|
92
|
+
}
|
|
93
|
+
// A step it doesn't know, or one cut short, ends the list: what's
|
|
94
|
+
// after it would be read as the wrong numbers.
|
|
95
|
+
if (arity == 0 || i + arity > steps.size) break
|
|
96
|
+
parsed.add(Step(kind, steps.copyOfRange(i, i + arity)))
|
|
97
|
+
i += arity
|
|
98
|
+
}
|
|
99
|
+
for (step in parsed.filter { it.isMovedShadow }.takeLast(MAX_OWN_LAYERS)) step.castsAlone = true
|
|
100
|
+
return parsed
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* One step on a layer's bytes, in a layer `scale` of whose pixels make a
|
|
105
|
+
* canvas pixel: its lengths (a deviation, an offset) are in the canvas's
|
|
106
|
+
* pixels, so they're scaled to the layer's.
|
|
107
|
+
*/
|
|
108
|
+
fun applyStep(bytes: ByteArray, width: Int, height: Int, step: Step, scale: Double) {
|
|
109
|
+
val v = step.values
|
|
110
|
+
when (step.kind) {
|
|
111
|
+
BLUR -> gaussianBlur(bytes, width, height, v[0] * scale)
|
|
112
|
+
MATRIX -> colorMatrix(bytes, v)
|
|
113
|
+
else -> {
|
|
114
|
+
val shadow = shadowOf(bytes, width, height, v[0] * scale, v[1] * scale, v[2] * scale, v[3], v[4], v[5], v[6])
|
|
115
|
+
under(bytes, shadow)
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** globalAlpha on a layer's bytes, which are premultiplied, so every channel scales. */
|
|
121
|
+
fun scaleAlpha(bytes: ByteArray, alpha: Double) {
|
|
122
|
+
if (alpha >= 1) return
|
|
123
|
+
for (i in bytes.indices) bytes[i] = clampByte(bytes.at(i) * alpha)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
private fun clampByte(value: Double): Byte = when {
|
|
127
|
+
value <= 0 -> 0.toByte()
|
|
128
|
+
value >= 255 -> 255.toByte()
|
|
129
|
+
else -> (value + 0.5).toInt().toByte()
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
private fun clampUnit(value: Double): Double = value.coerceIn(0.0, 1.0)
|
|
133
|
+
|
|
134
|
+
private fun ByteArray.at(index: Int): Int = this[index].toInt() and 0xff
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* A color matrix (row by row: red, green, blue, alpha; each row's factors
|
|
138
|
+
* and offset) on the colors not premultiplied, clamped, as feColorMatrix is.
|
|
139
|
+
*/
|
|
140
|
+
private fun colorMatrix(bytes: ByteArray, m: DoubleArray) {
|
|
141
|
+
for (p in 0 until bytes.size step 4) {
|
|
142
|
+
val a = bytes.at(p + 3) / 255.0
|
|
143
|
+
var r = 0.0
|
|
144
|
+
var g = 0.0
|
|
145
|
+
var b = 0.0
|
|
146
|
+
if (a > 0) {
|
|
147
|
+
r = bytes.at(p) / 255.0 / a
|
|
148
|
+
g = bytes.at(p + 1) / 255.0 / a
|
|
149
|
+
b = bytes.at(p + 2) / 255.0 / a
|
|
150
|
+
}
|
|
151
|
+
val r2 = clampUnit(m[0] * r + m[1] * g + m[2] * b + m[3] * a + m[4])
|
|
152
|
+
val g2 = clampUnit(m[5] * r + m[6] * g + m[7] * b + m[8] * a + m[9])
|
|
153
|
+
val b2 = clampUnit(m[10] * r + m[11] * g + m[12] * b + m[13] * a + m[14])
|
|
154
|
+
val a2 = clampUnit(m[15] * r + m[16] * g + m[17] * b + m[18] * a + m[19])
|
|
155
|
+
bytes[p] = clampByte(r2 * a2 * 255)
|
|
156
|
+
bytes[p + 1] = clampByte(g2 * a2 * 255)
|
|
157
|
+
bytes[p + 2] = clampByte(b2 * a2 * 255)
|
|
158
|
+
bytes[p + 3] = clampByte(a2 * 255)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* One box blur along each row (or each column), each output the mean of
|
|
164
|
+
* the `lo` bytes before it, itself and the `hi` after; transparent past
|
|
165
|
+
* the edges.
|
|
166
|
+
*/
|
|
167
|
+
private fun boxPass(src: ByteArray, dst: ByteArray, width: Int, height: Int, lo: Int, hi: Int, horizontal: Boolean) {
|
|
168
|
+
val lines = if (horizontal) height else width
|
|
169
|
+
val length = if (horizontal) width else height
|
|
170
|
+
val step = if (horizontal) 4 else width * 4
|
|
171
|
+
val lineStride = if (horizontal) width * 4 else 4
|
|
172
|
+
val size = lo + hi + 1
|
|
173
|
+
for (line in 0 until lines) {
|
|
174
|
+
val base = line * lineStride
|
|
175
|
+
for (channel in 0 until 4) {
|
|
176
|
+
var sum = 0
|
|
177
|
+
for (i in 0..min(hi, length - 1)) sum += src.at(base + i * step + channel)
|
|
178
|
+
for (x in 0 until length) {
|
|
179
|
+
dst[base + x * step + channel] = ((sum * 2 + size) / (size * 2)).toByte()
|
|
180
|
+
if (x + hi + 1 < length) sum += src.at(base + (x + hi + 1) * step + channel)
|
|
181
|
+
if (x >= lo) sum -= src.at(base + (x - lo) * step + channel)
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** One pass of a Gaussian kernel along each row (or each column). */
|
|
188
|
+
private fun kernelPass(src: ByteArray, dst: ByteArray, width: Int, height: Int, weights: DoubleArray, radius: Int, horizontal: Boolean) {
|
|
189
|
+
val lines = if (horizontal) height else width
|
|
190
|
+
val length = if (horizontal) width else height
|
|
191
|
+
val step = if (horizontal) 4 else width * 4
|
|
192
|
+
val lineStride = if (horizontal) width * 4 else 4
|
|
193
|
+
val sum = DoubleArray(4)
|
|
194
|
+
for (line in 0 until lines) {
|
|
195
|
+
val base = line * lineStride
|
|
196
|
+
for (x in 0 until length) {
|
|
197
|
+
sum.fill(0.0)
|
|
198
|
+
for (i in maxOf(0, x - radius)..min(length - 1, x + radius)) {
|
|
199
|
+
val weight = weights[i + radius - x]
|
|
200
|
+
val p = base + i * step
|
|
201
|
+
for (channel in 0 until 4) sum[channel] += src.at(p + channel) * weight
|
|
202
|
+
}
|
|
203
|
+
for (channel in 0 until 4) dst[base + x * step + channel] = clampByte(sum[channel])
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* A Gaussian blur of deviation `sigma`, as feGaussianBlur draws it: from a
|
|
210
|
+
* deviation of 2, three box blurs, which the spec gives as within 3% of
|
|
211
|
+
* the Gaussian (and which cost the same whatever the deviation); below
|
|
212
|
+
* it, the Gaussian's own kernel, which is small there.
|
|
213
|
+
*/
|
|
214
|
+
private fun gaussianBlur(bytes: ByteArray, width: Int, height: Int, sigma: Double) {
|
|
215
|
+
if (!(sigma > 0) || width == 0 || height == 0) return
|
|
216
|
+
val scratch = ByteArray(bytes.size)
|
|
217
|
+
for (horizontal in booleanArrayOf(true, false)) {
|
|
218
|
+
if (sigma >= 2) {
|
|
219
|
+
val d = floor(sigma * 3 * sqrt(2 * PI) / 4 + 0.5).toInt()
|
|
220
|
+
if (d % 2 == 1) {
|
|
221
|
+
boxPass(bytes, scratch, width, height, d / 2, d / 2, horizontal)
|
|
222
|
+
boxPass(scratch, bytes, width, height, d / 2, d / 2, horizontal)
|
|
223
|
+
boxPass(bytes, scratch, width, height, d / 2, d / 2, horizontal)
|
|
224
|
+
} else {
|
|
225
|
+
// An even box is centered between two pixels: one leans
|
|
226
|
+
// left, one right, and the third is a pixel wider and
|
|
227
|
+
// centered.
|
|
228
|
+
boxPass(bytes, scratch, width, height, d / 2, d / 2 - 1, horizontal)
|
|
229
|
+
boxPass(scratch, bytes, width, height, d / 2 - 1, d / 2, horizontal)
|
|
230
|
+
boxPass(bytes, scratch, width, height, d / 2, d / 2, horizontal)
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
val radius = ceil(sigma * 3).toInt()
|
|
234
|
+
val weights = DoubleArray(radius * 2 + 1) { i ->
|
|
235
|
+
val k = (i - radius).toDouble()
|
|
236
|
+
exp(-(k * k) / (2 * sigma * sigma))
|
|
237
|
+
}
|
|
238
|
+
val total = weights.sum()
|
|
239
|
+
for (i in weights.indices) weights[i] /= total
|
|
240
|
+
kernelPass(bytes, scratch, width, height, weights, radius, horizontal)
|
|
241
|
+
}
|
|
242
|
+
scratch.copyInto(bytes)
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* The shadow of what's in `bytes`: its alpha, moved by the offset (to the
|
|
248
|
+
* nearest pixel), blurred by the deviation and in the color (red, green
|
|
249
|
+
* and blue 0 to 255, alpha 0 to 1), as new premultiplied bytes.
|
|
250
|
+
*/
|
|
251
|
+
fun shadowOf(
|
|
252
|
+
bytes: ByteArray,
|
|
253
|
+
width: Int,
|
|
254
|
+
height: Int,
|
|
255
|
+
dx: Double,
|
|
256
|
+
dy: Double,
|
|
257
|
+
sigma: Double,
|
|
258
|
+
r: Double,
|
|
259
|
+
g: Double,
|
|
260
|
+
b: Double,
|
|
261
|
+
a: Double,
|
|
262
|
+
): ByteArray {
|
|
263
|
+
val offsetX = dx.roundToInt()
|
|
264
|
+
val offsetY = dy.roundToInt()
|
|
265
|
+
val shadow = ByteArray(bytes.size)
|
|
266
|
+
if (abs(offsetX) < width && abs(offsetY) < height) {
|
|
267
|
+
for (y in maxOf(0, offsetY) until min(height, height + offsetY)) {
|
|
268
|
+
for (x in maxOf(0, offsetX) until min(width, width + offsetX)) {
|
|
269
|
+
shadow[(y * width + x) * 4 + 3] = bytes[((y - offsetY) * width + (x - offsetX)) * 4 + 3]
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
gaussianBlur(shadow, width, height, sigma)
|
|
274
|
+
for (p in 0 until shadow.size step 4) {
|
|
275
|
+
val shadowAlpha = shadow.at(p + 3) / 255.0 * a
|
|
276
|
+
shadow[p] = clampByte(r * shadowAlpha)
|
|
277
|
+
shadow[p + 1] = clampByte(g * shadowAlpha)
|
|
278
|
+
shadow[p + 2] = clampByte(b * shadowAlpha)
|
|
279
|
+
shadow[p + 3] = clampByte(255 * shadowAlpha)
|
|
280
|
+
}
|
|
281
|
+
return shadow
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* `under` drawn under `bytes`, source-over, as drop-shadow() puts its
|
|
286
|
+
* shadow under what's drawn. Both are premultiplied, the same size.
|
|
287
|
+
*/
|
|
288
|
+
fun under(bytes: ByteArray, under: ByteArray) {
|
|
289
|
+
for (p in 0 until bytes.size) {
|
|
290
|
+
val uncovered = 1 - bytes.at(p - p % 4 + 3) / 255.0
|
|
291
|
+
bytes[p] = clampByte(bytes.at(p) + under.at(p) * uncovered)
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* The bytes of a layer resampled onto another: `src`, over the canvas's
|
|
297
|
+
* pixels from (srcLeft, srcTop) at `srcScale` of its pixels to a canvas
|
|
298
|
+
* pixel, read with bilinear filtering at the center of each of the
|
|
299
|
+
* `dstWidth` by `dstHeight` pixels of a layer from (dstLeft, dstTop) at
|
|
300
|
+
* `dstScale`, moved by (shiftX, shiftY) canvas pixels. Transparent past
|
|
301
|
+
* `src`'s edges. It's how a blur worked out in a smaller layer is scaled
|
|
302
|
+
* up, and how a drop shadow's offset lands between two pixels, which a
|
|
303
|
+
* blur that wide has no edge to show.
|
|
304
|
+
*/
|
|
305
|
+
fun resample(
|
|
306
|
+
src: ByteArray,
|
|
307
|
+
srcWidth: Int,
|
|
308
|
+
srcHeight: Int,
|
|
309
|
+
srcLeft: Double,
|
|
310
|
+
srcTop: Double,
|
|
311
|
+
srcScale: Double,
|
|
312
|
+
dstWidth: Int,
|
|
313
|
+
dstHeight: Int,
|
|
314
|
+
dstLeft: Double,
|
|
315
|
+
dstTop: Double,
|
|
316
|
+
dstScale: Double,
|
|
317
|
+
shiftX: Double,
|
|
318
|
+
shiftY: Double,
|
|
319
|
+
): ByteArray {
|
|
320
|
+
val dst = ByteArray(dstWidth * dstHeight * 4)
|
|
321
|
+
// Where each column's and row's center falls in src, as the pixel
|
|
322
|
+
// before it and how far past that pixel's center it is. Clamped, so a
|
|
323
|
+
// far shift stays an Int (and reads nothing).
|
|
324
|
+
fun axis(count: Int, from: Double, shift: Double, srcFrom: Double, size: Int): Pair<IntArray, DoubleArray> {
|
|
325
|
+
val index = IntArray(count)
|
|
326
|
+
val fraction = DoubleArray(count)
|
|
327
|
+
for (i in 0 until count) {
|
|
328
|
+
val u = ((from + (i + 0.5) / dstScale - shift - srcFrom) * srcScale - 0.5).coerceIn(-2.0, size + 1.0)
|
|
329
|
+
val whole = floor(u)
|
|
330
|
+
index[i] = whole.toInt()
|
|
331
|
+
fraction[i] = u - whole
|
|
332
|
+
}
|
|
333
|
+
return index to fraction
|
|
334
|
+
}
|
|
335
|
+
val (xs, fx) = axis(dstWidth, dstLeft, shiftX, srcLeft, srcWidth)
|
|
336
|
+
val (ys, fy) = axis(dstHeight, dstTop, shiftY, srcTop, srcHeight)
|
|
337
|
+
fun sample(x: Int, y: Int, channel: Int): Int =
|
|
338
|
+
if (x < 0 || y < 0 || x >= srcWidth || y >= srcHeight) 0 else src.at((y * srcWidth + x) * 4 + channel)
|
|
339
|
+
for (j in 0 until dstHeight) {
|
|
340
|
+
val y = ys[j]
|
|
341
|
+
if (y < -1 || y >= srcHeight) continue
|
|
342
|
+
val wy = fy[j]
|
|
343
|
+
for (i in 0 until dstWidth) {
|
|
344
|
+
val x = xs[i]
|
|
345
|
+
if (x < -1 || x >= srcWidth) continue
|
|
346
|
+
val wx = fx[i]
|
|
347
|
+
val p = (j * dstWidth + i) * 4
|
|
348
|
+
for (channel in 0 until 4) {
|
|
349
|
+
val top = sample(x, y, channel) * (1 - wx) + sample(x + 1, y, channel) * wx
|
|
350
|
+
val bottom = sample(x, y + 1, channel) * (1 - wx) + sample(x + 1, y + 1, channel) * wx
|
|
351
|
+
dst[p + channel] = clampByte(top * (1 - wy) + bottom * wy)
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
return dst
|
|
356
|
+
}
|
|
357
|
+
}
|
|
@@ -10,8 +10,9 @@ import com.lynx.tasm.behavior.LynxProp
|
|
|
10
10
|
import com.lynx.tasm.behavior.ui.LynxUI
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
|
-
* The `canvas` element: a TextureView its
|
|
14
|
-
*
|
|
13
|
+
* The `canvas` element: a TextureView its context copies each finished frame
|
|
14
|
+
* into: a WebGL context's drawing buffer (WebGLContext), or a 2D context's
|
|
15
|
+
* bitmap (Canvas2DContext). Its `canvas-id` attribute, which the runtime
|
|
15
16
|
* sets, pairs it with the context the runtime made for it.
|
|
16
17
|
*
|
|
17
18
|
* A TextureView composites with the views around it, so a canvas can sit
|
|
@@ -52,7 +53,7 @@ class CanvasUI(context: LynxContext) : LynxUI<TextureView>(context) {
|
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
private fun contextOrNull():
|
|
56
|
+
private fun contextOrNull(): CanvasContext? = canvasId?.let { CanvasRegistry.context(it) }
|
|
56
57
|
|
|
57
58
|
/**
|
|
58
59
|
* Whether the frames can be shown see-through, as the context's `alpha`
|
|
@@ -2,11 +2,14 @@ package dev.angularlynx.shell
|
|
|
2
2
|
|
|
3
3
|
import android.os.Build
|
|
4
4
|
import android.view.WindowManager
|
|
5
|
+
import android.window.OnBackInvokedCallback
|
|
6
|
+
import android.window.OnBackInvokedDispatcher
|
|
5
7
|
import androidx.core.view.WindowCompat
|
|
6
8
|
import com.lynx.tasm.behavior.Behavior
|
|
7
9
|
import com.lynx.tasm.behavior.LynxContext
|
|
8
10
|
import com.lynx.tasm.behavior.shadow.ShadowNode
|
|
9
11
|
import com.lynx.tasm.behavior.ui.LynxUI
|
|
12
|
+
import com.lynx.tasm.event.LynxDetailEvent
|
|
10
13
|
import com.lynx.xelement.LynxUIOverlayAutoRegistry
|
|
11
14
|
import com.lynx.xelement.LynxUIOverlayShadowNodeAutoRegistry
|
|
12
15
|
|
|
@@ -31,6 +34,16 @@ import com.lynx.xelement.LynxUIOverlayShadowNodeAutoRegistry
|
|
|
31
34
|
*
|
|
32
35
|
* An overlay that sets `android-adapt-edge-to-edge` itself still gets what it
|
|
33
36
|
* asks for on Android 15 and later.
|
|
37
|
+
*
|
|
38
|
+
* Android's back also reaches the overlay as `requestclose`, which the app
|
|
39
|
+
* closes it on (dolan's bottom sheet animates down, then hides it). XElement
|
|
40
|
+
* sends the event from the Dialog's key listener for KEYCODE_BACK, but the
|
|
41
|
+
* shell opts in to predictive back (enableOnBackInvokedCallback), and from
|
|
42
|
+
* Android 13 that sends back to the window's OnBackInvokedCallbacks instead,
|
|
43
|
+
* never as a key. The Dialog's own callback then canceled it: the overlay
|
|
44
|
+
* vanished in a frame, `requestclose` never came, and an app bound to it still
|
|
45
|
+
* held it open, so it couldn't open it again. A callback of the overlay's own,
|
|
46
|
+
* ahead of the Dialog's, sends the event as the key did.
|
|
34
47
|
*/
|
|
35
48
|
class EdgeToEdgeOverlay(context: LynxContext) : LynxUIOverlayAutoRegistry(context) {
|
|
36
49
|
init {
|
|
@@ -49,6 +62,17 @@ class EdgeToEdgeOverlay(context: LynxContext) : LynxUIOverlayAutoRegistry(contex
|
|
|
49
62
|
}
|
|
50
63
|
}
|
|
51
64
|
}
|
|
65
|
+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
66
|
+
// Registered once, on the window the Dialog shows in: the
|
|
67
|
+
// dispatcher keeps it while the Dialog is hidden, and only an
|
|
68
|
+
// overlay that's showing can take back.
|
|
69
|
+
window.onBackInvokedDispatcher.registerOnBackInvokedCallback(
|
|
70
|
+
OnBackInvokedDispatcher.PRIORITY_OVERLAY,
|
|
71
|
+
OnBackInvokedCallback {
|
|
72
|
+
lynxContext.eventEmitter.sendCustomEvent(LynxDetailEvent(sign, "requestclose"))
|
|
73
|
+
},
|
|
74
|
+
)
|
|
75
|
+
}
|
|
52
76
|
}
|
|
53
77
|
}
|
|
54
78
|
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
package dev.angularlynx.shell
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import android.os.Build
|
|
5
|
+
import android.os.PerformanceHintManager
|
|
6
|
+
import android.os.SystemClock
|
|
7
|
+
import android.util.Log
|
|
8
|
+
import android.view.MotionEvent
|
|
9
|
+
import androidx.annotation.RequiresApi
|
|
10
|
+
import java.io.File
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Tells Android, at every touch, that Lynx's engine thread has work coming.
|
|
14
|
+
*
|
|
15
|
+
* The engine thread runs the whole Angular app, layout and Lynx's animator
|
|
16
|
+
* (see MainActivity's thread strategy), and it works in bursts: nothing while
|
|
17
|
+
* the app is still, then a tap's handler, a navigation and a page to build,
|
|
18
|
+
* all at once. Android's scheduler sizes a thread's core and that core's
|
|
19
|
+
* frequency from how busy the thread has been, so each burst starts on a
|
|
20
|
+
* core that's slow, and most are over before the scheduler has caught up. On
|
|
21
|
+
* a Pixel 9 Pro Fold a push ran at an average of 1.2 GHz on a phone whose
|
|
22
|
+
* cores reach 3.1, and took 44 ms from the tap's handler to the page's first
|
|
23
|
+
* render. The UI thread and RenderThread don't have this problem: Android
|
|
24
|
+
* keeps a performance hint session for them itself.
|
|
25
|
+
*
|
|
26
|
+
* This is one for the engine thread. A session takes a target for a piece of
|
|
27
|
+
* the thread's work and reports of how long the work took, and the system
|
|
28
|
+
* gives the thread faster cores while the reports run over the target.
|
|
29
|
+
* Nothing here can time the engine thread's work, so the target is a frame
|
|
30
|
+
* and each report says the last work took two, at the moments its longest
|
|
31
|
+
* work starts: a finger going down, moving and lifting. With it the same
|
|
32
|
+
* push took 22 ms. The reports stop when the touches do, and the system
|
|
33
|
+
* lets the thread back down by itself.
|
|
34
|
+
*
|
|
35
|
+
* Android 12 and later. A phone whose system has no such sessions gives
|
|
36
|
+
* none ([PerformanceHintManager.createHintSession] returns null), and the
|
|
37
|
+
* touches then do nothing.
|
|
38
|
+
*/
|
|
39
|
+
@RequiresApi(Build.VERSION_CODES.S)
|
|
40
|
+
class EngineThreadHint(context: Context) {
|
|
41
|
+
private val manager = context.getSystemService(PerformanceHintManager::class.java)
|
|
42
|
+
|
|
43
|
+
// Made at the first touch that finds the engine thread: Lynx starts it
|
|
44
|
+
// with the first LynxView, after the activity is made.
|
|
45
|
+
private var session: PerformanceHintManager.Session? = null
|
|
46
|
+
|
|
47
|
+
// Whether a session was asked for and refused, so it isn't asked for at
|
|
48
|
+
// every touch.
|
|
49
|
+
private var unsupported = false
|
|
50
|
+
|
|
51
|
+
// When the last report was made, in SystemClock.uptimeMillis().
|
|
52
|
+
private var reportedAt = 0L
|
|
53
|
+
|
|
54
|
+
// When the engine thread was last looked for and not found, in
|
|
55
|
+
// SystemClock.uptimeMillis(), or null when it hasn't been missed. Looking
|
|
56
|
+
// reads every thread's name in /proc on the UI thread, so a miss holds
|
|
57
|
+
// the next look off for SEARCH_INTERVAL_MILLIS: a thread that's late is
|
|
58
|
+
// still found, a second at most after it starts, and one that never
|
|
59
|
+
// comes (a Lynx that names it differently) costs a look a second, not
|
|
60
|
+
// one at every touch.
|
|
61
|
+
private var missedAt: Long? = null
|
|
62
|
+
|
|
63
|
+
// The least time between two reports while a finger moves: the system
|
|
64
|
+
// reads a session's reports no more often than this.
|
|
65
|
+
private val moveInterval =
|
|
66
|
+
(manager?.preferredUpdateRateNanos ?: 0L).coerceAtLeast(0L) / NANOS_PER_MILLISECOND
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Reports for a touch `event` the activity is about to dispatch: always
|
|
70
|
+
* for a finger going down or lifting, where a press, a tap or a swipe's
|
|
71
|
+
* end starts the engine thread's work, and for a move no more often than
|
|
72
|
+
* the system reads reports, for the handlers a drag runs. Reporting only
|
|
73
|
+
* when a finger goes down pushed a page as fast, but over a scroll of
|
|
74
|
+
* a long list the engine thread then ran 10% longer, for no measurable
|
|
75
|
+
* saving in energy.
|
|
76
|
+
*/
|
|
77
|
+
fun touched(event: MotionEvent) {
|
|
78
|
+
val now = SystemClock.uptimeMillis()
|
|
79
|
+
when (event.actionMasked) {
|
|
80
|
+
MotionEvent.ACTION_DOWN, MotionEvent.ACTION_POINTER_DOWN, MotionEvent.ACTION_UP -> {}
|
|
81
|
+
MotionEvent.ACTION_MOVE -> if (now - reportedAt < moveInterval) return
|
|
82
|
+
else -> return
|
|
83
|
+
}
|
|
84
|
+
val session = session ?: open(now) ?: return
|
|
85
|
+
reportedAt = now
|
|
86
|
+
try {
|
|
87
|
+
session.reportActualWorkDuration(REPORTED_NANOS)
|
|
88
|
+
} catch (error: RuntimeException) {
|
|
89
|
+
// The session's threads are gone, or the system dropped it: start
|
|
90
|
+
// again at the next touch.
|
|
91
|
+
Log.w(TAG, "Engine thread hint: report failed", error)
|
|
92
|
+
close()
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Ends the session, with the activity. */
|
|
97
|
+
fun close() {
|
|
98
|
+
session?.close()
|
|
99
|
+
session = null
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
private fun open(now: Long): PerformanceHintManager.Session? {
|
|
103
|
+
if (unsupported || manager == null) return null
|
|
104
|
+
if (missedAt?.let { now - it < SEARCH_INTERVAL_MILLIS } == true) return null
|
|
105
|
+
val threads = engineThreads()
|
|
106
|
+
if (threads.isEmpty()) {
|
|
107
|
+
missedAt = now
|
|
108
|
+
return null
|
|
109
|
+
}
|
|
110
|
+
session = try {
|
|
111
|
+
manager.createHintSession(threads, TARGET_NANOS)
|
|
112
|
+
} catch (error: RuntimeException) {
|
|
113
|
+
Log.w(TAG, "Engine thread hint: no session", error)
|
|
114
|
+
null
|
|
115
|
+
}
|
|
116
|
+
unsupported = session == null
|
|
117
|
+
return session
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The ids of the process's threads Lynx named as its engine thread
|
|
122
|
+
* (`Lynx_TASM`, or `Lynx_TASM1` and up when it keeps several), read from
|
|
123
|
+
* /proc: Lynx starts the thread itself, in native code, and has no call
|
|
124
|
+
* that gives its id.
|
|
125
|
+
*/
|
|
126
|
+
private fun engineThreads(): IntArray =
|
|
127
|
+
(File("/proc/self/task").listFiles() ?: emptyArray())
|
|
128
|
+
.filter { task ->
|
|
129
|
+
try {
|
|
130
|
+
File(task, "comm").readText().startsWith(ENGINE_THREAD_NAME)
|
|
131
|
+
} catch (_: java.io.IOException) {
|
|
132
|
+
// The thread ended between the listing and the read.
|
|
133
|
+
false
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
.mapNotNull { it.name.toIntOrNull() }
|
|
137
|
+
.toIntArray()
|
|
138
|
+
|
|
139
|
+
private companion object {
|
|
140
|
+
const val TAG = "AngularLynxShell"
|
|
141
|
+
|
|
142
|
+
// Lynx's name for the thread, in its task runners' StartTASMThread().
|
|
143
|
+
const val ENGINE_THREAD_NAME = "Lynx_TASM"
|
|
144
|
+
const val NANOS_PER_MILLISECOND = 1_000_000L
|
|
145
|
+
|
|
146
|
+
// The least time between two looks for an engine thread that wasn't
|
|
147
|
+
// there.
|
|
148
|
+
const val SEARCH_INTERVAL_MILLIS = 1_000L
|
|
149
|
+
|
|
150
|
+
// A frame at 120 Hz, and two of them. What matters is that the
|
|
151
|
+
// report is over the target: on the Pixel a report of twice the
|
|
152
|
+
// target and one of twelve times it sped a push up alike.
|
|
153
|
+
const val TARGET_NANOS = 8_333_333L
|
|
154
|
+
const val REPORTED_NANOS = 2 * TARGET_NANOS
|
|
155
|
+
}
|
|
156
|
+
}
|