Flutter Engine
dart_ui.cc
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 
5 #include "flutter/lib/ui/dart_ui.h"
6 
7 #include "flutter/fml/build_config.h"
8 #include "flutter/lib/ui/compositing/scene.h"
9 #include "flutter/lib/ui/compositing/scene_builder.h"
10 #include "flutter/lib/ui/dart_runtime_hooks.h"
11 #include "flutter/lib/ui/isolate_name_server/isolate_name_server_natives.h"
12 #include "flutter/lib/ui/painting/canvas.h"
13 #include "flutter/lib/ui/painting/codec.h"
14 #include "flutter/lib/ui/painting/color_filter.h"
15 #include "flutter/lib/ui/painting/engine_layer.h"
16 #include "flutter/lib/ui/painting/gradient.h"
17 #include "flutter/lib/ui/painting/image.h"
18 #include "flutter/lib/ui/painting/image_descriptor.h"
19 #include "flutter/lib/ui/painting/image_filter.h"
20 #include "flutter/lib/ui/painting/image_shader.h"
21 #include "flutter/lib/ui/painting/immutable_buffer.h"
22 #include "flutter/lib/ui/painting/path.h"
23 #include "flutter/lib/ui/painting/path_measure.h"
24 #include "flutter/lib/ui/painting/picture.h"
25 #include "flutter/lib/ui/painting/picture_recorder.h"
26 #include "flutter/lib/ui/painting/vertices.h"
27 #include "flutter/lib/ui/semantics/semantics_update.h"
28 #include "flutter/lib/ui/semantics/semantics_update_builder.h"
29 #include "flutter/lib/ui/text/font_collection.h"
30 #include "flutter/lib/ui/text/paragraph.h"
31 #include "flutter/lib/ui/text/paragraph_builder.h"
32 #include "flutter/lib/ui/window/platform_configuration.h"
35 
36 #if defined(LEGACY_FUCHSIA_EMBEDDER)
37 #include "flutter/lib/ui/compositing/scene_host.h" // nogncheck
38 #endif
39 
40 using tonic::ToDart;
41 
42 namespace flutter {
43 namespace {
44 
45 static tonic::DartLibraryNatives* g_natives;
46 
47 Dart_NativeFunction GetNativeFunction(Dart_Handle name,
48  int argument_count,
49  bool* auto_setup_scope) {
50  return g_natives->GetNativeFunction(name, argument_count, auto_setup_scope);
51 }
52 
53 const uint8_t* GetSymbol(Dart_NativeFunction native_function) {
54  return g_natives->GetSymbol(native_function);
55 }
56 
57 } // namespace
58 
60  if (!g_natives) {
61  g_natives = new tonic::DartLibraryNatives();
62  Canvas::RegisterNatives(g_natives);
65  CanvasPath::RegisterNatives(g_natives);
67  Codec::RegisterNatives(g_natives);
77  Paragraph::RegisterNatives(g_natives);
79  Picture::RegisterNatives(g_natives);
81  Scene::RegisterNatives(g_natives);
85  Vertices::RegisterNatives(g_natives);
87 #if defined(LEGACY_FUCHSIA_EMBEDDER)
88  SceneHost::RegisterNatives(g_natives);
89 #endif
90  }
91 }
92 
94  FML_DCHECK(g_natives);
95  Dart_Handle result = Dart_SetNativeResolver(
96  Dart_LookupLibrary(ToDart("dart:ui")), GetNativeFunction, GetSymbol);
97  if (Dart_IsError(result)) {
98  Dart_PropagateError(result);
99  }
100 }
101 
102 } // namespace flutter
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Registers the native handlers for Dart functions that this class handles.
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: vertices.cc:42
#define FML_DCHECK(condition)
Definition: logging.h:86
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: canvas.cc:69
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: path.cc:65
static void RegisterNatives(tonic::DartLibraryNatives *natives)
int argument_count
Definition: fuchsia.cc:52
static void InitForIsolate()
Definition: dart_ui.cc:93
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: image.cc:34
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: gradient.cc:32
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: color_filter.cc:32
const uint8_t * GetSymbol(Dart_NativeFunction native_function)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: codec.cc:33
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: path_measure.cc:39
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void InitForGlobal()
Definition: dart_ui.cc:59
const char * name
Definition: fuchsia.cc:50
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: scene_host.cc:123
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: image_filter.cc:33
static void RegisterNatives(tonic::DartLibraryNatives *natives)
Definition: image_shader.cc:27
Dart_NativeFunction GetNativeFunction(Dart_Handle name, int argument_count, bool *auto_setup_scope)
Dart_Handle ToDart(const T &object)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)
static void RegisterNatives(tonic::DartLibraryNatives *natives)