Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3ba1c4e

Browse files
committed
createOverlaySurface JNI
1 parent 87d8888 commit 3ba1c4e

File tree

10 files changed

+143
-1
lines changed

10 files changed

+143
-1
lines changed
1 Byte
Binary file not shown.

.gradle/6.5/gc.properties

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#Fri Jun 05 11:53:05 CDT 2020
2+
gradle.version=6.5

.gradle/vcs-1/gc.properties

Whitespace-only changes.

ci/licenses_golden/licenses_flutter

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ LIBRARY: txt
1111
ORIGIN: ../../../flutter/LICENSE
1212
TYPE: LicenseType.bsd
1313
FILE: ../../../flutter/.clang-tidy
14+
FILE: ../../../flutter/.gradle/6.5/fileChanges/last-build.bin
15+
FILE: ../../../flutter/.gradle/buildOutputCleanup/cache.properties
1416
FILE: ../../../flutter/DEPS
1517
FILE: ../../../flutter/assets/asset_manager.cc
1618
FILE: ../../../flutter/assets/asset_manager.h
@@ -702,6 +704,7 @@ FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/Flutte
702704
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEngineCache.java
703705
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterEnginePluginRegistry.java
704706
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterJNI.java
707+
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterOverlaySurface.java
705708
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/FlutterShellArgs.java
706709
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/dart/DartExecutor.java
707710
FILE: ../../../flutter/shell/platform/android/io/flutter/embedding/engine/dart/DartMessenger.java

shell/platform/android/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ android_java_sources = [
150150
"io/flutter/embedding/engine/FlutterEngineCache.java",
151151
"io/flutter/embedding/engine/FlutterEnginePluginRegistry.java",
152152
"io/flutter/embedding/engine/FlutterJNI.java",
153+
"io/flutter/embedding/engine/FlutterOverlaySurface.java",
153154
"io/flutter/embedding/engine/FlutterShellArgs.java",
154155
"io/flutter/embedding/engine/dart/DartExecutor.java",
155156
"io/flutter/embedding/engine/dart/DartMessenger.java",
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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+
5+
package io.flutter.embedding.engine;
6+
7+
import android.view.Surface;
8+
9+
public class FlutterOverlaySurface {
10+
private final Surface surface;
11+
private final long id;
12+
13+
public FlutterOverlaySurface(long id, Surface surface) {
14+
this.id = id;
15+
this.surface = surface;
16+
}
17+
18+
public long getId() {
19+
return id;
20+
}
21+
22+
public Surface getSurface() {
23+
return surface;
24+
}
25+
}

shell/platform/android/io/flutter/plugin/platform/PlatformViewsController.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import androidx.annotation.VisibleForTesting;
2020
import io.flutter.embedding.engine.dart.DartExecutor;
2121
import io.flutter.embedding.engine.systemchannels.PlatformViewsChannel;
22+
import io.flutter.embedding.engine.FlutterOverlaySurface;
2223
import io.flutter.plugin.editing.TextInputPlugin;
2324
import io.flutter.view.AccessibilityBridge;
2425
import io.flutter.view.TextureRegistry;
@@ -541,4 +542,17 @@ public void onDisplayPlatformView(int viewId, int x, int y, int width, int heigh
541542
public void onDisplayOverlaySurface(int id, int x, int y, int width, int height) {
542543
// TODO: Implement this method. https://github.com/flutter/flutter/issues/58288
543544
}
544-
}
545+
546+
public void onBeginFrame() {
547+
// TODO: Implement this method. https://github.com/flutter/flutter/issues/58288
548+
}
549+
550+
public void onEndFrame() {
551+
// TODO: Implement this method. https://github.com/flutter/flutter/issues/58288
552+
}
553+
554+
public FlutterOverlaySurface createOverlaySurface() {
555+
// TODO: Implement this method. https://github.com/flutter/flutter/issues/58288
556+
return null;
557+
}
558+
}
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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+
5+
#ifndef FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_
6+
#define FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_
7+
8+
#include <jni.h>
9+
#include "flutter/fml/macros.h"
10+
#include "flutter/shell/platform/android/platform_view_android.h"
11+
12+
namespace flutter {
13+
14+
void FlutterViewHandlePlatformMessage(JNIEnv* env,
15+
jobject obj,
16+
jstring channel,
17+
jobject message,
18+
jint responseId);
19+
20+
void FlutterViewHandlePlatformMessageResponse(JNIEnv* env,
21+
jobject obj,
22+
jint responseId,
23+
jobject response);
24+
25+
void FlutterViewUpdateSemantics(JNIEnv* env,
26+
jobject obj,
27+
jobject buffer,
28+
jobjectArray strings);
29+
30+
void FlutterViewUpdateCustomAccessibilityActions(JNIEnv* env,
31+
jobject obj,
32+
jobject buffer,
33+
jobjectArray strings);
34+
35+
void FlutterViewOnFirstFrame(JNIEnv* env, jobject obj);
36+
37+
void FlutterViewOnPreEngineRestart(JNIEnv* env, jobject obj);
38+
39+
class AndroidFlutterOverlaySurface {
40+
public:
41+
AndroidFlutterOverlaySurface(long id, fml::RefPtr<AndroidNativeWindow> window)
42+
: id_(id), window_(std::move(window)){};
43+
44+
long GetId() { return id_; }
45+
46+
fml::RefPtr<AndroidNativeWindow> GetWindow() { return window_; }
47+
48+
private:
49+
long id_;
50+
fml::RefPtr<AndroidNativeWindow> window_;
51+
};
52+
53+
std::unique_ptr<AndroidFlutterOverlaySurface> FlutterViewCreateOverlaySurface(
54+
JNIEnv* env,
55+
jobject obj);
56+
57+
void SurfaceTextureAttachToGLContext(JNIEnv* env, jobject obj, jint textureId);
58+
59+
void SurfaceTextureUpdateTexImage(JNIEnv* env, jobject obj);
60+
61+
void SurfaceTextureGetTransformMatrix(JNIEnv* env,
62+
jobject obj,
63+
jfloatArray result);
64+
65+
void SurfaceTextureDetachFromGLContext(JNIEnv* env, jobject obj);
66+
67+
} // namespace flutter
68+
69+
#endif // FLUTTER_SHELL_PLATFORM_ANDROID_PLATFORM_VIEW_ANDROID_JNI_H_

shell/platform/android/platform_view_android_jni_impl.cc

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,26 @@ static jmethodID g_on_first_frame_method = nullptr;
8080

8181
static jmethodID g_on_engine_restart_method = nullptr;
8282

83+
static jmethodID g_create_overlay_surface_method = nullptr;
84+
static jmethodID g_flutter_overlay_layer_get_id_method = nullptr;
85+
static jmethodID g_flutter_overlay_layer_get_surface_method = nullptr;
86+
87+
std::unique_ptr<AndroidFlutterOverlaySurface> FlutterViewCreateOverlaySurface(
88+
JNIEnv* env,
89+
jobject obj) {
90+
jobject joverlay_layer =
91+
env->CallObjectMethod(obj, g_create_overlay_surface_method);
92+
jlong layer_id = env->CallLongMethod(joverlay_layer,
93+
g_flutter_overlay_layer_get_id_method);
94+
jobject surface = env->CallObjectMethod(
95+
joverlay_layer, g_flutter_overlay_layer_get_surface_method);
96+
97+
FML_CHECK(CheckException(env));
98+
return std::make_unique<AndroidFlutterOverlaySurface>(
99+
layer_id, fml::MakeRefCounted<AndroidNativeWindow>(
100+
ANativeWindow_fromSurface(env, surface)));
101+
}
102+
83103
static jmethodID g_attach_to_gl_context_method = nullptr;
84104

85105
static jmethodID g_update_tex_image_method = nullptr;
@@ -679,6 +699,10 @@ bool RegisterApi(JNIEnv* env) {
679699
return false;
680700
}
681701

702+
g_create_overlay_surface_method =
703+
env->GetMethodID(g_flutter_jni_class->obj(), "createOverlaySurface",
704+
"()Lio/flutter/embedding/engine/FlutterOverlaySurface;");
705+
682706
return true;
683707
}
684708

@@ -703,6 +727,10 @@ bool PlatformViewAndroid::Register(JNIEnv* env) {
703727
return false;
704728
}
705729

730+
g_create_overlay_surface_method =
731+
env->GetMethodID(g_flutter_jni_class->obj(), "createOverlaySurface",
732+
"()Lio/flutter/embedding/engine/FlutterOverlaySurface;");
733+
706734
g_flutter_jni_class = new fml::jni::ScopedJavaGlobalRef<jclass>(
707735
env, env->FindClass("io/flutter/embedding/engine/FlutterJNI"));
708736
if (g_flutter_jni_class->is_null()) {

0 commit comments

Comments
 (0)