Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
RenderSurface.java
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5package io.flutter.embedding.engine.renderer;
6
7import android.view.Surface;
8import androidx.annotation.NonNull;
9import androidx.annotation.Nullable;
10
11/**
12 * Owns a {@code Surface} that {@code FlutterRenderer} would like to paint.
13 *
14 * <p>{@code RenderSurface} is responsible for providing a {@code Surface} to a given {@code
15 * FlutterRenderer} when requested, and then notify that {@code FlutterRenderer} when the {@code
16 * Surface} changes, or is destroyed.
17 *
18 * <p>The behavior of providing a {@code Surface} is delegated to this interface because the timing
19 * of a {@code Surface}'s availability is determined by Android. Therefore, an accessor method would
20 * not fulfill the requirements. Therefore, a {@code RenderSurface} is given a {@code
21 * FlutterRenderer}, which the {@code RenderSurface} is expected to notify as a {@code Surface}
22 * becomes available, changes, or is destroyed.
23 */
24public interface RenderSurface {
25 /**
26 * Returns the {@code FlutterRenderer} that is attached to this {@code RenderSurface}, or null if
27 * no {@code FlutterRenderer} is currently attached.
28 */
29 @Nullable
31
32 /**
33 * Instructs this {@code RenderSurface} to give its {@code Surface} to the given {@code
34 * FlutterRenderer} so that Flutter can paint pixels on it.
35 *
36 * <p>After this call, {@code RenderSurface} is expected to invoke the following methods on {@link
37 * FlutterRenderer} at the appropriate times:
38 *
39 * <ol>
40 * <li>{@link FlutterRenderer#startRenderingToSurface(Surface, boolean)}
41 * <li>{@link FlutterRenderer#surfaceChanged(int, int)}}
42 * <li>{@link FlutterRenderer#stopRenderingToSurface()}
43 * </ol>
44 */
45 void attachToRenderer(@NonNull FlutterRenderer renderer);
46
47 /**
48 * Instructs this {@code RenderSurface} to stop forwarding {@code Surface} notifications to the
49 * {@code FlutterRenderer} that was previously connected with {@link
50 * #attachToRenderer(FlutterRenderer)}.
51 *
52 * <p>This {@code RenderSurface} should also clean up any references related to the previously
53 * connected {@code FlutterRenderer}.
54 */
56
57 /**
58 * Instructs this {@code RenderSurface} to stop forwarding {@code Surface} notifications to the
59 * {@code FlutterRenderer} that was previously connected with {@link
60 * #attachToRenderer(FlutterRenderer)}.
61 */
62 void pause();
63
64 /**
65 * Instructs this {@code RenderSurface} to resume forwarding {@code Surface} notifications to the
66 * {@code FlutterRenderer} that was previously connected with {@link
67 * #attachToRenderer(FlutterRenderer)}.
68 */
69 void resume();
70}
void attachToRenderer(@NonNull FlutterRenderer renderer)