mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
[Impeller] add --enable-impeller-3d flag to support scene experimentation (flutter/engine#37990)
* ++ * ++ * ++ * ++ * ++ * ++ * ++ * ++
This commit is contained in:
parent
1152a06319
commit
da4e6080bd
@ -1714,6 +1714,7 @@ FILE: ../../../flutter/impeller/typographer/typographer_unittests.cc
|
||||
FILE: ../../../flutter/lib/io/dart_io.cc
|
||||
FILE: ../../../flutter/lib/io/dart_io.h
|
||||
FILE: ../../../flutter/lib/snapshot/libraries.json
|
||||
FILE: ../../../flutter/lib/snapshot/libraries_experimental.json
|
||||
FILE: ../../../flutter/lib/snapshot/snapshot.h
|
||||
FILE: ../../../flutter/lib/ui/annotations.dart
|
||||
FILE: ../../../flutter/lib/ui/channel_buffers.dart
|
||||
@ -1728,6 +1729,8 @@ FILE: ../../../flutter/lib/ui/dart_runtime_hooks.h
|
||||
FILE: ../../../flutter/lib/ui/dart_ui.cc
|
||||
FILE: ../../../flutter/lib/ui/dart_ui.h
|
||||
FILE: ../../../flutter/lib/ui/dart_wrapper.h
|
||||
FILE: ../../../flutter/lib/ui/experiments/compositing_3d.dart
|
||||
FILE: ../../../flutter/lib/ui/experiments/ui.dart
|
||||
FILE: ../../../flutter/lib/ui/geometry.dart
|
||||
FILE: ../../../flutter/lib/ui/hash_codes.dart
|
||||
FILE: ../../../flutter/lib/ui/hooks.dart
|
||||
|
||||
@ -35,6 +35,9 @@ declare_args() {
|
||||
|
||||
# Call glGetError after each OpenGL call and log failures.
|
||||
impeller_error_check_all_gl_calls = is_debug
|
||||
|
||||
# Eperimentally enable 3d code paths.
|
||||
impeller_enable_3d = false
|
||||
}
|
||||
|
||||
declare_args() {
|
||||
|
||||
@ -5,6 +5,7 @@
|
||||
import("//build/compiled_action.gni")
|
||||
import("//build/fuchsia/sdk.gni")
|
||||
import("//flutter/common/config.gni")
|
||||
import("//flutter/impeller/tools/impeller.gni")
|
||||
import("//flutter/lib/ui/dart_ui.gni")
|
||||
import("//third_party/dart/utils/compile_platform.gni")
|
||||
|
||||
@ -315,8 +316,13 @@ source_set("snapshot") {
|
||||
compile_platform("strong_platform") {
|
||||
single_root_scheme = "org-dartlang-sdk"
|
||||
single_root_base = rebase_path("../../../")
|
||||
libraries_specification_uri =
|
||||
"org-dartlang-sdk:///flutter/lib/snapshot/libraries.json"
|
||||
if (impeller_enable_3d) {
|
||||
libraries_specification_uri =
|
||||
"org-dartlang-sdk:///flutter/lib/snapshot/libraries_experimental.json"
|
||||
} else {
|
||||
libraries_specification_uri =
|
||||
"org-dartlang-sdk:///flutter/lib/snapshot/libraries.json"
|
||||
}
|
||||
|
||||
outputs = [
|
||||
"$root_out_dir/flutter_patched_sdk/platform_strong.dill",
|
||||
|
||||
17
engine/src/flutter/lib/snapshot/libraries_experimental.json
Normal file
17
engine/src/flutter/lib/snapshot/libraries_experimental.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"comment:0": "NOTE: THIS FILE IS GENERATED. DO NOT EDIT.",
|
||||
"comment:1": "Instead modify 'flutter/lib/snapshot/libraries.yaml' and follow the instructions therein.",
|
||||
"flutter": {
|
||||
"include": [
|
||||
{
|
||||
"path": "../../../third_party/dart/sdk/lib/libraries.json",
|
||||
"target": "vm_common"
|
||||
}
|
||||
],
|
||||
"libraries": {
|
||||
"ui": {
|
||||
"uri": "../../lib/ui/experiments/ui.dart"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -189,6 +189,9 @@ source_set("ui") {
|
||||
# Required for M_PI and others.
|
||||
defines += [ "_USE_MATH_DEFINES" ]
|
||||
}
|
||||
if (impeller_enable_3d) {
|
||||
defines += [ "IMPELLER_ENABLE_3D" ]
|
||||
}
|
||||
}
|
||||
|
||||
if (enable_unittests) {
|
||||
|
||||
@ -262,6 +262,22 @@ void SceneBuilder::addTexture(double dx,
|
||||
AddLayer(std::move(layer));
|
||||
}
|
||||
|
||||
#ifdef IMPELLER_ENABLE_3D
|
||||
// static
|
||||
void SceneBuilder::addModelLayer(Dart_Handle wrapper,
|
||||
double dx,
|
||||
double dy,
|
||||
double width,
|
||||
double height,
|
||||
int64_t viewId) {
|
||||
auto* scene_builder = tonic::DartConverter<SceneBuilder*>::FromDart(wrapper);
|
||||
SkMatrix sk_matrix = SkMatrix::Translate(dx, dy);
|
||||
auto layer = std::make_shared<flutter::TransformLayer>(sk_matrix);
|
||||
scene_builder->AddLayer(std::move(layer));
|
||||
}
|
||||
|
||||
#endif // IMPELLER_ENABLE_3D
|
||||
|
||||
void SceneBuilder::addPlatformView(double dx,
|
||||
double dy,
|
||||
double width,
|
||||
|
||||
@ -34,6 +34,15 @@ class SceneBuilder : public RefCountedDartWrappable<SceneBuilder> {
|
||||
res->AssociateWithDartWrapper(wrapper);
|
||||
}
|
||||
|
||||
#ifdef IMPELLER_ENABLE_3D
|
||||
static void addModelLayer(Dart_Handle wrapper,
|
||||
double dx,
|
||||
double dy,
|
||||
double width,
|
||||
double height,
|
||||
int64_t viewId);
|
||||
#endif // IMPELLER_ENABLE_3D
|
||||
|
||||
~SceneBuilder() override;
|
||||
|
||||
void pushTransformHandle(Dart_Handle layer_handle,
|
||||
|
||||
@ -294,6 +294,10 @@ typedef CanvasPath Path;
|
||||
V(SemanticsUpdate, dispose, 1) \
|
||||
V(Vertices, dispose, 1)
|
||||
|
||||
#ifdef IMPELLER_ENABLE_3D
|
||||
#define FFI_METHOD_LIST_3D(V) V(SceneBuilder::addModelLayer, 7)
|
||||
#endif // IMPELLER_ENABLE_3D
|
||||
|
||||
#define FFI_FUNCTION_INSERT(FUNCTION, ARGS) \
|
||||
g_function_dispatchers.insert(std::make_pair( \
|
||||
std::string_view(#FUNCTION), \
|
||||
@ -320,6 +324,9 @@ void* ResolveFfiNativeFunction(const char* name, uintptr_t args) {
|
||||
void InitDispatcherMap() {
|
||||
FFI_FUNCTION_LIST(FFI_FUNCTION_INSERT)
|
||||
FFI_METHOD_LIST(FFI_METHOD_INSERT)
|
||||
#ifdef IMPELLER_ENABLE_3D
|
||||
FFI_METHOD_LIST_3D(FFI_FUNCTION_INSERT)
|
||||
#endif // IMPELLER_ENABLE_3D
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
18
engine/src/flutter/lib/ui/experiments/compositing_3d.dart
Normal file
18
engine/src/flutter/lib/ui/experiments/compositing_3d.dart
Normal file
@ -0,0 +1,18 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
part of dart.ui;
|
||||
|
||||
void addModelLayer(
|
||||
SceneBuilder builder,
|
||||
int viewId, {
|
||||
Offset offset = Offset.zero,
|
||||
double width = 0.0,
|
||||
double height = 0.0,
|
||||
}) {
|
||||
assert(offset != null, 'Offset argument was null');
|
||||
_addModelLayer(builder, offset.dx, offset.dy, width, height, viewId);
|
||||
}
|
||||
|
||||
@FfiNative<Void Function(Handle, Double, Double, Double, Double, Int64)>('SceneBuilder::addModelLayer')
|
||||
external void _addModelLayer(Object object, double dx, double dy, double width, double height, int viewId);
|
||||
43
engine/src/flutter/lib/ui/experiments/ui.dart
Normal file
43
engine/src/flutter/lib/ui/experiments/ui.dart
Normal file
@ -0,0 +1,43 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
/// Built-in types and core primitives for a Flutter application.
|
||||
///
|
||||
/// To use, import `dart:ui`.
|
||||
///
|
||||
/// This library exposes the lowest-level services that Flutter frameworks use
|
||||
/// to bootstrap applications, such as classes for driving the input, graphics
|
||||
/// text, layout, and rendering subsystems.
|
||||
library dart.ui;
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:collection' as collection;
|
||||
import 'dart:convert';
|
||||
import 'dart:developer' as developer;
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'dart:isolate' show SendPort;
|
||||
import 'dart:math' as math;
|
||||
import 'dart:nativewrappers';
|
||||
import 'dart:typed_data';
|
||||
|
||||
part '../annotations.dart';
|
||||
part '../channel_buffers.dart';
|
||||
part '../compositing.dart';
|
||||
part 'compositing_3d.dart';
|
||||
part '../geometry.dart';
|
||||
part '../hash_codes.dart';
|
||||
part '../hooks.dart';
|
||||
part '../isolate_name_server.dart';
|
||||
part '../key.dart';
|
||||
part '../lerp.dart';
|
||||
part '../math.dart';
|
||||
part '../natives.dart';
|
||||
part '../painting.dart';
|
||||
part '../platform_dispatcher.dart';
|
||||
part '../plugins.dart';
|
||||
part '../pointer.dart';
|
||||
part '../semantics.dart';
|
||||
part '../text.dart';
|
||||
part '../window.dart';
|
||||
@ -551,6 +551,9 @@ def to_gn_args(args):
|
||||
elif os.getenv('FLUTTER_IMPELLER_ENABLE_PLAYGROUND', '0') == '1':
|
||||
gn_args['impeller_enable_playground'] = True
|
||||
|
||||
if args.enable_impeller_3d:
|
||||
gn_args['impeller_enable_3d'] = True
|
||||
|
||||
if args.prebuilt_impellerc is not None:
|
||||
gn_args['impeller_use_prebuilt_impellerc'] = args.prebuilt_impellerc
|
||||
|
||||
@ -978,6 +981,13 @@ def parse_args(args):
|
||||
'https://github.com/flutter/flutter/issues/107357'
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
'--enable-impeller-3d',
|
||||
default=False,
|
||||
action='store_true',
|
||||
help='Enables experimental 3d support.'
|
||||
)
|
||||
|
||||
# Sanitizers.
|
||||
parser.add_argument('--asan', default=False, action='store_true')
|
||||
parser.add_argument('--lsan', default=False, action='store_true')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user