提交 3f7d5ef6 编写于 作者: A Adam Barth

Update code to account for Mozart changes

The layout protocol in Mozart changed. Now we need to pipe a scene version
through the system to the compositor.
上级 aeb68a5b
......@@ -19,7 +19,7 @@
vars = {
'chromium_git': 'https://chromium.googlesource.com',
'mojo_sdk_revision': '8d13caec84db234e320129722d2f0d5d873def11',
'mojo_sdk_revision': '11e4cee4bc0d7093f7c672c35dda2ffbc1affc91',
'base_revision': '672b04e54b937ec899429a6bd5409c5a6300d151',
'skia_revision': 'ddf0713f0ba4ea75ca49a4ed6b4249eef72da1ce',
......
......@@ -9,7 +9,7 @@
namespace flow {
LayerTree::LayerTree() : rasterizer_tracing_threashold_(0) {
LayerTree::LayerTree() : scene_version_(0), rasterizer_tracing_threashold_(0) {
}
LayerTree::~LayerTree() {
......
......@@ -38,6 +38,11 @@ class LayerTree {
void set_frame_size(const SkISize& frame_size) { frame_size_ = frame_size; }
uint32_t scene_version() const { return scene_version_; }
void set_scene_version(uint32_t scene_version) {
scene_version_ = scene_version;
}
void set_construction_time(const base::TimeDelta& delta) {
construction_time_ = delta;
}
......@@ -59,6 +64,7 @@ class LayerTree {
private:
SkISize frame_size_; // Physical pixels.
uint32_t scene_version_;
std::unique_ptr<Layer> root_layer_;
base::TimeDelta construction_time_;
......
......@@ -6,7 +6,7 @@
#define SKY_ENGINE_BINDINGS_DART_MOJO_INTERNAL_H_
#include "base/macros.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/handle.h"
namespace blink {
......
......@@ -37,12 +37,14 @@ enum AppLifecycleState {
/// For a generic class that represents distances around a rectangle, see the
/// [EdgeDims] class.
class WindowPadding {
const WindowPadding._({ this.top, this.right, this.bottom, this.left });
const WindowPadding._({ this.left, this.top, this.right, this.bottom });
final double left;
final double top;
final double right;
final double bottom;
final double left;
static const WindowPadding zero = const WindowPadding._(left: 0.0, top: 0.0, right: 0.0, bottom: 0.0);
}
/// An identifier used to select a user's language and formatting preferences,
......@@ -95,12 +97,12 @@ class Window {
/// be a power of two. Indeed, it might not even be an integer. For example,
/// the Nexus 6 has a device pixel ratio of 3.5.
double get devicePixelRatio => _devicePixelRatio;
double _devicePixelRatio;
double _devicePixelRatio = 1.0;
/// The dimensions of the rectangle into which the application will be drawn,
/// in logical pixels.
Size get size => _size;
Size _size;
Size _size = Size.zero;
/// The number of pixels on each side of the display rectangle into which the
/// application can render, but over which the operating system will likely
......@@ -108,7 +110,7 @@ class Window {
/// might be rendered outside of the physical display (e.g. overscan regions
/// on television screens).
WindowPadding get padding => _padding;
WindowPadding _padding;
WindowPadding _padding = WindowPadding.zero;
/// A callback that is invoked whenever the [devicePixelRatio], [size], or
/// [padding] values change.
......
......@@ -6,7 +6,6 @@
#include "sky/engine/core/compositing/Scene.h"
#include "sky/engine/core/script/ui_dart_state.h"
#include "sky/engine/public/platform/sky_display_metrics.h"
#include "sky/engine/tonic/dart_converter.h"
#include "sky/engine/tonic/dart_invoke.h"
#include "sky/engine/tonic/dart_library_natives.h"
......@@ -49,20 +48,20 @@ void Window::DidCreateIsolate() {
library_.Set(DartState::Current(), Dart_LookupLibrary(ToDart("dart:ui")));
}
void Window::UpdateWindowMetrics(const SkyDisplayMetrics& metrics) {
void Window::UpdateWindowMetrics(const sky::ViewportMetricsPtr& metrics) {
DartState* dart_state = library_.dart_state().get();
if (!dart_state)
return;
DartState::Scope scope(dart_state);
double device_pixel_ratio = metrics.device_pixel_ratio;
double device_pixel_ratio = metrics->device_pixel_ratio;
DartInvokeField(library_.value(), "_updateWindowMetrics", {
ToDart(device_pixel_ratio),
ToDart(metrics.physical_width / device_pixel_ratio),
ToDart(metrics.physical_height / device_pixel_ratio),
ToDart(metrics.physical_padding_top / device_pixel_ratio),
ToDart(metrics.physical_padding_right / device_pixel_ratio),
ToDart(metrics.physical_padding_bottom / device_pixel_ratio),
ToDart(metrics.physical_padding_left / device_pixel_ratio),
ToDart(metrics->physical_width / device_pixel_ratio),
ToDart(metrics->physical_height / device_pixel_ratio),
ToDart(metrics->physical_padding_top / device_pixel_ratio),
ToDart(metrics->physical_padding_right / device_pixel_ratio),
ToDart(metrics->physical_padding_bottom / device_pixel_ratio),
ToDart(metrics->physical_padding_left / device_pixel_ratio),
});
}
......
......@@ -13,7 +13,6 @@
namespace blink {
class Scene;
struct SkyDisplayMetrics;
class DartLibraryNatives;
class WindowClient {
......@@ -34,7 +33,7 @@ class Window {
WindowClient* client() const { return client_; }
void DidCreateIsolate();
void UpdateWindowMetrics(const SkyDisplayMetrics& metrics);
void UpdateWindowMetrics(const sky::ViewportMetricsPtr& metrics);
void UpdateLocale(const std::string& language_code,
const std::string& country_code);
void DispatchPointerPacket(const pointer::PointerPacketPtr& packet);
......
......@@ -6,7 +6,7 @@
#define SKY_ENGINE_PLATFORM_MOJO_DATA_PIPE_H_
#include "base/callback.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "sky/engine/platform/SharedBuffer.h"
namespace blink {
......
......@@ -54,7 +54,6 @@ source_set("platform_headers") {
"platform/WebString.h",
"platform/WebThread.h",
"platform/WebVector.h",
"platform/sky_display_metrics.h",
"platform/android/WebSandboxSupport.h",
"platform/linux/WebFallbackFont.h",
"platform/linux/WebFontInfo.h",
......
// 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_ENGINE_PUBLIC_SKY_SKY_DISPLAY_METRICS_H_
#define SKY_ENGINE_PUBLIC_SKY_SKY_DISPLAY_METRICS_H_
#include "sky/engine/public/platform/WebSize.h"
namespace blink {
struct SkyDisplayMetrics {
float device_pixel_ratio = 1.0;
int physical_width = 0;
int physical_height = 0;
int physical_padding_top = 0;
int physical_padding_right = 0;
int physical_padding_bottom = 0;
int physical_padding_left = 0;
};
} // namespace blink
#endif // SKY_ENGINE_PUBLIC_SKY_SKY_DISPLAY_METRICS_H_
......@@ -28,9 +28,13 @@ SkyView::SkyView(SkyViewClient* client)
SkyView::~SkyView() {
}
void SkyView::SetDisplayMetrics(const SkyDisplayMetrics& metrics) {
display_metrics_ = metrics;
GetWindow()->UpdateWindowMetrics(display_metrics_);
void SkyView::SetViewportMetrics(const sky::ViewportMetricsPtr& metrics) {
if (metrics) {
viewport_metrics_ = metrics->Clone();
GetWindow()->UpdateWindowMetrics(viewport_metrics_);
} else {
viewport_metrics_ = nullptr;
}
}
void SkyView::SetLocale(const std::string& language_code,
......@@ -63,7 +67,8 @@ void SkyView::CreateView(const std::string& script_uri) {
dart_state->window()->DidCreateIsolate();
client_->DidCreateMainIsolate(dart_state->isolate());
GetWindow()->UpdateWindowMetrics(display_metrics_);
if (viewport_metrics_)
GetWindow()->UpdateWindowMetrics(viewport_metrics_);
GetWindow()->UpdateLocale(language_code_, country_code_);
}
......
......@@ -14,7 +14,6 @@
#include "mojo/services/network/interfaces/url_loader.mojom.h"
#include "sky/engine/bindings/flutter_dart_state.h"
#include "sky/engine/core/window/window.h"
#include "sky/engine/public/platform/sky_display_metrics.h"
#include "sky/engine/public/platform/WebCommon.h"
#include "sky/engine/public/platform/WebString.h"
#include "sky/engine/wtf/OwnPtr.h"
......@@ -38,8 +37,7 @@ class SkyView : public WindowClient, public IsolateClient {
static std::unique_ptr<SkyView> Create(SkyViewClient* client);
~SkyView();
const SkyDisplayMetrics& display_metrics() const { return display_metrics_; }
void SetDisplayMetrics(const SkyDisplayMetrics& metrics);
void SetViewportMetrics(const sky::ViewportMetricsPtr& metrics);
void SetLocale(const std::string& language_code,
const std::string& country_code);
void PushRoute(const std::string& route);
......@@ -71,7 +69,7 @@ class SkyView : public WindowClient, public IsolateClient {
void DidCreateSecondaryIsolate(Dart_Isolate isolate) override;
SkyViewClient* client_;
SkyDisplayMetrics display_metrics_;
sky::ViewportMetricsPtr viewport_metrics_;
std::string language_code_;
std::string country_code_;
std::unique_ptr<DartController> dart_controller_;
......
......@@ -4,6 +4,6 @@ author: Flutter Authors <flutter-dev@googlegroups.com>
description: Mojom interfaces associated with Flutter
homepage: http://flutter.io
dependencies:
mojo_sdk: 0.2.20
mojo_sdk: 0.2.22
environment:
sdk: '>=1.8.0 <2.0.0'
......@@ -25,6 +25,7 @@ struct ViewportMetrics {
int32 physical_padding_right;
int32 physical_padding_bottom;
int32 physical_padding_left;
uint32 scene_version;
};
struct ServicesData {
......
......@@ -104,7 +104,9 @@ void RasterizerMojo::Draw(uint64_t layer_tree_ptr,
update->nodes.insert(kRootNodeId, root_node.Pass());
scene_->Update(update.Pass());
scene_->Publish(nullptr);
auto metadata = mojo::gfx::composition::SceneMetadata::New();
metadata->version = layer_tree->scene_version();
scene_->Publish(metadata.Pass());
callback.Run();
}
......
......@@ -98,19 +98,18 @@ void ViewImpl::Run(base::FilePath bundle_path) {
engine_->RunFromBundle(url_, bundle_path.value());
}
void ViewImpl::OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params,
mojo::Array<uint32_t> children_needing_layout,
const OnLayoutCallback& callback) {
viewport_metrics_.device_pixel_ratio = layout_params->device_pixel_ratio;
viewport_metrics_.physical_width = layout_params->constraints->max_width;
viewport_metrics_.physical_height = layout_params->constraints->max_height;
void ViewImpl::OnPropertiesChanged(
uint32_t scene_version,
mojo::ui::ViewPropertiesPtr properties,
const OnPropertiesChangedCallback& callback) {
auto& display_metrics = properties->display_metrics;
viewport_metrics_.device_pixel_ratio = display_metrics->device_pixel_ratio;
auto& size = properties->view_layout->size;
viewport_metrics_.physical_width = size->width;
viewport_metrics_.physical_height = size->height;
viewport_metrics_.scene_version = scene_version;
engine_->OnViewportMetricsChanged(viewport_metrics_.Clone());
auto info = mojo::ui::ViewLayoutResult::New();
info->size = mojo::Size::New();
info->size->width = viewport_metrics_.physical_width;
info->size->height = viewport_metrics_.physical_height;
callback.Run(info.Pass());
callback.Run();
}
void ViewImpl::OnEvent(mojo::EventPtr event, const OnEventCallback& callback) {
......
......@@ -38,9 +38,9 @@ class ViewImpl : public mojo::ui::ViewListener,
private:
// mojo::ui::ViewListener
void OnLayout(mojo::ui::ViewLayoutParamsPtr layout_params,
mojo::Array<uint32_t> children_needing_layout,
const OnLayoutCallback& callback) override;
void OnPropertiesChanged(uint32_t scene_version,
mojo::ui::ViewPropertiesPtr properties,
const OnPropertiesChangedCallback& callback) override;
// mojo::ui::InputListener
void OnEvent(mojo::EventPtr event, const OnEventCallback& callback) override;
......
......@@ -16,7 +16,6 @@
#include "sky/engine/bindings/mojo_services.h"
#include "sky/engine/core/script/dart_init.h"
#include "sky/engine/core/script/ui_dart_state.h"
#include "sky/engine/public/platform/sky_display_metrics.h"
#include "sky/engine/public/platform/WebInputEvent.h"
#include "sky/engine/public/web/Sky.h"
#include "sky/shell/dart/dart_library_provider_files.h"
......@@ -75,8 +74,9 @@ std::unique_ptr<flow::LayerTree> Engine::BeginFrame(
std::unique_ptr<flow::LayerTree> layer_tree =
sky_view_->BeginFrame(frame_time);
if (layer_tree) {
layer_tree->set_frame_size(SkISize::Make(display_metrics_.physical_width,
display_metrics_.physical_height));
layer_tree->set_scene_version(viewport_metrics_->scene_version);
layer_tree->set_frame_size(SkISize::Make(viewport_metrics_->physical_width,
viewport_metrics_->physical_height));
layer_tree->set_construction_time(base::TimeTicks::Now() - begin_time);
}
return layer_tree;
......@@ -132,16 +132,9 @@ void Engine::SetServices(ServicesDataPtr services) {
}
void Engine::OnViewportMetricsChanged(ViewportMetricsPtr metrics) {
display_metrics_.device_pixel_ratio = metrics->device_pixel_ratio;
display_metrics_.physical_width = metrics->physical_width;
display_metrics_.physical_height = metrics->physical_height;
display_metrics_.physical_padding_top = metrics->physical_padding_top;
display_metrics_.physical_padding_right = metrics->physical_padding_right;
display_metrics_.physical_padding_bottom = metrics->physical_padding_bottom;
display_metrics_.physical_padding_left = metrics->physical_padding_left;
viewport_metrics_ = metrics.Pass();
if (sky_view_)
sky_view_->SetDisplayMetrics(display_metrics_);
sky_view_->SetViewportMetrics(viewport_metrics_);
}
void Engine::OnLocaleChanged(const mojo::String& language_code,
......@@ -157,8 +150,8 @@ void Engine::OnPointerPacket(pointer::PointerPacketPtr packet) {
// Convert the pointers' x and y coordinates to logical pixels.
for (auto it = packet->pointers.begin(); it != packet->pointers.end(); ++it) {
(*it)->x /= display_metrics_.device_pixel_ratio;
(*it)->y /= display_metrics_.device_pixel_ratio;
(*it)->x /= viewport_metrics_->device_pixel_ratio;
(*it)->y /= viewport_metrics_->device_pixel_ratio;
}
if (sky_view_)
......@@ -170,7 +163,7 @@ void Engine::RunFromLibrary(const std::string& name) {
sky_view_ = blink::SkyView::Create(this);
sky_view_->CreateView(name);
sky_view_->RunFromLibrary(name, dart_library_provider_.get());
sky_view_->SetDisplayMetrics(display_metrics_);
sky_view_->SetViewportMetrics(viewport_metrics_);
sky_view_->SetLocale(language_code_, country_code_);
if (!initial_route_.empty())
sky_view_->PushRoute(initial_route_);
......@@ -183,7 +176,7 @@ void Engine::RunFromSnapshotStream(
sky_view_ = blink::SkyView::Create(this);
sky_view_->CreateView(script_uri);
sky_view_->RunFromSnapshot(snapshot.Pass());
sky_view_->SetDisplayMetrics(display_metrics_);
sky_view_->SetViewportMetrics(viewport_metrics_);
sky_view_->SetLocale(language_code_, country_code_);
if (!initial_route_.empty())
sky_view_->PushRoute(initial_route_);
......@@ -203,7 +196,7 @@ void Engine::RunFromPrecompiledSnapshot(const mojo::String& bundle_path) {
sky_view_ = blink::SkyView::Create(this);
sky_view_->CreateView("http://localhost");
sky_view_->RunFromPrecompiledSnapshot();
sky_view_->SetDisplayMetrics(display_metrics_);
sky_view_->SetViewportMetrics(viewport_metrics_);
sky_view_->SetLocale(language_code_, country_code_);
if (!initial_route_.empty())
sky_view_->PushRoute(initial_route_);
......
......@@ -13,8 +13,8 @@
#include "mojo/public/cpp/application/interface_factory.h"
#include "mojo/public/cpp/application/service_provider_impl.h"
#include "mojo/public/cpp/bindings/binding.h"
#include "mojo/public/cpp/system/core.h"
#include "mojo/public/cpp/system/data_pipe.h"
#include "mojo/public/cpp/system/handle.h"
#include "mojo/public/interfaces/application/service_provider.mojom.h"
#include "mojo/services/asset_bundle/interfaces/asset_bundle.mojom.h"
#include "skia/ext/refptr.h"
......@@ -117,7 +117,7 @@ class Engine : public UIDelegate,
std::unique_ptr<blink::SkyView> sky_view_;
std::string initial_route_;
blink::SkyDisplayMetrics display_metrics_;
ViewportMetricsPtr viewport_metrics_;
std::string language_code_;
std::string country_code_;
mojo::Binding<SkyEngine> binding_;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册