mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Previously, we weren't scheduling a visual update when our surface was created, so we'd just continue to show black until the author requested a new animation frame. After this CL, we schedule a visual update as soon as our surface is created. As part of this change, I've removed knowledge of the GPU delegate from PlatformView. Now, all the calls from PlatformView to the GPU system bounce through the UI delegate, which serializes the commands with other commands from the UI engine to the GPU rasterizer. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/974483004
106 lines
3.3 KiB
C++
106 lines
3.3 KiB
C++
// Copyright 2015 The Chromium 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 SKY_SHELL_UI_ENGINE_H_
|
|
#define SKY_SHELL_UI_ENGINE_H_
|
|
|
|
#include "base/macros.h"
|
|
#include "base/memory/scoped_ptr.h"
|
|
#include "base/memory/weak_ptr.h"
|
|
#include "base/single_thread_task_runner.h"
|
|
#include "mojo/public/cpp/bindings/binding.h"
|
|
#include "mojo/public/cpp/system/core.h"
|
|
#include "mojo/public/interfaces/application/service_provider.mojom.h"
|
|
#include "mojo/services/navigation/public/interfaces/navigation.mojom.h"
|
|
#include "skia/ext/refptr.h"
|
|
#include "sky/engine/public/platform/ServiceProvider.h"
|
|
#include "sky/engine/public/web/WebFrameClient.h"
|
|
#include "sky/engine/public/web/WebViewClient.h"
|
|
#include "sky/shell/gpu_delegate.h"
|
|
#include "sky/shell/ui_delegate.h"
|
|
#include "third_party/skia/include/core/SkPicture.h"
|
|
#include "ui/gfx/geometry/size.h"
|
|
|
|
namespace sky {
|
|
class PlatformImpl;
|
|
namespace shell {
|
|
class Animator;
|
|
|
|
class Engine : public UIDelegate,
|
|
public ViewportObserver,
|
|
public blink::ServiceProvider,
|
|
public mojo::NavigatorHost,
|
|
public blink::WebFrameClient,
|
|
public blink::WebViewClient {
|
|
public:
|
|
struct Config {
|
|
scoped_refptr<base::SingleThreadTaskRunner> java_task_runner;
|
|
|
|
base::WeakPtr<GPUDelegate> gpu_delegate;
|
|
scoped_refptr<base::SingleThreadTaskRunner> gpu_task_runner;
|
|
};
|
|
|
|
explicit Engine(const Config& config);
|
|
~Engine() override;
|
|
|
|
base::WeakPtr<Engine> GetWeakPtr();
|
|
|
|
void Init();
|
|
|
|
void BeginFrame(base::TimeTicks frame_time);
|
|
skia::RefPtr<SkPicture> Paint();
|
|
|
|
private:
|
|
// UIDelegate methods:
|
|
void ConnectToViewportObserver(
|
|
mojo::InterfaceRequest<ViewportObserver> request) override;
|
|
void OnAcceleratedWidgetAvailable(gfx::AcceleratedWidget widget) override;
|
|
void OnOutputSurfaceDestroyed() override;
|
|
|
|
// ViewportObserver:
|
|
void OnViewportMetricsChanged(int width, int height,
|
|
float device_pixel_ratio) override;
|
|
void OnInputEvent(InputEventPtr event) override;
|
|
void LoadURL(const mojo::String& url) override;
|
|
|
|
// WebViewClient methods:
|
|
void frameDetached(blink::WebFrame*) override;
|
|
void initializeLayerTreeView() override;
|
|
void scheduleVisualUpdate() override;
|
|
blink::WebScreenInfo screenInfo() override;
|
|
blink::ServiceProvider* services() override;
|
|
void didCreateIsolate(blink::WebLocalFrame* frame,
|
|
Dart_Isolate isolate) override;
|
|
|
|
// Services methods:
|
|
mojo::NavigatorHost* NavigatorHost() override;
|
|
|
|
// NavigatorHost methods:
|
|
void RequestNavigate(mojo::Target target,
|
|
mojo::URLRequestPtr request) override;
|
|
void DidNavigateLocally(const mojo::String& url) override;
|
|
void RequestNavigateHistory(int32_t delta) override;
|
|
|
|
mojo::ServiceProviderPtr CreateServiceProvider();
|
|
void UpdateWebViewSize();
|
|
|
|
Config config_;
|
|
mojo::ServiceProviderPtr service_provider_;
|
|
scoped_ptr<PlatformImpl> platform_impl_;
|
|
scoped_ptr<Animator> animator_;
|
|
blink::WebView* web_view_;
|
|
float device_pixel_ratio_;
|
|
gfx::Size physical_size_;
|
|
mojo::Binding<ViewportObserver> viewport_observer_binding_;
|
|
|
|
base::WeakPtrFactory<Engine> weak_factory_;
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Engine);
|
|
};
|
|
|
|
} // namespace shell
|
|
} // namespace sky
|
|
|
|
#endif // SKY_SHELL_UI_ENGINE_H_
|