Retrieve screen info once

The method getScreenInfo() is synchronized, and the result may change
between calls.

Call it once and store the result in a local variable.
locked
Romain Vimont 4 years ago
parent c0f428eb05
commit ef56cc6ff7

@ -63,8 +63,9 @@ public class ScreenEncoder implements Device.RotationListener {
do {
MediaCodec codec = createCodec();
IBinder display = createDisplay();
Rect contentRect = device.getScreenInfo().getContentRect();
Rect videoRect = device.getScreenInfo().getVideoSize().toRect();
ScreenInfo screenInfo = device.getScreenInfo();
Rect contentRect = screenInfo.getContentRect();
Rect videoRect = screenInfo.getVideoSize().toRect();
setSize(format, videoRect.width(), videoRect.height());
configure(codec, format);
Surface surface = codec.createInputSurface();

Loading…
Cancel
Save