Loïc Sharma a9e12287f6 [dart:ui] Introduce PlatformDispatcher.implicitView (flutter/engine#39553)
This introduces `PlatformDispatcher.implicitView`, a low-level primitive for the framework's bootstrapping. Most code, including the framework after bootstrapping, will use `View.of(context)` instead of this new API. This new primitive will let us deprecate the `window` global.

Goals:

1. **Enable multi-window**. The `PlatformDispatcher.implicitView` is nullable. If `null`, the app must create a window to get a view it can draw into.
2. **Backwards compatibility**. For "single window" apps, `PlatformDispatcher.instance.implicitView` should behave as similar to `window` as possible.
    1. The `PlatformDispatcher.instance.implicitView.viewId` should be `0`.
    1. The `PlatformDispatcher.instance.implicitView` must be available synchronously at root isolate startup. This allows the framework to determine if it can make single window assumptions at startup.
    2. The `PlatformDispatcher.instance.implicitView` reference must not change after startup: if it is null at startup, it must always be null; if it is non-null at startup, it must always be non-null. If "single window" app enters headless mode, the implicit view must remain non-null.

In the future, the embedder will control whether an implicit view is created: mobile & legacy desktop apps will have an implicit view, multi-window desktop apps won't have an implicit view. This requires updating the engine's embedder API and is out-of-scope for this change. For now, all apps will have an implicit view.

Part of https://github.com/flutter/flutter/issues/120306
2023-02-16 16:32:14 -08:00

65 lines
2.0 KiB
C++

// 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.
#ifndef FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
#define FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_
#include <memory>
#include <vector>
#include "flutter/assets/asset_manager.h"
#include "flutter/flow/layers/layer_tree.h"
#include "flutter/lib/ui/semantics/custom_accessibility_action.h"
#include "flutter/lib/ui/semantics/semantics_node.h"
#include "flutter/lib/ui/text/font_collection.h"
#include "flutter/lib/ui/window/platform_message.h"
#include "flutter/shell/common/platform_message_handler.h"
#include "third_party/dart/runtime/include/dart_api.h"
namespace flutter {
class RuntimeDelegate {
public:
virtual bool ImplicitViewEnabled() = 0;
virtual std::string DefaultRouteName() = 0;
virtual void ScheduleFrame(bool regenerate_layer_tree = true) = 0;
virtual void Render(std::shared_ptr<flutter::LayerTree> layer_tree) = 0;
virtual void UpdateSemantics(SemanticsNodeUpdates update,
CustomAccessibilityActionUpdates actions) = 0;
virtual void HandlePlatformMessage(
std::unique_ptr<PlatformMessage> message) = 0;
virtual FontCollection& GetFontCollection() = 0;
virtual std::shared_ptr<AssetManager> GetAssetManager() = 0;
virtual void OnRootIsolateCreated() = 0;
virtual void UpdateIsolateDescription(const std::string isolate_name,
int64_t isolate_port) = 0;
virtual void SetNeedsReportTimings(bool value) = 0;
virtual std::unique_ptr<std::vector<std::string>>
ComputePlatformResolvedLocale(
const std::vector<std::string>& supported_locale_data) = 0;
virtual void RequestDartDeferredLibrary(intptr_t loading_unit_id) = 0;
virtual std::weak_ptr<PlatformMessageHandler> GetPlatformMessageHandler()
const = 0;
protected:
virtual ~RuntimeDelegate();
};
} // namespace flutter
#endif // FLUTTER_RUNTIME_RUNTIME_DELEGATE_H_