26 {
28
29
30 final Handler handler = new Handler(Looper.getMainLooper());
31 final SurfaceTextureSurfaceProducer producer =
32 new SurfaceTextureSurfaceProducer(
33 0, handler, fakeJNI, flutterRenderer.registerSurfaceTexture(new SurfaceTexture(0)));
34 final Surface
surface = producer.getSurface();
35 AtomicInteger frames = new AtomicInteger();
36 producer
37 .getSurfaceTexture()
38 .setOnFrameAvailableListener(
41 return;
42 }
43 frames.getAndIncrement();
44 });
45 producer.setSize(100, 200);
46
47
48 Canvas canvas =
surface.lockHardwareCanvas();
49 canvas.drawARGB(255, 255, 0, 0);
50 surface.unlockCanvasAndPost(canvas);
51 shadowOf(Looper.getMainLooper()).idle();
52 assertEquals(frames.get(), 1);
53
54
55 producer.setSize(400, 800);
56 canvas =
surface.lockHardwareCanvas();
57 canvas.drawARGB(255, 255, 0, 0);
58 surface.unlockCanvasAndPost(canvas);
59 shadowOf(Looper.getMainLooper()).idle();
60 assertEquals(frames.get(), 2);
61
62
64 producer.release();
65 }
void detachFromNativeAndReleaseResources()