Skip to content

Commit d2a4915

Browse files
authored
Add notes about new SurfaceProducer APIs for 3.27. (#11179)
Documents (for end-users) the changes made in: - flutter/engine#55418 - flutter/engine#55434 (pending merge)
1 parent 5d3318d commit d2a4915

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

src/content/release/breaking-changes/android-surface-plugins.md

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ use the provided [`setCallback`][] method to listen to surface lifecycle events:
6060
surfaceProducer.setCallback(
6161
new TextureRegistry.SurfaceProducer.Callback() {
6262
@Override
63-
public void onSurfaceCreated() {
63+
public void onSurfaceAvailable() {
6464
// Do surface initialization here, and draw the current frame.
6565
}
6666

@@ -75,6 +75,12 @@ surfaceProducer.setCallback(
7575
A full example of using this new API can be found in [PR 6989][] for the
7676
`video_player_android` plugin.
7777

78+
:::note
79+
In early versions of this API, the callback was named `onSurfaceCreated`, and
80+
was invoked even if the original surface was not destroyed. This has been fixed
81+
in the latest (pending 3.27) version of the API.
82+
:::
83+
7884
## Note on camera previews
7985

8086
If your plugin implements a camera preview, your migration might also require
@@ -91,13 +97,16 @@ rotation = (sensorOrientationDegrees - deviceOrientationDegrees * sign + 360) %
9197
```
9298

9399
where `deviceOrientationDegrees` is counterclockwise degrees and `sign` is 1 for
94-
front-facing cameras and -1 for back-facing cameras.
100+
front-facing cameras and -1 for back-facing cameras.
95101

96102
To calculate this rotation,
103+
104+
- Use [`SurfaceProducer.handlesCropAndRotation`][] to check if the underlying
105+
`Surface` handles rotation (if `false`, you may need to handle the rotation).
97106
- Retrieve the sensor orientation degrees by retrieving the value of
98-
[`CameraCharacteristics.SENSOR_ORIENTATION`][].
107+
[`CameraCharacteristics.SENSOR_ORIENTATION`][].
99108
- Retrieve the device orientation degrees in one of the ways that the
100-
[Android orientation calculation documentation][] details.
109+
[Android orientation calculation documentation][] details.
101110

102111
To apply this rotation, you can use a [`RotatedBox`][] widget.
103112

@@ -116,6 +125,9 @@ plugins that migrate to this API should set `3.24` as a minimum version constrai
116125

117126
In stable release: 3.24
118127

128+
In the upcoming stable release, 3.27, `onSurfaceCreated` is deprecated, and
129+
`onSurfaceAvailable` and `handlesCropAndRotation` are added.
130+
119131
## References
120132

121133
API documentation:
@@ -142,6 +154,7 @@ Relevant PRs:
142154
[`HardwareBuffer`]: https://developer.android.com/reference/android/hardware/HardwareBuffer
143155
[`Surface`]: https://developer.android.com/reference/android/view/Surface
144156
[`SurfaceProducer`]: {{site.api}}/javadoc/io/flutter/view/TextureRegistry.SurfaceProducer.html
157+
[`SurfaceProducer.handlesCropAndRotation`]: {{site.api}}/javadoc/io/flutter/view/TextureRegistry.SurfaceProducer.html#handlesCropAndRotation()
145158
[`SurfaceTexture`]: https://source.android.com/docs/core/graphics/arch-st
146159
[`createSurfaceProducer`]: {{site.api}}/javadoc/io/flutter/view/TextureRegistry.html#createSurfaceProducer()
147160
[`createSurfaceTexture`]: {{site.api}}/javadoc/io/flutter/view/TextureRegistry.html#createSurfaceTexture()

0 commit comments

Comments
 (0)